@Test void failsWhenChildDiscoverFails() { BucketLoader loader = new BaseBucketLoader(core, SERVICE) { @Override protected Mono<byte[]> discoverConfig(NodeIdentifier seed, String bucket) { return Mono.error(new CouchbaseException("Failed discovering for some reason")); } }; when(core.ensureServiceAt(eq(SEED), eq(SERVICE), eq(PORT), eq(Optional.of(BUCKET)), eq(Optional.empty()))) .thenReturn(Mono.empty()); assertThrows(ConfigException.class, () -> loader.load(SEED, PORT, BUCKET, Optional.empty()).block()); }
@Override public Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket, final Optional<String> alternateAddress) { return core .ensureServiceAt(seed, serviceType, port, Optional.of(bucket), alternateAddress) .then(ensureServiceConnected(seed, serviceType, Optional.of(bucket))) .then(discoverConfig(seed, bucket)) .map(config -> new String(config, UTF_8)) .map(config -> config.replace("$HOST", seed.address())) .map(config -> new ProposedBucketConfigContext(bucket, config, seed.address())) .onErrorResume(ex -> Mono.error(ex instanceof ConfigException ? ex : new ConfigException("Caught exception while loading config.", ex) )); }
BaseBucketLoader implements BucketLoader { @Override public Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket, final Optional<String> alternateAddress) { return core .ensureServiceAt(seed, serviceType, port, Optional.of(bucket), alternateAddress) .then(ensureServiceConnected(seed, serviceType, Optional.of(bucket))) .then(discoverConfig(seed, bucket)) .map(config -> new String(config, UTF_8)) .map(config -> config.replace("$HOST", seed.address())) .map(config -> new ProposedBucketConfigContext(bucket, config, seed.address())) .onErrorResume(ex -> Mono.error(ex instanceof ConfigException ? ex : new ConfigException("Caught exception while loading config.", ex) )); } }
BaseBucketLoader implements BucketLoader { @Override public Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket, final Optional<String> alternateAddress) { return core .ensureServiceAt(seed, serviceType, port, Optional.of(bucket), alternateAddress) .then(ensureServiceConnected(seed, serviceType, Optional.of(bucket))) .then(discoverConfig(seed, bucket)) .map(config -> new String(config, UTF_8)) .map(config -> config.replace("$HOST", seed.address())) .map(config -> new ProposedBucketConfigContext(bucket, config, seed.address())) .onErrorResume(ex -> Mono.error(ex instanceof ConfigException ? ex : new ConfigException("Caught exception while loading config.", ex) )); } BaseBucketLoader(final Core core, final ServiceType serviceType); }
BaseBucketLoader implements BucketLoader { @Override public Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket, final Optional<String> alternateAddress) { return core .ensureServiceAt(seed, serviceType, port, Optional.of(bucket), alternateAddress) .then(ensureServiceConnected(seed, serviceType, Optional.of(bucket))) .then(discoverConfig(seed, bucket)) .map(config -> new String(config, UTF_8)) .map(config -> config.replace("$HOST", seed.address())) .map(config -> new ProposedBucketConfigContext(bucket, config, seed.address())) .onErrorResume(ex -> Mono.error(ex instanceof ConfigException ? ex : new ConfigException("Caught exception while loading config.", ex) )); } BaseBucketLoader(final Core core, final ServiceType serviceType); @Override Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket,
                                                final Optional<String> alternateAddress); }
BaseBucketLoader implements BucketLoader { @Override public Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket, final Optional<String> alternateAddress) { return core .ensureServiceAt(seed, serviceType, port, Optional.of(bucket), alternateAddress) .then(ensureServiceConnected(seed, serviceType, Optional.of(bucket))) .then(discoverConfig(seed, bucket)) .map(config -> new String(config, UTF_8)) .map(config -> config.replace("$HOST", seed.address())) .map(config -> new ProposedBucketConfigContext(bucket, config, seed.address())) .onErrorResume(ex -> Mono.error(ex instanceof ConfigException ? ex : new ConfigException("Caught exception while loading config.", ex) )); } BaseBucketLoader(final Core core, final ServiceType serviceType); @Override Mono<ProposedBucketConfigContext> load(final NodeIdentifier seed, final int port, final String bucket,
                                                final Optional<String> alternateAddress);  }