Package com.sun.sgs.impl.util

Examples of com.sun.sgs.impl.util.ShouldRetryIo


    /* -- Test constructor -- */

    @Test(expected=IllegalArgumentException.class)
    public void testConstructorNegativeMaxRetry() {
  new ShouldRetryIo(-1, 1);
    }
View Full Code Here


  new ShouldRetryIo(-1, 1);
    }

    @Test(expected=IllegalArgumentException.class)
    public void testConstructorNegativeRetryWait() {
  new ShouldRetryIo(1, -1);
    }
View Full Code Here

    /* -- Test shouldRetry -- */

    @Test
    public void testShouldRetryMaxRetry() throws InterruptedException {
  ShouldRetryIo should = new ShouldRetryIo(300, 110);
  long start = System.currentTimeMillis();
  long stop = start + 300;
  while (stop > System.currentTimeMillis() + 110) {
      assertTrue(should.shouldRetry());
  }
  assertFalse(should.shouldRetry());
    }
View Full Code Here

  assertFalse(should.shouldRetry());
    }

    @Test
    public void testShouldRetryRetryWait() throws InterruptedException {
  ShouldRetryIo should = new ShouldRetryIo(300, 100);
  long stop = System.currentTimeMillis() + 300;
  while (stop < System.currentTimeMillis()) {
      long now = System.currentTimeMillis();
      should.shouldRetry();
      long delay = System.currentTimeMillis() - now;
      assertTrue("Delay should be greater than 90 and less than 110: " +
           delay,
           delay > 90 && delay < 110);
  }
View Full Code Here

    /* -- Test ioSucceeded -- */

    @Test
    public void testIoSucceeded() throws InterruptedException {
  ShouldRetryIo should = new ShouldRetryIo(100, 0);
  assertTrue(should.shouldRetry());
  Thread.sleep(110);
  should.ioSucceeded();
  assertTrue(should.shouldRetry());
    }
View Full Code Here

     */
    private CachingDataStoreServer lookupServer(
  String serverHost, int serverPort)
  throws IOException, NotBoundException
    {
  ShouldRetryIo retry = new ShouldRetryIo(maxRetry, retryWait);
  while (true) {
      try {
    return (CachingDataStoreServer) LocateRegistry.getRegistry(
        serverHost, serverPort).lookup("CachingDataStoreServer");
      } catch (IOException e) {
    if (!retry.shouldRetry()) {
        throw e;
    }
      }
  }
    }
View Full Code Here

     * @throws  IOException if there are too many I/O failures
     */
    private RegisterNodeResult registerNode(CallbackServer callbackProxy)
  throws IOException
    {
  ShouldRetryIo retry = new ShouldRetryIo(maxRetry, retryWait);
  while (true) {
      try {
    return server.registerNode(callbackProxy);
      } catch (IOException e) {
    if (!retry.shouldRetry()) {
        throw e;
    }
      }
  }
    }
View Full Code Here

TOP

Related Classes of com.sun.sgs.impl.util.ShouldRetryIo

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.