Search in sources :

Example 1 with OFFLINE

use of org.infinispan.xsite.XSiteAdminOperations.OFFLINE 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)));
}
Also used : XSiteResponse(org.infinispan.remoting.transport.XSiteResponse) Arrays(java.util.Arrays) XSiteResponseImpl(org.infinispan.remoting.transport.impl.XSiteResponseImpl) RestResponses.assertSuccessful(org.infinispan.rest.helper.RestResponses.assertSuccessful) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) TimeoutException(java.util.concurrent.TimeoutException) RestClient(org.infinispan.client.rest.RestClient) Test(org.testng.annotations.Test) Cache(org.infinispan.Cache) AfterMethod(org.testng.annotations.AfterMethod) AssertJUnit.assertTrue(org.testng.AssertJUnit.assertTrue) RestResponses.assertStatus(org.infinispan.rest.helper.RestResponses.assertStatus) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) EmbeddedCacheManagerAdmin(org.infinispan.manager.EmbeddedCacheManagerAdmin) Map(java.util.Map) ONLINE(org.infinispan.xsite.XSiteAdminOperations.ONLINE) TestingUtil(org.infinispan.test.TestingUtil) RestResponses.jsonResponseBody(org.infinispan.rest.helper.RestResponses.jsonResponseBody) XSiteBackup(org.infinispan.xsite.XSiteBackup) RestResponses.responseStatus(org.infinispan.rest.helper.RestResponses.responseStatus) BeforeClass(org.testng.annotations.BeforeClass) RestClientConfiguration(org.infinispan.client.rest.configuration.RestClientConfiguration) RestServerHelper(org.infinispan.rest.helper.RestServerHelper) List(java.util.List) SuccessfulResponse(org.infinispan.remoting.responses.SuccessfulResponse) GuardedBy(net.jcip.annotations.GuardedBy) AbstractMultipleSitesTest(org.infinispan.xsite.AbstractMultipleSitesTest) IntStream(java.util.stream.IntStream) TestResourceTracker(org.infinispan.commons.test.TestResourceTracker) RestResponses.responseBody(org.infinispan.rest.helper.RestResponses.responseBody) BackupConfiguration(org.infinispan.configuration.cache.BackupConfiguration) TestingUtil.wrapGlobalComponent(org.infinispan.test.TestingUtil.wrapGlobalComponent) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) AbstractDelegatingTransport(org.infinispan.remoting.transport.AbstractDelegatingTransport) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) VOLATILE(org.infinispan.commons.api.CacheContainerAdmin.AdminFlag.VOLATILE) TakeOfflineManager(org.infinispan.xsite.status.TakeOfflineManager) TestingUtil.extractGlobalComponent(org.infinispan.test.TestingUtil.extractGlobalComponent) AfterClass(org.testng.annotations.AfterClass) Transport(org.infinispan.remoting.transport.Transport) XSiteReplicateCommand(org.infinispan.xsite.XSiteReplicateCommand) RestResponses.assertNoContent(org.infinispan.rest.helper.RestResponses.assertNoContent) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) XSiteStatePushCommand(org.infinispan.xsite.statetransfer.XSiteStatePushCommand) AssertJUnit.assertFalse(org.testng.AssertJUnit.assertFalse) IOException(java.io.IOException) Json(org.infinispan.commons.dataconversion.internal.Json) RestCacheClient(org.infinispan.client.rest.RestCacheClient) TimeUnit(java.util.concurrent.TimeUnit) RestCacheManagerClient(org.infinispan.client.rest.RestCacheManagerClient) CacheMode(org.infinispan.configuration.cache.CacheMode) Configuration(org.infinispan.configuration.cache.Configuration) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) OFFLINE(org.infinispan.xsite.XSiteAdminOperations.OFFLINE) RestCacheClient(org.infinispan.client.rest.RestCacheClient) Test(org.testng.annotations.Test) AbstractMultipleSitesTest(org.infinispan.xsite.AbstractMultipleSitesTest)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 Function (java.util.function.Function)1 IntStream (java.util.stream.IntStream)1 GuardedBy (net.jcip.annotations.GuardedBy)1 Cache (org.infinispan.Cache)1 RestCacheClient (org.infinispan.client.rest.RestCacheClient)1 RestCacheManagerClient (org.infinispan.client.rest.RestCacheManagerClient)1 RestClient (org.infinispan.client.rest.RestClient)1 RestClientConfiguration (org.infinispan.client.rest.configuration.RestClientConfiguration)1 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)1 VOLATILE (org.infinispan.commons.api.CacheContainerAdmin.AdminFlag.VOLATILE)1 Json (org.infinispan.commons.dataconversion.internal.Json)1 TestResourceTracker (org.infinispan.commons.test.TestResourceTracker)1