/** * Returns the state machine's current index. * * @return The state machine's current index. */ protected long getCurrentIndex() { return context.currentIndex(); }
/** * Returns the ID of the cluster member this service instance is running on. * Caution: This information should not be used in anyway to modify the machine's state, * as it could be used to violate the invariant that all instances of a partition must * have the same state. * However, it can be used safely for logging purposes or for generating meaningful * filenames for instance (this can be useful especially in the case where several * cluster members are run on the same host). * @return The local member ID */ protected MemberId getLocalMemberId() { return context.localMemberId(); }
/** * Returns the state machine's logical clock. * * @return The state machine's logical clock. */ protected LogicalClock getLogicalClock() { return context.logicalClock(); }
public DefaultServiceExecutor(ServiceContext context, Serializer serializer) { this.serializer = checkNotNull(serializer); this.context = checkNotNull(context); this.log = ContextualLoggerFactory.getLogger(getClass(), LoggerContext.builder(PrimitiveService.class) .addValue(context.serviceId()) .add("type", context.serviceType()) .add("name", context.serviceName()) .build()); }
/** * Returns the unique state machine identifier. * * @return The unique state machine identifier. */ protected PrimitiveId getServiceId() { return context.serviceId(); }
/** * Returns the state machine's wall clock. * * @return The state machine's wall clock. */ protected WallClock getWallClock() { return context.wallClock(); }
/** * Returns the unique state machine name. * * @return The unique state machine name. */ protected String getServiceName() { return context.serviceName(); }
/** * Returns the current session. * * @return the current session */ protected Session<C> getCurrentSession() { return getSession(context.currentSession().sessionId()); }
@Override public final void init(ServiceContext context) { this.context = context; this.executor = new DefaultServiceExecutor(context, serializer()); this.log = ContextualLoggerFactory.getLogger(getClass(), LoggerContext.builder(PrimitiveService.class) .addValue(context.serviceId()) .add("type", context.serviceType()) .add("name", context.serviceName()) .build()); configure(executor); }