@SneakyThrows
public void initCluster() {
urlBase = String.format("http://%s:%s", getContainerIpAddress(), getMappedPort(REST));
String poolURL = "/pools/default";
String poolPayload = "memoryQuota=" + URLEncoder.encode(memoryQuota, "UTF-8") + "&indexMemoryQuota=" + URLEncoder.encode(indexMemoryQuota, "UTF-8");
String setupServicesURL = "/node/controller/setupServices";
StringBuilder servicePayloadBuilder = new StringBuilder();
if (keyValue) {
servicePayloadBuilder.append("kv,");
}
if (query) {
servicePayloadBuilder.append("n1ql,");
}
if (index) {
servicePayloadBuilder.append("index,");
}
if (fts) {
servicePayloadBuilder.append("fts,");
}
String setupServiceContent = "services=" + URLEncoder.encode(servicePayloadBuilder.toString(), "UTF-8");
String webSettingsURL = "/settings/web";
String webSettingsContent = "username=" + URLEncoder.encode(clusterUsername, "UTF-8") + "&password=" + URLEncoder.encode(clusterPassword, "UTF-8") + "&port=8091";
callCouchbaseRestAPI(poolURL, poolPayload);
callCouchbaseRestAPI(setupServicesURL, setupServiceContent);
callCouchbaseRestAPI(webSettingsURL, webSettingsContent);
createNodeWaitStrategy().waitUntilReady(this);
callCouchbaseRestAPI("/settings/indexes", "indexerThreads=0&logLevel=info&maxRollbackPoints=5&storageMode=memory_optimized");
}