Commit ab05509d authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Fix most of the style issues found by checkstyle.

Fixed the following number of issues per type:

 559 EmptyLineSeparator
 196 CustomImportOrder
 180 OperatorWrap
 120 Indentation
 117 JavadocMethod
  80 MemberName
  56 MultipleVariableDeclarations
  23 AbbreviationAsWordInName
  16 ModifierOrder
  11 ParameterName
   9 LocalVariableName
   7 VariableDeclarationUsageDistance
   6 SeparatorWrap
   4 EmptyCatchBlock
   3 OneTopLevelClass
   2 JavadocTagContinuationIndentation
   1 (... types with single occurrence omitted...)
parent ce4be425
Loading
Loading
Loading
Loading
+36 −27
Original line number Diff line number Diff line
/* Copyright 2011--2015 The Tor Project
 * See LICENSE for licensing information */
package org.torproject.onionoo.cron;

import java.io.File;
import java.util.Calendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
package org.torproject.onionoo.cron;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.torproject.onionoo.docs.DocumentStore;
import org.torproject.onionoo.docs.DocumentStoreFactory;
import org.torproject.onionoo.updater.DescriptorSource;
@@ -18,6 +11,15 @@ import org.torproject.onionoo.updater.StatusUpdateRunner;
import org.torproject.onionoo.util.LockFile;
import org.torproject.onionoo.writer.DocumentWriterRunner;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Calendar;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/* Update search data and status data files. */
public class Main implements Runnable {

@@ -32,8 +34,15 @@ public class Main implements Runnable {
    main.runOrScheduleExecutions();
  }

  boolean defaultMode = false, singleRun = false, downloadOnly = false,
      updateOnly = false, writeOnly = false;
  boolean defaultMode = false;

  boolean singleRun = false;

  boolean downloadOnly = false;

  boolean updateOnly = false;

  boolean writeOnly = false;

  /* TODO Parsing command-line arguments is only a workaround until we're
   * more certain what kind of options we want to support.  We should then
+4 −0
Original line number Diff line number Diff line
/* Copyright 2013 The Tor Project
 * See LICENSE for licensing information */

package org.torproject.onionoo.docs;

import java.util.Map;
@@ -8,18 +9,21 @@ public class BandwidthDocument extends Document {

  @SuppressWarnings("unused")
  private String fingerprint;

  public void setFingerprint(String fingerprint) {
    this.fingerprint = fingerprint;
  }

  @SuppressWarnings("unused")
  private Map<String, GraphHistory> write_history;

  public void setWriteHistory(Map<String, GraphHistory> writeHistory) {
    this.write_history = writeHistory;
  }

  @SuppressWarnings("unused")
  private Map<String, GraphHistory> read_history;

  public void setReadHistory(Map<String, GraphHistory> readHistory) {
    this.read_history = readHistory;
  }
+31 −19
Original line number Diff line number Diff line
/* Copyright 2013--2014 The Tor Project
 * See LICENSE for licensing information */

package org.torproject.onionoo.docs;

import org.torproject.descriptor.BandwidthHistory;
import org.torproject.onionoo.util.TimeFactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.torproject.descriptor.BandwidthHistory;
import org.torproject.onionoo.util.TimeFactory;

public class BandwidthStatus extends Document {

  private static Logger log = LoggerFactory.getLogger(
      BandwidthStatus.class);

  private transient boolean isDirty = false;

  public boolean isDirty() {
    return this.isDirty;
  }

  public void clearDirty() {
    this.isDirty = false;
  }

  private SortedMap<Long, long[]> writeHistory =
      new TreeMap<Long, long[]>();

  public void setWriteHistory(SortedMap<Long, long[]> writeHistory) {
    this.writeHistory = writeHistory;
  }

  public SortedMap<Long, long[]> getWriteHistory() {
    return this.writeHistory;
  }

  private SortedMap<Long, long[]> readHistory =
      new TreeMap<Long, long[]>();

  public void setReadHistory(SortedMap<Long, long[]> readHistory) {
    this.readHistory = readHistory;
  }

  public SortedMap<Long, long[]> getReadHistory() {
    return this.readHistory;
  }
@@ -68,8 +76,8 @@ public class BandwidthStatus extends Document {
            : history.get(history.headMap(startMillis).lastKey())[1];
        long nextStartMillis = history.tailMap(startMillis).isEmpty()
            ? endMillis : history.tailMap(startMillis).firstKey();
        if (previousEndMillis <= startMillis &&
            nextStartMillis >= endMillis) {
        if (previousEndMillis <= startMillis
            && nextStartMillis >= endMillis) {
          history.put(startMillis, new long[] { startMillis, endMillis,
              bandwidth });
        }
@@ -111,34 +119,38 @@ public class BandwidthStatus extends Document {
    SortedMap<Long, long[]> uncompressedHistory =
        new TreeMap<Long, long[]>(history);
    history.clear();
    long lastStartMillis = 0L, lastEndMillis = 0L, lastBandwidth = 0L;
    long lastStartMillis = 0L;
    long lastEndMillis = 0L;
    long lastBandwidth = 0L;
    String lastMonthString = "1970-01";
    long now = TimeFactory.getTime().currentTimeMillis();
    for (long[] v : uncompressedHistory.values()) {
      long startMillis = v[0], endMillis = v[1], bandwidth = v[2];
      long startMillis = v[0];
      long endMillis = v[1];
      long bandwidth = v[2];
      long intervalLengthMillis;
      if (now - endMillis <= DateTimeHelper.THREE_DAYS) {
        intervalLengthMillis = DateTimeHelper.FIFTEEN_MINUTES;
      } else if (now - endMillis <= DateTimeHelper.ONE_WEEK) {
        intervalLengthMillis = DateTimeHelper.ONE_HOUR;
      } else if (now - endMillis <=
          DateTimeHelper.ROUGHLY_ONE_MONTH) {
      } else if (now - endMillis
          <= DateTimeHelper.ROUGHLY_ONE_MONTH) {
        intervalLengthMillis = DateTimeHelper.FOUR_HOURS;
      } else if (now - endMillis <=
          DateTimeHelper.ROUGHLY_THREE_MONTHS) {
      } else if (now - endMillis
          <= DateTimeHelper.ROUGHLY_THREE_MONTHS) {
        intervalLengthMillis = DateTimeHelper.TWELVE_HOURS;
      } else if (now - endMillis <=
          DateTimeHelper.ROUGHLY_ONE_YEAR) {
      } else if (now - endMillis
          <= DateTimeHelper.ROUGHLY_ONE_YEAR) {
        intervalLengthMillis = DateTimeHelper.TWO_DAYS;
      } else {
        intervalLengthMillis = DateTimeHelper.TEN_DAYS;
      }
      String monthString = DateTimeHelper.format(startMillis,
          DateTimeHelper.ISO_YEARMONTH_FORMAT);
      if (lastEndMillis == startMillis &&
          ((lastEndMillis - 1L) / intervalLengthMillis) ==
          ((endMillis - 1L) / intervalLengthMillis) &&
          lastMonthString.equals(monthString)) {
      if (lastEndMillis == startMillis
          && ((lastEndMillis - 1L) / intervalLengthMillis)
          == ((endMillis - 1L) / intervalLengthMillis)
          && lastMonthString.equals(monthString)) {
        lastEndMillis = endMillis;
        lastBandwidth += bandwidth;
      } else {
+3 −0
Original line number Diff line number Diff line
/* Copyright 2014 The Tor Project
 * See LICENSE for licensing information */

package org.torproject.onionoo.docs;

import java.util.Map;
@@ -8,12 +9,14 @@ public class ClientsDocument extends Document {

  @SuppressWarnings("unused")
  private String fingerprint;

  public void setFingerprint(String fingerprint) {
    this.fingerprint = fingerprint;
  }

  @SuppressWarnings("unused")
  private Map<String, ClientsGraphHistory> average_clients;

  public void setAverageClients(
      Map<String, ClientsGraphHistory> averageClients) {
    this.average_clients = averageClients;
+19 −0
Original line number Diff line number Diff line
/* Copyright 2014 The Tor Project
 * See LICENSE for licensing information */

package org.torproject.onionoo.docs;

import java.util.ArrayList;
@@ -9,73 +10,91 @@ import java.util.SortedMap;
public class ClientsGraphHistory {

  private String first;

  public void setFirst(long first) {
    this.first = DateTimeHelper.format(first);
  }

  public long getFirst() {
    return DateTimeHelper.parse(this.first);
  }

  private String last;

  public void setLast(long last) {
    this.last = DateTimeHelper.format(last);
  }

  public long getLast() {
    return DateTimeHelper.parse(this.last);
  }

  private Integer interval;

  public void setInterval(Integer interval) {
    this.interval = interval;
  }

  public Integer getInterval() {
    return this.interval;
  }

  private Double factor;

  public void setFactor(Double factor) {
    this.factor = factor;
  }

  public Double getFactor() {
    return this.factor;
  }

  private Integer count;

  public void setCount(Integer count) {
    this.count = count;
  }

  public Integer getCount() {
    return this.count;
  }

  private List<Integer> values = new ArrayList<Integer>();

  public void setValues(List<Integer> values) {
    this.values = values;
  }

  public List<Integer> getValues() {
    return this.values;
  }

  private SortedMap<String, Float> countries;

  public void setCountries(SortedMap<String, Float> countries) {
    this.countries = countries;
  }

  public SortedMap<String, Float> getCountries() {
    return this.countries;
  }

  private SortedMap<String, Float> transports;

  public void setTransports(SortedMap<String, Float> transports) {
    this.transports = transports;
  }

  public SortedMap<String, Float> getTransports() {
    return this.transports;
  }

  private SortedMap<String, Float> versions;

  public void setVersions(SortedMap<String, Float> versions) {
    this.versions = versions;
  }

  public SortedMap<String, Float> getVersions() {
    return this.versions;
  }
Loading