use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class AbstractMultiClusterIT method addSchema.
protected void addSchema(RestClient client) {
RestCacheClient cache = client.cache(PROTOBUF_METADATA_CACHE_NAME);
RestResponse response = join(cache.put("schema.proto", "message Person {required string name = 1;}"));
assertEquals(204, response.getStatus());
RestResponse errorResponse = join(client.cache(PROTOBUF_METADATA_CACHE_NAME).get("schema.proto.errors"));
assertEquals(404, errorResponse.getStatus());
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class BackupManagerIT method assertWildcardContent.
private void assertWildcardContent(RestClient client) {
String cacheName = "cache1";
RestCacheClient cache = client.cache(cacheName);
assertEquals(Integer.toString(NUM_ENTRIES), await(cache.size()).getBody());
for (int i = 0; i < NUM_ENTRIES; i++) {
String index = String.valueOf(i);
assertEquals("Val-" + index, join(cache.get(index)).getBody());
}
assertCounter(client, "weak-volatile", Element.WEAK_COUNTER, Storage.VOLATILE, 0);
assertCounter(client, "weak-persistent", Element.WEAK_COUNTER, Storage.PERSISTENT, -100);
assertCounter(client, "strong-volatile", Element.STRONG_COUNTER, Storage.VOLATILE, 50);
assertCounter(client, "strong-persistent", Element.STRONG_COUNTER, Storage.PERSISTENT, 0);
RestResponse rsp = await(client.schemas().get("schema.proto"));
assertEquals(200, rsp.getStatus());
assertTrue(rsp.getBody().contains("message Person"));
rsp = await(client.tasks().list(RestTaskClient.ResultType.USER));
assertEquals(200, rsp.getStatus());
Json json = Json.read(rsp.getBody());
assertTrue(json.isArray());
List<Json> tasks = json.asJsonList();
assertEquals(1, tasks.size());
assertEquals("scripts/test.js", tasks.get(0).at("name").asString());
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class BackupManagerIT method populateContainer.
private void populateContainer(RestClient client) throws Exception {
String cacheName = "cache1";
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
createCache(cacheName, builder, client);
RestCacheClient cache = client.cache(cacheName);
for (int i = 0; i < NUM_ENTRIES; i++) {
join(cache.put(String.valueOf(i), "Val-" + i));
}
assertEquals(NUM_ENTRIES, getCacheSize(cacheName, client));
createCounter("weak-volatile", Element.WEAK_COUNTER, Storage.VOLATILE, client, 0);
createCounter("weak-persistent", Element.WEAK_COUNTER, Storage.PERSISTENT, client, -100);
createCounter("strong-volatile", Element.STRONG_COUNTER, Storage.VOLATILE, client, 50);
createCounter("strong-persistent", Element.STRONG_COUNTER, Storage.PERSISTENT, client, 0);
addSchema(client);
try (InputStream is = BackupManagerIT.class.getResourceAsStream("/scripts/test.js")) {
String script = CommonsTestingUtil.loadFileAsString(is);
RestResponse rsp = await(client.tasks().uploadScript("scripts/test.js", RestEntity.create(MediaType.APPLICATION_JAVASCRIPT, script)));
assertEquals(200, rsp.getStatus());
}
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class RollingUpgradeDynamicStoreIT method connectTargetCluster.
protected void connectTargetCluster() throws IOException {
RestCacheClient client = target.getClient().cache(CACHE_NAME);
ConfigurationBuilder builder = new ConfigurationBuilder();
addRemoteStore(builder);
RemoteStoreConfiguration remoteStore = (RemoteStoreConfiguration) builder.build().persistence().stores().iterator().next();
RestEntity restEntity = RestEntity.create(MediaType.APPLICATION_JSON, SerializationUtils.toJson(remoteStore));
RestResponse response = join(client.connectSource(restEntity));
assertEquals(response.getBody(), 204, response.getStatus());
response = join(client.sourceConnection());
RemoteStoreConfiguration remoteStoreConfiguration = SerializationUtils.fromJson(response.getBody());
List<RemoteServerConfiguration> servers = remoteStoreConfiguration.servers();
assertEquals(1, servers.size());
RemoteServerConfiguration initialConfig = remoteStore.servers().iterator().next();
assertEquals(initialConfig.host(), servers.get(0).host());
assertEquals(initialConfig.port(), servers.get(0).port());
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class RollingUpgradeIT method populateCluster.
public void populateCluster(RestClient client) {
RestCacheClient cache = client.cache(CACHE_NAME);
for (int i = 0; i < ENTRIES; i++) {
String person = createPerson("name-" + i);
join(cache.put(String.valueOf(i), person));
}
assertEquals(ENTRIES, getCacheSize(CACHE_NAME, client));
}
Aggregations