From 95d60bcc62fec88fe3cd0cc48db6a3ed0c455e33 Mon Sep 17 00:00:00 2001 From: RagnarW Date: Fri, 20 Apr 2018 18:29:05 +0200 Subject: [PATCH] Change name from Enableable to Suspendable --- .../catchup/tx/CatchupPollingProcess.java | 6 +-- .../core/server/CoreServerModule.java | 13 +++--- .../state/snapshot/CoreStateDownloader.java | 12 ++--- ...bleable.java => CompositeSuspendable.java} | 18 ++++---- .../{Enableable.java => Suspendable.java} | 2 +- ...feCycle.java => SuspendableLifeCycle.java} | 4 +- .../neo4j/causalclustering/net/Server.java | 4 +- .../EnterpriseReadReplicaEditionModule.java | 4 +- .../catchup/tx/CatchupPollingProcessTest.java | 6 +-- .../snapshot/CoreStateDownloaderTest.java | 4 +- ...CountingThrowingSuspendableLifeCycle.java} | 4 +- ...va => StateAwareSuspendableLifeCycle.java} | 6 +-- ...a => SuspendableLifeCycleFailingTest.java} | 14 +++--- ...pendableLifeCycleLifeStateChangeTest.java} | 28 ++++++------ ...bleLifeCycleSuspendedStateChangeTest.java} | 44 ++++++++++--------- ...SuspendableLifecycleStateTestHelpers.java} | 22 +++++----- .../causalclustering/net/ServerStateTest.java | 8 ++-- 17 files changed, 100 insertions(+), 99 deletions(-) rename enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/{CompositeEnableable.java => CompositeSuspendable.java} (72%) rename enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/{Enableable.java => Suspendable.java} (97%) rename enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/{EnableableLifeCycle.java => SuspendableLifeCycle.java} (95%) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/{CountingThrowingEnableableLifeCycle.java => CountingThrowingSuspendableLifeCycle.java} (92%) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/{StateAwareEnableableLifeCycle.java => StateAwareSuspendableLifeCycle.java} (86%) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/{EnableableLifeCycleFailingTest.java => SuspendableLifeCycleFailingTest.java} (82%) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/{EnableableLifeCycleStateChangeTest.java => SuspendableLifeCycleLifeStateChangeTest.java} (70%) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/{EnableableLifeCylcleEnableableStateChangeTest.java => SuspendableLifeCycleSuspendedStateChangeTest.java} (60%) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/{EnableableLifecycleStateTestHelpers.java => SuspendableLifecycleStateTestHelpers.java} (75%) diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcess.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcess.java index b0b3a15e695f8..0e697b390b2c2 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcess.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcess.java @@ -37,7 +37,7 @@ import org.neo4j.causalclustering.core.consensus.schedule.TimerService.TimerName; import org.neo4j.causalclustering.core.state.snapshot.TopologyLookupException; import org.neo4j.causalclustering.discovery.TopologyService; -import org.neo4j.causalclustering.helper.Enableable; +import org.neo4j.causalclustering.helper.Suspendable; import org.neo4j.causalclustering.identity.MemberId; import org.neo4j.causalclustering.identity.StoreId; import org.neo4j.causalclustering.upstream.UpstreamDatabaseSelectionException; @@ -86,7 +86,7 @@ enum State private final LocalDatabase localDatabase; private final Log log; - private final Enableable enableDisableOnStoreCopy; + private final Suspendable enableDisableOnStoreCopy; private final StoreCopyProcess storeCopyProcess; private final Supplier databaseHealthSupplier; private final CatchUpClient catchUpClient; @@ -103,7 +103,7 @@ enum State private CompletableFuture upToDateFuture; // we are up-to-date when we are successfully pulling private volatile long latestTxIdOfUpStream; - public CatchupPollingProcess( LogProvider logProvider, LocalDatabase localDatabase, Enableable enableDisableOnSoreCopy, CatchUpClient catchUpClient, + public CatchupPollingProcess( LogProvider logProvider, LocalDatabase localDatabase, Suspendable enableDisableOnSoreCopy, CatchUpClient catchUpClient, UpstreamDatabaseStrategySelector selectionStrategy, TimerService timerService, long txPullIntervalMillis, BatchingTxApplier applier, Monitors monitors, StoreCopyProcess storeCopyProcess, Supplier databaseHealthSupplier, TopologyService topologyService ) diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/server/CoreServerModule.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/server/CoreServerModule.java index 637c9b808572d..db0be393374db 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/server/CoreServerModule.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/server/CoreServerModule.java @@ -63,10 +63,10 @@ import org.neo4j.causalclustering.core.state.snapshot.CoreStateDownloaderService; import org.neo4j.causalclustering.core.state.storage.DurableStateStorage; import org.neo4j.causalclustering.core.state.storage.StateStorage; -import org.neo4j.causalclustering.helper.CompositeEnableable; +import org.neo4j.causalclustering.helper.CompositeSuspendable; import org.neo4j.causalclustering.helper.ExponentialBackoffStrategy; import org.neo4j.causalclustering.messaging.LifecycleMessageHandler; -import org.neo4j.causalclustering.helper.Enableable; +import org.neo4j.causalclustering.helper.Suspendable; import org.neo4j.causalclustering.net.InstalledProtocolHandler; import org.neo4j.causalclustering.net.Server; import org.neo4j.causalclustering.protocol.ModifierProtocolInstaller; @@ -89,7 +89,6 @@ import org.neo4j.kernel.impl.util.Dependencies; import org.neo4j.kernel.internal.DatabaseHealth; import org.neo4j.kernel.lifecycle.LifeSupport; -import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.logging.LogProvider; import org.neo4j.scheduler.JobScheduler; @@ -147,7 +146,7 @@ public CoreServerModule( IdentityModule identityModule, final PlatformModule pla this.logProvider = logging.getInternalLogProvider(); LogProvider userLogProvider = logging.getUserLogProvider(); - CompositeEnableable servicesToStopOnStoreCopy = new CompositeEnableable(); + CompositeSuspendable servicesToStopOnStoreCopy = new CompositeSuspendable(); StateStorage lastFlushedStorage = platformModule.life.add( new DurableStateStorage<>( platformModule.fileSystem, clusterStateDirectory, LAST_FLUSHED_NAME, new LongIndexMarshal(), @@ -251,7 +250,7 @@ private CatchUpClient createCatchupClient( NettyPipelineBuilderFactory clientPip return catchUpClient; } - private CoreStateDownloader createCoreStateDownloader( Enableable servicesToStopOnStoreCopy, CatchUpClient catchUpClient ) + private CoreStateDownloader createCoreStateDownloader( Suspendable servicesToSuspendOnStoreCopy, CatchUpClient catchUpClient ) { ExponentialBackoffStrategy storeCopyBackoffStrategy = new ExponentialBackoffStrategy( 1, config.get( CausalClusteringSettings.store_copy_backoff_max_wait ).toMillis(), TimeUnit.MILLISECONDS ); @@ -267,8 +266,8 @@ private CoreStateDownloader createCoreStateDownloader( Enableable servicesToStop copiedStoreRecovery, remoteStore, logProvider ); CommitStateHelper commitStateHelper = new CommitStateHelper( platformModule.pageCache, platformModule.fileSystem, config ); - return new CoreStateDownloader( localDatabase, servicesToStopOnStoreCopy, remoteStore, catchUpClient, logProvider, - storeCopyProcess, coreStateMachinesModule.coreStateMachines, snapshotService, commitStateHelper ); + return new CoreStateDownloader( localDatabase, servicesToSuspendOnStoreCopy, remoteStore, catchUpClient, logProvider, + storeCopyProcess, coreStateMachinesModule.coreStateMachines, snapshotService, commitStateHelper ); } private MembershipWaiterLifecycle createMembershipWaiterLifecycle() diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloader.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloader.java index dd57e661f8411..75c59116bfff0 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloader.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloader.java @@ -37,7 +37,7 @@ import org.neo4j.causalclustering.catchup.storecopy.StoreIdDownloadFailedException; import org.neo4j.causalclustering.core.state.CoreSnapshotService; import org.neo4j.causalclustering.core.state.machines.CoreStateMachines; -import org.neo4j.causalclustering.helper.Enableable; +import org.neo4j.causalclustering.helper.Suspendable; import org.neo4j.causalclustering.identity.StoreId; import org.neo4j.helpers.AdvertisedSocketAddress; import org.neo4j.kernel.lifecycle.LifecycleException; @@ -51,7 +51,7 @@ public class CoreStateDownloader { private final LocalDatabase localDatabase; - private final Enableable enableDisableOnStoreCopy; + private final Suspendable suspendOnStoreCopy; private final RemoteStore remoteStore; private final CatchUpClient catchUpClient; private final Log log; @@ -60,13 +60,13 @@ public class CoreStateDownloader private final CoreSnapshotService snapshotService; private CommitStateHelper commitStateHelper; - public CoreStateDownloader( LocalDatabase localDatabase, Enableable enableDisableOnStoreCopy, RemoteStore remoteStore, + public CoreStateDownloader( LocalDatabase localDatabase, Suspendable suspendOnStoreCopy, RemoteStore remoteStore, CatchUpClient catchUpClient, LogProvider logProvider, StoreCopyProcess storeCopyProcess, CoreStateMachines coreStateMachines, CoreSnapshotService snapshotService, CommitStateHelper commitStateHelper ) { this.localDatabase = localDatabase; - this.enableDisableOnStoreCopy = enableDisableOnStoreCopy; + this.suspendOnStoreCopy = suspendOnStoreCopy; this.remoteStore = remoteStore; this.catchUpClient = catchUpClient; this.log = logProvider.getLog( getClass() ); @@ -129,7 +129,7 @@ boolean downloadSnapshot( CatchupAddressProvider addressProvider ) return false; } - ensure( enableDisableOnStoreCopy::disable, "disable auxiliary services before store copy" ); + ensure( suspendOnStoreCopy::disable, "disable auxiliary services before store copy" ); ensure( localDatabase::stopForStoreCopy, "stop local database for store copy" ); log.info( "Downloading snapshot from core server at %s", primary ); @@ -211,7 +211,7 @@ else if ( catchupResult != SUCCESS_END_OF_STREAM ) ensure( localDatabase::start, "start local database after store copy" ); coreStateMachines.installCommitProcess( localDatabase.getCommitProcess() ); - ensure( enableDisableOnStoreCopy::enable, "enable auxiliary services after store copy" ); + ensure( suspendOnStoreCopy::enable, "enable auxiliary services after store copy" ); return true; } diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/CompositeEnableable.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/CompositeSuspendable.java similarity index 72% rename from enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/CompositeEnableable.java rename to enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/CompositeSuspendable.java index 9c875a5a3dfa3..2a5a066230c3b 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/CompositeEnableable.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/CompositeSuspendable.java @@ -24,36 +24,36 @@ import org.neo4j.function.ThrowingConsumer; -public class CompositeEnableable implements Enableable +public class CompositeSuspendable implements Suspendable { - private final List enableables = new ArrayList<>(); + private final List suspendables = new ArrayList<>(); - public void add( Enableable enableable ) + public void add( Suspendable suspendable ) { - enableables.add( enableable ); + suspendables.add( suspendable ); } @Override public void enable() { - doOperation( Enableable::enable, "Enable" ); + doOperation( Suspendable::enable, "Enable" ); } @Override public void disable() { - doOperation( Enableable::disable, "Disable" ); + doOperation( Suspendable::disable, "Disable" ); } - private void doOperation( ThrowingConsumer operation, String description ) + private void doOperation( ThrowingConsumer operation, String description ) { try ( ErrorHandler errorHandler = new ErrorHandler( description ) ) { - for ( Enableable enableable : enableables ) + for ( Suspendable suspendable : suspendables ) { try { - operation.accept( enableable ); + operation.accept( suspendable ); } catch ( Throwable throwable ) { diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/Enableable.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/Suspendable.java similarity index 97% rename from enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/Enableable.java rename to enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/Suspendable.java index c7fa0f072ae7b..480f004724bda 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/Enableable.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/Suspendable.java @@ -19,7 +19,7 @@ */ package org.neo4j.causalclustering.helper; -public interface Enableable +public interface Suspendable { void enable() throws Throwable; diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/EnableableLifeCycle.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/SuspendableLifeCycle.java similarity index 95% rename from enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/EnableableLifeCycle.java rename to enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/SuspendableLifeCycle.java index 74cfd0b11caf9..ab14d05796dda 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/EnableableLifeCycle.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/helper/SuspendableLifeCycle.java @@ -22,13 +22,13 @@ import org.neo4j.kernel.lifecycle.Lifecycle; import org.neo4j.logging.Log; -public abstract class EnableableLifeCycle implements Lifecycle, Enableable +public abstract class SuspendableLifeCycle implements Lifecycle, Suspendable { private final Log debugLog; private boolean stoppedByLifeCycle = true; private boolean enabled = true; - public EnableableLifeCycle( Log debugLog ) + public SuspendableLifeCycle( Log debugLog ) { this.debugLog = debugLog; } diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/net/Server.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/net/Server.java index fd1e0cfbad21a..e935b5f491f04 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/net/Server.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/net/Server.java @@ -30,7 +30,7 @@ import java.net.BindException; import java.util.concurrent.TimeUnit; -import org.neo4j.causalclustering.helper.EnableableLifeCycle; +import org.neo4j.causalclustering.helper.SuspendableLifeCycle; import org.neo4j.helpers.ListenSocketAddress; import org.neo4j.helpers.NamedThreadFactory; import org.neo4j.logging.Log; @@ -39,7 +39,7 @@ import static java.lang.String.format; -public class Server extends EnableableLifeCycle +public class Server extends SuspendableLifeCycle { private final Log debugLog; private final Log userLog; diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/readreplica/EnterpriseReadReplicaEditionModule.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/readreplica/EnterpriseReadReplicaEditionModule.java index 82df705dff590..7fe5de5d091fc 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/readreplica/EnterpriseReadReplicaEditionModule.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/readreplica/EnterpriseReadReplicaEditionModule.java @@ -61,7 +61,7 @@ import org.neo4j.causalclustering.handlers.DuplexPipelineWrapperFactory; import org.neo4j.causalclustering.handlers.PipelineWrapper; import org.neo4j.causalclustering.handlers.VoidPipelineWrapperFactory; -import org.neo4j.causalclustering.helper.CompositeEnableable; +import org.neo4j.causalclustering.helper.CompositeSuspendable; import org.neo4j.causalclustering.helper.ExponentialBackoffStrategy; import org.neo4j.causalclustering.identity.MemberId; import org.neo4j.causalclustering.net.InstalledProtocolHandler; @@ -286,7 +286,7 @@ public EnterpriseReadReplicaEditionModule( final PlatformModule platformModule, txPulling.add( copiedStoreRecovery ); - CompositeEnableable servicesToStopOnStoreCopy = new CompositeEnableable(); + CompositeSuspendable servicesToStopOnStoreCopy = new CompositeSuspendable(); StoreCopyProcess storeCopyProcess = new StoreCopyProcess( fileSystem, pageCache, localDatabase, copiedStoreRecovery, remoteStore, logProvider ); diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcessTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcessTest.java index fbfa44875f554..3644308ca28e7 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcessTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/tx/CatchupPollingProcessTest.java @@ -36,15 +36,13 @@ import org.neo4j.causalclustering.core.consensus.schedule.CountingTimerService; import org.neo4j.causalclustering.core.consensus.schedule.Timer; import org.neo4j.causalclustering.discovery.TopologyService; -import org.neo4j.causalclustering.helper.CompositeEnableable; -import org.neo4j.causalclustering.helper.Enableable; +import org.neo4j.causalclustering.helper.Suspendable; import org.neo4j.causalclustering.identity.MemberId; import org.neo4j.causalclustering.identity.StoreId; import org.neo4j.causalclustering.upstream.UpstreamDatabaseStrategySelector; import org.neo4j.helpers.AdvertisedSocketAddress; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; import org.neo4j.kernel.internal.DatabaseHealth; -import org.neo4j.kernel.lifecycle.Lifecycle; import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.logging.NullLogProvider; import org.neo4j.test.FakeClockJobScheduler; @@ -91,7 +89,7 @@ public class CatchupPollingProcessTest when( topologyService.findCatchupAddress( coreMemberId ) ).thenReturn( Optional.of( coreMemberAddress ) ); } - private final Enableable startStopOnStoreCopy = mock( Enableable.class ); + private final Suspendable startStopOnStoreCopy = mock( Suspendable.class ); private final CatchupPollingProcess txPuller = new CatchupPollingProcess( NullLogProvider.getInstance(), localDatabase, startStopOnStoreCopy, catchUpClient, strategyPipeline, timerService, diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloaderTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloaderTest.java index 07ef54cedae98..f199a5fe40de0 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloaderTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/core/state/snapshot/CoreStateDownloaderTest.java @@ -35,7 +35,7 @@ import org.neo4j.causalclustering.core.state.CoreSnapshotService; import org.neo4j.causalclustering.core.state.machines.CoreStateMachines; import org.neo4j.causalclustering.discovery.TopologyService; -import org.neo4j.causalclustering.helper.Enableable; +import org.neo4j.causalclustering.helper.Suspendable; import org.neo4j.causalclustering.identity.MemberId; import org.neo4j.causalclustering.identity.StoreId; import org.neo4j.helpers.AdvertisedSocketAddress; @@ -54,7 +54,7 @@ public class CoreStateDownloaderTest { private final LocalDatabase localDatabase = mock( LocalDatabase.class ); - private final Enableable startStopLife = mock( Enableable.class ); + private final Suspendable startStopLife = mock( Suspendable.class ); private final RemoteStore remoteStore = mock( RemoteStore.class ); private final CatchUpClient catchUpClient = mock( CatchUpClient.class ); private final StoreCopyProcess storeCopyProcess = mock( StoreCopyProcess.class ); diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/CountingThrowingEnableableLifeCycle.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/CountingThrowingSuspendableLifeCycle.java similarity index 92% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/CountingThrowingEnableableLifeCycle.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/CountingThrowingSuspendableLifeCycle.java index c7a690cefee4b..bb55e928fc1b0 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/CountingThrowingEnableableLifeCycle.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/CountingThrowingSuspendableLifeCycle.java @@ -21,9 +21,9 @@ import org.neo4j.logging.NullLog; -public class CountingThrowingEnableableLifeCycle extends EnableableLifeCycle +public class CountingThrowingSuspendableLifeCycle extends SuspendableLifeCycle { - public CountingThrowingEnableableLifeCycle() + public CountingThrowingSuspendableLifeCycle() { super( NullLog.getInstance() ); } diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/StateAwareEnableableLifeCycle.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/StateAwareSuspendableLifeCycle.java similarity index 86% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/StateAwareEnableableLifeCycle.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/StateAwareSuspendableLifeCycle.java index 81e226e92e8b4..1f4df9e6a4ced 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/StateAwareEnableableLifeCycle.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/StateAwareSuspendableLifeCycle.java @@ -19,14 +19,14 @@ */ package org.neo4j.causalclustering.helper; -import org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.LifeCycleState; +import org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.LifeCycleState; import org.neo4j.logging.Log; -public class StateAwareEnableableLifeCycle extends EnableableLifeCycle +public class StateAwareSuspendableLifeCycle extends SuspendableLifeCycle { public LifeCycleState status; - StateAwareEnableableLifeCycle( Log debugLog ) + StateAwareSuspendableLifeCycle( Log debugLog ) { super( debugLog ); } diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCycleFailingTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleFailingTest.java similarity index 82% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCycleFailingTest.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleFailingTest.java index eee2815fb30be..3df6dcf7fcac3 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCycleFailingTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleFailingTest.java @@ -27,15 +27,15 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -public class EnableableLifeCycleFailingTest +public class SuspendableLifeCycleFailingTest { - private CountingThrowingEnableableLifeCycle lifeCycle; + private CountingThrowingSuspendableLifeCycle lifeCycle; @Before public void setup() throws Throwable { - lifeCycle = new CountingThrowingEnableableLifeCycle(); + lifeCycle = new CountingThrowingSuspendableLifeCycle(); lifeCycle.init(); } @@ -45,7 +45,7 @@ public void canEnableIfStopFailed() throws Throwable lifeCycle.start(); lifeCycle.setFailMode(); - runFailing( EnableableLifeCycle::stop ); + runFailing( SuspendableLifeCycle::stop ); lifeCycle.setSuccessMode(); @@ -60,7 +60,7 @@ public void canEnableIfShutdownFailed() throws Throwable lifeCycle.start(); lifeCycle.setFailMode(); - runFailing( EnableableLifeCycle::shutdown ); + runFailing( SuspendableLifeCycle::shutdown ); lifeCycle.setSuccessMode(); @@ -73,7 +73,7 @@ public void canEnableIfShutdownFailed() throws Throwable public void canStartifDisableFailed() throws Throwable { lifeCycle.setFailMode(); - runFailing( EnableableLifeCycle::disable ); + runFailing( SuspendableLifeCycle::disable ); lifeCycle.setSuccessMode(); lifeCycle.start(); @@ -81,7 +81,7 @@ public void canStartifDisableFailed() throws Throwable assertEquals( 1, lifeCycle.starts ); } - private void runFailing( ThrowingConsumer consumer ) throws Throwable + private void runFailing( ThrowingConsumer consumer ) throws Throwable { try { diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCycleStateChangeTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleLifeStateChangeTest.java similarity index 70% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCycleStateChangeTest.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleLifeStateChangeTest.java index f5d5363ba22fd..999f352a8e740 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCycleStateChangeTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleLifeStateChangeTest.java @@ -27,21 +27,21 @@ import java.util.ArrayList; import java.util.List; -import org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.EnableableState; -import org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.LifeCycleState; +import org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.SuspendedState; +import org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.LifeCycleState; import org.neo4j.logging.AssertableLogProvider; import static org.junit.Assert.assertEquals; -import static org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.setInitialState; +import static org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.setInitialState; @RunWith( Parameterized.class ) -public class EnableableLifeCycleStateChangeTest +public class SuspendableLifeCycleLifeStateChangeTest { @Parameterized.Parameter() public LifeCycleState fromState; @Parameterized.Parameter( 1 ) - public EnableableState fromEnableableState; + public SuspendedState fromSuspendedState; @Parameterized.Parameter( 2 ) public LifeCycleState toLifeCycleState; @@ -55,18 +55,18 @@ public static Iterable data() List params = new ArrayList<>(); for ( LifeCycleState lifeCycleState : LifeCycleState.values() ) { - for ( EnableableState enableableState : EnableableState.values() ) + for ( SuspendedState suspendedState : SuspendedState.values() ) { for ( LifeCycleState toState : lifeCycleOperation() ) { - params.add( new Object[]{lifeCycleState, enableableState, toState, expectedResult( enableableState, toState )} ); + params.add( new Object[]{lifeCycleState, suspendedState, toState, expectedResult( suspendedState, toState )} ); } } } return params; } - private StateAwareEnableableLifeCycle lifeCycle; + private StateAwareSuspendableLifeCycle lifeCycle; private static LifeCycleState[] lifeCycleOperation() { @@ -76,25 +76,25 @@ private static LifeCycleState[] lifeCycleOperation() @Before public void setUpServer() throws Throwable { - lifeCycle = new StateAwareEnableableLifeCycle( new AssertableLogProvider( false ).getLog( "log" ) ); + lifeCycle = new StateAwareSuspendableLifeCycle( new AssertableLogProvider( false ).getLog( "log" ) ); setInitialState( lifeCycle, fromState ); - fromEnableableState.set( lifeCycle ); + fromSuspendedState.set( lifeCycle ); } @Test - public void executeEnableable() throws Throwable + public void changeLifeState() throws Throwable { toLifeCycleState.set( lifeCycle ); assertEquals( shouldBeRunning, lifeCycle.status ); } - private static LifeCycleState expectedResult( EnableableState state, LifeCycleState toLifeCycle ) + private static LifeCycleState expectedResult( SuspendedState state, LifeCycleState toLifeCycle ) { - if ( state == EnableableState.Untouched || state == EnableableState.Enabled ) + if ( state == SuspendedState.Untouched || state == SuspendedState.Enabled ) { return toLifeCycle; } - else if ( state == EnableableState.Disabled ) + else if ( state == SuspendedState.Disabled ) { if ( toLifeCycle == LifeCycleState.Shutdown ) { diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCylcleEnableableStateChangeTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleSuspendedStateChangeTest.java similarity index 60% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCylcleEnableableStateChangeTest.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleSuspendedStateChangeTest.java index 757c06bf3530c..b58bac1251c59 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifeCylcleEnableableStateChangeTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifeCycleSuspendedStateChangeTest.java @@ -27,24 +27,24 @@ import java.util.ArrayList; import java.util.List; -import org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.EnableableState; -import org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.LifeCycleState; +import org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.SuspendedState; +import org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.LifeCycleState; import org.neo4j.logging.NullLogProvider; import static org.junit.Assert.assertEquals; -import static org.neo4j.causalclustering.helper.EnableableLifecycleStateTestHelpers.setInitialState; +import static org.neo4j.causalclustering.helper.SuspendableLifecycleStateTestHelpers.setInitialState; @RunWith( Parameterized.class ) -public class EnableableLifeCylcleEnableableStateChangeTest +public class SuspendableLifeCycleSuspendedStateChangeTest { @Parameterized.Parameter() public LifeCycleState fromState; @Parameterized.Parameter( 1 ) - public EnableableState fromEnableableState; + public SuspendedState fromSuspendedState; @Parameterized.Parameter( 2 ) - public EnableableState toEnableableState; + public SuspendedState toSuspendedState; @Parameterized.Parameter( 3 ) public LifeCycleState shouldEndInState; @@ -55,48 +55,50 @@ public static Iterable data() List params = new ArrayList<>(); for ( LifeCycleState lifeCycleState : LifeCycleState.values() ) { - for ( EnableableState enableableState : EnableableState.values() ) + for ( SuspendedState suspendedState : SuspendedState.values() ) { - for ( EnableableState toEnableable : toEnableableState() ) + for ( SuspendedState toSuspendedState : toSuspendedState() ) { - params.add( new Object[]{lifeCycleState, enableableState, toEnableable, expectedResult( lifeCycleState, enableableState, toEnableable )} ); + params.add( new Object[]{lifeCycleState, suspendedState, toSuspendedState, + expectedResult( lifeCycleState, suspendedState, toSuspendedState )} ); } } } return params; } - private StateAwareEnableableLifeCycle lifeCycle; + private StateAwareSuspendableLifeCycle lifeCycle; - private static EnableableState[] toEnableableState() + private static SuspendedState[] toSuspendedState() { - return new EnableableState[]{EnableableState.Enabled, EnableableState.Disabled}; + return new SuspendedState[]{SuspendedState.Enabled, SuspendedState.Disabled}; } @Before public void setUpServer() throws Throwable { - lifeCycle = new StateAwareEnableableLifeCycle( NullLogProvider.getInstance().getLog( "log" ) ); + lifeCycle = new StateAwareSuspendableLifeCycle( NullLogProvider.getInstance() + .getLog( "log" ) ); setInitialState( lifeCycle, fromState ); - fromEnableableState.set( lifeCycle ); + fromSuspendedState.set( lifeCycle ); } @Test - public void executeEnableable() throws Throwable + public void changeSuspendedState() throws Throwable { - toEnableableState.set( lifeCycle ); + toSuspendedState.set( lifeCycle ); assertEquals( shouldEndInState, lifeCycle.status ); } - private static LifeCycleState expectedResult( LifeCycleState fromState, EnableableState fromEnableableState, EnableableState toEnableable ) + private static LifeCycleState expectedResult( LifeCycleState fromState, SuspendedState fromSuspendedState, SuspendedState toSuspendedState ) { - if ( toEnableable == EnableableState.Disabled ) + if ( toSuspendedState == SuspendedState.Disabled ) { return LifeCycleState.Stop; } - else if ( toEnableable == EnableableState.Enabled ) + else if ( toSuspendedState == SuspendedState.Enabled ) { - if ( fromEnableableState == EnableableState.Disabled ) + if ( fromSuspendedState == SuspendedState.Disabled ) { if ( fromState == LifeCycleState.Init || fromState == LifeCycleState.Shutdown ) { @@ -107,7 +109,7 @@ else if ( toEnableable == EnableableState.Enabled ) } else { - throw new IllegalStateException( "Should not transition to any other state got: " + toEnableable ); + throw new IllegalStateException( "Should not transition to any other state got: " + toSuspendedState ); } } } diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifecycleStateTestHelpers.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifecycleStateTestHelpers.java similarity index 75% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifecycleStateTestHelpers.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifecycleStateTestHelpers.java index f1b7f26818852..98884f6d26093 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/EnableableLifecycleStateTestHelpers.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/helper/SuspendableLifecycleStateTestHelpers.java @@ -22,9 +22,9 @@ import org.neo4j.function.ThrowingConsumer; import org.neo4j.kernel.lifecycle.Lifecycle; -class EnableableLifecycleStateTestHelpers +class SuspendableLifecycleStateTestHelpers { - static void setInitialState( StateAwareEnableableLifeCycle lifeCycle, LifeCycleState state ) throws Throwable + static void setInitialState( StateAwareSuspendableLifeCycle lifeCycle, LifeCycleState state ) throws Throwable { for ( LifeCycleState lifeCycleState : LifeCycleState.values() ) { @@ -55,22 +55,24 @@ void set( Lifecycle lifecycle ) throws Throwable } } - enum EnableableState + enum SuspendedState { - Untouched( enableable -> {} ), - Enabled( Enableable::enable ), - Disabled( Enableable::disable ); + Untouched( suspendable -> + { + } ), + Enabled( Suspendable::enable ), + Disabled( Suspendable::disable ); - private final ThrowingConsumer consumer; + private final ThrowingConsumer consumer; - EnableableState( ThrowingConsumer consumer ) + SuspendedState( ThrowingConsumer consumer ) { this.consumer = consumer; } - void set( Enableable enableable ) throws Throwable + void set( Suspendable suspendable ) throws Throwable { - consumer.accept( enableable ); + consumer.accept( suspendable ); } } } diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/net/ServerStateTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/net/ServerStateTest.java index db377e615a45e..dfa01b9fc495b 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/net/ServerStateTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/net/ServerStateTest.java @@ -32,8 +32,8 @@ import org.junit.BeforeClass; import org.junit.Test; -import org.neo4j.causalclustering.helper.EnableableLifeCycleStateChangeTest; -import org.neo4j.causalclustering.helper.EnableableLifeCylcleEnableableStateChangeTest; +import org.neo4j.causalclustering.helper.SuspendableLifeCycleLifeStateChangeTest; +import org.neo4j.causalclustering.helper.SuspendableLifeCycleSuspendedStateChangeTest; import org.neo4j.helpers.ListenSocketAddress; import org.neo4j.logging.FormattedLogProvider; import org.neo4j.logging.Level; @@ -43,8 +43,8 @@ import static org.junit.Assert.assertTrue; /** - * More generalized state tests of EnableableLifeCycle can be found {@link EnableableLifeCycleStateChangeTest} and - * {@link EnableableLifeCylcleEnableableStateChangeTest} + * More generalized state tests of SuspendableLifeCycle can be found {@link SuspendableLifeCycleLifeStateChangeTest} and + * {@link SuspendableLifeCycleSuspendedStateChangeTest} */ public class ServerStateTest {