Hello,
I am currently exploring how to actively initialize two clusters while using spring-data-couchbase, the goal is to connect to two clusters on deployment of the app. One to act as primary and the other as secondary.
Normally the setup for a single cluster and bucket is rather simple:
@Configuration
@Data
@Slf4j
public class CouchbaseConfigurationPrimary extends AbstractCouchbaseConfiguration {
private String bucketName;
private String username;
private String password;
private String timeout;
private String ip;
public CouchbaseConfigurationPrimary(@Value("${couchbase.cluster.bucketname}") String bucketName,
@Value("${couchbase.cluster.user}") String username,
@Value("${couchbase.cluster.password}") String password,
@Value("${couchbase.cluster.ip}") String ip,
@Value("${couchbase.cluster.timeout}") String timeout){
this.bucketName = bucketName;
this.username = username;
this.password = password;
this.timeout = timeout;
this.ip = ip;
}
@Override
protected List<String> getBootstrapHosts() {
return Arrays.asList(ip);
}
@Override
protected String getBucketName() {
return this.bucketName;
}
@Override
protected String getBucketPassword() {
return this.password;
}
protected CouchbaseEnvironment getEnvironment(){
Long timeOut = Long.valueOf(timeout);
return DefaultCouchbaseEnvironment
.builder()
.keepAliveTimeout(timeOut)
.queryTimeout(timeOut)
.connectTimeout(timeOut)
.build();
}
}
the bucket then can be autowired throughout the service as:
@Autowired
public Bucket couchbaseBucket
Can anyone pls explain how to hold two different clusters using spring-data-couchbase 3.1.5?