Package org.infinispan.xsite

Examples of org.infinispan.xsite.OfflineStatus


*/
@Test (groups = "xsite, functional", testName = "xsite.offline.OfflineStatusTest")
public class OfflineStatusTest extends AbstractInfinispanTest {

   public void timeBasedTakeOffline() {
      final OfflineStatus offlineStatus = new OfflineStatus(new TakeOfflineConfiguration(10, 3000));

      assert !offlineStatus.isOffline();
      for (int i = 0; i < 9; i++) {
         offlineStatus.updateOnCommunicationFailure(now());
      }

      assertEquals(9, offlineStatus.getFailureCount());
      assert !offlineStatus.isOffline();
      assert !offlineStatus.minTimeHasElapsed() : offlineStatus.millisSinceFirstFailure();

      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            Thread.sleep(1000);
            return offlineStatus.minTimeHasElapsed();
         }
      });

      assertEquals(9, offlineStatus.getFailureCount());
      assert !offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();


      offlineStatus.updateOnCommunicationFailure(now());
      assertEquals(10, offlineStatus.getFailureCount());
      assert offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();
   }
View Full Code Here


      assert offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();
   }

   public void testFailureBasedOnly() throws Throwable {
      final OfflineStatus offlineStatus = new OfflineStatus(new TakeOfflineConfiguration(10, 0));
      test(offlineStatus);
      offlineStatus.reset();
      test(offlineStatus);
   }
View Full Code Here

      Transport transport= registry.getComponent(Transport.class);
      DelegatingTransport delegatingTransport = new DelegatingTransport(transport);
      registry.getGlobalComponentRegistry().registerComponent(delegatingTransport, Transport.class);
      BackupSenderImpl bs = (BackupSenderImpl) registry.getComponent(BackupSender.class);
      registry.rewire();
      OfflineStatus offlineStatus = bs.getOfflineStatus("NYC");

      delegatingTransport.fail = true;
      for (int i = 0; i < FAILURES; i++) {
         try {
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            //expected
         }
      }

      for (int i = 0; i < FAILURES; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }

      for (int i = 0; i < FAILURES; i++) {
         assertEquals("v" + i, cache("LON", 0).get("k" + i));
      }

      assertEquals(BackupSender.BringSiteOnlineResponse.BROUGHT_ONLINE, bs.bringSiteOnline("NYC"));

      for (int i = 0; i < FAILURES - 1; i++) {
         try {
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            //expected
         }
      }

      delegatingTransport.fail = false;
      assertEquals(FAILURES - 1, offlineStatus.getFailureCount());
      cache("LON", 0).put("ki", "vi"); //this should reset the offline status
      assertEquals(0, offlineStatus.getFailureCount());

      for (int i = 0; i < FAILURES * 10; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }

View Full Code Here

      assert offlineStatus.minTimeHasElapsed();
   }


   public void testFailureBasedOnly() throws Throwable {
      final OfflineStatus offlineStatus = new OfflineStatus(new TakeOfflineConfiguration(10, 0));
      test(offlineStatus);
      offlineStatus.reset();
      test(offlineStatus);
   }
View Full Code Here

      Transport transport= registry.getComponent(Transport.class);
      DelegatingTransport delegatingTransport = new DelegatingTransport(transport);
      registry.getGlobalComponentRegistry().registerComponent(delegatingTransport, Transport.class);
      BackupSenderImpl bs = (BackupSenderImpl) registry.getComponent(BackupSender.class);
      registry.rewire();
      OfflineStatus offlineStatus = bs.getOfflineStatus("NYC");

      delegatingTransport.fail = true;
      for (int i = 0; i < FAILURES; i++) {
         try {
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            //expected
         }
      }

      for (int i = 0; i < FAILURES; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }

      for (int i = 0; i < FAILURES; i++) {
         assertEquals("v" + i, cache("LON", 0).get("k" + i));
      }

      assertEquals(BackupSender.BringSiteOnlineResponse.BROUGHT_ONLINE, bs.bringSiteOnline("NYC"));

      for (int i = 0; i < FAILURES - 1; i++) {
         try {
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            //expected
         }
      }

      delegatingTransport.fail = false;
      assertEquals(FAILURES - 1, offlineStatus.getFailureCount());
      cache("LON", 0).put("ki", "vi"); //this should reset the offline status
      assertEquals(0, offlineStatus.getFailureCount());

      for (int i = 0; i < FAILURES * 10; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }

View Full Code Here

   }

   public void testPutWithFailures() {

      BackupSenderImpl bs = (BackupSenderImpl) cache("LON", 0).getAdvancedCache().getComponentRegistry().getComponent(BackupSender.class);
      OfflineStatus nycStatus = bs.getOfflineStatus("NYC");

      for (int i = 0; i < FAILURES / nrRpcPerPut; i++) {
         try {
            assertEquals(BackupSender.BringSiteOnlineResponse.ALREADY_ONLINE, bs.bringSiteOnline("NYC"));
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            Assert.assertEquals(i + 1, nycStatus.getFailureCount());
         }
      }

      assert nycStatus.isOffline();

      for (int i = 0; i < FAILURES; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }
View Full Code Here

*/
@Test (groups = "xsite, functional", testName = "xsite.offline.OfflineStatusTest")
public class OfflineStatusTest extends AbstractInfinispanTest {

   public void timeBasedTakeOffline() {
      final OfflineStatus offlineStatus = new OfflineStatus(new TakeOfflineConfiguration(10, 3000));

      assert !offlineStatus.isOffline();
      for (int i = 0; i < 9; i++) {
         offlineStatus.updateOnCommunicationFailure(System.currentTimeMillis());
      }

      assertEquals(9, offlineStatus.getFailureCount());
      assert !offlineStatus.isOffline();
      assert !offlineStatus.minTimeHasElapsed() : offlineStatus.millisSinceFirstFailure();

      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            Thread.sleep(1000);
            return offlineStatus.minTimeHasElapsed();
         }
      });

      assertEquals(9, offlineStatus.getFailureCount());
      assert !offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();


      offlineStatus.updateOnCommunicationFailure(System.currentTimeMillis());
      assertEquals(10, offlineStatus.getFailureCount());
      assert offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();
   }
View Full Code Here

*/
@Test (groups = "xsite, functional", testName = "xsite.offline.OfflineStatusTest")
public class OfflineStatusTest extends AbstractInfinispanTest {

   public void timeBasedTakeOffline() {
      final OfflineStatus offlineStatus = new OfflineStatus(new TakeOfflineConfiguration(10, 3000), TIME_SERVICE);

      assert !offlineStatus.isOffline();
      for (int i = 0; i < 9; i++) {
         offlineStatus.updateOnCommunicationFailure(now());
      }

      assertEquals(9, offlineStatus.getFailureCount());
      assert !offlineStatus.isOffline();
      assert !offlineStatus.minTimeHasElapsed() : offlineStatus.millisSinceFirstFailure();

      eventually(new Condition() {
         @Override
         public boolean isSatisfied() throws Exception {
            Thread.sleep(1000);
            return offlineStatus.minTimeHasElapsed();
         }
      });

      assertEquals(9, offlineStatus.getFailureCount());
      assert !offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();


      offlineStatus.updateOnCommunicationFailure(now());
      assertEquals(10, offlineStatus.getFailureCount());
      assert offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();
   }
View Full Code Here

      assert offlineStatus.isOffline();
      assert offlineStatus.minTimeHasElapsed();
   }

   public void testFailureBasedOnly() throws Throwable {
      final OfflineStatus offlineStatus = new OfflineStatus(new TakeOfflineConfiguration(10, 0), TIME_SERVICE);
      test(offlineStatus);
      offlineStatus.reset();
      test(offlineStatus);
   }
View Full Code Here

      Transport transport= registry.getComponent(Transport.class);
      DelegatingTransport delegatingTransport = new DelegatingTransport(transport);
      registry.getGlobalComponentRegistry().registerComponent(delegatingTransport, Transport.class);
      BackupSenderImpl bs = (BackupSenderImpl) registry.getComponent(BackupSender.class);
      registry.rewire();
      OfflineStatus offlineStatus = bs.getOfflineStatus("NYC");

      delegatingTransport.fail = true;
      for (int i = 0; i < FAILURES; i++) {
         try {
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            //expected
         }
      }

      for (int i = 0; i < FAILURES; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }

      for (int i = 0; i < FAILURES; i++) {
         assertEquals("v" + i, cache("LON", 0).get("k" + i));
      }

      assertEquals(BackupSender.BringSiteOnlineResponse.BROUGHT_ONLINE, bs.bringSiteOnline("NYC"));

      for (int i = 0; i < FAILURES - 1; i++) {
         try {
            cache("LON", 0).put("k" + i, "v" + i);
            fail("This should have failed");
         } catch (Exception e) {
            //expected
         }
      }

      delegatingTransport.fail = false;
      assertEquals(FAILURES - 1, offlineStatus.getFailureCount());
      cache("LON", 0).put("ki", "vi"); //this should reset the offline status
      assertEquals(0, offlineStatus.getFailureCount());

      for (int i = 0; i < FAILURES * 10; i++) {
         cache("LON", 0).put("k" + i, "v" + i);
      }

View Full Code Here

TOP

Related Classes of org.infinispan.xsite.OfflineStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.