Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid doing interrupt on main thread when termination is requested
This had some nasty side effects where ClosedByInterruptExceptions prevented the system from shutdown properly.
- Loading branch information
1 parent
66a478c
commit 3332eca
Showing
2 changed files
with
63 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../src/test/java/org/neo4j/causalclustering/discovery/HazelcastCoreTopologyServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.neo4j.causalclustering.discovery; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import org.neo4j.causalclustering.core.CausalClusteringSettings; | ||
import org.neo4j.causalclustering.identity.MemberId; | ||
import org.neo4j.kernel.configuration.BoltConnector; | ||
import org.neo4j.kernel.configuration.Config; | ||
import org.neo4j.kernel.impl.scheduler.CentralJobScheduler; | ||
import org.neo4j.logging.NullLogProvider; | ||
import org.neo4j.ports.allocation.PortAuthority; | ||
|
||
import static org.neo4j.causalclustering.core.CausalClusteringSettings.initial_discovery_members; | ||
import static org.neo4j.helpers.collection.MapUtil.stringMap; | ||
|
||
public class HazelcastCoreTopologyServiceTest | ||
{ | ||
@Test( timeout = 120_000) | ||
public void shouldBeAbleToStartAndStoreWithoutSuccessfulJoin() | ||
{ | ||
CentralJobScheduler jobScheduler = new CentralJobScheduler(); | ||
jobScheduler.init(); | ||
HostnameResolver hostnameResolver = new NoOpHostnameResolver(); | ||
|
||
// Random members that does not exists, discovery will never succeed | ||
String initialHosts = "localhost:" + PortAuthority.allocatePort() + ",localhost:" + PortAuthority.allocatePort(); | ||
Config config = config(); | ||
config.augment( initial_discovery_members, initialHosts ); | ||
HazelcastCoreTopologyService service = new HazelcastCoreTopologyService( config, | ||
new MemberId( UUID.randomUUID() ), | ||
jobScheduler, | ||
NullLogProvider.getInstance(), | ||
NullLogProvider.getInstance(), | ||
hostnameResolver, | ||
new TopologyServiceNoRetriesStrategy() ); | ||
service.start(); | ||
Thread.yield(); | ||
service.stop(); | ||
} | ||
|
||
private static Config config() | ||
{ | ||
return Config.defaults( stringMap( | ||
CausalClusteringSettings.raft_advertised_address.name(), "127.0.0.1:7000", | ||
CausalClusteringSettings.transaction_advertised_address.name(), "127.0.0.1:7001", | ||
new BoltConnector( "bolt" ).enabled.name(), "true", | ||
new BoltConnector( "bolt" ).advertised_address.name(), "127.0.0.1:7002" ) ); | ||
} | ||
} |