use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method testPushState.
@Test
public void testPushState() {
RestCacheClient cache = getCacheClient(LON);
RestCacheClient backupCache = getCacheClient(NYC);
String key = "key";
String value = "value";
Function<String, Integer> keyOnBackup = k -> responseStatus(backupCache.get(key));
takeBackupOffline(LON, NYC);
assertEquals(OFFLINE, getBackupStatus(LON, NYC));
assertEquals(ONLINE, getBackupStatus(LON, SFO));
assertNoContent(cache.put(key, value));
assertEquals(404, (int) keyOnBackup.apply(key));
assertSuccessful(cache.pushSiteState(NYC));
assertEquals(ONLINE, getBackupStatus(LON, NYC));
eventuallyEquals("OK", () -> pushStateStatus(cache, NYC));
assertEquals(200, responseStatus(backupCache.get(key)));
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method testTakeOfflineConfig.
@Test
public void testTakeOfflineConfig() {
RestCacheClient cacheClient = getCacheClient(LON);
Json takeOfflineConfig = jsonResponseBody(cacheClient.getXSiteTakeOfflineConfig(NYC));
assertEquals(0, takeOfflineConfig.at("after_failures").asInteger());
assertEquals(0, takeOfflineConfig.at("min_wait").asInteger());
assertNoContent(cacheClient.updateXSiteTakeOfflineConfig(NYC, 5, 1000));
takeOfflineConfig = jsonResponseBody(cacheClient.getXSiteTakeOfflineConfig(NYC));
assertEquals(5, takeOfflineConfig.at("after_failures").asInteger());
assertEquals(1000, takeOfflineConfig.at("min_wait").asInteger());
}
use of org.infinispan.client.rest.RestCacheClient 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.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method testBackups.
@Test
public void testBackups() {
RestCacheClient cache = getCacheClient(LON);
Json status = jsonResponseBody(cache.xsiteBackups());
assertEquals(ONLINE, status.at(NYC).at("status").asString());
// add a second node
TestSite site = site(LON);
EmbeddedCacheManager cm = site.addCacheManager(null, defaultGlobalConfigurationForSite(site.getSiteIndex()), defaultConfigurationForSite(site.getSiteIndex()), false);
site.waitForClusterToForm(CACHE_1);
site.waitForClusterToForm(CACHE_2);
TakeOfflineManager takeOfflineManager = TestingUtil.extractComponent(cm.getCache(CACHE_1), TakeOfflineManager.class);
takeOfflineManager.takeSiteOffline(NYC);
String node1 = String.valueOf(site.cacheManagers().get(0).getAddress());
String node2 = String.valueOf(cm.getAddress());
status = jsonResponseBody(cache.xsiteBackups());
assertEquals("mixed", status.at(NYC).at("status").asString());
assertEquals(status.at(NYC).at("online").asJsonList().iterator().next().asString(), node1);
assertEquals(status.at(NYC).at("offline").asJsonList().iterator().next().asString(), node2);
assertFalse(status.at(NYC).has("mixed"));
status = jsonResponseBody(cache.backupStatus(NYC));
assertEquals(ONLINE, status.at(node1).asString());
assertEquals(OFFLINE, status.at(node2).asString());
// bring NYC online
takeOfflineManager.bringSiteOnline(NYC);
status = jsonResponseBody(cache.xsiteBackups());
assertEquals(ONLINE, status.at(NYC).at("status").asString());
status = jsonResponseBody(cache.backupStatus(NYC));
assertEquals(ONLINE, status.at(node1).asString());
assertEquals(ONLINE, status.at(node2).asString());
}
use of org.infinispan.client.rest.RestCacheClient in project infinispan by infinispan.
the class XSiteResourceTest method takeBackupOffline.
private void takeBackupOffline(String site, String backup) {
RestCacheClient client = getCacheClient(site);
assertSuccessful(client.takeSiteOffline(backup));
}
Aggregations