public static ILocalAssignmentsBackend getBackend(Map<String, Object> conf) { if (conf.get(Config.NIMBUS_LOCAL_ASSIGNMENTS_BACKEND_CLASS) != null) { Object targetObj = ReflectionUtils.newInstance((String) conf.get(Config.NIMBUS_LOCAL_ASSIGNMENTS_BACKEND_CLASS)); Preconditions.checkState(targetObj instanceof ILocalAssignmentsBackend, "{} must implements ILocalAssignmentsBackend", Config.NIMBUS_LOCAL_ASSIGNMENTS_BACKEND_CLASS); ((ILocalAssignmentsBackend) targetObj).prepare(conf); return (ILocalAssignmentsBackend) targetObj; } return getDefault(); }
@Override public void operationComplete(ChannelFuture future) throws Exception { // This call returns immediately Channel newChannel = future.channel(); if (future.isSuccess() && connectionEstablished(newChannel)) { boolean setChannel = channelRef.compareAndSet(null, newChannel); checkState(setChannel); LOG.debug("successfully connected to {}, {} [attempt {}]", address.toString(), newChannel.toString(), connectionAttempt); if (messagesLost.get() > 0) { LOG.warn("Re-connection to {} was successful but {} messages has been lost so far", address.toString(), messagesLost.get()); } } else { Throwable cause = future.cause(); reschedule(cause); if (newChannel != null) { newChannel.close(); } } } });
/** * Get instance of {@link IWorkerHeartbeatsRecoveryStrategy} with conf. * @param conf strategy config * @return an instance of {@link IWorkerHeartbeatsRecoveryStrategy} */ public static IWorkerHeartbeatsRecoveryStrategy getStrategy(Map<String, Object> conf) { IWorkerHeartbeatsRecoveryStrategy strategy; if (conf.get(DaemonConfig.NIMBUS_WORKER_HEARTBEATS_RECOVERY_STRATEGY_CLASS) != null) { Object targetObj = ReflectionUtils.newInstance((String) conf.get(DaemonConfig.NIMBUS_WORKER_HEARTBEATS_RECOVERY_STRATEGY_CLASS)); Preconditions.checkState(targetObj instanceof IWorkerHeartbeatsRecoveryStrategy, "{} must implements IWorkerHeartbeatsRecoveryStrategy", DaemonConfig.NIMBUS_WORKER_HEARTBEATS_RECOVERY_STRATEGY_CLASS); strategy = ((IWorkerHeartbeatsRecoveryStrategy) targetObj); } else { strategy = new TimeOutWorkerHeartbeatsRecoveryStrategy(); } strategy.prepare(conf); return strategy; }
@Override public void operationComplete(ChannelFuture future) throws Exception { // This call returns immediately Channel newChannel = future.getChannel(); if (future.isSuccess() && connectionEstablished(newChannel)) { boolean setChannel = channelRef.compareAndSet(null, newChannel); checkState(setChannel); LOG.debug("successfully connected to {}, {} [attempt {}]", address.toString(), newChannel.toString(), connectionAttempt); if (messagesLost.get() > 0) { LOG.warn("Re-connection to {} was successful but {} messages has been lost so far", address.toString(), messagesLost.get()); } } else { Throwable cause = future.getCause(); reschedule(cause); if (newChannel != null) { newChannel.close(); } } } });