当前位置: 首页>>代码示例>>Java>>正文


Java UnreliableException类代码示例

本文整理汇总了Java中org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException的典型用法代码示例。如果您正苦于以下问题:Java UnreliableException类的具体用法?Java UnreliableException怎么用?Java UnreliableException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnreliableException类属于org.apache.hadoop.io.retry.UnreliableInterface包,在下文中一共展示了UnreliableException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRetryByException

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testRetryByException() throws UnreliableException {
  Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap =
    Collections.<Class<? extends Exception>, RetryPolicy>singletonMap(FatalException.class, TRY_ONCE_THEN_FAIL);
  
  UnreliableInterface unreliable = (UnreliableInterface)
    RetryProxy.create(UnreliableInterface.class, unreliableImpl,
                      retryByException(RETRY_FOREVER, exceptionToPolicyMap));
  unreliable.failsOnceThenSucceeds();
  try {
    unreliable.alwaysFailsWithFatalException();
    fail("Should fail");
  } catch (FatalException e) {
    // expected
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestRetryProxy.java

示例2: testSuccedsOnceThenFailOver

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testSuccedsOnceThenFailOver() throws UnreliableException,
    IOException, StandbyException {
  UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.create(
      UnreliableInterface.class, newFlipFlopProxyProvider(),
      new FailOverOnceOnAnyExceptionPolicy());
  
  assertEquals("impl1", unreliable.succeedsOnceThenFailsReturningString());
  assertEquals("impl2", unreliable.succeedsOnceThenFailsReturningString());
  try {
    unreliable.succeedsOnceThenFailsReturningString();
    fail("should not have succeeded more than twice");
  } catch (UnreliableException e) {
    // expected
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestFailoverProxy.java

示例3: testNeverFailOver

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testNeverFailOver() throws UnreliableException,
    IOException, StandbyException {
  UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.create(
      UnreliableInterface.class,
      newFlipFlopProxyProvider(),
      RetryPolicies.TRY_ONCE_THEN_FAIL);

  unreliable.succeedsOnceThenFailsReturningString();
  try {
    unreliable.succeedsOnceThenFailsReturningString();
    fail("should not have succeeded twice");
  } catch (UnreliableException e) {
    assertEquals("impl1", e.getMessage());
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestFailoverProxy.java

示例4: testFailoverOnNetworkExceptionIdempotentOperation

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testFailoverOnNetworkExceptionIdempotentOperation()
    throws UnreliableException, IOException, StandbyException {
  UnreliableInterface unreliable = (UnreliableInterface)RetryProxy.create(
      UnreliableInterface.class,
      newFlipFlopProxyProvider(
          TypeOfExceptionToFailWith.IO_EXCEPTION,
          TypeOfExceptionToFailWith.UNRELIABLE_EXCEPTION),
      RetryPolicies.failoverOnNetworkException(1));
  
  assertEquals("impl1", unreliable.succeedsOnceThenFailsReturningString());
  try {
    unreliable.succeedsOnceThenFailsReturningString();
    fail("should not have succeeded twice");
  } catch (IOException e) {
    // Make sure we *don't* fail over since the first implementation threw an
    // IOException and this method is not idempotent
    assertEquals("impl1", e.getMessage());
  }
  
  assertEquals("impl1", unreliable.succeedsOnceThenFailsReturningStringIdempotent());
  // Make sure we fail over since the first implementation threw an
  // IOException and this method is idempotent.
  assertEquals("impl2", unreliable.succeedsOnceThenFailsReturningStringIdempotent());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:TestFailoverProxy.java

示例5: testSuccedsOnceThenFailOver

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testSuccedsOnceThenFailOver() throws UnreliableException,
    IOException, StandbyException {
  UnreliableInterface unreliable = (UnreliableInterface)RetryProxy
      .create(UnreliableInterface.class,
          new FlipFlopProxyProvider(UnreliableInterface.class,
            new UnreliableImplementation("impl1"),
            new UnreliableImplementation("impl2")),
          new FailOverOnceOnAnyExceptionPolicy());
  
  assertEquals("impl1", unreliable.succeedsOnceThenFailsReturningString());
  assertEquals("impl2", unreliable.succeedsOnceThenFailsReturningString());
  try {
    unreliable.succeedsOnceThenFailsReturningString();
    fail("should not have succeeded more than twice");
  } catch (UnreliableException e) {
    // expected
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:20,代码来源:TestFailoverProxy.java

示例6: testNeverFailOver

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testNeverFailOver() throws UnreliableException,
    IOException, StandbyException {
  UnreliableInterface unreliable = (UnreliableInterface)RetryProxy
  .create(UnreliableInterface.class,
      new FlipFlopProxyProvider(UnreliableInterface.class,
        new UnreliableImplementation("impl1"),
        new UnreliableImplementation("impl2")),
      RetryPolicies.TRY_ONCE_THEN_FAIL);

  unreliable.succeedsOnceThenFailsReturningString();
  try {
    unreliable.succeedsOnceThenFailsReturningString();
    fail("should not have succeeded twice");
  } catch (UnreliableException e) {
    assertEquals("impl1", e.getMessage());
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:19,代码来源:TestFailoverProxy.java

示例7: testFailoverOnNetworkExceptionIdempotentOperation

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testFailoverOnNetworkExceptionIdempotentOperation()
    throws UnreliableException, IOException, StandbyException {
  UnreliableInterface unreliable = (UnreliableInterface)RetryProxy
  .create(UnreliableInterface.class,
      new FlipFlopProxyProvider(UnreliableInterface.class,
        new UnreliableImplementation("impl1", TypeOfExceptionToFailWith.IO_EXCEPTION),
        new UnreliableImplementation("impl2", TypeOfExceptionToFailWith.UNRELIABLE_EXCEPTION)),
      RetryPolicies.failoverOnNetworkException(1));
  
  assertEquals("impl1", unreliable.succeedsOnceThenFailsReturningString());
  try {
    unreliable.succeedsOnceThenFailsReturningString();
    fail("should not have succeeded twice");
  } catch (IOException e) {
    // Make sure we *don't* fail over since the first implementation threw an
    // IOException and this method is not idempotent
    assertEquals("impl1", e.getMessage());
  }
  
  assertEquals("impl1", unreliable.succeedsOnceThenFailsReturningStringIdempotent());
  // Make sure we fail over since the first implementation threw an
  // IOException and this method is idempotent.
  assertEquals("impl2", unreliable.succeedsOnceThenFailsReturningStringIdempotent());
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:26,代码来源:TestFailoverProxy.java

示例8: testRetryForever

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testRetryForever() throws UnreliableException {
  UnreliableInterface unreliable = (UnreliableInterface)
    RetryProxy.create(UnreliableInterface.class, unreliableImpl, RETRY_FOREVER);
  unreliable.alwaysSucceeds();
  unreliable.failsOnceThenSucceeds();
  unreliable.failsTenTimesThenSucceeds();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:TestRetryProxy.java

示例9: testRetryForeverWithFixedSleep

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testRetryForeverWithFixedSleep() throws UnreliableException {
  UnreliableInterface unreliable = (UnreliableInterface) RetryProxy.create(
      UnreliableInterface.class, unreliableImpl,
      retryForeverWithFixedSleep(1, TimeUnit.MILLISECONDS));
  unreliable.alwaysSucceeds();
  unreliable.failsOnceThenSucceeds();
  unreliable.failsTenTimesThenSucceeds();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:TestRetryProxy.java

示例10: testRetryUpToMaximumCountWithProportionalSleep

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testRetryUpToMaximumCountWithProportionalSleep() throws UnreliableException {
  UnreliableInterface unreliable = (UnreliableInterface)
    RetryProxy.create(UnreliableInterface.class, unreliableImpl,
                      retryUpToMaximumCountWithProportionalSleep(8, 1, TimeUnit.NANOSECONDS));
  unreliable.alwaysSucceeds();
  unreliable.failsOnceThenSucceeds();
  try {
    unreliable.failsTenTimesThenSucceeds();
    fail("Should fail");
  } catch (UnreliableException e) {
    // expected
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestRetryProxy.java

示例11: testExponentialRetry

import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException; //导入依赖的package包/类
@Test
public void testExponentialRetry() throws UnreliableException {
  UnreliableInterface unreliable = (UnreliableInterface)
    RetryProxy.create(UnreliableInterface.class, unreliableImpl,
                      exponentialBackoffRetry(5, 1L, TimeUnit.NANOSECONDS));
  unreliable.alwaysSucceeds();
  unreliable.failsOnceThenSucceeds();
  try {
    unreliable.failsTenTimesThenSucceeds();
    fail("Should fail");
  } catch (UnreliableException e) {
    // expected
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:TestRetryProxy.java


注:本文中的org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。