r region.
* @param r
- * @throws IOException
+ * @throws IOException
*/
static void cleanupAnySplitDetritus(final HRegion r) throws IOException {
Path splitdir = getSplitDir(r);
Index: src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java (revision 11224)
+++ src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java (working copy)
@@ -29,10 +29,9 @@
import org.apache.hadoop.hbase.executor.EventHandler;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
+import org.apache.hadoop.hbase.util.CancelableProgressable;
import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.util.Progressable;
import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.Code;
/**
* Handles opening of a region on a region server.
@@ -95,33 +94,29 @@
// Instantiate the region. This also periodically updates OPENING.
region = HRegion.openHRegion(regionInfo, this.rsServices.getWAL(),
server.getConfiguration(), this.rsServices.getFlushRequester(),
- new Progressable() {
- public void progress() {
+ new CancelableProgressable() {
+ public boolean progress() {
try {
int vsn = ZKAssign.retransitionNodeOpening(
server.getZooKeeper(), regionInfo, server.getServerName(),
openingInteger.get());
if (vsn == -1) {
- throw KeeperException.create(Code.BADVERSION);
+ // Unable to retransition node, abort region open
+ return false;
}
openingInteger.set(vsn);
+ return true;
} catch (KeeperException e) {
server.abort("ZK exception refreshing OPENING node; " + name, e);
+ return false;
}
}
});
} catch (IOException e) {
LOG.error("Failed open of " + regionInfo +
- "; resetting state of transition node from OPENING to OFFLINE", e);
- try {
- // TODO: We should rely on the master timing out OPENING instead of this
- // TODO: What if this was a split open? The RS made the OFFLINE
- // znode, not the master.
- ZKAssign.forceNodeOffline(server.getZooKeeper(), regionInfo,
- server.getServerName());
- } catch (KeeperException e1) {
- LOG.error("Error forcing node back to OFFLINE from OPENING; " + name);
- }
+ "; stopping open and will allow master to timeout operation", e);
+ // TODO we should be able to do an atomic transition from OPENING to
+ // OFFLINE to make it so we don't always have to wait for timeout
return;
}
// Region is now open. Close it if error.
Index: src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (revision 11224)
+++ src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (working copy)
@@ -55,12 +55,12 @@
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.UnknownScannerException;
+import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
@@ -77,6 +77,7 @@
import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.CancelableProgressable;
import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.hadoop.hbase.util.CompressionTest;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -324,7 +325,7 @@
* @return What the next sequence (edit) id should be.
* @throws IOException e
*/
- public long initialize(final Progressable reporter)
+ public long initialize(final CancelableProgressable reporter)
throws IOException {
// A region can be reopened if failed a split; reset flags
this.closing.set(false);
@@ -1428,7 +1429,7 @@
lastIndexExclusive++;
numReadyToWrite++;
}
- // Nothing to put -- an exception in the above such as NoSuchColumnFamily?
+ // Nothing to put -- an exception in the above such as NoSuchColumnFamily?
if (numReadyToWrite <= 0) return 0L;
// We've now grabbed as many puts off the list as we can
@@ -1793,7 +1794,7 @@
* @throws IOException
*/
protected long replayRecoveredEditsIfAny(final Path regiondir,
- final long minSeqId, final Progressable reporter)
+ final long minSeqId, final CancelableProgressable reporter)
throws UnsupportedEncodingException, IOException {
long seqid = minSeqId;
NavigableSetthis
* @throws IOException
*/
- protected HRegion openHRegion(final Progressable reporter)
+ protected HRegion openHRegion(final CancelableProgressable reporter)
throws IOException {
checkCompressionCodecs();
Index: src/main/java/org/apache/hadoop/hbase/util/CancelableProgressable.java
===================================================================
--- src/main/java/org/apache/hadoop/hbase/util/CancelableProgressable.java (revision 0)
+++ src/main/java/org/apache/hadoop/hbase/util/CancelableProgressable.java (revision 0)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2010 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.util;
+
+/**
+ * Similar interface as {@link org.apache.hadoop.util.Progressable} but returns
+ * a boolean to support canceling the operation.
+ * + * Used for doing updating of OPENING znode during log replay on region open. + */ +public interface CancelableProgressable { + + /** + * Report progress. Returns true if operations should continue, false if the + * operation should be canceled and rolled back. + * @return whether to continue (true) or cancel (false) the operation + */ + public boolean progress(); + +} \ No newline at end of file