public static int getNumFailed(String stormId) { synchronized (failed) { return get(failed, stormId, 0); } }
public static int getInt(Map<String, Object> conf, String key, int defaultValue) { Object obj = Utils.get(conf, key, defaultValue); return Utils.getInt(obj); }
public static int getNumAcked(String stormId) { synchronized (acked) { return get(acked, stormId, 0); } }
public static int getNumFailed(String stormId) { synchronized (failed) { return get(failed, stormId, 0); } }
public static int getNumAcked(String stormId) { synchronized (acked) { return get(acked, stormId, 0); } }
public void ack(Object msgId) { synchronized (acked) { int curr = get(acked, _id, 0); acked.put(_id, curr + 1); } }
public void ack(Object msgId) { synchronized (acked) { int curr = get(acked, uid, 0); acked.put(uid, curr + 1); } }
public void fail(Object msgId) { synchronized (failed) { int curr = get(failed, uid, 0); failed.put(uid, curr + 1); } }
public void fail(Object msgId) { synchronized (failed) { int curr = get(failed, _id, 0); failed.put(_id, curr + 1); } }
private void updateTaskCounts(List<Integer> tasks) { if (_currBatch != null) { Map<Integer, Integer> taskEmittedTuples = _currBatch.taskEmittedTuples; for (Integer task : tasks) { int newCount = Utils.get(taskEmittedTuples, task, 0) + 1; taskEmittedTuples.put(task, newCount); } } } }
private void updateTaskCounts(Object id, List<Integer> tasks) { synchronized (_tracked) { TrackingInfo track = _tracked.get(id); if (track != null) { Map<Integer, Integer> taskEmittedTuples = track.taskEmittedTuples; for (Integer task : tasks) { int newCount = Utils.get(taskEmittedTuples, task, 0) + 1; taskEmittedTuples.put(task, newCount); } } } } }
public static int getInt(Map map, Object key, int def) { return ObjectReader.getInt(Utils.get(map, key, def)); }
public static int getInt(Map map, Object key, int def) { return ObjectReader.getInt(Utils.get(map, key, def)); }
/** * Submits the topology with the name taken from the configuration **/ protected int submit(Config conf, TopologyBuilder builder) { String name = (String) Utils.get(conf, Config.TOPOLOGY_NAME, null); if (StringUtils.isBlank(name)) { throw new RuntimeException( "No value found for " + Config.TOPOLOGY_NAME); } return submit(name, conf, builder); }
/** * Creates a new {@link CassandraConf} instance. * * @param conf The storm configuration. */ public CassandraConf(Map<String, Object> conf) { this.username = (String) Utils.get(conf, CASSANDRA_USERNAME, null); this.password = (String) Utils.get(conf, CASSANDRA_PASSWORD, null); this.keyspace = get(conf, CASSANDRA_KEYSPACE); this.consistencyLevel = ConsistencyLevel.valueOf((String) Utils.get(conf, CASSANDRA_CONSISTENCY_LEVEL, ConsistencyLevel.ONE.name())); this.nodes = ((String) Utils.get(conf, CASSANDRA_NODES, "localhost")).split(","); this.batchSizeRows = ObjectReader.getInt(conf.get(CASSANDRA_BATCH_SIZE_ROWS), 100); this.port = ObjectReader.getInt(conf.get(CASSANDRA_PORT), 9042); this.retryPolicyName = (String) Utils.get(conf, CASSANDRA_RETRY_POLICY, DefaultRetryPolicy.class.getSimpleName()); this.reconnectionPolicyBaseMs = getLong(conf.get(CASSANDRA_RECONNECT_POLICY_BASE_MS), 100L); this.reconnectionPolicyMaxMs = getLong(conf.get(CASSANDRA_RECONNECT_POLICY_MAX_MS), TimeUnit.MINUTES.toMillis(1)); this.poolMaxQueueSize = getInt(conf.get(CASSANDRA_POOL_MAX_SIZE), 256); this.loadBalancingPolicyName = (String) Utils.get(conf, CASSANDRA_LOAD_BALANCING_POLICY, TokenAwarePolicy.class.getSimpleName()); this.datacenterName = (String) Utils.get(conf, CASSANDRA_DATACENTER_NAME, null); this.maxRequestPerConnectionLocal = getInt(conf.get(CASSANDRA_MAX_REQUESTS_PER_CON_LOCAL), 1024); this.maxRequestPerConnectionRemote = getInt(conf.get(CASSANDRA_MAX_REQUESTS_PER_CON_REMOTE), 256); this.heartbeatIntervalSeconds = getInt(conf.get(CASSANDRA_HEARTBEAT_INTERVAL_SEC), 30); this.idleTimeoutSeconds = getInt(conf.get(CASSANDRA_IDLE_TIMEOUT_SEC), 60); this.socketReadTimeoutMillis = getLong(conf.get(CASSANDRA_SOCKET_READ_TIMEOUT_MS), (long) SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS); this.socketConnectTimeoutMillis = getLong(conf.get(CASSANDRA_SOCKET_CONNECT_TIMEOUT_MS), (long) SocketOptions.DEFAULT_CONNECT_TIMEOUT_MILLIS); }
@Override public void open(Map<String, Object> conf, TopologyContext context, SpoutOutputCollector collector) { _delegate.open(conf, context, new SpoutOutputCollector(new StreamOverrideCollector(collector))); _outputTasks = new ArrayList<>(); for (String component : Utils.get(context.getThisTargets(), _coordStream, new HashMap<String, Grouping>()).keySet()) { _outputTasks.addAll(context.getComponentTasks(component)); } _rand = new Random(Utils.secureRandomLong()); }
public void prepare(Map<String, Object> config, TopologyContext context, OutputCollector collector) { TimeCacheMap.ExpiredCallback<Object, TrackingInfo> callback = null; if (_delegate instanceof TimeoutCallback) { callback = new TimeoutItems(); } _tracked = new TimeCacheMap<>(context.maxTopologyMessageTimeout(), callback); _collector = collector; _delegate.prepare(config, context, new OutputCollector(new CoordinatedOutputCollector(collector))); for (String component : Utils.get(context.getThisTargets(), Constants.COORDINATED_STREAM_ID, new HashMap<String, Grouping>()) .keySet()) { for (Integer task : context.getComponentTasks(component)) { _countOutTasks.add(task); } } if (!_sourceArgs.isEmpty()) { _numSourceReports = 0; for (Entry<String, SourceArgs> entry : _sourceArgs.entrySet()) { if (entry.getValue().singleCount) { _numSourceReports += 1; } else { _numSourceReports += context.getComponentTasks(entry.getKey()).size(); } } } }
for (String component : Utils.get(context.getThisTargets(), COORD_STREAM(batchGroup), new HashMap<String, Grouping>()).keySet()) {
while (outTasks.hasNext()) { int task = outTasks.next(); int numTuples = Utils.get(track.taskEmittedTuples, task, 0); _collector.emitDirect(task, Constants.COORDINATED_STREAM_ID, tup, new Values(id, numTuples));
private boolean finishBatch(TrackedBatch tracked, Tuple finishTuple) { boolean success = true; try { _bolt.finishBatch(tracked.info); String stream = COORD_STREAM(tracked.info.batchGroup); for (Integer task : tracked.condition.targetTasks) { _collector .emitDirect(task, stream, finishTuple, new Values(tracked.info.batchId, Utils.get(tracked.taskEmittedTuples, task, 0))); } if (tracked.delayedAck != null) { _collector.ack(tracked.delayedAck); tracked.delayedAck = null; } } catch (FailedException e) { failBatch(tracked, e); success = false; } _batches.remove(tracked.info.batchId.getId()); return success; }