public CausalCluster build() { int nDatabases = databases.size(); if ( nDatabases > numCoreHosts ) { throw new IllegalArgumentException( "You cannot have more databases than core hosts. Each database in the cluster must have at least 1 core " + "host. You have provided " + nDatabases + " databases and " + numCoreHosts + " core hosts." ); } return new CausalCluster( this ); } }
public static void main( String[] args ) { try { Path clusterPath = Files.createTempDirectory( "causal-cluster" ); System.out.println( "clusterPath = " + clusterPath ); CausalClusterInProcessBuilder.CausalCluster cluster = CausalClusterInProcessBuilder.init() .withCores( 6 ) .withReplicas( 4 ) .withLogger( toOutputStream( System.out ) ) .atPath( clusterPath ) .withOptionalDatabases( Arrays.asList("foo", "bar") ) .build(); System.out.println( "Waiting for cluster to boot up..." ); cluster.boot(); System.out.println( "Press ENTER to exit ..." ); //noinspection ResultOfMethodCallIgnored System.in.read(); System.out.println( "Shutting down..." ); cluster.shutdown(); } catch ( Throwable e ) { e.printStackTrace(); System.exit( -1 ); } System.exit( 0 ); }
Map<Integer,String> initialMembersToDatabase = distributeHostsBetweenDatabases( nCores, databaseNames ); builder.withConfig( CausalClusteringSettings.initial_discovery_members.name(), String.join( ",", initialMembers ) ); builder.withConfig( CausalClusteringSettings.discovery_listen_address.name(), specifyPortOnly( hazelcastPort ) ); builder.withConfig( CausalClusteringSettings.transaction_listen_address.name(), specifyPortOnly( txPort ) ); builder.withConfig( CausalClusteringSettings.raft_listen_address.name(), specifyPortOnly( raftPort ) ); builder.withConfig( CausalClusteringSettings.minimum_core_cluster_size_at_runtime.name(), String.valueOf( nCores ) ); builder.withConfig( CausalClusteringSettings.server_groups.name(), "core," + "core" + coreId ); configureConnectors( boltPort, httpPort, httpsPort, builder ); Map<Integer,String> replicasToDatabase = distributeHostsBetweenDatabases( nReplicas, databaseNames ); builder.withConfig( CausalClusteringSettings.transaction_listen_address.name(), specifyPortOnly( txPort ) ); configureConnectors( boltPort, httpPort, httpsPort, builder );
public static void main( String[] args ) { try { Path clusterPath = Files.createTempDirectory( "causal-cluster" ); System.out.println( "clusterPath = " + clusterPath ); CausalClusterInProcessBuilder.CausalCluster cluster = CausalClusterInProcessBuilder.init() .withCores( 3 ) .withReplicas( 3 ) .withLogger( toOutputStream( System.out ) ) .atPath( clusterPath ) .build(); System.out.println( "Waiting for cluster to boot up..." ); cluster.boot(); System.out.println( "Press ENTER to exit..." ); //noinspection ResultOfMethodCallIgnored System.in.read(); System.out.println( "Shutting down..." ); cluster.shutdown(); } catch ( Throwable e ) { e.printStackTrace(); System.exit( -1 ); } System.exit( 0 ); }
private static void configureConnectors( int boltPort, int httpPort, int httpsPort, TestServerBuilder builder ) { builder.withConfig( new BoltConnector( "bolt" ).type.name(), "BOLT" ); builder.withConfig( new BoltConnector( "bolt" ).enabled.name(), "true" ); builder.withConfig( new BoltConnector( "bolt" ).listen_address.name(), specifyPortOnly( boltPort ) ); builder.withConfig( new BoltConnector( "bolt" ).advertised_address.name(), specifyPortOnly( boltPort ) ); builder.withConfig( new HttpConnector( "http", HttpConnector.Encryption.NONE ).type.name(), "HTTP" ); builder.withConfig( new HttpConnector( "http", HttpConnector.Encryption.NONE ).enabled.name(), "true" ); builder.withConfig( new HttpConnector( "http", HttpConnector.Encryption.NONE ).listen_address.name(), specifyPortOnly( httpPort ) ); builder.withConfig( new HttpConnector( "http", HttpConnector.Encryption.NONE ).advertised_address.name(), specifyPortOnly( httpPort ) ); builder.withConfig( new HttpConnector( "https", HttpConnector.Encryption.TLS ).type.name(), "HTTP" ); builder.withConfig( new HttpConnector( "https", HttpConnector.Encryption.TLS ).enabled.name(), "true" ); builder.withConfig( new HttpConnector( "https", HttpConnector.Encryption.TLS ).listen_address.name(), specifyPortOnly( httpsPort ) ); builder.withConfig( new HttpConnector( "https", HttpConnector.Encryption.TLS ).advertised_address.name(), specifyPortOnly( httpsPort ) ); }
void shutdown() throws InterruptedException { shutdownControls( replicaControls ); shutdownControls( coreControls ); }