@Override public long index() { return parent.index(); }
@Override public Clock clock() { return parent.clock(); }
/** * Initializes the state machine. * * @param executor The state machine executor. * @throws NullPointerException if {@code context} is null */ public void init(StateMachineExecutor executor) { this.executor = Assert.notNull(executor, "executor"); this.context = executor.context(); this.clock = context.clock(); this.sessions = context.sessions(); if (this instanceof SessionListener) { executor.context().sessions().addListener((SessionListener) this); } configure(executor); }
@Override public final void init(StateMachineExecutor executor) { executor.serializer().register(ResourceCommand.class, -50); executor.serializer().register(ResourceQuery.class, -51); executor.serializer().register(ResourceQuery.Config.class, -52); executor.serializer().register(ResourceCommand.Delete.class, -53); executor.serializer().register(ResourceEvent.class, -49); executor.context().sessions().addListener(this); ResourceStateMachineExecutor wrappedExecutor = new ResourceStateMachineExecutor(executor); wrappedExecutor.register(ResourceQuery.Config.class, this::config); wrappedExecutor.<ResourceCommand.Register>register(ResourceCommand.Register.class, this::register); wrappedExecutor.<ResourceCommand.Unregister>register(ResourceCommand.Unregister.class, this::unregister); wrappedExecutor.<ResourceCommand.Delete>register(ResourceCommand.Delete.class, this::delete); super.init(wrappedExecutor); }
/** * Initializes the state machine. * * @param executor The state machine executor. * @throws NullPointerException if {@code context} is null */ public void init(StateMachineExecutor executor) { this.executor = Assert.notNull(executor, "executor"); this.context = executor.context(); this.clock = context.clock(); this.sessions = context.sessions(); if (this instanceof SessionListener) { executor.context().sessions().addListener((SessionListener) this); } configure(executor); }
/** * Increments the term. */ private void incrementTerm() { term = context.index(); sessions.values().forEach(s -> s.term(term)); }
/** * Initializes the state machine. * * @param executor The state machine executor. * @throws NullPointerException if {@code context} is null */ public void init(StateMachineExecutor executor) { this.executor = Assert.notNull(executor, "executor"); this.context = executor.context(); this.clock = context.clock(); this.sessions = context.sessions(); if (this instanceof SessionListener) { executor.context().sessions().addListener((SessionListener) this); } configure(executor); }
/** * Increments the term. */ private void incrementTerm() { term = context.index(); for (ServerSession session : sessions) { if (session.state() == ServerSession.State.OPEN) { session.publish("term", term); } } }
/** * Increments the term. */ private void incrementTerm() { term = context.index(); for (ServerSession session : sessions) { if (session.state() == ServerSession.State.OPEN) { session.publish("term", term); } } }
private void testExecute(Commit<TestExecute> commit) { executor.execute((Runnable) () -> { threadAssertEquals(context.index(), 2L); resume(); }); } }