public UsedReplayWorkersForPeer(String peerId) { this.event = new ProcedureEvent<>(peerId); }
public TestTableProcedureWithEvent(long procId, TableName tableName, TableOperationType opType) { super(procId, tableName, opType); event = new ProcedureEvent<>(tableName + " procId=" + procId); }
public SplitWorkerAssigner(MasterServices master, int maxSplitTasks) { this.maxSplitTasks = maxSplitTasks; this.master = master; this.event = new ProcedureEvent<>("split-WAL-worker-assigning"); this.master.getServerManager().registerListener(this); }
public TestProcedureWithEvent(long procId) { setProcId(procId); event = new ProcedureEvent("test-event procId=" + procId); }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (succ) { return null; } // retry dispatched = false; } // Dispatch task to target server try { env.getRemoteDispatcher().addOperationToNode(targetServer, this); } catch (FailedRemoteDispatchException e) { LOG.warn("Can not add remote operation for replay wals {} on {} for peer id={}, " + "this usually because the server is already dead", wals, targetServer, peerId); // Return directly and the parent procedure will assign a new worker to replay wals return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (succ) { return null; } dispatched = false; } try { env.getRemoteDispatcher().addOperationToNode(targetServer, this); } catch (FailedRemoteDispatchException frde) { LOG.warn("Can not add remote operation for switching rpc throttle to {} on {}", rpcThrottleEnabled, targetServer); return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected synchronized Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (succ) { return null; } // retry dispatched = false; } try { env.getRemoteDispatcher().addOperationToNode(targetServer, this); } catch (FailedRemoteDispatchException frde) { LOG.info("Can not add remote operation for refreshing peer {} for {} to {}, " + "this is usually because the server is already dead, " + "give up and mark the procedure as complete", peerId, type, targetServer, frde); return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Override protected Procedure<MasterProcedureEnv>[] execute(MasterProcedureEnv env) throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException { if (dispatched) { if (success) { return null; } dispatched = false; } try { env.getRemoteDispatcher().addOperationToNode(worker, this); } catch (NoNodeDispatchException | NullTargetServerDispatchException | NoServerDispatchException e) { // When send to a wrong target server, it need construct a new SplitWALRemoteProcedure. // Thus return null for this procedure and let SplitWALProcedure to handle this. LOG.warn("dispatch WAL {} to {} failed, will retry on another server", walPath, worker, e); return null; } dispatched = true; event = new ProcedureEvent<>(this); event.suspendIfNotReady(this); throw new ProcedureSuspendedException(); }
@Test public void testSuspendedProcedure() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); queue.addBack( new TestTableProcedure(1, tableName, TableProcedureInterface.TableOperationType.READ)); queue.addBack( new TestTableProcedure(2, tableName, TableProcedureInterface.TableOperationType.READ)); Procedure<?> proc = queue.poll(); assertEquals(1, proc.getProcId()); // suspend ProcedureEvent<?> event = new ProcedureEvent<>("testSuspendedProcedureEvent"); assertEquals(true, event.suspendIfNotReady(proc)); proc = queue.poll(); assertEquals(2, proc.getProcId()); assertEquals(null, queue.poll(0)); // resume event.wake(queue); proc = queue.poll(); assertEquals(1, proc.getProcId()); assertEquals(null, queue.poll(0)); }
public TestTableProcedureWithEvent(long procId, TableName tableName, TableOperationType opType) { super(procId, tableName, opType); event = new ProcedureEvent<>(tableName + " procId=" + procId); }
public TestProcedureWithEvent(long procId) { setProcId(procId); event = new ProcedureEvent("test-event procId=" + procId); }
public TestProcedureWithEvent(long procId) { setProcId(procId); event = new ProcedureEvent("test-event procId=" + procId); }
@Test public void testSuspendedProcedure() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); queue.addBack( new TestTableProcedure(1, tableName, TableProcedureInterface.TableOperationType.READ)); queue.addBack( new TestTableProcedure(2, tableName, TableProcedureInterface.TableOperationType.READ)); Procedure<?> proc = queue.poll(); assertEquals(1, proc.getProcId()); // suspend ProcedureEvent<?> event = new ProcedureEvent<>("testSuspendedProcedureEvent"); assertEquals(true, event.suspendIfNotReady(proc)); proc = queue.poll(); assertEquals(2, proc.getProcId()); assertEquals(null, queue.poll(0)); // resume event.wake(queue); proc = queue.poll(); assertEquals(1, proc.getProcId()); assertEquals(null, queue.poll(0)); }