本文整理汇总了Java中org.apache.hadoop.hbase.executor.EventHandler类的典型用法代码示例。如果您正苦于以下问题:Java EventHandler类的具体用法?Java EventHandler怎么用?Java EventHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventHandler类属于org.apache.hadoop.hbase.executor包,在下文中一共展示了EventHandler类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterProcess
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
@Override
public void afterProcess(EventHandler event) {
this.done.set(true);
synchronized (this.done) {
// Wake anyone waiting on this value to change.
this.done.notifyAll();
}
}
示例2: process
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
@Override
public void process() {
String encodedRegionName = this.parent.getEncodedName();
LOG.debug("Handling SPLIT event for " + encodedRegionName +
"; deleting node");
// The below is for testing ONLY! We can't do fault injection easily, so
// resort to this kinda uglyness -- St.Ack 02/25/2011.
if (TEST_SKIP) {
LOG.warn("Skipping split message, TEST_SKIP is set");
return;
}
this.assignmentManager.handleSplitReport(this.sn, this.parent,
this.daughters.get(0), this.daughters.get(1));
// Remove region from ZK
try {
boolean successful = false;
while (!successful) {
// It's possible that the RS tickles in between the reading of the
// znode and the deleting, so it's safe to retry.
successful = ZKAssign.deleteNode(this.server.getZooKeeper(),
encodedRegionName,
EventHandler.EventType.RS_ZK_REGION_SPLIT);
}
} catch (KeeperException e) {
if (e instanceof NoNodeException) {
String znodePath = ZKUtil.joinZNode(
this.server.getZooKeeper().splitLogZNode, encodedRegionName);
LOG.debug("The znode " + znodePath
+ " does not exist. May be deleted already.");
} else {
server.abort("Error deleting SPLIT node in ZK for transition ZK node (" +
parent.getEncodedName() + ")", e);
}
}
LOG.info("Handled SPLIT event; parent=" +
this.parent.getRegionNameAsString() +
" daughter a=" + this.daughters.get(0).getRegionNameAsString() +
"daughter b=" + this.daughters.get(1).getRegionNameAsString());
}
示例3: afterProcess
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
@Override
public void afterProcess(EventHandler event) {
if (event.getEventType() != EventType.RS_ZK_REGION_SPLIT) {
return;
}
try {
split.countDown();
proceed.await(60, TimeUnit.SECONDS);
} catch (InterruptedException ie) {
throw new RuntimeException(ie);
}
return;
}
示例4: afterProcess
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
@Override
public void afterProcess(EventHandler event) {
LOG.info("afterProcess(" + event + ")");
if(event.getEventType() == EventType.RS_ZK_REGION_CLOSED) {
LOG.info("Finished processing CLOSE REGION");
TotesHRegionInfo hriCarrier = (TotesHRegionInfo)event;
if (regionToClose.equals(hriCarrier.getHRegionInfo().getRegionNameAsString())) {
LOG.info("Setting closeEventProcessed flag");
closeEventProcessed.set(true);
} else {
LOG.info("Region to close didn't match");
}
}
}
示例5: testCancelOpeningWithoutZK
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
/**
* Test that if we do a close while opening it stops the opening.
*/
@Test(timeout = 20000)
public void testCancelOpeningWithoutZK() throws Exception {
// We close
closeNoZK();
checkRegionIsClosed();
// Let do the initial steps, without having a handler
ZKAssign.createNodeOffline(HTU.getZooKeeperWatcher(), hri, getRS().getServerName());
getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE);
// That's a close without ZK.
AdminProtos.CloseRegionRequest crr =
RequestConverter.buildCloseRegionRequest(regionName, false);
try {
getRS().closeRegion(null, crr);
Assert.assertTrue(false);
} catch (ServiceException expected) {
}
// The state in RIT should have changed to close
Assert.assertEquals(Boolean.FALSE, getRS().getRegionsInTransitionInRS().get(
hri.getEncodedNameAsBytes()));
// Let's start the open handler
HTableDescriptor htd = getRS().tableDescriptors.get(hri.getTableName());
getRS().service.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, 0));
// The open handler should have removed the region from RIT but kept the region closed
checkRegionIsClosed();
// The open handler should have updated the value in ZK.
Assert.assertTrue(ZKAssign.deleteNode(
getRS().getZooKeeperWatcher(), hri.getEncodedName(),
EventHandler.EventType.RS_ZK_REGION_FAILED_OPEN, 1)
);
reopenRegion();
}
示例6: retrySendRegionOpen
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
/**
* At master failover, for pending_open region, make sure
* sendRegionOpen RPC call is sent to the target regionserver
*/
private void retrySendRegionOpen(final RegionState regionState) {
this.executorService.submit(
new EventHandler(server, EventType.M_MASTER_RECOVERY) {
@Override
public void process() throws IOException {
HRegionInfo hri = regionState.getRegion();
ServerName serverName = regionState.getServerName();
ReentrantLock lock = locker.acquireLock(hri.getEncodedName());
try {
for (int i = 1; i <= maximumAttempts; i++) {
if (!serverManager.isServerOnline(serverName)
|| server.isStopped() || server.isAborted()) {
return; // No need any more
}
try {
if (!regionState.equals(regionStates.getRegionState(hri))) {
return; // Region is not in the expected state any more
}
List<ServerName> favoredNodes = ServerName.EMPTY_SERVER_LIST;
if (shouldAssignRegionsWithFavoredNodes) {
favoredNodes = ((FavoredNodeLoadBalancer)balancer).getFavoredNodes(hri);
}
RegionOpeningState regionOpenState = serverManager.sendRegionOpen(
serverName, hri, -1, favoredNodes);
if (regionOpenState == RegionOpeningState.FAILED_OPENING) {
// Failed opening this region, this means the target server didn't get
// the original region open RPC, so re-assign it with a new plan
LOG.debug("Got failed_opening in retry sendRegionOpen for "
+ regionState + ", re-assign it");
invokeAssign(hri, true);
}
return; // Done.
} catch (Throwable t) {
if (t instanceof RemoteException) {
t = ((RemoteException) t).unwrapRemoteException();
}
// In case SocketTimeoutException/FailedServerException, retry
if (t instanceof java.net.SocketTimeoutException
|| t instanceof FailedServerException) {
Threads.sleep(100);
continue;
}
// For other exceptions, re-assign it
LOG.debug("Got exception in retry sendRegionOpen for "
+ regionState + ", re-assign it", t);
invokeAssign(hri);
return; // Done.
}
}
} finally {
lock.unlock();
}
}
});
}
示例7: retrySendRegionClose
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
/**
* At master failover, for pending_close region, make sure
* sendRegionClose RPC call is sent to the target regionserver
*/
private void retrySendRegionClose(final RegionState regionState) {
this.executorService.submit(
new EventHandler(server, EventType.M_MASTER_RECOVERY) {
@Override
public void process() throws IOException {
HRegionInfo hri = regionState.getRegion();
ServerName serverName = regionState.getServerName();
ReentrantLock lock = locker.acquireLock(hri.getEncodedName());
try {
for (int i = 1; i <= maximumAttempts; i++) {
if (!serverManager.isServerOnline(serverName)
|| server.isStopped() || server.isAborted()) {
return; // No need any more
}
try {
if (!regionState.equals(regionStates.getRegionState(hri))) {
return; // Region is not in the expected state any more
}
if (!serverManager.sendRegionClose(serverName, hri, -1, null, false)) {
// This means the region is still on the target server
LOG.debug("Got false in retry sendRegionClose for "
+ regionState + ", re-close it");
invokeUnAssign(hri);
}
return; // Done.
} catch (Throwable t) {
if (t instanceof RemoteException) {
t = ((RemoteException) t).unwrapRemoteException();
}
// In case SocketTimeoutException/FailedServerException, retry
if (t instanceof java.net.SocketTimeoutException
|| t instanceof FailedServerException) {
Threads.sleep(100);
continue;
}
if (!(t instanceof NotServingRegionException
|| t instanceof RegionAlreadyInTransitionException)) {
// NotServingRegionException/RegionAlreadyInTransitionException
// means the target server got the original region close request.
// For other exceptions, re-close it
LOG.debug("Got exception in retry sendRegionClose for "
+ regionState + ", re-close it", t);
invokeUnAssign(hri);
}
return; // Done.
}
}
} finally {
lock.unlock();
}
}
});
}
示例8: beforeProcess
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
@Override
public void beforeProcess(EventHandler event) {
// continue
}
示例9: beforeProcess
import org.apache.hadoop.hbase.executor.EventHandler; //导入依赖的package包/类
@Override
public void beforeProcess(EventHandler event) {
}