@Test void updatesSeedNodesFromGlobalConfig() { Core core = mock(Core.class); when(core.context()).thenReturn(new CoreContext(core, 1, ENVIRONMENT, mock(Authenticator.class))); DefaultConfigurationProvider provider = new DefaultConfigurationProvider(core, SeedNode.LOCALHOST); String newConfig = readResource( "global_config_mad_hatter_multi_node.json", DefaultConfigurationProviderTest.class ); provider.proposeGlobalConfig(new ProposedGlobalConfigContext(newConfig, "127.0.0.1")); assertEquals(2, getSeedNodesFromConfig(provider).size()); for (SeedNode sn : getSeedNodesFromConfig(provider)) { assertEquals(11210, sn.kvPort().get()); assertEquals(8091, sn.clusterManagerPort().get()); assertTrue(sn.address().equals("10.143.193.101") || sn.address().equals("10.143.193.102")); } }
@Override public void proposeGlobalConfig(final ProposedGlobalConfigContext ctx) { if (!shutdown.get()) { try { GlobalConfig config = GlobalConfigParser.parse(ctx.config(), ctx.origin()); checkAndApplyConfig(config); } catch (Exception ex) { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()) )); } } else { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()) )); } }
DefaultConfigurationProvider implements ConfigurationProvider { @Override public void proposeGlobalConfig(final ProposedGlobalConfigContext ctx) { if (!shutdown.get()) { try { GlobalConfig config = GlobalConfigParser.parse(ctx.config(), ctx.origin()); checkAndApplyConfig(config); } catch (Exception ex) { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()) )); } } else { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()) )); } } }
DefaultConfigurationProvider implements ConfigurationProvider { @Override public void proposeGlobalConfig(final ProposedGlobalConfigContext ctx) { if (!shutdown.get()) { try { GlobalConfig config = GlobalConfigParser.parse(ctx.config(), ctx.origin()); checkAndApplyConfig(config); } catch (Exception ex) { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()) )); } } else { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()) )); } } DefaultConfigurationProvider(final Core core, final Set<SeedNode> seedNodes); }
DefaultConfigurationProvider implements ConfigurationProvider { @Override public void proposeGlobalConfig(final ProposedGlobalConfigContext ctx) { if (!shutdown.get()) { try { GlobalConfig config = GlobalConfigParser.parse(ctx.config(), ctx.origin()); checkAndApplyConfig(config); } catch (Exception ex) { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()) )); } } else { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()) )); } } DefaultConfigurationProvider(final Core core, final Set<SeedNode> seedNodes); @Override CollectionMap collectionMap(); @Override Flux<ClusterConfig> configs(); @Override ClusterConfig config(); @Override Flux<Set<SeedNode>> seedNodes(); @Override Mono<Void> openBucket(final String name); @Override Mono<Void> loadAndRefreshGlobalConfig(); @Override void proposeBucketConfig(final ProposedBucketConfigContext ctx); @Override void proposeGlobalConfig(final ProposedGlobalConfigContext ctx); @Override Mono<Void> closeBucket(final String name); @Override Mono<Void> shutdown(); @Override void refreshCollectionMap(final String bucket, final boolean force); @Override boolean collectionMapRefreshInProgress(); static List<AlternateAddressHolder> extractAlternateAddressInfos(final ClusterConfig config); static String determineNetworkResolution(final List<AlternateAddressHolder> nodes, final NetworkResolution nr,
                                                  final Set<String> seedHosts); @Override boolean globalConfigLoadInProgress(); @Override boolean bucketConfigLoadInProgress(); }
DefaultConfigurationProvider implements ConfigurationProvider { @Override public void proposeGlobalConfig(final ProposedGlobalConfigContext ctx) { if (!shutdown.get()) { try { GlobalConfig config = GlobalConfigParser.parse(ctx.config(), ctx.origin()); checkAndApplyConfig(config); } catch (Exception ex) { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.PARSE_FAILURE, Optional.of(ex), Optional.of(ctx.config()) )); } } else { eventBus.publish(new ConfigIgnoredEvent( core.context(), ConfigIgnoredEvent.Reason.ALREADY_SHUTDOWN, Optional.empty(), Optional.of(ctx.config()) )); } } DefaultConfigurationProvider(final Core core, final Set<SeedNode> seedNodes); @Override CollectionMap collectionMap(); @Override Flux<ClusterConfig> configs(); @Override ClusterConfig config(); @Override Flux<Set<SeedNode>> seedNodes(); @Override Mono<Void> openBucket(final String name); @Override Mono<Void> loadAndRefreshGlobalConfig(); @Override void proposeBucketConfig(final ProposedBucketConfigContext ctx); @Override void proposeGlobalConfig(final ProposedGlobalConfigContext ctx); @Override Mono<Void> closeBucket(final String name); @Override Mono<Void> shutdown(); @Override void refreshCollectionMap(final String bucket, final boolean force); @Override boolean collectionMapRefreshInProgress(); static List<AlternateAddressHolder> extractAlternateAddressInfos(final ClusterConfig config); static String determineNetworkResolution(final List<AlternateAddressHolder> nodes, final NetworkResolution nr,
                                                  final Set<String> seedHosts); @Override boolean globalConfigLoadInProgress(); @Override boolean bucketConfigLoadInProgress();  }