job.waitTermination(); job.cancel( true );
logJob.cancel( true );
@Override public void start0() throws Throwable { BoundState boundState = clusterBinder.bindToCluster(); raftMessageHandler.start( boundState.clusterId() ); boolean startedByDownloader = false; if ( boundState.snapshot().isPresent() ) { // this means that we bootstrapped the cluster CoreSnapshot snapshot = boundState.snapshot().get(); snapshotService.installSnapshot( snapshot ); } else { snapshotService.awaitState(); Optional<JobScheduler.JobHandle> downloadJob = downloadService.downloadJob(); if ( downloadJob.isPresent() ) { downloadJob.get().waitTermination(); startedByDownloader = true; } } if ( !startedByDownloader ) { localDatabase.start(); coreStateMachines.installCommitProcess( localDatabase.getCommitProcess() ); } applicationProcess.start(); raftMachine.postRecoveryActions(); }
jobHandle.cancel( true ); jobHandle = null;
@Override public void stop() { log.info( String.format( "HazelcastCoreTopologyService stopping and unbinding from %s", config.get( discovery_listen_address ) ) ); // Interrupt the starting thread. Not really necessary, just cleaner exit startingThread.interrupt(); // Flag to notify waiters stopped = true; if ( refreshJob != null ) { refreshJob.cancel( true ); } if ( hazelcastInstance != null && membershipRegistrationId != null ) { try { hazelcastInstance.getCluster().removeMembershipListener( membershipRegistrationId ); hazelcastInstance.getLifecycleService().shutdown(); } catch ( Throwable e ) { log.warn( "Failed to stop Hazelcast", e ); } } }
@Override public synchronized void handle( RaftMessages.ReceivedInstantClusterIdAwareMessage<?> wrappedMessage ) { try { ConsensusOutcome outcome = raftMachine.handle( wrappedMessage.message() ); if ( outcome.needsFreshSnapshot() ) { Optional<JobScheduler.JobHandle> downloadJob = downloadService.scheduleDownload( catchupAddressProvider ); if ( downloadJob.isPresent() ) { downloadJob.get().waitTermination(); } } else { notifyCommitted( outcome.getCommitIndex() ); } } catch ( Throwable e ) { log.error( "Error handling message", e ); raftMachine.panic(); localDatabase.panic( e ); } }
@Override public void stop() throws Throwable { initialUserRepository.stop(); defaultAdminRepository.stop(); userRepository.stop(); roleRepository.stop(); if ( reloadJobHandle != null ) { reloadJobHandle.cancel( true ); reloadJobHandle = null; } }
@Override public synchronized void stop() throws Throwable { readerPoolPruner.cancel( false ); readerPool.close(); state.segments.close(); }
CompletableFuture<Boolean> waitUntilCaughtUpMember( RaftMachine raft ) { CompletableFuture<Boolean> catchUpFuture = new CompletableFuture<>(); Evaluator evaluator = new Evaluator( raft, catchUpFuture, dbHealthSupplier ); JobScheduler.JobHandle jobHandle = jobScheduler.schedule( new JobScheduler.Group( getClass().toString() ), evaluator, currentCatchupDelayInMs, MILLISECONDS ); catchUpFuture.whenComplete( ( result, e ) -> jobHandle.cancel( true ) ); return catchUpFuture; }
@Override public void stop() { log.info( "PruningScheduler stopping" ); stopped = true; if ( handle != null ) { handle.cancel( false ); } Predicates.awaitForever( checkPointingCondition, 100, MILLISECONDS ); } }
@Override public synchronized void unavailable() { available = false; if ( jobHandle != null ) { jobHandle.cancel( false ); jobHandle = null; } } }