@Test void ignoresFailedGlobalConfigInitAttempt() { final ConfigurationProvider configProvider = mock(ConfigurationProvider.class); when(configProvider.configs()).thenReturn(Flux.empty()); Core core = new Core(ENV, AUTHENTICATOR, SeedNode.LOCALHOST) { @Override public ConfigurationProvider createConfigurationProvider() { return configProvider; } }; when(configProvider.loadAndRefreshGlobalConfig()).thenReturn(Mono.error(new GlobalConfigNotFoundException())); core.initGlobalConfig(); when(configProvider.loadAndRefreshGlobalConfig()).thenReturn(Mono.error(new UnsupportedConfigMechanismException())); core.initGlobalConfig(); int numRaised = 0; for (Event event : EVENT_BUS.publishedEvents()) { if (event instanceof InitGlobalConfigFailedEvent) { numRaised++; } } assertEquals(2, numRaised); }
@Stability.Internal public void initGlobalConfig() { long start = System.nanoTime(); configurationProvider .loadAndRefreshGlobalConfig() .subscribe( v -> {}, throwable -> { InitGlobalConfigFailedEvent.Reason reason = InitGlobalConfigFailedEvent.Reason.UNKNOWN; if (throwable instanceof UnsupportedConfigMechanismException) { reason = InitGlobalConfigFailedEvent.Reason.UNSUPPORTED; } else if (throwable instanceof GlobalConfigNotFoundException) { reason = InitGlobalConfigFailedEvent.Reason.NO_CONFIG_FOUND; } else if (throwable instanceof ConfigException) { if (throwable.getCause() instanceof RequestCanceledException) { RequestContext ctx = ((RequestCanceledException) throwable.getCause()).context().requestContext(); if (ctx.request().cancellationReason() == CancellationReason.SHUTDOWN) { reason = InitGlobalConfigFailedEvent.Reason.SHUTDOWN; } } } eventBus.publish(new InitGlobalConfigFailedEvent( reason.severity(), Duration.ofNanos(System.nanoTime() - start), context(), reason, throwable )); } ); }
Core { @Stability.Internal public void initGlobalConfig() { long start = System.nanoTime(); configurationProvider .loadAndRefreshGlobalConfig() .subscribe( v -> {}, throwable -> { InitGlobalConfigFailedEvent.Reason reason = InitGlobalConfigFailedEvent.Reason.UNKNOWN; if (throwable instanceof UnsupportedConfigMechanismException) { reason = InitGlobalConfigFailedEvent.Reason.UNSUPPORTED; } else if (throwable instanceof GlobalConfigNotFoundException) { reason = InitGlobalConfigFailedEvent.Reason.NO_CONFIG_FOUND; } else if (throwable instanceof ConfigException) { if (throwable.getCause() instanceof RequestCanceledException) { RequestContext ctx = ((RequestCanceledException) throwable.getCause()).context().requestContext(); if (ctx.request().cancellationReason() == CancellationReason.SHUTDOWN) { reason = InitGlobalConfigFailedEvent.Reason.SHUTDOWN; } } } eventBus.publish(new InitGlobalConfigFailedEvent( reason.severity(), Duration.ofNanos(System.nanoTime() - start), context(), reason, throwable )); } ); } }
Core { @Stability.Internal public void initGlobalConfig() { long start = System.nanoTime(); configurationProvider .loadAndRefreshGlobalConfig() .subscribe( v -> {}, throwable -> { InitGlobalConfigFailedEvent.Reason reason = InitGlobalConfigFailedEvent.Reason.UNKNOWN; if (throwable instanceof UnsupportedConfigMechanismException) { reason = InitGlobalConfigFailedEvent.Reason.UNSUPPORTED; } else if (throwable instanceof GlobalConfigNotFoundException) { reason = InitGlobalConfigFailedEvent.Reason.NO_CONFIG_FOUND; } else if (throwable instanceof ConfigException) { if (throwable.getCause() instanceof RequestCanceledException) { RequestContext ctx = ((RequestCanceledException) throwable.getCause()).context().requestContext(); if (ctx.request().cancellationReason() == CancellationReason.SHUTDOWN) { reason = InitGlobalConfigFailedEvent.Reason.SHUTDOWN; } } } eventBus.publish(new InitGlobalConfigFailedEvent( reason.severity(), Duration.ofNanos(System.nanoTime() - start), context(), reason, throwable )); } ); } protected  Core(final CoreEnvironment environment, final Authenticator authenticator, final Set<SeedNode> seedNodes); }
Core { @Stability.Internal public void initGlobalConfig() { long start = System.nanoTime(); configurationProvider .loadAndRefreshGlobalConfig() .subscribe( v -> {}, throwable -> { InitGlobalConfigFailedEvent.Reason reason = InitGlobalConfigFailedEvent.Reason.UNKNOWN; if (throwable instanceof UnsupportedConfigMechanismException) { reason = InitGlobalConfigFailedEvent.Reason.UNSUPPORTED; } else if (throwable instanceof GlobalConfigNotFoundException) { reason = InitGlobalConfigFailedEvent.Reason.NO_CONFIG_FOUND; } else if (throwable instanceof ConfigException) { if (throwable.getCause() instanceof RequestCanceledException) { RequestContext ctx = ((RequestCanceledException) throwable.getCause()).context().requestContext(); if (ctx.request().cancellationReason() == CancellationReason.SHUTDOWN) { reason = InitGlobalConfigFailedEvent.Reason.SHUTDOWN; } } } eventBus.publish(new InitGlobalConfigFailedEvent( reason.severity(), Duration.ofNanos(System.nanoTime() - start), context(), reason, throwable )); } ); } protected  Core(final CoreEnvironment environment, final Authenticator authenticator, final Set<SeedNode> seedNodes); static Core create(final CoreEnvironment environment, final Authenticator authenticator, final Set<SeedNode> seedNodes); @Stability.Internal ConfigurationProvider configurationProvider(); void send(final Request<R> request); @Stability.Internal @SuppressWarnings({"unchecked"}) void send(final Request<R> request, final boolean registerForTimeout); CoreContext context(); @Stability.Internal Stream<EndpointDiagnostics> diagnostics(); @Stability.Internal Optional<Flux<ServiceState>> serviceState(NodeIdentifier nodeIdentifier, ServiceType type, Optional<String> bucket); @Stability.Internal void initGlobalConfig(); @Stability.Internal void openBucket(final String name); @Stability.Internal ClusterConfig clusterConfig(); @Stability.Internal Mono<Void> ensureServiceAt(final NodeIdentifier identifier, final ServiceType serviceType, final int port,
                                    final Optional<String> bucket, final Optional<String> alternateAddress); @Stability.Internal Mono<Void> shutdown(); @Stability.Internal Mono<Void> shutdown(Duration timeout); }
Core { @Stability.Internal public void initGlobalConfig() { long start = System.nanoTime(); configurationProvider .loadAndRefreshGlobalConfig() .subscribe( v -> {}, throwable -> { InitGlobalConfigFailedEvent.Reason reason = InitGlobalConfigFailedEvent.Reason.UNKNOWN; if (throwable instanceof UnsupportedConfigMechanismException) { reason = InitGlobalConfigFailedEvent.Reason.UNSUPPORTED; } else if (throwable instanceof GlobalConfigNotFoundException) { reason = InitGlobalConfigFailedEvent.Reason.NO_CONFIG_FOUND; } else if (throwable instanceof ConfigException) { if (throwable.getCause() instanceof RequestCanceledException) { RequestContext ctx = ((RequestCanceledException) throwable.getCause()).context().requestContext(); if (ctx.request().cancellationReason() == CancellationReason.SHUTDOWN) { reason = InitGlobalConfigFailedEvent.Reason.SHUTDOWN; } } } eventBus.publish(new InitGlobalConfigFailedEvent( reason.severity(), Duration.ofNanos(System.nanoTime() - start), context(), reason, throwable )); } ); } protected  Core(final CoreEnvironment environment, final Authenticator authenticator, final Set<SeedNode> seedNodes); static Core create(final CoreEnvironment environment, final Authenticator authenticator, final Set<SeedNode> seedNodes); @Stability.Internal ConfigurationProvider configurationProvider(); void send(final Request<R> request); @Stability.Internal @SuppressWarnings({"unchecked"}) void send(final Request<R> request, final boolean registerForTimeout); CoreContext context(); @Stability.Internal Stream<EndpointDiagnostics> diagnostics(); @Stability.Internal Optional<Flux<ServiceState>> serviceState(NodeIdentifier nodeIdentifier, ServiceType type, Optional<String> bucket); @Stability.Internal void initGlobalConfig(); @Stability.Internal void openBucket(final String name); @Stability.Internal ClusterConfig clusterConfig(); @Stability.Internal Mono<Void> ensureServiceAt(final NodeIdentifier identifier, final ServiceType serviceType, final int port,
                                    final Optional<String> bucket, final Optional<String> alternateAddress); @Stability.Internal Mono<Void> shutdown(); @Stability.Internal Mono<Void> shutdown(Duration timeout);  }