You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/11/26 19:28:21 UTC
[4/5] accumulo git commit: ACCUMULO-1085 respond to Keith's review
ACCUMULO-1085 respond to Keith's review
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/b2456f6f
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/b2456f6f
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/b2456f6f
Branch: refs/heads/master
Commit: b2456f6f1da20f4c6378f5810fce8f25901bae42
Parents: bac65c7
Author: Eric C. Newton <er...@gmail.com>
Authored: Mon Nov 24 16:11:56 2014 -0500
Committer: Eric C. Newton <er...@gmail.com>
Committed: Mon Nov 24 16:11:56 2014 -0500
----------------------------------------------------------------------
.../apache/accumulo/tserver/TabletServer.java | 46 ++++++++++----------
1 file changed, 23 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/b2456f6f/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 5574384..fd53756 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -42,12 +42,12 @@ import java.util.concurrent.BlockingDeque;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReentrantLock;
import javax.management.StandardMBean;
@@ -237,6 +237,7 @@ import org.apache.thrift.TServiceClient;
import org.apache.thrift.server.TServer;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NoNodeException;
+
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.accumulo.server.problems.ProblemType.TABLET_LOAD;
@@ -356,7 +357,7 @@ public class TabletServer implements Runnable {
private final RowLocks rowLocks = new RowLocks();
private final AtomicLong totalQueuedMutationSize = new AtomicLong(0);
- private final Semaphore recoverySemaphore = new Semaphore(1, true);
+ private final ReentrantLock recoveryLock = new ReentrantLock(true);
private class ThriftClientHandler extends ClientServiceHandler implements TabletClientService.Iface {
@@ -2120,29 +2121,28 @@ public class TabletServer implements Runnable {
boolean successful = false;
try {
+ acquireRecoveryMemory(extent);
+
TabletResourceManager trm = resourceManager.createTabletResourceManager(extent, getTableConfiguration(extent));
- // this opens the tablet file and fills in the endKey in the
- // extent
+ // this opens the tablet file and fills in the endKey in the extent
locationToOpen = VolumeUtil.switchRootTabletVolume(extent, locationToOpen);
- acquireRecoveryMemory(extent);
- {
-
- tablet = new Tablet(TabletServer.this, extent, locationToOpen, trm, tabletsKeyValues);
- /*
- * If a minor compaction starts after a tablet opens, this indicates a log recovery occurred. This recovered data must be minor compacted.
- *
- * There are three reasons to wait for this minor compaction to finish before placing the tablet in online tablets.
- *
- * 1) The log recovery code does not handle data written to the tablet on multiple tablet servers. 2) The log recovery code does not block if memory is
- * full. Therefore recovering lots of tablets that use a lot of memory could run out of memory. 3) The minor compaction finish event did not make it to
- * the logs (the file will be in metadata, preventing replay of compacted data)... but do not want a majc to wipe the file out from metadata and then
- * have another process failure... this could cause duplicate data to replay
- */
- if (tablet.getNumEntriesInMemory() > 0 && !tablet.minorCompactNow(MinorCompactionReason.RECOVERY)) {
- throw new RuntimeException("Minor compaction after recovery fails for " + extent);
- }
+ tablet = new Tablet(TabletServer.this, extent, locationToOpen, trm, tabletsKeyValues);
+ /* @formatter:off
+ * If a minor compaction starts after a tablet opens, this indicates a log recovery occurred. This recovered data must be minor compacted.
+ *
+ * There are three reasons to wait for this minor compaction to finish before placing the tablet in online tablets.
+ *
+ * 1) The log recovery code does not handle data written to the tablet on multiple tablet servers.
+ * 2) The log recovery code does not block if memory is full. Therefore recovering lots of tablets that use a lot of memory could run out of memory.
+ * 3) The minor compaction finish event did not make it to the logs (the file will be in metadata, preventing replay of compacted data)...
+ * but do not want a majc to wipe the file out from metadata and then have another process failure...
+ * this could cause duplicate data to replay.
+ * @formatter:on
+ */
+ if (tablet.getNumEntriesInMemory() > 0 && !tablet.minorCompactNow(MinorCompactionReason.RECOVERY)) {
+ throw new RuntimeException("Minor compaction after recovery fails for " + extent);
}
Assignment assignment = new Assignment(extent, getTabletSession());
TabletStateStore.setLocation(assignment);
@@ -2203,13 +2203,13 @@ public class TabletServer implements Runnable {
private void acquireRecoveryMemory(KeyExtent extent) throws InterruptedException {
if (!extent.isMeta()) {
- recoverySemaphore.acquireUninterruptibly();
+ recoveryLock.lock();
}
}
private void releaseRecoveryMemory(KeyExtent extent) {
if (!extent.isMeta()) {
- recoverySemaphore.release();
+ recoveryLock.unlock();
}
}