@Override
public InetAddress call(String hostname) {
try {
return InetAddress.getByName(hostname);
} catch(UnknownHostException e) {
throw new CouchbaseException(e);
}
}
})
.flatMap(new Func1<InetAddress, Observable<AddServiceResponse>>() {
@Override
public Observable<AddServiceResponse> call(final InetAddress hostname) {
return core
.<AddNodeResponse>send(new AddNodeRequest(hostname))
.flatMap(new Func1<AddNodeResponse, Observable<AddServiceResponse>>() {
@Override
public Observable<AddServiceResponse> call(AddNodeResponse response) {
int port = environment.sslEnabled()
? environment.bootstrapHttpSslPort() : environment.bootstrapHttpDirectPort();
return core.send(new AddServiceRequest(ServiceType.CONFIG, username, password,
port, hostname));
}
});
}
})
.map(new Func1<AddServiceResponse, Boolean>() {
@Override
public Boolean call(AddServiceResponse addServiceResponse) {
if (!addServiceResponse.status().isSuccess()) {
throw new CouchbaseException("Could not enable ClusterManager service to function properly.");
}
return true;
}
});
}