private CatchUpClient catchUpClient( Config config ) { SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator( config, logProvider ); ApplicationSupportedProtocols supportedCatchupProtocols = supportedProtocolCreator.createSupportedCatchupProtocol(); Collection<ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.createSupportedModifierProtocols(); NettyPipelineBuilderFactory clientPipelineBuilderFactory = new NettyPipelineBuilderFactory( createPipelineWrapper( config ) ); Duration handshakeTimeout = config.get( CausalClusteringSettings.handshake_timeout ); long inactivityTimeoutMillis = TimeUnit.MINUTES.toMillis( 1 ); return new CatchupClientBuilder( supportedCatchupProtocols, supportedModifierProtocols, clientPipelineBuilderFactory, handshakeTimeout, inactivityTimeoutMillis, logProvider, clock ) .build(); }
public List<ModifierSupportedProtocols> createSupportedModifierProtocols() { ModifierSupportedProtocols supportedCompression = compressionProtocolVersions(); return Stream.of( supportedCompression ) .filter( supportedProtocols -> !supportedProtocols.versions().isEmpty() ) .collect( Collectors.toList() ); }
public ApplicationSupportedProtocols createSupportedCatchupProtocol() { return getApplicationSupportedProtocols( config.get( CausalClusteringSettings.catchup_implementations ), CATCHUP ); }
SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator( config, logProvider ); ApplicationSupportedProtocols supportedRaftProtocols = supportedProtocolCreator.createSupportedRaftProtocol(); Collection<ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.createSupportedModifierProtocols();
private ApplicationSupportedProtocols getApplicationSupportedProtocols( List<Integer> configVersions, Protocol.ApplicationProtocolCategory category ) { if ( configVersions.isEmpty() ) { return new ApplicationSupportedProtocols( category, Collections.emptyList() ); } else { List<Integer> knownVersions = protocolsForConfig( category, configVersions, version -> Protocol.ApplicationProtocols.find( category, version ) ); if ( knownVersions.isEmpty() ) { throw new IllegalArgumentException( format( "None of configured %s implementations %s are known", category.canonicalName(), configVersions ) ); } else { return new ApplicationSupportedProtocols( category, knownVersions ); } } }
private <IMPL extends Comparable<IMPL>, T extends Protocol<IMPL>> List<IMPL> protocolsForConfig( Protocol.Category<T> category, List<IMPL> implementations, Function<IMPL,Optional<T>> finder ) { return implementations.stream() .map( impl -> Pair.of( impl, finder.apply( impl ) ) ) .peek( protocolWithImplementation -> logUnknownProtocol( category, protocolWithImplementation ) ) .map( Pair::other ) .flatMap( Streams::ofOptional ) .map( Protocol::implementation ) .collect( Collectors.toList() ); }
private ModifierSupportedProtocols compressionProtocolVersions() { List<String> implementations = protocolsForConfig( COMPRESSION, config.get( CausalClusteringSettings.compression_implementations ), implementation -> Protocol.ModifierProtocols.find( COMPRESSION, implementation ) ); return new ModifierSupportedProtocols( COMPRESSION, implementations ); }
private CatchUpClient createCatchupClient( NettyPipelineBuilderFactory clientPipelineBuilderFactory ) { SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator( config, logProvider ); ApplicationSupportedProtocols supportedCatchupProtocols = supportedProtocolCreator.createSupportedCatchupProtocol(); Collection<ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.createSupportedModifierProtocols(); Duration handshakeTimeout = config.get( CausalClusteringSettings.handshake_timeout ); long inactivityTimeoutMillis = platformModule.config.get( CausalClusteringSettings.catch_up_client_inactivity_timeout ).toMillis(); CatchUpClient catchUpClient = new CatchupClientBuilder( supportedCatchupProtocols, supportedModifierProtocols, clientPipelineBuilderFactory, handshakeTimeout, inactivityTimeoutMillis, logProvider, systemClock() ).build(); platformModule.life.add( catchUpClient ); return catchUpClient; }
public ApplicationSupportedProtocols createSupportedRaftProtocol() { return getApplicationSupportedProtocols( config.get( CausalClusteringSettings.raft_implementations ), RAFT ); }
SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator( config, logProvider ); ApplicationSupportedProtocols supportedCatchupProtocols = supportedProtocolCreator.createSupportedCatchupProtocol(); Collection<ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.createSupportedModifierProtocols();
NettyPipelineBuilderFactory backupServerPipelineBuilderFactory = new NettyPipelineBuilderFactory( backupServerPipelineWrapper ); SupportedProtocolCreator supportedProtocolCreator = new SupportedProtocolCreator( config, logProvider ); ApplicationSupportedProtocols supportedCatchupProtocols = supportedProtocolCreator.createSupportedCatchupProtocol(); Collection<ModifierSupportedProtocols> supportedModifierProtocols = supportedProtocolCreator.createSupportedModifierProtocols();