Skip to content

Commit

Permalink
Mark member variables as final in server-base (#4833)
Browse files Browse the repository at this point in the history
See #4830
  • Loading branch information
cshannon authored Aug 24, 2024
1 parent 5e6b075 commit 99d9149
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class ProvisionalCompactionPlanner implements CompactionPlanner {

private final CompactionServiceId serviceId;
private AtomicLong lastWarnNanoTime = new AtomicLong(System.nanoTime());
private final AtomicLong lastWarnNanoTime = new AtomicLong(System.nanoTime());

public ProvisionalCompactionPlanner(CompactionServiceId serviceId) {
this.serviceId = serviceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class ServerColumnUpdate extends ColumnUpdate {

ServerMutation parent;
final ServerMutation parent;

public ServerColumnUpdate(byte[] cf, byte[] cq, byte[] cv, boolean hasts, long ts,
boolean deleted, byte[] val, ServerMutation serverMutation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

public class ServerConditionalMutation extends ServerMutation {

private long cmid;
private List<TCondition> conditions;
private final long cmid;
private final List<TCondition> conditions;

public ServerConditionalMutation(TConditionalMutation input) {
super(input.mutation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public class FileManager {
private int maxOpen;

private static class OpenReader implements Comparable<OpenReader> {
long releaseTime;
FileSKVIterator reader;
StoredTabletFile file;
final long releaseTime;
final FileSKVIterator reader;
final StoredTabletFile file;

public OpenReader(StoredTabletFile file, FileSKVIterator reader) {
this.file = file;
Expand Down Expand Up @@ -383,7 +383,7 @@ private void releaseReaders(KeyExtent tablet, List<FileSKVIterator> readers,
static class FileDataSource implements DataSource {

private SortedKeyValueIterator<Key,Value> iter;
private ArrayList<FileDataSource> deepCopies;
private final ArrayList<FileDataSource> deepCopies;
private boolean current = true;
private IteratorEnvironment env;
private StoredTabletFile file;
Expand Down Expand Up @@ -456,11 +456,11 @@ public void setInterruptFlag(AtomicBoolean flag) {

public class ScanFileManager {

private ArrayList<FileDataSource> dataSources;
private ArrayList<FileSKVIterator> tabletReservedReaders;
private KeyExtent tablet;
private final ArrayList<FileDataSource> dataSources;
private final ArrayList<FileSKVIterator> tabletReservedReaders;
private final KeyExtent tablet;
private boolean continueOnFailure;
private CacheProvider cacheProvider;
private final CacheProvider cacheProvider;

ScanFileManager(KeyExtent tablet, CacheProvider cacheProvider) {
tabletReservedReaders = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public interface VolumeManager extends AutoCloseable {
enum FileType {
TABLE(Constants.TABLE_DIR), WAL(Constants.WAL_DIR), RECOVERY(Constants.RECOVERY_DIR);

private String dir;
private final String dir;

FileType(String dir) {
this.dir = dir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public static LogEntry switchVolume(LogEntry le, Map<Path,Path> replacements) {

public static class TabletFiles {
public String dirName;
public List<LogEntry> logEntries;
public SortedMap<StoredTabletFile,DataFileValue> datafiles;
public final List<LogEntry> logEntries;
public final SortedMap<StoredTabletFile,DataFileValue> datafiles;

public TabletFiles() {
logEntries = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ public FileSystemInitializer(InitialConfiguration initConfig) {
}

public static class InitialTablet {
TableId tableId;
String dirName;
Text prevEndRow, endRow, extent;
String[] files;
final TableId tableId;
final String dirName;
final Text prevEndRow;
final Text endRow;
final Text extent;
final String[] files;

InitialTablet(TableId tableId, String dirName, Text prevEndRow, Text endRow, String... files) {
this.tableId = tableId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public enum SortedLogState {
FINISHED("finished"), FAILED("failed");

private String marker;
private final String marker;

private SortedLogState(String marker) {
this.marker = marker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ public void flush(ServiceLock lock, TableId tableId, byte[] startRow, byte[] end
}

static class TServerInfo {
TServerConnection connection;
TServerInstance instance;
String resourceGroup;
final TServerConnection connection;
final TServerInstance instance;
final String resourceGroup;

TServerInfo(TServerInstance instance, TServerConnection connection, String resourceGroup) {
this.connection = connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
class LoggingTabletStateStore implements TabletStateStore {

private TabletStateStore wrapped;
private final TabletStateStore wrapped;

LoggingTabletStateStore(TabletStateStore tss) {
this.wrapped = tss;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public enum TabletServerState {

private byte id;

private static HashMap<Byte,TabletServerState> mapping;
private static HashSet<TabletServerState> badStates;
private static final HashMap<Byte,TabletServerState> mapping;
private static final HashSet<TabletServerState> badStates;

static {
mapping = new HashMap<>(TabletServerState.values().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public class ConditionalTabletsMutatorImpl implements Ample.ConditionalTabletsMu
private final ServerContext context;
private Ample.DataLevel dataLevel = null;

private List<ConditionalMutation> mutations = new ArrayList<>();
private final List<ConditionalMutation> mutations = new ArrayList<>();

private Map<Text,KeyExtent> extents = new HashMap<>();
private final Map<Text,KeyExtent> extents = new HashMap<>();

private boolean active = true;

Map<KeyExtent,Ample.RejectionHandler> rejectedHandlers = new HashMap<>();
final Map<KeyExtent,Ample.RejectionHandler> rejectedHandlers = new HashMap<>();
private final Function<DataLevel,String> tableMapper;

public ConditionalTabletsMutatorImpl(ServerContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public class ScanServerRefStoreImpl implements ScanServerRefStore {

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

private final ClientContext context;
private final String tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

public class ServerAmpleImpl extends AmpleImpl implements Ample {

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

private final ServerContext context;
private final ScanServerRefStore scanServerRefStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import org.apache.zookeeper.KeeperException;

public class ProblemReport {
private TableId tableId;
private ProblemType problemType;
private String resource;
private final TableId tableId;
private final ProblemType problemType;
private final String resource;
private String exception;
private String server;
private long creationTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class ProblemReportingIterator implements InterruptibleIterator {
private final SortedKeyValueIterator<Key,Value> source;
private boolean sawError = false;
private final boolean continueOnError;
private String resource;
private TableId tableId;
private final String resource;
private final TableId tableId;
private final ServerContext context;

public ProblemReportingIterator(ServerContext context, TableId tableId, String resource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static boolean isMeta(TableId tableId) {
public Iterator<ProblemReport> iterator(final TableId table) {
return new Iterator<>() {

ZooReaderWriter zoo = context.getZooReaderWriter();
final ZooReaderWriter zoo = context.getZooReaderWriter();
private int iter1Count = 0;
private Iterator<String> iter1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class AuthenticationTokenKeyManager implements Runnable {
private final ZooAuthenticationKeyDistributor keyDistributor;

private long lastKeyUpdate = 0;
private long keyUpdateInterval;
private long tokenMaxLifetime;
private final long keyUpdateInterval;
private final long tokenMaxLifetime;
private int idSeq = 0;
private volatile boolean keepRunning = true, initialized = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ZooAuthenticationKeyDistributor {

private final ZooReaderWriter zk;
private final String baseNode;
private AtomicBoolean initialized = new AtomicBoolean(false);
private final AtomicBoolean initialized = new AtomicBoolean(false);

public ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode) {
requireNonNull(zk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@
import org.apache.hadoop.io.Text;

public class ConditionCheckerContext {
private CompressedIterators compressedIters;
private final CompressedIterators compressedIters;

private List<IterInfo> tableIters;
private Map<String,Map<String,String>> tableIterOpts;
private TabletIteratorEnvironment tie;
private String context;
private final List<IterInfo> tableIters;
private final Map<String,Map<String,String>> tableIterOpts;
private final TabletIteratorEnvironment tie;
private final String context;

private static class MergedIterConfig {
List<IterInfo> mergedIters;
Map<String,Map<String,String>> mergedItersOpts;
final List<IterInfo> mergedIters;
final Map<String,Map<String,String>> mergedItersOpts;

MergedIterConfig(List<IterInfo> mergedIters, Map<String,Map<String,String>> mergedItersOpts) {
this.mergedIters = mergedIters;
this.mergedItersOpts = mergedItersOpts;
}
}

private Map<ByteSequence,MergedIterConfig> mergedIterCache = new HashMap<>();
private final Map<ByteSequence,MergedIterConfig> mergedIterCache = new HashMap<>();

public ConditionCheckerContext(ServerContext context, CompressedIterators compressedIters,
TableConfiguration tableConf) {
Expand Down Expand Up @@ -144,9 +144,9 @@ boolean checkConditions(SortedKeyValueIterator<Key,Value> systemIter,

public class ConditionChecker {

private List<ServerConditionalMutation> conditionsToCheck;
private List<ServerConditionalMutation> okMutations;
private List<TCMResult> results;
private final List<ServerConditionalMutation> conditionsToCheck;
private final List<ServerConditionalMutation> okMutations;
private final List<TCMResult> results;
private boolean checked = false;

public ConditionChecker(List<ServerConditionalMutation> conditionsToCheck,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public long getAndUpdateTime() {
}

static class LogicalTime extends TabletTime {
AtomicLong nextTime;
final AtomicLong nextTime;

private LogicalTime(Long time) {
this.nextTime = new AtomicLong(time + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@

public class RandomWriter {

private static int num_columns_per_row = 1;
private static int num_payload_bytes = 1024;
private static final int num_columns_per_row = 1;
private static final int num_payload_bytes = 1024;
private static final Logger log = LoggerFactory.getLogger(RandomWriter.class);

public static class RandomMutationGenerator implements Iterable<Mutation>, Iterator<Mutation> {
private long max_mutations;
private final long max_mutations;
private int mutations_so_far = 0;
private static final Logger log = LoggerFactory.getLogger(RandomMutationGenerator.class);

Expand Down Expand Up @@ -93,7 +93,7 @@ static class Opts extends ClientOpts {
@Parameter(names = "--count", description = "number of mutations to write", required = true)
long count;
@Parameter(names = "--table", description = "table to use")
String tableName = "test_write_table";
final String tableName = "test_write_table";
}

public static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public class TableDiskUsage {

private static final Logger log = LoggerFactory.getLogger(TableDiskUsage.class);
private int nextInternalId = 0;
private Map<TableId,Integer> internalIds = new HashMap<>();
private Map<Integer,TableId> externalIds = new HashMap<>();
private Map<String,Integer[]> tableFiles = new HashMap<>();
private Map<String,Long> fileSizes = new HashMap<>();
private final Map<TableId,Integer> internalIds = new HashMap<>();
private final Map<Integer,TableId> externalIds = new HashMap<>();
private final Map<String,Integer[]> tableFiles = new HashMap<>();
private final Map<String,Long> fileSizes = new HashMap<>();

void addTable(TableId tableId) {
if (internalIds.containsKey(tableId)) {
Expand Down Expand Up @@ -329,7 +329,7 @@ public static void printDiskUsage(Collection<String> tableNames, AccumuloClient

static class Opts extends ServerUtilOpts {
@Parameter(description = " <table> { <table> ... } ")
List<String> tables = new ArrayList<>();
final List<String> tables = new ArrayList<>();
}

public static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BaseRelativeTime implements ProvidesTime {

private long diff = 0;
private long lastReportedTime = 0;
ProvidesTime local;
final ProvidesTime local;

BaseRelativeTime(ProvidesTime real, long lastReportedTime) {
this.local = real;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private RelativeTime() {
super(new SystemTime());
}

private static BaseRelativeTime instance = new RelativeTime();
private static final BaseRelativeTime instance = new RelativeTime();

public static BaseRelativeTime getInstance() {
return instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ public class DistributedWorkQueue {

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

private ZooReaderWriter zoo;
private String path;
private ServerContext context;
private long timerInitialDelay, timerPeriod;
private final ZooReaderWriter zoo;
private final String path;
private final ServerContext context;
private final long timerInitialDelay;
private final long timerPeriod;

private AtomicInteger numTask = new AtomicInteger(0);
private final AtomicInteger numTask = new AtomicInteger(0);

/**
* Finds a child in {@code children} that is not currently being processed and adds a Runnable to
Expand Down

0 comments on commit 99d9149

Please sign in to comment.