@Test public void testConnectHelixManagerWithRetry() { HelixManager instanceManager = HelixManagerFactory.getZKHelixManager( clusterName, corruptHelixInstance, InstanceType.PARTICIPANT, testingZKServer.getConnectString()); ClusterIntegrationTestUtils.createPartialInstanceStructure(instanceManager, testingZKServer.getConnectString()); try { corruptGobblinTaskRunner.connectHelixManager(); Assert.fail("Unexpected success in connecting to HelixManager"); } catch (Exception e) { Assert.assertTrue(e.getClass().equals(HelixException.class)); } corruptGobblinTaskRunner.connectHelixManagerWithRetry(); Assert.assertTrue(true); }
@VisibleForTesting void connectHelixManagerWithRetry() { Callable<Void> connectHelixManagerCallable = () -> { try { logger.info("Instance: {} attempting to join cluster: {}", helixInstanceName, clusterName); connectHelixManager(); } catch (HelixException e) { logger.error("Exception encountered when joining cluster", e); onClusterJoinFailure(); throw e; } return null; }; Retryer<Void> retryer = RetryerBuilder.<Void>newBuilder() .retryIfException() .withStopStrategy(StopStrategies.stopAfterAttempt(5)).build(); try { retryer.call(connectHelixManagerCallable); } catch (ExecutionException | RetryException e) { Throwables.propagate(e); } }
GobblinTaskRunner implements StandardMetricsBridge { @VisibleForTesting void connectHelixManagerWithRetry() { Callable<Void> connectHelixManagerCallable = () -> { try { logger.info("Instance: {} attempting to join cluster: {}", helixInstanceName, clusterName); connectHelixManager(); } catch (HelixException e) { logger.error("Exception encountered when joining cluster", e); onClusterJoinFailure(); throw e; } return null; }; Retryer<Void> retryer = RetryerBuilder.<Void>newBuilder() .retryIfException() .withStopStrategy(StopStrategies.stopAfterAttempt(5)).build(); try { retryer.call(connectHelixManagerCallable); } catch (ExecutionException | RetryException e) { Throwables.propagate(e); } } }
GobblinTaskRunner implements StandardMetricsBridge { @VisibleForTesting void connectHelixManagerWithRetry() { Callable<Void> connectHelixManagerCallable = () -> { try { logger.info("Instance: {} attempting to join cluster: {}", helixInstanceName, clusterName); connectHelixManager(); } catch (HelixException e) { logger.error("Exception encountered when joining cluster", e); onClusterJoinFailure(); throw e; } return null; }; Retryer<Void> retryer = RetryerBuilder.<Void>newBuilder() .retryIfException() .withStopStrategy(StopStrategies.stopAfterAttempt(5)).build(); try { retryer.call(connectHelixManagerCallable); } catch (ExecutionException | RetryException e) { Throwables.propagate(e); } } GobblinTaskRunner(String applicationName,
      String helixInstanceName,
      String applicationId,
      String taskRunnerId,
      Config config,
      Optional<Path> appWorkDirOptional); }
GobblinTaskRunner implements StandardMetricsBridge { @VisibleForTesting void connectHelixManagerWithRetry() { Callable<Void> connectHelixManagerCallable = () -> { try { logger.info("Instance: {} attempting to join cluster: {}", helixInstanceName, clusterName); connectHelixManager(); } catch (HelixException e) { logger.error("Exception encountered when joining cluster", e); onClusterJoinFailure(); throw e; } return null; }; Retryer<Void> retryer = RetryerBuilder.<Void>newBuilder() .retryIfException() .withStopStrategy(StopStrategies.stopAfterAttempt(5)).build(); try { retryer.call(connectHelixManagerCallable); } catch (ExecutionException | RetryException e) { Throwables.propagate(e); } } GobblinTaskRunner(String applicationName,
      String helixInstanceName,
      String applicationId,
      String taskRunnerId,
      Config config,
      Optional<Path> appWorkDirOptional); void start(); synchronized void stop(); @Override Collection<StandardMetrics> getStandardMetricsCollection(); @Subscribe void handleContainerHealthCheckFailureEvent(ContainerHealthCheckFailureEvent event); static Options buildOptions(); static void printUsage(Options options); static void main(String[] args); }
GobblinTaskRunner implements StandardMetricsBridge { @VisibleForTesting void connectHelixManagerWithRetry() { Callable<Void> connectHelixManagerCallable = () -> { try { logger.info("Instance: {} attempting to join cluster: {}", helixInstanceName, clusterName); connectHelixManager(); } catch (HelixException e) { logger.error("Exception encountered when joining cluster", e); onClusterJoinFailure(); throw e; } return null; }; Retryer<Void> retryer = RetryerBuilder.<Void>newBuilder() .retryIfException() .withStopStrategy(StopStrategies.stopAfterAttempt(5)).build(); try { retryer.call(connectHelixManagerCallable); } catch (ExecutionException | RetryException e) { Throwables.propagate(e); } } GobblinTaskRunner(String applicationName,
      String helixInstanceName,
      String applicationId,
      String taskRunnerId,
      Config config,
      Optional<Path> appWorkDirOptional); void start(); synchronized void stop(); @Override Collection<StandardMetrics> getStandardMetricsCollection(); @Subscribe void handleContainerHealthCheckFailureEvent(ContainerHealthCheckFailureEvent event); static Options buildOptions(); static void printUsage(Options options); static void main(String[] args); static final String CLUSTER_APP_WORK_DIR; }