Search in sources :

Example 1 with MasterProcedureScheduler

use of org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler in project hbase by apache.

the class HMaster method getLocks.

@Override
public List<LockedResource> getLocks() throws IOException {
    if (cpHost != null) {
        cpHost.preGetLocks();
    }
    MasterProcedureScheduler procedureScheduler = procedureExecutor.getEnvironment().getProcedureScheduler();
    final List<LockedResource> lockedResources = procedureScheduler.getLocks();
    if (cpHost != null) {
        cpHost.postGetLocks(lockedResources);
    }
    return lockedResources;
}
Also used : LockedResource(org.apache.hadoop.hbase.procedure2.LockedResource) MasterProcedureScheduler(org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler)

Example 2 with MasterProcedureScheduler

use of org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler in project hbase by apache.

the class TestSyncReplicationReplayWALManager method setUp.

@Before
public void setUp() throws IOException, ReplicationException {
    wokenProcedures = new ArrayDeque<>();
    onlineServers = new HashSet<>();
    listeners = new ArrayList<>();
    ServerManager serverManager = mock(ServerManager.class);
    doAnswer(inv -> listeners.add(inv.getArgument(0))).when(serverManager).registerListener(any(ServerListener.class));
    ServerMetrics serverMetrics = mock(ServerMetrics.class);
    doAnswer(inv -> onlineServers.stream().collect(Collectors.toMap(Function.identity(), k -> serverMetrics))).when(serverManager).getOnlineServers();
    MasterFileSystem mfs = mock(MasterFileSystem.class);
    when(mfs.getFileSystem()).thenReturn(UTIL.getTestFileSystem());
    when(mfs.getWALRootDir()).thenReturn(new Path("/"));
    scheduler = mock(MasterProcedureScheduler.class);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            ProcedureEvent<?> event = ((ProcedureEvent<?>[]) invocation.getArgument(0))[0];
            event.wakeInternal(new MasterProcedureScheduler(pid -> null) {

                @Override
                public void addFront(Iterator<Procedure> procedureIterator) {
                    procedureIterator.forEachRemaining(wokenProcedures::add);
                }
            });
            return null;
        }
    }).when(scheduler).wakeEvents(any(ProcedureEvent[].class));
    MasterProcedureEnv env = mock(MasterProcedureEnv.class);
    when(env.getProcedureScheduler()).thenReturn(scheduler);
    ProcedureExecutor<MasterProcedureEnv> procExec = mock(ProcedureExecutor.class);
    when(procExec.getEnvironment()).thenReturn(env);
    MasterServices services = mock(MasterServices.class);
    when(services.getServerManager()).thenReturn(serverManager);
    when(services.getMasterFileSystem()).thenReturn(mfs);
    when(services.getMasterProcedureExecutor()).thenReturn(procExec);
    manager = new SyncReplicationReplayWALManager(services);
    assertEquals(1, listeners.size());
}
Also used : ServerManager(org.apache.hadoop.hbase.master.ServerManager) MasterFileSystem(org.apache.hadoop.hbase.master.MasterFileSystem) Path(org.apache.hadoop.fs.Path) ProcedureEvent(org.apache.hadoop.hbase.procedure2.ProcedureEvent) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) MasterProcedureScheduler(org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler) MasterServices(org.apache.hadoop.hbase.master.MasterServices) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Iterator(java.util.Iterator) ServerMetrics(org.apache.hadoop.hbase.ServerMetrics) ServerListener(org.apache.hadoop.hbase.master.ServerListener) Before(org.junit.Before)

Example 3 with MasterProcedureScheduler

use of org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler in project hbase by apache.

the class HMaster method createProcedureExecutor.

private void createProcedureExecutor() throws IOException {
    MasterProcedureEnv procEnv = new MasterProcedureEnv(this);
    procedureStore = new RegionProcedureStore(this, masterRegion, new MasterProcedureEnv.FsUtilsLeaseRecovery(this));
    procedureStore.registerListener(new ProcedureStoreListener() {

        @Override
        public void abortProcess() {
            abort("The Procedure Store lost the lease", null);
        }
    });
    MasterProcedureScheduler procedureScheduler = procEnv.getProcedureScheduler();
    procedureExecutor = new ProcedureExecutor<>(conf, procEnv, procedureStore, procedureScheduler);
    configurationManager.registerObserver(procEnv);
    int cpus = Runtime.getRuntime().availableProcessors();
    final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, Math.max((cpus > 0 ? cpus / 4 : 0), MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS));
    final boolean abortOnCorruption = conf.getBoolean(MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION, MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION);
    procedureStore.start(numThreads);
    // Just initialize it but do not start the workers, we will start the workers later by calling
    // startProcedureExecutor. See the javadoc for finishActiveMasterInitialization for more
    // details.
    procedureExecutor.init(numThreads, abortOnCorruption);
    if (!procEnv.getRemoteDispatcher().start()) {
        throw new HBaseIOException("Failed start of remote dispatcher");
    }
}
Also used : HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) RegionProcedureStore(org.apache.hadoop.hbase.procedure2.store.region.RegionProcedureStore) MasterProcedureEnv(org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv) MasterProcedureScheduler(org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler) ProcedureStoreListener(org.apache.hadoop.hbase.procedure2.store.ProcedureStore.ProcedureStoreListener) RSGroupAdminEndpoint(org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)

Aggregations

MasterProcedureScheduler (org.apache.hadoop.hbase.master.procedure.MasterProcedureScheduler)3 MasterProcedureEnv (org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv)2 Iterator (java.util.Iterator)1 Path (org.apache.hadoop.fs.Path)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 ServerMetrics (org.apache.hadoop.hbase.ServerMetrics)1 MasterFileSystem (org.apache.hadoop.hbase.master.MasterFileSystem)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 ServerListener (org.apache.hadoop.hbase.master.ServerListener)1 ServerManager (org.apache.hadoop.hbase.master.ServerManager)1 LockedResource (org.apache.hadoop.hbase.procedure2.LockedResource)1 ProcedureEvent (org.apache.hadoop.hbase.procedure2.ProcedureEvent)1 ProcedureStoreListener (org.apache.hadoop.hbase.procedure2.store.ProcedureStore.ProcedureStoreListener)1 RegionProcedureStore (org.apache.hadoop.hbase.procedure2.store.region.RegionProcedureStore)1 RSGroupAdminEndpoint (org.apache.hadoop.hbase.rsgroup.RSGroupAdminEndpoint)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1