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(); }
public static void nonNullCheckForKey(Object key) { Preconditions.checkArgument(key != null, "key argument can not be null"); }
public int read (byte[] bytes, int off, int len) throws IOException { Preconditions.checkNotNull(bytes, "Given byte array can not be null"); Preconditions.checkPositionIndexes(off, off + len, bytes.length); if (!buf.hasRemaining()) { return -1; } if (len == 0) { return 0; } int end = Math.min(len, buf.remaining()); buf.get(bytes, off, end); return end; } }
@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(); } } } });
public static void nonNullCheckForValue(Object value) { Preconditions.checkArgument(value != null, "value argument can not be null"); }
/** * 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; }
public static void main(String[] args) throws Exception { Preconditions.checkArgument(args.length == 5, "Illegal number of arguments. Expected: 5, Actual: " + args.length); String stormId = args[0]; String assignmentId = args[1]; String supervisorPort = args[2]; String portStr = args[3]; String workerId = args[4]; Map<String, Object> conf = ConfigUtils.readStormConfig(); Utils.setupDefaultUncaughtExceptionHandler(); StormCommon.validateDistributedMode(conf); Worker worker = new Worker(conf, null, stormId, assignmentId, Integer.parseInt(supervisorPort), Integer.parseInt(portStr), workerId); worker.start(); Utils.addShutdownHookWithForceKillIn1Sec(worker::shutdown); }
@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(); } } } });
public static void nonNullCheckForKey(Object key) { Preconditions.checkArgument(key != null, "key argument can not be null"); }
public static void nonNullCheckForValue(Object value) { Preconditions.checkArgument(value != null, "value argument can not be null"); }