public synchronized void stop() throws IOException { pauseApplier( "shutdown" ); coreState.flush( applierState.lastApplied ); }
@Override public void dispatch( CommandDispatcher commandDispatcher, long commandIndex, Consumer<Result> callback ) { commandDispatcher.dispatch( this, commandIndex, callback ); } }
/** * For use by special tooling which does not need the functionality * of migration or ensuring the directory for cluster state actually * exists. */ public static ClusterStateDirectory withoutInitializing( File dataDir ) { ClusterStateDirectory clusterStateDirectory = new ClusterStateDirectory( dataDir ); clusterStateDirectory.initialized = true; return clusterStateDirectory; }
DumpClusterState( FileSystemAbstraction fs, File dataDirectory, PrintStream out ) throws ClusterStateException { this.fs = fs; this.clusterStateDirectory = new ClusterStateDirectory( dataDirectory ).initialize( fs ).get(); this.out = out; }
protected ClusteringModule getClusteringModule( PlatformModule platformModule, DiscoveryServiceFactory discoveryServiceFactory, ClusterStateDirectory clusterStateDirectory, IdentityModule identityModule, Dependencies dependencies ) { return new ClusteringModule( discoveryServiceFactory, identityModule.myself(), platformModule, clusterStateDirectory.get() ); }
private void stopApplierThread() { applierState.setKeepRunning( false ); ignoringInterrupts( () -> applierThread.join() ); }
/** * Returns true if the cluster state base directory exists or * could be created. This method also takes care of any necessary * migration. * * It is a requirement to initialize before using the class, unless * the non-migrating version is used. */ public ClusterStateDirectory initialize( FileSystemAbstraction fs ) throws ClusterStateException { assert !initialized; if ( !readOnly ) { migrateIfNeeded( fs ); } ensureDirectoryExists( fs ); initialized = true; return this; }
public CoreLife createCoreLife( LifecycleMessageHandler<RaftMessages.ReceivedInstantClusterIdAwareMessage<?>> handler ) { return new CoreLife( consensusModule.raftMachine(), localDatabase, clusteringModule.clusterBinder(), commandApplicationProcess, coreStateMachinesModule.coreStateMachines, handler, snapshotService, downloadService ); }
public static Result of( Object result ) { return new Result( result ); }
private void notifyCommitted( long commitIndex ) { applicationProcess.notifyCommitted( commitIndex ); } }
private void maybeFlushToDisk() throws IOException { if ( (applierState.lastApplied - lastFlushed) > flushEvery ) { coreState.flush( applierState.lastApplied ); lastFlushed = applierState.lastApplied; } }
void notifyCommitted( long commitIndex ) { applierState.notifyCommitted( commitIndex ); }
@Override public void applyCommand( DummyRequest dummyRequest, long commandIndex, Consumer<Result> callback ) { callback.accept( Result.of( dummyRequest ) ); }
private void spawnApplierThread() { applierState.setKeepRunning( true ); applierThread = new Thread( this::applyJob, "core-state-applier" ); applierThread.start(); }
void add( long index, DistributedOperation operation ) throws Exception { assert batch.size() <= 0 || index == (lastIndex + 1); batch.add( operation ); lastIndex = index; if ( batch.size() == maxBatchSize ) { flush(); } }
@Override public void dispatch( CommandDispatcher commandDispatcher, long commandIndex, Consumer<Result> callback ) { commandDispatcher.dispatch( this, commandIndex, callback ); }
public static Result of( Exception exception ) { return new Result( exception ); }
@Override public void dispatch( CommandDispatcher commandDispatcher, long commandIndex, Consumer<Result> callback ) { commandDispatcher.dispatch( this, commandIndex, callback ); }
@Override public void dispatch( CommandDispatcher commandDispatcher, long commandIndex, Consumer<Result> callback ) { commandDispatcher.dispatch( this, commandIndex, callback ); } }
@Override public void dispatch( CommandDispatcher commandDispatcher, long commandIndex, Consumer<Result> callback ) { commandDispatcher.dispatch( this, commandIndex, callback ); } }