public void executeProcedure(long procId, RSProcedureCallable callable) { executorService.submit(new RSProcedureHandler(this, procId, callable)); }
ParallelSeekHandler seekHandler = new ParallelSeekHandler(scanner, kv, this.readPt, latch); executor.submit(seekHandler); handlers.add(seekHandler); } else {
public void delayedSubmit(EventHandler eh, long delay, TimeUnit unit) { ListenableFuture<?> future = delayedSubmitTimer.schedule(() -> submit(eh), delay, unit); future.addListener(() -> { try { future.get(); } catch (Exception e) { LOG.error("Failed to submit the event handler {} to executor", eh, e); } }, MoreExecutors.directExecutor()); }
private void executeCloseRegionProcedures(CloseRegionRequest request) { String encodedName; try { encodedName = ProtobufUtil.getRegionEncodedName(request.getRegion()); } catch (DoNotRetryIOException e) { throw new UncheckedIOException("Should not happen", e); } ServerName destination = request.hasDestinationServer() ? ProtobufUtil.toServerName(request.getDestinationServer()) : null; regionServer.executorService .submit(UnassignRegionHandler.create(regionServer, encodedName, false, destination)); }
try { handler.prepare(); this.executorService.submit(handler); this.snapshotHandlers.put(TableName.valueOf(snapshot.getTable()), handler); } catch (Exception e) {
crh = new CloseRegionHandler(this, this, hri, abort, sn); this.executorService.submit(crh); return true;
CompactedHFilesDischargeHandler handler = new CompactedHFilesDischargeHandler( (Server) regionServerServices, EventType.RS_COMPACTED_FILES_DISCHARGER, store); regionServerServices.getExecutorService().submit(handler); } else {
@Test public void testAborting() throws Exception { final Configuration conf = HBaseConfiguration.create(); final Server server = mock(Server.class); when(server.getConfiguration()).thenReturn(conf); ExecutorService executorService = new ExecutorService("unit_test"); executorService.startExecutorService( ExecutorType.MASTER_SERVER_OPERATIONS, 1); executorService.submit(new EventHandler(server, EventType.M_SERVER_SHUTDOWN) { @Override public void process() throws IOException { throw new RuntimeException("Should cause abort"); } }); Waiter.waitFor(conf, 30000, new Predicate<Exception>() { @Override public boolean evaluate() throws Exception { try { verify(server, times(1)).abort(anyString(), (Throwable) anyObject()); return true; } catch (Throwable t) { return false; } } }); executorService.shutdown(); }
/** * Trigger a flush in the primary region replica if this region is a secondary replica. Does not * block this thread. See RegionReplicaFlushHandler for details. */ void triggerFlushInPrimaryRegion(final HRegion region) { if (ServerRegionReplicaUtil.isDefaultReplica(region.getRegionInfo())) { return; } if (!ServerRegionReplicaUtil.isRegionReplicaReplicationEnabled(region.conf) || !ServerRegionReplicaUtil.isRegionReplicaWaitForPrimaryFlushEnabled( region.conf)) { region.setReadsEnabled(true); return; } region.setReadsEnabled(false); // disable reads before marking the region as opened. // RegionReplicaFlushHandler might reset this. // submit it to be handled by one of the handlers so that we do not block OpenRegionHandler if (this.executorService != null) { this.executorService.submit(new RegionReplicaFlushHandler(this, clusterConnection, rpcRetryingCallerFactory, rpcControllerFactory, operationTimeout, region)); } }
new WALSplitterHandler(server, this, splitTaskDetails, reporter, this.tasksInProgress, splitTaskExecutor); server.getExecutorService().submit(hsh);
executorService.submit( new TestEventHandler(mockedServer, EventType.M_SERVER_SHUTDOWN, lock, counter)); executorService.submit( new TestEventHandler(mockedServer, EventType.M_SERVER_SHUTDOWN, lock, counter)); executorService.submit( new TestEventHandler(mockedServer, EventType.M_SERVER_SHUTDOWN, lock, counter));
private void executeOpenRegionProcedures(OpenRegionRequest request, Map<TableName, TableDescriptor> tdCache) { long masterSystemTime = request.hasMasterSystemTime() ? request.getMasterSystemTime() : -1; for (RegionOpenInfo regionOpenInfo : request.getOpenInfoList()) { RegionInfo regionInfo = ProtobufUtil.toRegionInfo(regionOpenInfo.getRegion()); TableDescriptor tableDesc = tdCache.get(regionInfo.getTable()); if (tableDesc == null) { try { tableDesc = regionServer.getTableDescriptors().get(regionInfo.getTable()); } catch (IOException e) { // Here we do not fail the whole method since we also need deal with other // procedures, and we can not ignore this one, so we still schedule a // AssignRegionHandler and it will report back to master if we still can not get the // TableDescriptor. LOG.warn("Failed to get TableDescriptor of {}, will try again in the handler", regionInfo.getTable(), e); } } if (regionOpenInfo.getFavoredNodesCount() > 0) { regionServer.updateRegionFavoredNodesMapping(regionInfo.getEncodedName(), regionOpenInfo.getFavoredNodesList()); } regionServer.executorService .submit(AssignRegionHandler.create(regionServer, regionInfo, tableDesc, masterSystemTime)); } }
} else { if (region.isMetaRegion()) { regionServer.executorService.submit(new OpenMetaHandler( regionServer, regionServer, region, htd, masterSystemTime)); } else { regionServer.executorService.submit(new OpenPriorityRegionHandler( regionServer, regionServer, region, htd, masterSystemTime)); } else { regionServer.executorService.submit(new OpenRegionHandler( regionServer, regionServer, region, htd, masterSystemTime));
/** * Test that if we do a close while opening it stops the opening. */ @Test public void testCancelOpeningWithoutZK() throws Exception { // We close closeRegionNoZK(); checkRegionIsClosed(HTU, getRS(), hri); // Let do the initial steps, without having a handler getRS().getRegionsInTransitionInRS().put(hri.getEncodedNameAsBytes(), Boolean.TRUE); // That's a close without ZK. AdminProtos.CloseRegionRequest crr = ProtobufUtil.buildCloseRegionRequest(getRS().getServerName(), regionName); try { getRS().rpcServices.closeRegion(null, crr); Assert.assertTrue(false); } catch (org.apache.hbase.thirdparty.com.google.protobuf.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 TableDescriptor htd = getRS().tableDescriptors.get(hri.getTable()); getRS().executorService.submit(new OpenRegionHandler(getRS(), getRS(), hri, htd, -1)); // The open handler should have removed the region from RIT but kept the region closed checkRegionIsClosed(HTU, getRS(), hri); openRegion(HTU, getRS(), hri); }
@Override public void dispatchMergingRegions(final HRegionInfo region_a, final HRegionInfo region_b, final boolean forcible) throws IOException { checkInitialized(); this.service.submit(new DispatchMergingRegionHandler(this, this.catalogJanitorChore, region_a, region_b, forcible)); }
/** * Called when a node has been deleted * @param path full path of the deleted node */ @Override public void nodeDeleted(String path) { if (this.server.isStopped() || this.server.isStopping()) { return; } String parentPath = path.substring(0, path.lastIndexOf('/')); if (!this.watcher.recoveringRegionsZNode.equalsIgnoreCase(parentPath)) { return; } String regionName = path.substring(parentPath.length() + 1); server.getExecutorService().submit(new FinishRegionRecoveringHandler(server, regionName, path)); }
@Override public void deleteTable(final byte [] tableName) throws IOException { checkInitialized(); if (cpHost != null) { cpHost.preDeleteTable(tableName); } this.executorService.submit(new DeleteTableHandler(tableName, this, this)); if (cpHost != null) { cpHost.postDeleteTable(tableName); } }
public void disableTable(final byte [] tableName) throws IOException { checkInitialized(); if (cpHost != null) { cpHost.preDisableTable(tableName); } this.executorService.submit(new DisableTableHandler(this, tableName, catalogTracker, assignmentManager, false)); if (cpHost != null) { cpHost.postDisableTable(tableName); } }
public void enableTable(final byte [] tableName) throws IOException { checkInitialized(); if (cpHost != null) { cpHost.preEnableTable(tableName); } this.executorService.submit(new EnableTableHandler(this, tableName, catalogTracker, assignmentManager, false)); if (cpHost != null) { cpHost.postEnableTable(tableName); } }
@Override public void modifyTable(final byte[] tableName, HTableDescriptor htd) throws IOException { checkInitialized(); if (cpHost != null) { cpHost.preModifyTable(tableName, htd); } TableEventHandler tblHandler = new ModifyTableHandler(tableName, htd, this, this); this.executorService.submit(tblHandler); // prevent client from querying status even before the event is being handled. tblHandler.waitForEventBeingHandled(); if (cpHost != null) { cpHost.postModifyTable(tableName, htd); } }