You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2011/10/27 17:25:17 UTC
svn commit: r1189806 [39/46] - in /incubator/accumulo: branches/1.3/contrib/
branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/
branches/1.3/src/core/src/main/java/org/apache/accumulo/core/client/admin/
branches/1.3/src/core/src/main/...
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/logger/LogWriter.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/logger/LogWriter.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/logger/LogWriter.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/logger/LogWriter.java Thu Oct 27 15:24:51 2011
@@ -124,12 +124,15 @@ class LogWriter implements MutationLogge
long t1 = System.currentTimeMillis();
seq.append(key, value);
long t2 = System.currentTimeMillis();
- if (metrics.isEnabled()) metrics.add(LogWriterMetrics.logAppend, (t2 - t1));
+ if (metrics.isEnabled())
+ metrics.add(LogWriterMetrics.logAppend, (t2 - t1));
out.flush();
long t3 = System.currentTimeMillis();
- if (metrics.isEnabled()) metrics.add(LogWriterMetrics.logFlush, (t3 - t2));
+ if (metrics.isEnabled())
+ metrics.add(LogWriterMetrics.logFlush, (t3 - t2));
} catch (IOException ioe) {
- if (metrics.isEnabled()) metrics.add(LogWriterMetrics.logException, 0);
+ if (metrics.isEnabled())
+ metrics.add(LogWriterMetrics.logException, 0);
throw ioe;
}
}
@@ -212,7 +215,8 @@ class LogWriter implements MutationLogge
if (entry.getValue().equals(id)) {
file2id.remove(entry.getKey());
long t2 = System.currentTimeMillis();
- if (metrics.isEnabled()) metrics.add(LogWriterMetrics.close, (t2 - t1));
+ if (metrics.isEnabled())
+ metrics.add(LogWriterMetrics.close, (t2 - t1));
return;
}
}
@@ -223,7 +227,8 @@ class LogWriter implements MutationLogge
private final String findLocalFilename(String localLog) throws FileNotFoundException {
for (String root : roots) {
String path = root + "/" + localLog;
- if (new File(path).exists()) return path;
+ if (new File(path).exists())
+ return path;
}
throw new FileNotFoundException("No file " + localLog + " found in " + roots);
}
@@ -234,7 +239,8 @@ class LogWriter implements MutationLogge
final long t1 = System.currentTimeMillis();
try {
Long id = file2id.get(localLog);
- if (id != null) close(info, id);
+ if (id != null)
+ close(info, id);
} catch (NoSuchLogIDException e) {
log.error("Unexpected error thrown", e);
throw new RuntimeException(e);
@@ -272,7 +278,8 @@ class LogWriter implements MutationLogge
log.error("Unable to create failure flag file", ex);
}
long t2 = System.currentTimeMillis();
- if (metrics.isEnabled()) metrics.add(LogWriterMetrics.copy, (t2 - t1));
+ if (metrics.isEnabled())
+ metrics.add(LogWriterMetrics.copy, (t2 - t1));
}
private void copySortLog(String localLog, String fullyQualifiedFileName) throws IOException {
@@ -293,7 +300,8 @@ class LogWriter implements MutationLogge
final LogFileKey key = new LogFileKey();
final LogFileValue value = new LogFileValue();
try {
- if (!reader.next(key, value)) break;
+ if (!reader.next(key, value))
+ break;
} catch (EOFException e) {
log.warn("Unexpected end of file reading write ahead log " + localLog);
break;
@@ -306,7 +314,8 @@ class LogWriter implements MutationLogge
memorySize = 0;
}
}
- if (!kv.isEmpty()) writeSortedEntries(dest, part++, kv);
+ if (!kv.isEmpty())
+ writeSortedEntries(dest, part++, kv);
fs.create(new Path(dest, "finished")).close();
} finally {
reader.close();
@@ -361,8 +370,10 @@ class LogWriter implements MutationLogge
} catch (IOException ex) {
log.warn("May have a partial copy of a recovery file: " + localLog, ex);
} finally {
- if (reader != null) reader.close();
- if (writer != null) writer.close();
+ if (reader != null)
+ reader.close();
+ if (writer != null)
+ writer.close();
}
// Make file appear in the shared file system as the target name only after it is completely copied
fs.rename(dest, new Path(fullyQualifiedFileName));
@@ -374,7 +385,8 @@ class LogWriter implements MutationLogge
@Override
public LogFile create(TInfo info, AuthInfo credentials, String tserverSession) throws ThriftSecurityException {
- if (closed) throw new RuntimeException("Logger is closed");
+ if (closed)
+ throw new RuntimeException("Logger is closed");
long t1 = System.currentTimeMillis();
LogFile result = new LogFile();
result.id = random.nextLong();
@@ -403,7 +415,8 @@ class LogWriter implements MutationLogge
throw new RuntimeException(e);
}
long t2 = System.currentTimeMillis();
- if (metrics.isEnabled()) metrics.add(LogWriterMetrics.create, (t2 - t1));
+ if (metrics.isEnabled())
+ metrics.add(LogWriterMetrics.create, (t2 - t1));
log.info("Created log " + result.name);
return result;
}
@@ -411,7 +424,8 @@ class LogWriter implements MutationLogge
@Override
public void log(TInfo info, long id, final long seq, final int tid, final TMutation mutation) throws NoSuchLogIDException {
Logger out = logs.get(id);
- if (out == null) throw new NoSuchLogIDException();
+ if (out == null)
+ throw new NoSuchLogIDException();
out.key.event = MUTATION;
out.key.seq = seq;
@@ -433,7 +447,8 @@ class LogWriter implements MutationLogge
private void logMany(TInfo info, long id, final long seq, final int tid, Mutation muations[]) throws NoSuchLogIDException {
Logger out = logs.get(id);
- if (out == null) throw new NoSuchLogIDException();
+ if (out == null)
+ throw new NoSuchLogIDException();
out.key.event = MANY_MUTATIONS;
out.key.seq = seq;
out.key.tid = tid;
@@ -454,7 +469,8 @@ class LogWriter implements MutationLogge
@Override
public void minorCompactionFinished(TInfo info, long id, final long seq, final int tid, final String fqfn) throws NoSuchLogIDException {
Logger out = logs.get(id);
- if (out == null) throw new NoSuchLogIDException();
+ if (out == null)
+ throw new NoSuchLogIDException();
out.key.event = COMPACTION_FINISH;
out.key.seq = seq;
out.key.tid = tid;
@@ -476,7 +492,8 @@ class LogWriter implements MutationLogge
@Override
public void minorCompactionStarted(TInfo info, long id, final long seq, final int tid, final String fqfn) throws NoSuchLogIDException {
Logger out = logs.get(id);
- if (out == null) throw new NoSuchLogIDException();
+ if (out == null)
+ throw new NoSuchLogIDException();
out.key.event = COMPACTION_START;
out.key.seq = seq;
out.key.tid = tid;
@@ -498,7 +515,8 @@ class LogWriter implements MutationLogge
@Override
public void defineTablet(TInfo info, long id, final long seq, final int tid, final TKeyExtent tablet) throws NoSuchLogIDException {
Logger out = logs.get(id);
- if (out == null) throw new NoSuchLogIDException();
+ if (out == null)
+ throw new NoSuchLogIDException();
out.key.event = DEFINE_TABLET;
out.key.seq = seq;
out.key.tid = tid;
@@ -537,10 +555,13 @@ class LogWriter implements MutationLogge
for (String root : roots) {
for (File file : new File(root).listFiles()) {
// skip dot-files
- if (file.getName().indexOf('.') >= 0) continue;
+ if (file.getName().indexOf('.') >= 0)
+ continue;
// skip open logs
- if (file2id.containsKey(file.getName())) continue;
- if (LogArchiver.isArchive(file.getName())) continue;
+ if (file2id.containsKey(file.getName()))
+ continue;
+ if (LogArchiver.isArchive(file.getName()))
+ continue;
try {
UUID.fromString(file.getName());
result.add(file.getName());
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/CoordinateRecoveryTask.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/CoordinateRecoveryTask.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/CoordinateRecoveryTask.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/CoordinateRecoveryTask.java Thu Oct 27 15:24:51 2011
@@ -68,7 +68,8 @@ public class CoordinateRecoveryTask impl
LogFile(String metadataEntry) {
String parts[] = metadataEntry.split("/");
- if (parts.length != 2) throw new RuntimeException("Bad log file name: " + metadataEntry);
+ if (parts.length != 2)
+ throw new RuntimeException("Bad log file name: " + metadataEntry);
server = parts[0];
file = parts[1];
}
@@ -163,7 +164,8 @@ public class CoordinateRecoveryTask impl
if (elapsedMillis() > ServerConfiguration.getSystemConfiguration().getTimeInMillis(Property.MASTER_RECOVERY_MAXTIME)) {
log.warn("Recovery taking too long, giving up");
- if (sortJob != null) sortJob.killJob();
+ if (sortJob != null)
+ sortJob.killJob();
return true;
}
@@ -193,7 +195,8 @@ public class CoordinateRecoveryTask impl
sortJob = null;
String failed = logFile.failedFileName();
try {
- if (createFailFlag) fs.create(new Path(failed)).close();
+ if (createFailFlag)
+ fs.create(new Path(failed)).close();
} catch (IOException e) {
log.warn("Unable to create recovery fail marker" + failed);
}
@@ -220,7 +223,8 @@ public class CoordinateRecoveryTask impl
try {
if (useMapReduce) {
Path unsorted = new Path(logFile.unsortedFileName());
- if (fs.exists(unsorted)) return fs.getFileStatus(unsorted).getLen();
+ if (fs.exists(unsorted))
+ return fs.getFileStatus(unsorted).getLen();
return fs.getFileStatus(new Path(logFile.copyTempFileName())).getLen();
} else {
ContentSummary contentSummary = fs.getContentSummary(new Path(logFile.recoveryFileName()));
@@ -266,7 +270,8 @@ public class CoordinateRecoveryTask impl
log.info("Error looking for recovery files", ex);
}
}
- if (found) continue;
+ if (found)
+ continue;
finished = false;
// Start recovering all the logs we could need
for (String metadataEntry : set) {
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/EventCoordinator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/EventCoordinator.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/EventCoordinator.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/EventCoordinator.java Thu Oct 27 15:24:51 2011
@@ -27,7 +27,8 @@ public class EventCoordinator {
// Did something happen since the last time we waited?
if (lastEvent == eventCounter) {
// no
- if (millis <= 0) return eventCounter;
+ if (millis <= 0)
+ return eventCounter;
try {
wait(millis);
} catch (InterruptedException e) {
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java Thu Oct 27 15:24:51 2011
@@ -103,11 +103,13 @@ public class LiveTServerSet implements W
}
synchronized public void halt(ZooLock lock) throws TException, ThriftSecurityException {
- if (client != null) client.halt(null, SecurityConstants.getSystemCredentials(), lockString(lock));
+ if (client != null)
+ client.halt(null, SecurityConstants.getSystemCredentials(), lockString(lock));
}
public void fastHalt(ZooLock lock) throws TException {
- if (client != null) client.fastHalt(null, SecurityConstants.getSystemCredentials(), lockString(lock));
+ if (client != null)
+ client.fastHalt(null, SecurityConstants.getSystemCredentials(), lockString(lock));
}
synchronized public void flush(ZooLock lock, String tableId, byte[] startRow, byte[] endRow) throws TException {
@@ -171,7 +173,8 @@ public class LiveTServerSet implements W
}
public synchronized ZooCache getZooCache() {
- if (zooCache == null) zooCache = new ZooCache(this);
+ if (zooCache == null)
+ zooCache = new ZooCache(this);
return zooCache;
}
@@ -239,7 +242,8 @@ public class LiveTServerSet implements W
}
}
// log.debug("Current: " + current.keySet());
- if (!doomed.isEmpty() && !updates.isEmpty()) this.cback.update(this, doomed, updates);
+ if (!doomed.isEmpty() && !updates.isEmpty())
+ this.cback.update(this, doomed, updates);
} catch (Exception ex) {
log.error(ex, ex);
}
@@ -253,12 +257,15 @@ public class LiveTServerSet implements W
public synchronized TServerConnection getConnection(TServerInstance server) throws TException {
TServerConnection result;
synchronized (this) {
- if (server == null) return null;
+ if (server == null)
+ return null;
TServerInfo serverInfo = current.get(server.hostPort());
// lock was lost?
- if (serverInfo == null) return null;
+ if (serverInfo == null)
+ return null;
// instance changed?
- if (!serverInfo.instance.equals(server)) return null;
+ if (!serverInfo.instance.equals(server))
+ return null;
result = serverInfo.connection;
}
return result;
@@ -302,7 +309,7 @@ public class LiveTServerSet implements W
try {
ZooReaderWriter.getRetryingInstance().recursiveDelete(zpath, SKIP);
} catch (Exception e) {
- String msg = "error removing tablet server lock";
+ String msg = "error removing tablet server lock";
log.fatal(msg, e);
Halt.halt(msg, -1);
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LogSort.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LogSort.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LogSort.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/LogSort.java Thu Oct 27 15:24:51 2011
@@ -111,7 +111,8 @@ public class LogSort extends Configured
* The main driver for sort program. Invoke this method to submit the map/reduce job.
*/
public int run(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
- if (job != null) throw new RuntimeException("job has already run");
+ if (job != null)
+ throw new RuntimeException("job has already run");
// parse options
int num_reduces = 1;
@@ -120,10 +121,14 @@ public class LogSort extends Configured
List<String> otherArgs = new ArrayList<String>();
for (int i = 0; i < args.length; ++i) {
try {
- if ("-r".equals(args[i])) num_reduces = Integer.parseInt(args[++i]);
- else if ("-q".equals(args[i])) queueName = args[++i];
- else if ("-p".equals(args[i])) poolName = args[++i];
- else otherArgs.add(args[i]);
+ if ("-r".equals(args[i]))
+ num_reduces = Integer.parseInt(args[++i]);
+ else if ("-q".equals(args[i]))
+ queueName = args[++i];
+ else if ("-p".equals(args[i]))
+ poolName = args[++i];
+ else
+ otherArgs.add(args[i]);
} catch (NumberFormatException e) {
log.error("Integer expected instead of " + args[i], e);
printUsage();
@@ -178,8 +183,10 @@ public class LogSort extends Configured
public static Job startSort(boolean background, String[] args) throws Exception {
LogSort sort = new LogSort();
ToolRunner.run(CachedConfiguration.getInstance(), sort, args);
- if (background) sort.job.submit();
- else sort.job.waitForCompletion(true);
+ if (background)
+ sort.job.submit();
+ else
+ sort.job.waitForCompletion(true);
return sort.job;
}
@@ -188,7 +195,8 @@ public class LogSort extends Configured
log.info("Job started");
Job job = startSort(false, args);
log.info("The job finished after " + ((System.currentTimeMillis() - startTime) / 1000) + " seconds.");
- if (!job.isSuccessful()) System.exit(1);
+ if (!job.isSuccessful())
+ System.exit(1);
}
private static class LoggerMapFileOutputFormat extends FileOutputFormat<WritableComparable<?>,Writable> {
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/Master.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/Master.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/Master.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/Master.java Thu Oct 27 15:24:51 2011
@@ -204,13 +204,17 @@ public class Master implements LiveTServ
public MergeStats(MergeInfo info) {
this.info = info;
- if (info.getState().equals(MergeState.NONE)) return;
- if (info.getRange().getEndRow() == null) upperSplit = true;
- if (info.getRange().getPrevEndRow() == null) lowerSplit = true;
+ if (info.getState().equals(MergeState.NONE))
+ return;
+ if (info.getRange().getEndRow() == null)
+ upperSplit = true;
+ if (info.getRange().getPrevEndRow() == null)
+ lowerSplit = true;
}
void update(KeyExtent ke, TabletState state, boolean chopped) {
- if (info.getState().equals(MergeState.NONE)) return;
+ if (info.getState().equals(MergeState.NONE))
+ return;
if (!upperSplit && info.getRange().getEndRow().equals(ke.getPrevEndRow())) {
log.info("Upper split found");
upperSplit = true;
@@ -219,14 +223,18 @@ public class Master implements LiveTServ
log.info("Lower split found");
lowerSplit = true;
}
- if (!info.overlaps(ke)) return;
+ if (!info.overlaps(ke))
+ return;
if (info.needsToBeChopped(ke)) {
this.needsToBeChopped++;
- if (chopped) this.chopped++;
+ if (chopped)
+ this.chopped++;
}
this.total++;
- if (state.equals(TabletState.HOSTED)) this.hosted++;
- if (state.equals(TabletState.UNASSIGNED)) this.unassigned++;
+ if (state.equals(TabletState.HOSTED))
+ this.hosted++;
+ if (state.equals(TabletState.UNASSIGNED))
+ this.unassigned++;
}
}
@@ -268,17 +276,18 @@ public class Master implements LiveTServ
static final boolean X = true;
static final boolean _ = false;
static final boolean transitionOK[][] = {
- // INITIAL HAVE_LOCK SAFE_MODE NORMAL UNLOAD_META UNLOAD_ROOT STOP
- /* INITIAL */{X, X, _, _, _, _, X},
- /* HAVE_LOCK */{_, X, X, X, _, _, X},
- /* SAFE_MODE */{_, _, X, X, X, _, X},
- /* NORMAL */{_, _, X, X, X, _, X},
- /* UNLOAD_METADATA_TABLETS */{_, _, X, X, X, X, X},
- /* UNLOAD_ROOT_TABLET */{_, _, _, _, _, X, X},
- /* STOP */{_, _, _, _, _, _, X},};
+ // INITIAL HAVE_LOCK SAFE_MODE NORMAL UNLOAD_META UNLOAD_ROOT STOP
+ /* INITIAL */{X, X, _, _, _, _, X},
+ /* HAVE_LOCK */{_, X, X, X, _, _, X},
+ /* SAFE_MODE */{_, _, X, X, X, _, X},
+ /* NORMAL */{_, _, X, X, X, _, X},
+ /* UNLOAD_METADATA_TABLETS */{_, _, X, X, X, X, X},
+ /* UNLOAD_ROOT_TABLET */{_, _, _, _, _, X, X},
+ /* STOP */{_, _, _, _, _, _, X},};
synchronized private void setMasterState(MasterState newState) {
- if (state.equals(newState)) return;
+ if (state.equals(newState))
+ return;
if (!transitionOK[state.ordinal()][newState.ordinal()]) {
log.error("Programmer error: master should not transition from " + state + " to " + newState);
}
@@ -316,7 +325,8 @@ public class Master implements LiveTServ
log.error(String.format("Unable to upgrade: extent %s has log entry %s", entry.getKey().getRow(), entry.getValue()));
fail = true;
}
- if (fail) throw new Exception("Upgrade requires a clean shutdown");
+ if (fail)
+ throw new Exception("Upgrade requires a clean shutdown");
// perform 1.2 -> 1.3 settings
zset(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey() + "tablet",
@@ -442,13 +452,16 @@ public class Master implements LiveTServ
private void verify(AuthInfo credentials, String tableId, TableOperation op, boolean match) throws ThriftSecurityException, ThriftTableOperationException {
if (!match) {
Tables.clearCache(instance);
- if (!Tables.exists(instance, tableId)) throw new ThriftTableOperationException(tableId, null, op, TableOperationExceptionType.NOTFOUND, null);
- else throw new AccumuloSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED).asThriftException();
+ if (!Tables.exists(instance, tableId))
+ throw new ThriftTableOperationException(tableId, null, op, TableOperationExceptionType.NOTFOUND, null);
+ else
+ throw new AccumuloSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED).asThriftException();
}
}
private void verify(AuthInfo credentials, boolean match) throws ThriftSecurityException {
- if (!match) throw new AccumuloSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED).asThriftException();
+ if (!match)
+ throw new AccumuloSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED).asThriftException();
}
private boolean check(AuthInfo credentials, SystemPermission permission) throws ThriftSecurityException {
@@ -469,8 +482,8 @@ public class Master implements LiveTServ
public void mustBeOnline(final String tableId) throws ThriftTableOperationException {
Tables.clearCache(instance);
- if (!Tables.getTableState(instance, tableId).equals(TableState.ONLINE)) throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE,
- TableOperationExceptionType.OFFLINE, "table is not online");
+ if (!Tables.getTableState(instance, tableId).equals(TableState.ONLINE))
+ throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online");
}
Connector getConnector() throws AccumuloException, AccumuloSecurityException {
@@ -532,7 +545,8 @@ public class Master implements LiveTServ
protected String checkTableId(String tableName, TableOperation operation) throws ThriftTableOperationException {
final String tableId = Tables.getNameToIdMap(HdfsZooInstance.getInstance()).get(tableName);
- if (tableId == null) throw new ThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.NOTFOUND, null);
+ if (tableId == null)
+ throw new ThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.NOTFOUND, null);
return tableId;
}
@@ -567,8 +581,9 @@ public class Master implements LiveTServ
throws ThriftSecurityException, ThriftTableOperationException, TException {
verify(c, tableId, TableOperation.FLUSH, check(c, tableId, TablePermission.WRITE) || check(c, tableId, TablePermission.ALTER_TABLE));
- if (endRow != null && startRow != null && ByteBufferUtil.toText(startRow).compareTo(ByteBufferUtil.toText(endRow)) >= 0) throw new ThriftTableOperationException(
- tableId, null, TableOperation.FLUSH, TableOperationExceptionType.BAD_RANGE, "start row must be less than end row");
+ if (endRow != null && startRow != null && ByteBufferUtil.toText(startRow).compareTo(ByteBufferUtil.toText(endRow)) >= 0)
+ throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH, TableOperationExceptionType.BAD_RANGE,
+ "start row must be less than end row");
Set<TServerInstance> serversToFlush = new HashSet<TServerInstance>(tserverSet.getCurrentServers());
@@ -577,13 +592,15 @@ public class Master implements LiveTServ
for (TServerInstance instance : serversToFlush) {
try {
final TServerConnection server = tserverSet.getConnection(instance);
- if (server != null) server.flush(masterLock, tableId, ByteBufferUtil.toBytes(startRow), ByteBufferUtil.toBytes(endRow));
+ if (server != null)
+ server.flush(masterLock, tableId, ByteBufferUtil.toBytes(startRow), ByteBufferUtil.toBytes(endRow));
} catch (TException ex) {
log.error(ex.toString());
}
}
- if (l == maxLoops - 1) break;
+ if (l == maxLoops - 1)
+ break;
UtilWaitThread.sleep(50);
@@ -623,7 +640,8 @@ public class Master implements LiveTServ
tabletFlushID = Long.parseLong(entry.getValue().toString());
}
- if (Constants.METADATA_LOG_COLUMN_FAMILY.equals(key.getColumnFamily())) logs++;
+ if (Constants.METADATA_LOG_COLUMN_FAMILY.equals(key.getColumnFamily()))
+ logs++;
if (Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY.equals(key.getColumnFamily())) {
online = true;
@@ -635,21 +653,24 @@ public class Master implements LiveTServ
// when tablet is not online and has no logs, there is no reason to wait for it
if ((online || logs > 0) && tabletFlushID < flushID) {
tabletsToWaitFor++;
- if (server != null) serversToFlush.add(server);
+ if (server != null)
+ serversToFlush.add(server);
}
tabletCount++;
Text tabletEndRow = new KeyExtent(entry.getKey().getRow(), (Text) null).getEndRow();
- if (tabletEndRow == null || (ert != null && tabletEndRow.compareTo(ert) >= 0)) break;
+ if (tabletEndRow == null || (ert != null && tabletEndRow.compareTo(ert) >= 0))
+ break;
}
- if (tabletsToWaitFor == 0) break;
+ if (tabletsToWaitFor == 0)
+ break;
// TODO detect case of table offline AND tablets w/ logs?
- if (tabletCount == 0 && !Tables.exists(instance, tableId)) throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH,
- TableOperationExceptionType.NOTFOUND, null);
+ if (tabletCount == 0 && !Tables.exists(instance, tableId))
+ throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH, TableOperationExceptionType.NOTFOUND, null);
} catch (AccumuloException e) {
log.debug("Failed to scan !METADATA table to wait for flush " + tableId, e);
@@ -836,8 +857,8 @@ public class Master implements LiveTServ
private void authenticate(AuthInfo credentials) throws ThriftSecurityException {
try {
- if (!authenticator.authenticateUser(credentials, credentials.user, credentials.password)) throw new ThriftSecurityException(credentials.user,
- SecurityErrorCode.BAD_CREDENTIALS);
+ if (!authenticator.authenticateUser(credentials, credentials.user, credentials.password))
+ throw new ThriftSecurityException(credentials.user, SecurityErrorCode.BAD_CREDENTIALS);
} catch (AccumuloSecurityException e) {
throw e.asThriftException();
}
@@ -1003,14 +1024,19 @@ public class Master implements LiveTServ
TStatus status = fate.waitForCompletion(opid);
if (status == TStatus.FAILED) {
Exception e = fate.getException(opid);
- if (e instanceof ThriftTableOperationException) throw (ThriftTableOperationException) e;
- if (e instanceof ThriftSecurityException) throw (ThriftSecurityException) e;
- else if (e instanceof RuntimeException) throw (RuntimeException) e;
- else throw new RuntimeException(e);
+ if (e instanceof ThriftTableOperationException)
+ throw (ThriftTableOperationException) e;
+ if (e instanceof ThriftSecurityException)
+ throw (ThriftSecurityException) e;
+ else if (e instanceof RuntimeException)
+ throw (RuntimeException) e;
+ else
+ throw new RuntimeException(e);
}
String ret = fate.getReturn(opid);
- if (ret == null) ret = ""; // thrift does not like returning null
+ if (ret == null)
+ ret = ""; // thrift does not like returning null
return ret;
}
@@ -1027,7 +1053,8 @@ public class Master implements LiveTServ
synchronized (mergeLock) {
try {
String path = ZooUtil.getRoot(instance.getInstanceID()) + Constants.ZTABLES + "/" + tableId.toString() + "/merge";
- if (!ZooReaderWriter.getInstance().exists(path)) return new MergeInfo();
+ if (!ZooReaderWriter.getInstance().exists(path))
+ return new MergeInfo();
byte[] data = ZooReaderWriter.getInstance().getData(path, new Stat());
DataInputBuffer in = new DataInputBuffer();
in.reset(data, data.length);
@@ -1107,7 +1134,8 @@ public class Master implements LiveTServ
public boolean hasCycled(long time) {
for (TabletGroupWatcher watcher : watchers) {
- if (watcher.stats.lastScanFinished() < time) return false;
+ if (watcher.stats.lastScanFinished() < time)
+ return false;
}
return true;
@@ -1136,10 +1164,12 @@ public class Master implements LiveTServ
case HAVE_LOCK: // fall-through intended
case INITIAL: // fall-through intended
case SAFE_MODE:
- if (tls.extent.getTableId().equals(METADATA_TABLE_ID)) return TabletGoalState.HOSTED;
+ if (tls.extent.getTableId().equals(METADATA_TABLE_ID))
+ return TabletGoalState.HOSTED;
return TabletGoalState.UNASSIGNED;
case UNLOAD_METADATA_TABLETS:
- if (tls.extent.equals(Constants.ROOT_TABLET_EXTENT)) return TabletGoalState.HOSTED;
+ if (tls.extent.equals(Constants.ROOT_TABLET_EXTENT))
+ return TabletGoalState.HOSTED;
return TabletGoalState.UNASSIGNED;
case UNLOAD_ROOT_TABLET:
return TabletGoalState.UNASSIGNED;
@@ -1152,7 +1182,8 @@ public class Master implements LiveTServ
TabletGoalState getTableGoalState(KeyExtent extent) {
TableState tableState = TableManager.getInstance().getTableState(extent.getTableId().toString());
- if (tableState == null) return TabletGoalState.DELETED;
+ if (tableState == null)
+ return TabletGoalState.DELETED;
switch (tableState) {
case DELETING:
return TabletGoalState.DELETED;
@@ -1298,7 +1329,8 @@ public class Master implements LiveTServ
}
switch (state) {
case HOSTED:
- if (server.equals(migrations.get(tls.extent))) migrations.remove(tls.extent);
+ if (server.equals(migrations.get(tls.extent)))
+ migrations.remove(tls.extent);
break;
case ASSIGNED_TO_DEAD_SERVER:
assignedToDeadServers.add(tls);
@@ -1374,19 +1406,26 @@ public class Master implements LiveTServ
private void sendSplitRequest(MergeInfo info, TabletState state, TabletLocationState tls) {
// Already split?
- if (!info.getState().equals(MergeState.SPLITTING)) return;
+ if (!info.getState().equals(MergeState.SPLITTING))
+ return;
// Merges don't split
- if (!info.isDelete()) return;
+ if (!info.isDelete())
+ return;
// Online and ready to split?
- if (!state.equals(TabletState.HOSTED)) return;
+ if (!state.equals(TabletState.HOSTED))
+ return;
// Does this extent cover the end points of the delete?
KeyExtent range = info.getRange();
if (tls.extent.overlaps(range)) {
for (Text splitPoint : new Text[] {range.getPrevEndRow(), range.getEndRow()}) {
- if (splitPoint == null) continue;
- if (!tls.extent.contains(splitPoint)) continue;
- if (splitPoint.equals(tls.extent.getEndRow())) continue;
- if (splitPoint.equals(tls.extent.getPrevEndRow())) continue;
+ if (splitPoint == null)
+ continue;
+ if (!tls.extent.contains(splitPoint))
+ continue;
+ if (splitPoint.equals(tls.extent.getEndRow()))
+ continue;
+ if (splitPoint.equals(tls.extent.getPrevEndRow()))
+ continue;
try {
TServerConnection conn;
conn = tserverSet.getConnection(tls.current);
@@ -1405,11 +1444,14 @@ public class Master implements LiveTServ
private void sendChopRequest(MergeInfo info, TabletState state, TabletLocationState tls) {
// Don't bother if we're in the wrong state
- if (!info.getState().equals(MergeState.WAITING_FOR_CHOPPED)) return;
+ if (!info.getState().equals(MergeState.WAITING_FOR_CHOPPED))
+ return;
// Tablet must be online
- if (!state.equals(TabletState.HOSTED)) return;
+ if (!state.equals(TabletState.HOSTED))
+ return;
// Tablet isn't already chopped
- if (tls.chopped) return;
+ if (tls.chopped)
+ return;
// Tablet ranges intersect
if (info.needsToBeChopped(tls.extent)) {
TServerConnection conn;
@@ -1441,9 +1483,12 @@ public class Master implements LiveTServ
setMergeState(stats.info, state = MergeState.COMPLETE);
} else if (stats.hosted == stats.total) {
if (stats.info.isDelete()) {
- if (!stats.lowerSplit) log.info("Waiting for " + stats.info + " lower split to occur");
- else if (!stats.upperSplit) log.info("Waiting for " + stats.info + " upper split to occur");
- else setMergeState(stats.info, state = MergeState.WAITING_FOR_CHOPPED);
+ if (!stats.lowerSplit)
+ log.info("Waiting for " + stats.info + " lower split to occur");
+ else if (!stats.upperSplit)
+ log.info("Waiting for " + stats.info + " upper split to occur");
+ else
+ setMergeState(stats.info, state = MergeState.WAITING_FOR_CHOPPED);
} else {
setMergeState(stats.info, state = MergeState.WAITING_FOR_CHOPPED);
}
@@ -1485,8 +1530,10 @@ public class Master implements LiveTServ
log.info(stats.unassigned + " tablets are unassigned");
if (stats.hosted == 0 && stats.unassigned == stats.total) {
try {
- if (stats.info.isDelete()) deleteTablets(stats.info);
- else mergeMetadataRecords(stats.info);
+ if (stats.info.isDelete())
+ deleteTablets(stats.info);
+ else
+ mergeMetadataRecords(stats.info);
setMergeState(stats.info, state = MergeState.COMPLETE);
} catch (Exception ex) {
log.error("Unable merge metadata table records", ex);
@@ -1604,7 +1651,8 @@ public class Master implements LiveTServ
for (Entry<Key,Value> entry : scanner) {
Key key = entry.getKey();
Value value = entry.getValue();
- if (key.getRow().equals(stopRow)) break;
+ if (key.getRow().equals(stopRow))
+ break;
if (key.getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
m.put(key.getColumnFamily(), key.getColumnQualifier(), value);
fileCount++;
@@ -1652,7 +1700,8 @@ public class Master implements LiveTServ
scanner.setRange(scanRange);
for (Entry<Key,Value> entry : scanner) {
Key key = entry.getKey();
- if (key.getRow().equals(stopRow)) break;
+ if (key.getRow().equals(stopRow))
+ break;
if (Constants.METADATA_DIRECTORY_COLUMN.hasColumns(key)) {
bw.addMutation(MetadataTable.createDeleteMutation(range.getTableId().toString(), entry.getValue().toString()));
}
@@ -1729,7 +1778,8 @@ public class Master implements LiveTServ
log.warn(store.name() + " load balancer assigning tablet that was not nominated for assignment " + assignment.getKey());
}
}
- if (!unassigned.isEmpty() && assignedOut.isEmpty()) log.warn("Load balancer failed to assign any tablets");
+ if (!unassigned.isEmpty() && assignedOut.isEmpty())
+ log.warn("Load balancer failed to assign any tablets");
}
if (assignments.size() > 0) {
@@ -1821,7 +1871,8 @@ public class Master implements LiveTServ
case SAFE_MODE:
count = nonMetaDataTabletsAssignedOrHosted();
log.debug(String.format("There are %d non-metadata tablets assigned or hosted", count));
- if (count == 0) setMasterState(MasterState.UNLOAD_METADATA_TABLETS);
+ if (count == 0)
+ setMasterState(MasterState.UNLOAD_METADATA_TABLETS);
break;
case UNLOAD_METADATA_TABLETS:
count = assignedOrHosted(METADATA_TABLE_ID);
@@ -1829,11 +1880,13 @@ public class Master implements LiveTServ
// Assumes last tablet hosted is the root tablet;
// it's possible
// that's not the case (root tablet is offline?)
- if (count == 1) setMasterState(MasterState.UNLOAD_ROOT_TABLET);
+ if (count == 1)
+ setMasterState(MasterState.UNLOAD_ROOT_TABLET);
break;
case UNLOAD_ROOT_TABLET:
count = assignedOrHosted(METADATA_TABLE_ID);
- if (count > 0) log.debug(String.format("The root tablet is still assigned or hosted"));
+ if (count > 0)
+ log.debug(String.format("The root tablet is still assigned or hosted"));
if (count == 0) {
Set<TServerInstance> currentServers = tserverSet.getCurrentServers();
log.debug("stopping " + currentServers.size() + " tablet servers");
@@ -1847,7 +1900,8 @@ public class Master implements LiveTServ
tserverSet.remove(server);
}
}
- if (currentServers.size() == 0) setMasterState(MasterState.STOP);
+ if (currentServers.size() == 0)
+ setMasterState(MasterState.STOP);
}
break;
default:
@@ -1898,7 +1952,8 @@ public class Master implements LiveTServ
log.warn("Tablet server " + instance + " exceeded maximum hold time: attempting to kill it");
try {
TServerConnection connection = tserverSet.getConnection(instance);
- if (connection != null) connection.fastHalt(masterLock);
+ if (connection != null)
+ connection.fastHalt(masterLock);
} catch (TException e) {
log.error(e, e);
}
@@ -1920,7 +1975,8 @@ public class Master implements LiveTServ
try {
log.debug("Telling " + tserver.getInstance() + " to use loggers " + entry.getValue());
TServerConnection connection = tserverSet.getConnection(tserver.getInstance());
- if (connection != null) connection.useLoggers(new HashSet<String>(entry.getValue()));
+ if (connection != null)
+ connection.useLoggers(new HashSet<String>(entry.getValue()));
} catch (Exception ex) {
log.warn("Unable to talk to " + tserver.getInstance(), ex);
}
@@ -1960,7 +2016,8 @@ public class Master implements LiveTServ
log.warn("attempting to stop " + server);
try {
TServerConnection connection = tserverSet.getConnection(server);
- if (connection != null) connection.halt(masterLock);
+ if (connection != null)
+ connection.halt(masterLock);
} catch (TTransportException e) {
// ignore: it's probably down
} catch (Exception e) {
@@ -2131,8 +2188,10 @@ public class Master implements LiveTServ
}
for (TServerInstance dead : deleted) {
String cause = I_DONT_KNOW_WHY;
- if (serversToShutdown.contains(dead)) cause = "clean shutdown"; // maybe an incorrect assumption
- if (!getMasterGoalState().equals(MasterGoalState.CLEAN_STOP)) obit.post(dead.hostPort(), cause);
+ if (serversToShutdown.contains(dead))
+ cause = "clean shutdown"; // maybe an incorrect assumption
+ if (!getMasterGoalState().equals(MasterGoalState.CLEAN_STOP))
+ obit.post(dead.hostPort(), cause);
}
Set<TServerInstance> unexpected = new HashSet<TServerInstance>(deleted);
@@ -2173,7 +2232,8 @@ public class Master implements LiveTServ
public Set<String> onlineTables() {
Set<String> result = new HashSet<String>();
if (getMasterState() != MasterState.NORMAL) {
- if (getMasterState() != MasterState.UNLOAD_METADATA_TABLETS) result.add(Constants.METADATA_TABLE_ID);
+ if (getMasterState() != MasterState.UNLOAD_METADATA_TABLETS)
+ result.add(Constants.METADATA_TABLE_ID);
return result;
}
TableManager manager = TableManager.getInstance();
@@ -2181,7 +2241,8 @@ public class Master implements LiveTServ
for (String tableId : Tables.getIdToNameMap(instance).keySet()) {
TableState state = manager.getTableState(tableId);
if (state != null) {
- if (state == TableState.ONLINE) result.add(tableId);
+ if (state == TableState.ONLINE)
+ result.add(tableId);
}
}
return result;
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/TabletServerLoggers.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/TabletServerLoggers.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/TabletServerLoggers.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/TabletServerLoggers.java Thu Oct 27 15:24:51 2011
@@ -61,7 +61,8 @@ public class TabletServerLoggers impleme
Map<String,String> current = new HashMap<String,String>();
for (String child : cache.getChildren(path)) {
byte[] value = cache.get(path + "/" + child);
- if (value != null) current.put(child, new String(value));
+ if (value != null)
+ current.put(child, new String(value));
}
return current;
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java Thu Oct 27 15:24:51 2011
@@ -51,7 +51,8 @@ public class DefaultLoadBalancer extends
}
public TServerInstance getAssignment(SortedMap<TServerInstance,TabletServerStatus> locations, KeyExtent extent, TServerInstance last) {
- if (locations.size() == 0) return null;
+ if (locations.size() == 0)
+ return null;
if (last != null) {
// Maintain locality
@@ -59,13 +60,15 @@ public class DefaultLoadBalancer extends
Iterator<TServerInstance> find = locations.tailMap(simple).keySet().iterator();
if (find.hasNext()) {
TServerInstance current = find.next();
- if (current.host().equals(last.host())) return current;
+ if (current.host().equals(last.host()))
+ return current;
}
}
// The strategy here is to walk through the locations and hand them back, one at a time
// Grab an iterator off of the set of options; use a new iterator if it hands back something not in the current list.
- if (assignments == null || !assignments.hasNext()) assignments = locations.keySet().iterator();
+ if (assignments == null || !assignments.hasNext())
+ assignments = locations.keySet().iterator();
TServerInstance result = assignments.next();
if (!locations.containsKey(result)) {
assignments = null;
@@ -87,7 +90,8 @@ public class DefaultLoadBalancer extends
public int compareTo(ServerCounts obj) {
int result = count - obj.count;
- if (result == 0) return server.compareTo(obj.server);
+ if (result == 0)
+ return server.compareTo(obj.server);
return result;
}
}
@@ -110,7 +114,8 @@ public class DefaultLoadBalancer extends
/**
* The check below was on entry.getKey(), but that resolves to a tabletserver not a tablename. Believe it should be e.getKey() which is a tablename
*/
- if (tableToBalance == null || tableToBalance.equals(e.getKey())) serverTotal += e.getValue().onlineTablets;
+ if (tableToBalance == null || tableToBalance.equals(e.getKey()))
+ serverTotal += e.getValue().onlineTablets;
}
}
totals.add(new ServerCounts(serverTotal, entry.getKey(), entry.getValue()));
@@ -151,7 +156,8 @@ public class DefaultLoadBalancer extends
result.addAll(move(tooMany, tooLittle, needToUnload));
movedAlready += needToUnload;
}
- if (needToUnload > needToLoad) moreBalancingNeeded = true;
+ if (needToUnload > needToLoad)
+ moreBalancingNeeded = true;
}
} finally {
@@ -176,7 +182,8 @@ public class DefaultLoadBalancer extends
List<TabletMigration> move(ServerCounts tooMuch, ServerCounts tooLittle, int count) {
List<TabletMigration> result = new ArrayList<TabletMigration>();
- if (count == 0) return result;
+ if (count == 0)
+ return result;
Map<String,Map<KeyExtent,TabletStats>> onlineTablets = new HashMap<String,Map<KeyExtent,TabletStats>>();
// Copy counts so we can update them as we propose migrations
@@ -193,7 +200,8 @@ public class DefaultLoadBalancer extends
String biggestDifferenceTable = null;
for (Entry<String,Integer> tableEntry : tooMuchMap.entrySet()) {
String tableID = tableEntry.getKey();
- if (tooLittleMap.get(tableID) == null) tooLittleMap.put(tableID, 0);
+ if (tooLittleMap.get(tableID) == null)
+ tooLittleMap.put(tableID, 0);
int diff = tableEntry.getValue() - tooLittleMap.get(tableID);
if (diff > biggestDifference) {
biggestDifference = diff;
@@ -223,7 +231,8 @@ public class DefaultLoadBalancer extends
}
KeyExtent extent = selectTablet(tooMuch.server, onlineTabletsForTable);
onlineTabletsForTable.remove(extent);
- if (extent == null) return result;
+ if (extent == null)
+ return result;
tooMuchMap.put(table, tooMuchMap.get(table) - 1);
/**
* If a table grows from 1 tablet then tooLittleMap.get(table) can return a null, since there is only one tabletserver that holds all of the tablets. Here
@@ -252,7 +261,8 @@ public class DefaultLoadBalancer extends
}
static KeyExtent selectTablet(TServerInstance tserver, Map<KeyExtent,TabletStats> extents) {
- if (extents.size() == 0) return null;
+ if (extents.size() == 0)
+ return null;
KeyExtent mostRecentlySplit = null;
long splitTime = 0;
for (Entry<KeyExtent,TabletStats> entry : extents.entrySet())
@@ -292,7 +302,8 @@ public class DefaultLoadBalancer extends
if (current.size() > 0) {
// Don't migrate if we have migrations in progress
if (migrations.size() == 0) {
- if (getMigrations(current, migrationsOut)) return 1 * 1000;
+ if (getMigrations(current, migrationsOut))
+ return 1 * 1000;
}
}
return 5 * 1000;
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/SimpleLoggerBalancer.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/SimpleLoggerBalancer.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/SimpleLoggerBalancer.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/SimpleLoggerBalancer.java Thu Oct 27 15:24:51 2011
@@ -42,11 +42,14 @@ public class SimpleLoggerBalancer implem
@Override
public void balance(List<LoggerUser> current, List<String> loggers, Map<LoggerUser,List<String>> assignmentsOut, int loggersPerServer) {
- if (System.currentTimeMillis() - lastBalance < minimumTimeBetweenRebalances) return;
+ if (System.currentTimeMillis() - lastBalance < minimumTimeBetweenRebalances)
+ return;
// any loggers?
- if (loggers.size() <= 0) return;
+ if (loggers.size() <= 0)
+ return;
// more than one user of loggers?
- if (current.size() < 2) return;
+ if (current.size() < 2)
+ return;
// compute the "load" on loggers, create a list of the users for each logger
Map<String,List<LoggerUser>> counts = new HashMap<String,List<LoggerUser>>();
@@ -57,7 +60,8 @@ public class SimpleLoggerBalancer implem
for (LoggerUser user : current) {
for (String logger : user.getLoggers()) {
uses++;
- if (!counts.containsKey(logger)) counts.put(logger, new ArrayList<LoggerUser>());
+ if (!counts.containsKey(logger))
+ counts.put(logger, new ArrayList<LoggerUser>());
counts.get(logger).add(user);
}
}
@@ -73,26 +77,32 @@ public class SimpleLoggerBalancer implem
// already balanced?
// balanced means that no logger is being used by more than ceiling(average(number servers per logger))
final int average = (int) Math.ceil((double) uses / loggers.size());
- if (byCount.get(0).getValue().size() <= average) return;
+ if (byCount.get(0).getValue().size() <= average)
+ return;
// Rebalance
// move a server on high-use loggers to low-use loggers if it is not currently using that logger
for (Entry<String,List<LoggerUser>> entry : byCount) {
// String logger = entry.getKey();
List<LoggerUser> servers = entry.getValue();
- if (servers.size() <= average) return;
+ if (servers.size() <= average)
+ return;
// Walk backwards from the low-use loggers, looking for a logger that is:
// 1) still low-use and 2) not used by this server
for (int i = byCount.size() - 1; i >= 0; i--) {
String lowCountLogger = byCount.get(i).getKey();
List<LoggerUser> lowCountUsers = byCount.get(i).getValue();
- if (lowCountUsers.size() >= average) continue;
+ if (lowCountUsers.size() >= average)
+ continue;
Set<LoggerUser> notUsingLowCountLogger = (Set<LoggerUser>) new HashSet<LoggerUser>(servers);
notUsingLowCountLogger.removeAll(lowCountUsers);
- if (notUsingLowCountLogger.isEmpty()) continue;
+ if (notUsingLowCountLogger.isEmpty())
+ continue;
for (LoggerUser user : notUsingLowCountLogger) {
- if (lowCountUsers.size() >= average) break;
- if (!assignmentsOut.containsKey(user)) assignmentsOut.put(user, new ArrayList<String>());
+ if (lowCountUsers.size() >= average)
+ break;
+ if (!assignmentsOut.containsKey(user))
+ assignmentsOut.put(user, new ArrayList<String>());
if (assignmentsOut.get(user).size() < loggersPerServer) {
assignmentsOut.get(user).add(lowCountLogger);
lowCountUsers.add(user);
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TServerUsesLoggers.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TServerUsesLoggers.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TServerUsesLoggers.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TServerUsesLoggers.java Thu Oct 27 15:24:51 2011
@@ -39,7 +39,8 @@ public class TServerUsesLoggers implemen
@Override
public int compareTo(LoggerUser o) {
- if (o instanceof TServerUsesLoggers) return instance.compareTo(((TServerUsesLoggers) o).instance);
+ if (o instanceof TServerUsesLoggers)
+ return instance.compareTo(((TServerUsesLoggers) o).instance);
return -1;
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java Thu Oct 27 15:24:51 2011
@@ -60,7 +60,8 @@ public class TableLoadBalancer extends T
String clazzName = getLoadBalancerClassNameForTable(table);
- if (clazzName == null) clazzName = DefaultLoadBalancer.class.getName();
+ if (clazzName == null)
+ clazzName = DefaultLoadBalancer.class.getName();
if (balancer != null) {
if (clazzName.equals(balancer.getClass().getName()) == false) {
// the balancer class for this table does not match the class specified in the configuration
@@ -116,13 +117,14 @@ public class TableLoadBalancer extends T
private TableOperations tops = null;
protected TableOperations getTableOperations() {
- if (tops == null) try {
- tops = HdfsZooInstance.getInstance().getConnector(SecurityConstants.getSystemCredentials()).tableOperations();
- } catch (AccumuloException e) {
- log.error("Unable to access table operations from within table balancer", e);
- } catch (AccumuloSecurityException e) {
- log.error("Unable to access table operations from within table balancer", e);
- }
+ if (tops == null)
+ try {
+ tops = HdfsZooInstance.getInstance().getConnector(SecurityConstants.getSystemCredentials()).tableOperations();
+ } catch (AccumuloException e) {
+ log.error("Unable to access table operations from within table balancer", e);
+ } catch (AccumuloSecurityException e) {
+ log.error("Unable to access table operations from within table balancer", e);
+ }
return tops;
}
@@ -131,11 +133,13 @@ public class TableLoadBalancer extends T
long minBalanceTime = 5 * 1000;
// Iterate over the tables and balance each of them
TableOperations t = getTableOperations();
- if (t == null) return minBalanceTime;
+ if (t == null)
+ return minBalanceTime;
for (String s : t.tableIdMap().values()) {
ArrayList<TabletMigration> newMigrations = new ArrayList<TabletMigration>();
long tableBalanceTime = getBalancerForTable(s).balance(current, migrations, newMigrations);
- if (tableBalanceTime < minBalanceTime) minBalanceTime = tableBalanceTime;
+ if (tableBalanceTime < minBalanceTime)
+ minBalanceTime = tableBalanceTime;
migrationsOut.addAll(newMigrations);
}
return minBalanceTime;
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MergeInfo.java Thu Oct 27 15:24:51 2011
@@ -84,19 +84,24 @@ public class MergeInfo implements Writab
public boolean needsToBeChopped(KeyExtent extent) {
// During a delete, the block after the merge will be stretched to cover the deleted area.
// Therefore, it needs to be chopped
- if (!extent.getTableId().equals(range.getTableId())) return false;
- if (isDelete()) return extent.getPrevEndRow() != null && extent.getPrevEndRow().equals(range.getEndRow());
- else return this.range.overlaps(extent);
+ if (!extent.getTableId().equals(range.getTableId()))
+ return false;
+ if (isDelete())
+ return extent.getPrevEndRow() != null && extent.getPrevEndRow().equals(range.getEndRow());
+ else
+ return this.range.overlaps(extent);
}
public boolean overlaps(KeyExtent extent) {
boolean result = this.range.overlaps(extent);
- if (!result && needsToBeChopped(extent)) return true;
+ if (!result && needsToBeChopped(extent))
+ return true;
return result;
}
public String toString() {
- if (!state.equals(MergeState.NONE)) return "Merge " + operation.toString() + " of " + range + " State: " + state;
+ if (!state.equals(MergeState.NONE))
+ return "Merge " + operation.toString() + " of " + range + " State: " + state;
return "No Merge in progress";
}
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/MetaDataTableScanner.java Thu Oct 27 15:24:51 2011
@@ -91,7 +91,8 @@ public class MetaDataTableScanner implem
@Override
public boolean hasNext() {
boolean result = iter.hasNext();
- if (!result) mdScanner.close();
+ if (!result)
+ mdScanner.close();
return result;
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TServerInstance.java Thu Oct 27 15:24:51 2011
@@ -78,7 +78,8 @@ public class TServerInstance implements
@Override
public int compareTo(TServerInstance other) {
- if (this == other) return 0;
+ if (this == other)
+ return 0;
return this.toString().compareTo(other.toString());
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TableStats.java Thu Oct 27 15:24:51 2011
@@ -56,12 +56,14 @@ public class TableStats {
public synchronized TableCounts getLast(Text tableId) {
TableCounts result = last.get(tableId);
- if (result == null) return new TableCounts();
+ if (result == null)
+ return new TableCounts();
return result;
}
public synchronized long getScanTime() {
- if (endScan <= startScan) return System.currentTimeMillis() - startScan;
+ if (endScan <= startScan)
+ return System.currentTimeMillis() - startScan;
return endScan - startScan;
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletLocationState.java Thu Oct 27 15:24:51 2011
@@ -43,7 +43,8 @@ public class TabletLocationState {
this.future = future;
this.current = current;
this.last = last;
- if (walogs == null) walogs = Collections.emptyList();
+ if (walogs == null)
+ walogs = Collections.emptyList();
this.walogs = walogs;
this.chopped = chopped;
if (current != null && future != null) {
@@ -76,13 +77,15 @@ public class TabletLocationState {
public TabletState getState(Set<TServerInstance> liveServers) {
TServerInstance server = getServer();
- if (server == null) return TabletState.UNASSIGNED;
+ if (server == null)
+ return TabletState.UNASSIGNED;
if (server.equals(current) || server.equals(future)) {
- if (liveServers.contains(server)) if (server.equals(future)) {
- return TabletState.ASSIGNED;
- } else {
- return TabletState.HOSTED;
- }
+ if (liveServers.contains(server))
+ if (server.equals(future)) {
+ return TabletState.ASSIGNED;
+ } else {
+ return TabletState.HOSTED;
+ }
else {
return TabletState.ASSIGNED_TO_DEAD_SERVER;
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletServerState.java Thu Oct 27 15:24:51 2011
@@ -51,7 +51,8 @@ public enum TabletServerState {
badStates = new HashSet<TabletServerState>();
for (TabletServerState state : TabletServerState.values()) {
mapping.put(state.id, state);
- if (state.id > 99) badStates.add(state);
+ if (state.id > 99)
+ badStates.add(state);
}
}
@@ -64,7 +65,8 @@ public enum TabletServerState {
}
public static TabletServerState getStateById(byte id) {
- if (mapping.containsKey(id)) return mapping.get(id);
+ if (mapping.containsKey(id))
+ return mapping.get(id);
throw new IndexOutOfBoundsException("No such state");
}
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java Thu Oct 27 15:24:51 2011
@@ -63,7 +63,8 @@ public class TabletStateChangeIterator e
}
private Set<String> parseTables(String tables) {
- if (tables == null) return null;
+ if (tables == null)
+ return null;
Set<String> result = new HashSet<String>();
for (String table : tables.split(","))
result.add(table);
@@ -71,7 +72,8 @@ public class TabletStateChangeIterator e
}
private Set<TServerInstance> parseServers(String servers) {
- if (servers == null) return null;
+ if (servers == null)
+ return null;
// parse "host:port[INSTANCE]"
Set<TServerInstance> result = new HashSet<TServerInstance>();
if (servers.length() > 0) {
@@ -79,7 +81,8 @@ public class TabletStateChangeIterator e
String parts[] = part.split("\\[", 2);
String hostport = parts[0];
String instance = parts[1];
- if (instance != null && instance.endsWith("]")) instance = instance.substring(0, instance.length() - 1);
+ if (instance != null && instance.endsWith("]"))
+ instance = instance.substring(0, instance.length() - 1);
result.add(new TServerInstance(AddressUtil.parseAddress(hostport, Property.TSERV_CLIENTPORT), instance));
}
}
@@ -87,7 +90,8 @@ public class TabletStateChangeIterator e
}
private Map<Text,MergeInfo> parseMerges(String merges) {
- if (merges == null) return null;
+ if (merges == null)
+ return null;
try {
Map<Text,MergeInfo> result = new HashMap<Text,MergeInfo>();
DataInputBuffer buffer = new DataInputBuffer();
@@ -110,7 +114,8 @@ public class TabletStateChangeIterator e
Key k = getSource().getTopKey();
Value v = getSource().getTopValue();
- if (onlineTables == null || current == null) return;
+ if (onlineTables == null || current == null)
+ return;
SortedMap<Key,Value> decodedRow = WholeRowIterator.decodeRow(k, v);
TabletLocationState tls = MetaDataTableScanner.createTabletLocationState(decodedRow);
@@ -127,11 +132,13 @@ public class TabletStateChangeIterator e
// we always want data about assigned tablets
return;
case HOSTED:
- if (!shouldBeOnline) return;
+ if (!shouldBeOnline)
+ return;
case ASSIGNED_TO_DEAD_SERVER:
/* fall-through intentional */
case UNASSIGNED:
- if (shouldBeOnline) return;
+ if (shouldBeOnline)
+ return;
}
// table is in the expected state so don't bother returning any information about it
getSource().next();
@@ -153,7 +160,8 @@ public class TabletStateChangeIterator e
}
public static void setOnlineTables(IteratorSetting cfg, Set<String> onlineTables) {
- if (onlineTables != null) cfg.addOption(TABLES_OPTION, StringUtil.join(onlineTables, ","));
+ if (onlineTables != null)
+ cfg.addOption(TABLES_OPTION, StringUtil.join(onlineTables, ","));
}
public static void setMerges(IteratorSetting cfg, Collection<MergeInfo> merges) {
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooStore.java Thu Oct 27 15:24:51 2011
@@ -37,7 +37,8 @@ public class ZooStore implements Distrib
ZooCache cache = new ZooCache();
public ZooStore(String basePath) throws IOException {
- if (basePath.endsWith("/")) basePath = basePath.substring(0, basePath.length() - 1);
+ if (basePath.endsWith("/"))
+ basePath = basePath.substring(0, basePath.length() - 1);
this.basePath = basePath;
}
@@ -85,7 +86,8 @@ public class ZooStore implements Distrib
log.debug("Removing " + path);
path = relative(path);
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
- if (zoo.exists(path)) zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
+ if (zoo.exists(path))
+ zoo.recursiveDelete(path, NodeMissingPolicy.SKIP);
cache.clear();
} catch (Exception ex) {
throw new DistributedStoreException(ex);
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/ZooTabletStateStore.java Thu Oct 27 15:24:51 2011
@@ -68,9 +68,11 @@ public class ZooTabletStateStore extends
TServerInstance futureSession = null;
TServerInstance lastSession = null;
- if (future != null) futureSession = parse(future);
+ if (future != null)
+ futureSession = parse(future);
- if (last != null) lastSession = parse(last);
+ if (last != null)
+ lastSession = parse(last);
if (current != null) {
currentSession = parse(current);
@@ -115,18 +117,22 @@ public class ZooTabletStateStore extends
@Override
public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException {
- if (assignments.size() != 1) throw new IllegalArgumentException("There is only one root tablet");
+ if (assignments.size() != 1)
+ throw new IllegalArgumentException("There is only one root tablet");
Assignment assignment = assignments.iterator().next();
- if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location");
+ if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0)
+ throw new IllegalArgumentException("You can only store the root tablet location");
String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession();
store.put(Constants.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes());
}
@Override
public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException {
- if (assignments.size() != 1) throw new IllegalArgumentException("There is only one root tablet");
+ if (assignments.size() != 1)
+ throw new IllegalArgumentException("There is only one root tablet");
Assignment assignment = assignments.iterator().next();
- if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location");
+ if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0)
+ throw new IllegalArgumentException("You can only store the root tablet location");
String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession();
store.put(Constants.ZROOT_TABLET_LOCATION, value.getBytes());
store.put(Constants.ZROOT_TABLET_LAST_LOCATION, value.getBytes());
@@ -136,9 +142,11 @@ public class ZooTabletStateStore extends
@Override
public void unassign(Collection<TabletLocationState> tablets) throws DistributedStoreException {
- if (tablets.size() != 1) throw new IllegalArgumentException("There is only one root tablet");
+ if (tablets.size() != 1)
+ throw new IllegalArgumentException("There is only one root tablet");
TabletLocationState tls = tablets.iterator().next();
- if (tls.extent.compareTo(Constants.ROOT_TABLET_EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location");
+ if (tls.extent.compareTo(Constants.ROOT_TABLET_EXTENT) != 0)
+ throw new IllegalArgumentException("You can only store the root tablet location");
store.remove(Constants.ZROOT_TABLET_LOCATION);
store.remove(Constants.ZROOT_TABLET_FUTURE_LOCATION);
log.debug("unassign root tablet location");
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/state/tables/TableManager.java Thu Oct 27 15:24:51 2011
@@ -72,7 +72,8 @@ public class TableManager {
if (sm != null) {
sm.checkPermission(TABLE_MANAGER_PERMISSION);
}
- if (tableManager == null) tableManager = new TableManager();
+ if (tableManager == null)
+ tableManager = new TableManager();
return tableManager;
}
@@ -115,7 +116,8 @@ public class TableManager {
@Override
public byte[] mutate(byte[] oldData) throws Exception {
TableState oldState = TableState.UNKNOWN;
- if (oldData != null) oldState = TableState.valueOf(new String(oldData));
+ if (oldData != null)
+ oldState = TableState.valueOf(new String(oldData));
boolean transition = true;
// +--------+
// v |
@@ -134,7 +136,8 @@ public class TableManager {
transition = false;
break;
}
- if (!transition) throw new IllegalTableTransitionException(oldState, newState);
+ if (!transition)
+ throw new IllegalTableTransitionException(oldState, newState);
log.debug("Transitioning state for table " + tableId + " from " + oldState + " to " + newState);
return newState.name().getBytes();
}
@@ -148,7 +151,8 @@ public class TableManager {
private void updateTableStateCache() {
synchronized (tableStateCache) {
for (String tableId : zooStateCache.getChildren(ZooUtil.getRoot(instance) + Constants.ZTABLES))
- if (zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE) != null) updateTableStateCache(tableId);
+ if (zooStateCache.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_STATE) != null)
+ updateTableStateCache(tableId);
}
}
@@ -216,7 +220,8 @@ public class TableManager {
private class TableStateWatcher implements Watcher {
@Override
public void process(WatchedEvent event) {
- if (log.isTraceEnabled()) log.trace(event);
+ if (log.isTraceEnabled())
+ log.trace(event);
final String zPath = event.getPath();
final EventType zType = event.getType();
@@ -228,7 +233,8 @@ public class TableManager {
String suffix = zPath.substring(tablesPrefix.length() + 1);
if (suffix.contains("/")) {
String[] sa = suffix.split("/", 2);
- if (Constants.ZTABLE_STATE.equals("/" + sa[1])) tableId = sa[0];
+ if (Constants.ZTABLE_STATE.equals("/" + sa[1]))
+ tableId = sa[0];
}
if (tableId == null) {
log.warn("Unknown path in " + event);
@@ -258,12 +264,14 @@ public class TableManager {
if (zPath != null
&& tableId != null
&& (zPath.equals(tablesPrefix + "/" + tableId + Constants.ZTABLE_STATE) || zPath.equals(tablesPrefix + "/" + tableId + Constants.ZTABLE_CONF) || zPath
- .equals(tablesPrefix + "/" + tableId + Constants.ZTABLE_NAME))) tableStateCache.remove(tableId);
+ .equals(tablesPrefix + "/" + tableId + Constants.ZTABLE_NAME)))
+ tableStateCache.remove(tableId);
break;
case None:
switch (event.getState()) {
case Expired:
- if (log.isTraceEnabled()) log.trace("Session expired " + event);
+ if (log.isTraceEnabled())
+ log.trace("Session expired " + event);
synchronized (observers) {
for (TableObserver to : observers)
to.sessionExpired();
@@ -271,7 +279,8 @@ public class TableManager {
break;
case SyncConnected:
default:
- if (log.isTraceEnabled()) log.trace("Ignored " + event);
+ if (log.isTraceEnabled())
+ log.trace("Ignored " + event);
}
break;
default:
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/BulkImport.java Thu Oct 27 15:24:51 2011
@@ -110,14 +110,16 @@ public class BulkImport extends MasterRe
@Override
public long isReady(long tid, Master master) throws Exception {
- if (!Utils.getReadLock(tableId, tid).tryLock()) return 100;
+ if (!Utils.getReadLock(tableId, tid).tryLock())
+ return 100;
Instance instance = HdfsZooInstance.getInstance();
Tables.clearCache(instance);
if (Tables.getTableState(instance, tableId) == TableState.ONLINE) {
long reserve1, reserve2;
reserve1 = reserve2 = Utils.reserveHdfsDirectory(sourceDir, tid);
- if (reserve1 == 0) reserve2 = Utils.reserveHdfsDirectory(errorDir, tid);
+ if (reserve1 == 0)
+ reserve2 = Utils.reserveHdfsDirectory(errorDir, tid);
return reserve2;
} else {
throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.OFFLINE, null);
@@ -136,12 +138,15 @@ public class BulkImport extends MasterRe
;
Path errorPath = new Path(errorDir);
FileStatus errorStatus = fs.getFileStatus(errorPath);
- if (errorStatus == null) throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT,
- TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir + " does not exist");
- if (!errorStatus.isDir()) throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT,
- TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir + " is not a directory");
- if (fs.listStatus(errorPath).length != 0) throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT,
- TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir + " is not empty");
+ if (errorStatus == null)
+ throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir
+ + " does not exist");
+ if (!errorStatus.isDir())
+ throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir
+ + " is not a directory");
+ if (fs.listStatus(errorPath).length != 0)
+ throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir
+ + " is not empty");
ZooArbitrator.start(Constants.BULK_ARBITRATOR_TYPE, tid);
@@ -172,8 +177,9 @@ public class BulkImport extends MasterRe
while (true) {
Path newBulkDir = new Path(directory, Constants.BULK_PREFIX + namer.getNextName());
if (fs.exists(newBulkDir)) // sanity check
- throw new IllegalStateException("Dir exist when it should not " + newBulkDir);
- if (fs.mkdirs(newBulkDir)) return newBulkDir;
+ throw new IllegalStateException("Dir exist when it should not " + newBulkDir);
+ if (fs.mkdirs(newBulkDir))
+ return newBulkDir;
log.warn("Failed to create " + newBulkDir + " for unknown reason");
UtilWaitThread.sleep(3000);
@@ -272,12 +278,14 @@ class CleanUpBulkImport extends MasterRe
Set<TServerInstance> running = master.onlineTabletServers();
for (TServerInstance server : running) {
try {
- if (!master.getConnection(server).isActive(tid)) finished.add(server);
+ if (!master.getConnection(server).isActive(tid))
+ finished.add(server);
} catch (TException ex) {
log.info("Ignoring error trying to check on tid " + tid + " from server " + server + ": " + ex);
}
}
- if (finished.containsAll(running)) return 0;
+ if (finished.containsAll(running))
+ return 0;
return 1000;
}
@@ -374,8 +382,9 @@ class LoadFiles extends MasterRepo {
if (!fs.createNewFile(writable)) {
// Maybe this is a re-try... clear the flag and try again
fs.delete(writable, false);
- if (!fs.createNewFile(writable)) throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT,
- TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, "Unable to write to " + this.errorDir);
+ if (!fs.createNewFile(writable))
+ throw new ThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY,
+ "Unable to write to " + this.errorDir);
}
fs.delete(writable, false);
Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/ChangeTableState.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/ChangeTableState.java?rev=1189806&r1=1189805&r2=1189806&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/ChangeTableState.java (original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/master/tableOps/ChangeTableState.java Thu Oct 27 15:24:51 2011
@@ -33,7 +33,8 @@ public class ChangeTableState extends Ma
this.tableId = tableId;
this.top = top;
- if (top != TableOperation.ONLINE && top != TableOperation.OFFLINE) throw new IllegalArgumentException(top.toString());
+ if (top != TableOperation.ONLINE && top != TableOperation.OFFLINE)
+ throw new IllegalArgumentException(top.toString());
}
@Override
@@ -46,7 +47,8 @@ public class ChangeTableState extends Ma
public Repo<Master> call(long tid, Master env) throws Exception {
TableState ts = TableState.ONLINE;
- if (top == TableOperation.OFFLINE) ts = TableState.OFFLINE;
+ if (top == TableOperation.OFFLINE)
+ ts = TableState.OFFLINE;
TableManager.getInstance().transitionTableState(tableId, ts);
Utils.unreserveTable(tableId, tid, true);