use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class RollingUpgradeIT method testRollingUpgrade.
@Test
public void testRollingUpgrade() throws Exception {
RestClient restClientSource = source.getClient();
RestClient restClientTarget = target.getClient();
// Create cache in the source cluster
createSourceClusterCache();
// Create cache in the target cluster pointing to the source cluster via remote-store
createTargetClusterCache();
// Register proto schema
addSchema(restClientSource);
addSchema(restClientTarget);
// Populate source cluster
populateCluster(restClientSource);
// Make sure data is accessible from the target cluster
assertEquals("name-20", getPersonName("20", restClientTarget));
// Do a rolling upgrade from the target
doRollingUpgrade(restClientTarget);
// Do a second rolling upgrade, should be harmless and simply override the data
doRollingUpgrade(restClientTarget);
// Disconnect source from the remote store
disconnectSource(restClientTarget);
// Stop source cluster
stopSourceCluster();
// Assert all nodes are disconnected and data was migrated successfully
for (int i = 0; i < target.getMembers().size(); i++) {
RestClient restClient = target.getClient(i);
assertEquals(ENTRIES, getCacheSize(CACHE_NAME, restClient));
assertEquals("name-35", getPersonName("35", restClient));
}
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteHotRodCacheOperations method getTotalMemoryEntries.
private int getTotalMemoryEntries(String lonXML) {
RestClient restClient = SERVER_TEST.rest(LON).withServerConfiguration(new StringConfiguration(lonXML)).get();
RestCacheClient client = restClient.cache(SERVER_TEST.getMethodName());
Json json = Json.read(sync(client.stats()).getBody());
return json.asJsonMap().get("current_number_of_entries_in_memory").asInteger();
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method testCancelPushAllCaches.
@Test
public void testCancelPushAllCaches() throws Exception {
RestClient restClientLon = clientPerSite.get(LON);
RestCacheClient cache1Lon = restClientLon.cache(CACHE_1);
RestCacheClient cache2Lon = restClientLon.cache(CACHE_2);
assertNoContent(cache1Lon.put("k1", "v1"));
assertNoContent(cache2Lon.put("k2", "v2"));
// Block before pushing state on both caches
BlockXSitePushStateTransport transport = BlockXSitePushStateTransport.replace(cache(LON, CACHE_1, 0));
transport.startBlocking();
// Trigger a state push
assertSuccessful(restClientLon.cacheManager(CACHE_MANAGER).pushSiteState(SFO));
transport.waitForCommand();
// Cancel state push
assertSuccessful(restClientLon.cacheManager(CACHE_MANAGER).cancelPushState(SFO));
transport.stopBlocking();
// Verify that push was cancelled for both caches
Json pushStatusCache1 = jsonResponseBody(cache1Lon.pushStateStatus());
Json pushStatusCache2 = jsonResponseBody(cache2Lon.pushStateStatus());
assertEquals("CANCELED", pushStatusCache1.at(SFO).asString());
assertEquals("CANCELED", pushStatusCache2.at(SFO).asString());
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class XSiteResourceTest method startServers.
@BeforeClass
public void startServers() {
sites.forEach(site -> {
String siteName = site.getSiteName();
EmbeddedCacheManager cm = site.cacheManagers().iterator().next();
RestServerHelper restServerHelper = new RestServerHelper(cm);
restServerHelper.start(TestResourceTracker.getCurrentTestShortName());
restServerPerSite.put(siteName, restServerHelper);
RestClientConfiguration clientConfig = new RestClientConfigurationBuilder().addServer().host("127.0.0.1").port(restServerHelper.getPort()).build();
RestClient client = RestClient.forConfiguration(clientConfig);
clientPerSite.put(siteName, client);
});
}
use of org.infinispan.client.rest.RestClient in project infinispan by infinispan.
the class RestAccessLoggingTest method setup.
@Override
protected void setup() throws Exception {
super.setup();
testShortName = TestResourceTracker.getCurrentTestShortName();
logAppender = new StringLogAppender("org.infinispan.REST_ACCESS_LOG", Level.TRACE, t -> t.getName().startsWith("non-blocking-thread-" + testShortName), PatternLayout.newBuilder().withPattern(LOG_FORMAT).build());
logAppender.install();
restServer = new RestServerHelper(cacheManager);
restServer.start(TestResourceTracker.getCurrentTestShortName());
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder();
builder.addServer().host(restServer.getHost()).port(restServer.getPort());
restClient = RestClient.forConfiguration(builder.create());
cacheClient = restClient.cache("default");
}
Aggregations