id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,400 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java | TopologyMetricContext.mergeMeters | public void mergeMeters(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data) {
Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
if (existing == null) {
metricInfo.put_to_metrics(meta, data);
} else {
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Integer win = dataEntry.getKey();
MetricSnapshot snapshot = dataEntry.getValue();
MetricSnapshot old = existing.get(win);
if (old == null) {
existing.put(win, snapshot);
} else {
if (snapshot.get_ts() >= old.get_ts()) {
old.set_ts(snapshot.get_ts());
old.set_mean(old.get_mean() + snapshot.get_mean());
old.set_m1(old.get_m1() + snapshot.get_m1());
old.set_m5(old.get_m5() + snapshot.get_m5());
old.set_m15(old.get_m15() + snapshot.get_m15());
}
}
}
}
} | java | public void mergeMeters(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data) {
Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
if (existing == null) {
metricInfo.put_to_metrics(meta, data);
} else {
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Integer win = dataEntry.getKey();
MetricSnapshot snapshot = dataEntry.getValue();
MetricSnapshot old = existing.get(win);
if (old == null) {
existing.put(win, snapshot);
} else {
if (snapshot.get_ts() >= old.get_ts()) {
old.set_ts(snapshot.get_ts());
old.set_mean(old.get_mean() + snapshot.get_mean());
old.set_m1(old.get_m1() + snapshot.get_m1());
old.set_m5(old.get_m5() + snapshot.get_m5());
old.set_m15(old.get_m15() + snapshot.get_m15());
}
}
}
}
} | [
"public",
"void",
"mergeMeters",
"(",
"MetricInfo",
"metricInfo",
",",
"String",
"meta",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"data",
")",
"{",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"existing",
"=",
"metricInfo",
".",
"get_metrics",
"(",
")",
".",
"get",
"(",
"meta",
")",
";",
"if",
"(",
"existing",
"==",
"null",
")",
"{",
"metricInfo",
".",
"put_to_metrics",
"(",
"meta",
",",
"data",
")",
";",
"}",
"else",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"dataEntry",
":",
"data",
".",
"entrySet",
"(",
")",
")",
"{",
"Integer",
"win",
"=",
"dataEntry",
".",
"getKey",
"(",
")",
";",
"MetricSnapshot",
"snapshot",
"=",
"dataEntry",
".",
"getValue",
"(",
")",
";",
"MetricSnapshot",
"old",
"=",
"existing",
".",
"get",
"(",
"win",
")",
";",
"if",
"(",
"old",
"==",
"null",
")",
"{",
"existing",
".",
"put",
"(",
"win",
",",
"snapshot",
")",
";",
"}",
"else",
"{",
"if",
"(",
"snapshot",
".",
"get_ts",
"(",
")",
">=",
"old",
".",
"get_ts",
"(",
")",
")",
"{",
"old",
".",
"set_ts",
"(",
"snapshot",
".",
"get_ts",
"(",
")",
")",
";",
"old",
".",
"set_mean",
"(",
"old",
".",
"get_mean",
"(",
")",
"+",
"snapshot",
".",
"get_mean",
"(",
")",
")",
";",
"old",
".",
"set_m1",
"(",
"old",
".",
"get_m1",
"(",
")",
"+",
"snapshot",
".",
"get_m1",
"(",
")",
")",
";",
"old",
".",
"set_m5",
"(",
"old",
".",
"get_m5",
"(",
")",
"+",
"snapshot",
".",
"get_m5",
"(",
")",
")",
";",
"old",
".",
"set_m15",
"(",
"old",
".",
"get_m15",
"(",
")",
"+",
"snapshot",
".",
"get_m15",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | meters are not sampled. | [
"meters",
"are",
"not",
"sampled",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java#L309-L331 |
25,401 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java | TopologyMetricContext.mergeHistograms | public void mergeHistograms(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data,
Map<String, Integer> metaCounters, Map<String, Map<Integer, Histogram>> histograms) {
Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
if (existing == null) {
metricInfo.put_to_metrics(meta, data);
Map<Integer, Histogram> histogramMap = new HashMap<>();
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Histogram histogram = MetricUtils.metricSnapshot2Histogram(dataEntry.getValue());
histogramMap.put(dataEntry.getKey(), histogram);
}
histograms.put(meta, histogramMap);
} else {
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Integer win = dataEntry.getKey();
MetricSnapshot snapshot = dataEntry.getValue();
MetricSnapshot old = existing.get(win);
if (old == null) {
existing.put(win, snapshot);
histograms.get(meta).put(win, MetricUtils.metricSnapshot2Histogram(snapshot));
} else {
if (snapshot.get_ts() >= old.get_ts()) {
old.set_ts(snapshot.get_ts());
Histogram histogram = histograms.get(meta).get(win);
Snapshot updateSnapshot = histogram.getSnapshot();
if (updateSnapshot instanceof JAverageSnapshot) {
sumMetricSnapshot(((JAverageSnapshot) updateSnapshot).getMetricSnapshot(), snapshot);
} else {
// update points
MetricUtils.updateHistogramPoints(histogram, snapshot.get_points(), snapshot.get_pointSize());
}
}
}
}
}
updateMetricCounters(meta, metaCounters);
} | java | public void mergeHistograms(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data,
Map<String, Integer> metaCounters, Map<String, Map<Integer, Histogram>> histograms) {
Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
if (existing == null) {
metricInfo.put_to_metrics(meta, data);
Map<Integer, Histogram> histogramMap = new HashMap<>();
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Histogram histogram = MetricUtils.metricSnapshot2Histogram(dataEntry.getValue());
histogramMap.put(dataEntry.getKey(), histogram);
}
histograms.put(meta, histogramMap);
} else {
for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
Integer win = dataEntry.getKey();
MetricSnapshot snapshot = dataEntry.getValue();
MetricSnapshot old = existing.get(win);
if (old == null) {
existing.put(win, snapshot);
histograms.get(meta).put(win, MetricUtils.metricSnapshot2Histogram(snapshot));
} else {
if (snapshot.get_ts() >= old.get_ts()) {
old.set_ts(snapshot.get_ts());
Histogram histogram = histograms.get(meta).get(win);
Snapshot updateSnapshot = histogram.getSnapshot();
if (updateSnapshot instanceof JAverageSnapshot) {
sumMetricSnapshot(((JAverageSnapshot) updateSnapshot).getMetricSnapshot(), snapshot);
} else {
// update points
MetricUtils.updateHistogramPoints(histogram, snapshot.get_points(), snapshot.get_pointSize());
}
}
}
}
}
updateMetricCounters(meta, metaCounters);
} | [
"public",
"void",
"mergeHistograms",
"(",
"MetricInfo",
"metricInfo",
",",
"String",
"meta",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"data",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"metaCounters",
",",
"Map",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"Histogram",
">",
">",
"histograms",
")",
"{",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"existing",
"=",
"metricInfo",
".",
"get_metrics",
"(",
")",
".",
"get",
"(",
"meta",
")",
";",
"if",
"(",
"existing",
"==",
"null",
")",
"{",
"metricInfo",
".",
"put_to_metrics",
"(",
"meta",
",",
"data",
")",
";",
"Map",
"<",
"Integer",
",",
"Histogram",
">",
"histogramMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"dataEntry",
":",
"data",
".",
"entrySet",
"(",
")",
")",
"{",
"Histogram",
"histogram",
"=",
"MetricUtils",
".",
"metricSnapshot2Histogram",
"(",
"dataEntry",
".",
"getValue",
"(",
")",
")",
";",
"histogramMap",
".",
"put",
"(",
"dataEntry",
".",
"getKey",
"(",
")",
",",
"histogram",
")",
";",
"}",
"histograms",
".",
"put",
"(",
"meta",
",",
"histogramMap",
")",
";",
"}",
"else",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"dataEntry",
":",
"data",
".",
"entrySet",
"(",
")",
")",
"{",
"Integer",
"win",
"=",
"dataEntry",
".",
"getKey",
"(",
")",
";",
"MetricSnapshot",
"snapshot",
"=",
"dataEntry",
".",
"getValue",
"(",
")",
";",
"MetricSnapshot",
"old",
"=",
"existing",
".",
"get",
"(",
"win",
")",
";",
"if",
"(",
"old",
"==",
"null",
")",
"{",
"existing",
".",
"put",
"(",
"win",
",",
"snapshot",
")",
";",
"histograms",
".",
"get",
"(",
"meta",
")",
".",
"put",
"(",
"win",
",",
"MetricUtils",
".",
"metricSnapshot2Histogram",
"(",
"snapshot",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"snapshot",
".",
"get_ts",
"(",
")",
">=",
"old",
".",
"get_ts",
"(",
")",
")",
"{",
"old",
".",
"set_ts",
"(",
"snapshot",
".",
"get_ts",
"(",
")",
")",
";",
"Histogram",
"histogram",
"=",
"histograms",
".",
"get",
"(",
"meta",
")",
".",
"get",
"(",
"win",
")",
";",
"Snapshot",
"updateSnapshot",
"=",
"histogram",
".",
"getSnapshot",
"(",
")",
";",
"if",
"(",
"updateSnapshot",
"instanceof",
"JAverageSnapshot",
")",
"{",
"sumMetricSnapshot",
"(",
"(",
"(",
"JAverageSnapshot",
")",
"updateSnapshot",
")",
".",
"getMetricSnapshot",
"(",
")",
",",
"snapshot",
")",
";",
"}",
"else",
"{",
"// update points",
"MetricUtils",
".",
"updateHistogramPoints",
"(",
"histogram",
",",
"snapshot",
".",
"get_points",
"(",
")",
",",
"snapshot",
".",
"get_pointSize",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"updateMetricCounters",
"(",
"meta",
",",
"metaCounters",
")",
";",
"}"
] | histograms are sampled, but we just update points | [
"histograms",
"are",
"sampled",
"but",
"we",
"just",
"update",
"points"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java#L336-L371 |
25,402 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java | TopologyMetricContext.updateMetricCounters | protected void updateMetricCounters(String metricName, Map<String, Integer> metricNameCounters) {
if (metricNameCounters.containsKey(metricName)) {
metricNameCounters.put(metricName, metricNameCounters.get(metricName) + 1);
} else {
metricNameCounters.put(metricName, 1);
}
} | java | protected void updateMetricCounters(String metricName, Map<String, Integer> metricNameCounters) {
if (metricNameCounters.containsKey(metricName)) {
metricNameCounters.put(metricName, metricNameCounters.get(metricName) + 1);
} else {
metricNameCounters.put(metricName, 1);
}
} | [
"protected",
"void",
"updateMetricCounters",
"(",
"String",
"metricName",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"metricNameCounters",
")",
"{",
"if",
"(",
"metricNameCounters",
".",
"containsKey",
"(",
"metricName",
")",
")",
"{",
"metricNameCounters",
".",
"put",
"(",
"metricName",
",",
"metricNameCounters",
".",
"get",
"(",
"metricName",
")",
"+",
"1",
")",
";",
"}",
"else",
"{",
"metricNameCounters",
".",
"put",
"(",
"metricName",
",",
"1",
")",
";",
"}",
"}"
] | computes occurrences of specified metric name | [
"computes",
"occurrences",
"of",
"specified",
"metric",
"name"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java#L393-L399 |
25,403 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java | TopologyMetricContext.mergeCounters | private void mergeCounters(Map<String, Map<Integer, MetricSnapshot>> newCounters,
Map<String, Map<Integer, MetricSnapshot>> oldCounters) {
for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : newCounters.entrySet()) {
String metricName = entry.getKey();
Map<Integer, MetricSnapshot> snapshots = entry.getValue();
Map<Integer, MetricSnapshot> oldSnapshots = oldCounters.get(metricName);
if (oldSnapshots != null && oldSnapshots.size() > 0) {
for (Map.Entry<Integer, MetricSnapshot> snapshotEntry : snapshots.entrySet()) {
Integer win = snapshotEntry.getKey();
MetricSnapshot snapshot = snapshotEntry.getValue();
MetricSnapshot oldSnapshot = oldSnapshots.get(win);
if (oldSnapshot != null) {
snapshot.set_longValue(snapshot.get_longValue() + oldSnapshot.get_longValue());
}
}
}
}
} | java | private void mergeCounters(Map<String, Map<Integer, MetricSnapshot>> newCounters,
Map<String, Map<Integer, MetricSnapshot>> oldCounters) {
for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : newCounters.entrySet()) {
String metricName = entry.getKey();
Map<Integer, MetricSnapshot> snapshots = entry.getValue();
Map<Integer, MetricSnapshot> oldSnapshots = oldCounters.get(metricName);
if (oldSnapshots != null && oldSnapshots.size() > 0) {
for (Map.Entry<Integer, MetricSnapshot> snapshotEntry : snapshots.entrySet()) {
Integer win = snapshotEntry.getKey();
MetricSnapshot snapshot = snapshotEntry.getValue();
MetricSnapshot oldSnapshot = oldSnapshots.get(win);
if (oldSnapshot != null) {
snapshot.set_longValue(snapshot.get_longValue() + oldSnapshot.get_longValue());
}
}
}
}
} | [
"private",
"void",
"mergeCounters",
"(",
"Map",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
">",
"newCounters",
",",
"Map",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
">",
"oldCounters",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
">",
"entry",
":",
"newCounters",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"metricName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"snapshots",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"oldSnapshots",
"=",
"oldCounters",
".",
"get",
"(",
"metricName",
")",
";",
"if",
"(",
"oldSnapshots",
"!=",
"null",
"&&",
"oldSnapshots",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"snapshotEntry",
":",
"snapshots",
".",
"entrySet",
"(",
")",
")",
"{",
"Integer",
"win",
"=",
"snapshotEntry",
".",
"getKey",
"(",
")",
";",
"MetricSnapshot",
"snapshot",
"=",
"snapshotEntry",
".",
"getValue",
"(",
")",
";",
"MetricSnapshot",
"oldSnapshot",
"=",
"oldSnapshots",
".",
"get",
"(",
"win",
")",
";",
"if",
"(",
"oldSnapshot",
"!=",
"null",
")",
"{",
"snapshot",
".",
"set_longValue",
"(",
"snapshot",
".",
"get_longValue",
"(",
")",
"+",
"oldSnapshot",
".",
"get_longValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | sum old counter snapshots and new counter snapshots, sums are stored in new snapshots. | [
"sum",
"old",
"counter",
"snapshots",
"and",
"new",
"counter",
"snapshots",
"sums",
"are",
"stored",
"in",
"new",
"snapshots",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/metric/TopologyMetricContext.java#L493-L510 |
25,404 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java | WindowManager.track | private void track(Event<T> windowEvent) {
evictionPolicy.track(windowEvent);
triggerPolicy.track(windowEvent);
} | java | private void track(Event<T> windowEvent) {
evictionPolicy.track(windowEvent);
triggerPolicy.track(windowEvent);
} | [
"private",
"void",
"track",
"(",
"Event",
"<",
"T",
">",
"windowEvent",
")",
"{",
"evictionPolicy",
".",
"track",
"(",
"windowEvent",
")",
";",
"triggerPolicy",
".",
"track",
"(",
"windowEvent",
")",
";",
"}"
] | feed the event to the eviction and trigger policies
for bookkeeping and optionally firing the trigger. | [
"feed",
"the",
"event",
"to",
"the",
"eviction",
"and",
"trigger",
"policies",
"for",
"bookkeeping",
"and",
"optionally",
"firing",
"the",
"trigger",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java#L172-L175 |
25,405 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java | WindowManager.scanEvents | private List<Event<T>> scanEvents(boolean fullScan) {
LOG.debug("Scan events, eviction policy {}", evictionPolicy);
List<T> eventsToExpire = new ArrayList<>();
List<Event<T>> eventsToProcess = new ArrayList<>();
try {
lock.lock();
Iterator<Event<T>> it = queue.iterator();
while (it.hasNext()) {
Event<T> windowEvent = it.next();
Action action = evictionPolicy.evict(windowEvent);
if (action == Action.EXPIRE) {
eventsToExpire.add(windowEvent.get());
it.remove();
} else if (!fullScan || action == Action.STOP) {
break;
} else if (action == Action.PROCESS) {
eventsToProcess.add(windowEvent);
}
}
expiredEvents.addAll(eventsToExpire);
} finally {
lock.unlock();
}
eventsSinceLastExpiry.set(0);
LOG.debug("[{}] events expired from window.", eventsToExpire.size());
if (!eventsToExpire.isEmpty()) {
LOG.debug("invoking windowLifecycleListener.onExpiry");
windowLifecycleListener.onExpiry(eventsToExpire);
}
return eventsToProcess;
} | java | private List<Event<T>> scanEvents(boolean fullScan) {
LOG.debug("Scan events, eviction policy {}", evictionPolicy);
List<T> eventsToExpire = new ArrayList<>();
List<Event<T>> eventsToProcess = new ArrayList<>();
try {
lock.lock();
Iterator<Event<T>> it = queue.iterator();
while (it.hasNext()) {
Event<T> windowEvent = it.next();
Action action = evictionPolicy.evict(windowEvent);
if (action == Action.EXPIRE) {
eventsToExpire.add(windowEvent.get());
it.remove();
} else if (!fullScan || action == Action.STOP) {
break;
} else if (action == Action.PROCESS) {
eventsToProcess.add(windowEvent);
}
}
expiredEvents.addAll(eventsToExpire);
} finally {
lock.unlock();
}
eventsSinceLastExpiry.set(0);
LOG.debug("[{}] events expired from window.", eventsToExpire.size());
if (!eventsToExpire.isEmpty()) {
LOG.debug("invoking windowLifecycleListener.onExpiry");
windowLifecycleListener.onExpiry(eventsToExpire);
}
return eventsToProcess;
} | [
"private",
"List",
"<",
"Event",
"<",
"T",
">",
">",
"scanEvents",
"(",
"boolean",
"fullScan",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Scan events, eviction policy {}\"",
",",
"evictionPolicy",
")",
";",
"List",
"<",
"T",
">",
"eventsToExpire",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"Event",
"<",
"T",
">",
">",
"eventsToProcess",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"Iterator",
"<",
"Event",
"<",
"T",
">",
">",
"it",
"=",
"queue",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Event",
"<",
"T",
">",
"windowEvent",
"=",
"it",
".",
"next",
"(",
")",
";",
"Action",
"action",
"=",
"evictionPolicy",
".",
"evict",
"(",
"windowEvent",
")",
";",
"if",
"(",
"action",
"==",
"Action",
".",
"EXPIRE",
")",
"{",
"eventsToExpire",
".",
"add",
"(",
"windowEvent",
".",
"get",
"(",
")",
")",
";",
"it",
".",
"remove",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"fullScan",
"||",
"action",
"==",
"Action",
".",
"STOP",
")",
"{",
"break",
";",
"}",
"else",
"if",
"(",
"action",
"==",
"Action",
".",
"PROCESS",
")",
"{",
"eventsToProcess",
".",
"add",
"(",
"windowEvent",
")",
";",
"}",
"}",
"expiredEvents",
".",
"addAll",
"(",
"eventsToExpire",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"eventsSinceLastExpiry",
".",
"set",
"(",
"0",
")",
";",
"LOG",
".",
"debug",
"(",
"\"[{}] events expired from window.\"",
",",
"eventsToExpire",
".",
"size",
"(",
")",
")",
";",
"if",
"(",
"!",
"eventsToExpire",
".",
"isEmpty",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"invoking windowLifecycleListener.onExpiry\"",
")",
";",
"windowLifecycleListener",
".",
"onExpiry",
"(",
"eventsToExpire",
")",
";",
"}",
"return",
"eventsToProcess",
";",
"}"
] | Scan events in the queue, using the expiration policy to check
if the event should be evicted or not.
@param fullScan if set, will scan the entire queue; if not set, will stop
as soon as an event not satisfying the expiration policy is found
@return the list of events to be processed as a part of the current window | [
"Scan",
"events",
"in",
"the",
"queue",
"using",
"the",
"expiration",
"policy",
"to",
"check",
"if",
"the",
"event",
"should",
"be",
"evicted",
"or",
"not",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java#L185-L215 |
25,406 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java | WindowManager.getEarliestEventTs | public long getEarliestEventTs(long startTs, long endTs) {
long minTs = Long.MAX_VALUE;
for (Event<T> event : queue) {
if (event.getTimestamp() > startTs && event.getTimestamp() <= endTs) {
minTs = Math.min(minTs, event.getTimestamp());
}
}
return minTs;
} | java | public long getEarliestEventTs(long startTs, long endTs) {
long minTs = Long.MAX_VALUE;
for (Event<T> event : queue) {
if (event.getTimestamp() > startTs && event.getTimestamp() <= endTs) {
minTs = Math.min(minTs, event.getTimestamp());
}
}
return minTs;
} | [
"public",
"long",
"getEarliestEventTs",
"(",
"long",
"startTs",
",",
"long",
"endTs",
")",
"{",
"long",
"minTs",
"=",
"Long",
".",
"MAX_VALUE",
";",
"for",
"(",
"Event",
"<",
"T",
">",
"event",
":",
"queue",
")",
"{",
"if",
"(",
"event",
".",
"getTimestamp",
"(",
")",
">",
"startTs",
"&&",
"event",
".",
"getTimestamp",
"(",
")",
"<=",
"endTs",
")",
"{",
"minTs",
"=",
"Math",
".",
"min",
"(",
"minTs",
",",
"event",
".",
"getTimestamp",
"(",
")",
")",
";",
"}",
"}",
"return",
"minTs",
";",
"}"
] | Scans the event queue and returns the next earliest event ts
between the startTs and endTs
@param startTs the start ts (exclusive)
@param endTs the end ts (inclusive)
@return the earliest event ts between startTs and endTs | [
"Scans",
"the",
"event",
"queue",
"and",
"returns",
"the",
"next",
"earliest",
"event",
"ts",
"between",
"the",
"startTs",
"and",
"endTs"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java#L225-L233 |
25,407 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java | WindowManager.getEventCount | public int getEventCount(long referenceTime) {
int count = 0;
for (Event<T> event : queue) {
if (event.getTimestamp() <= referenceTime) {
++count;
}
}
return count;
} | java | public int getEventCount(long referenceTime) {
int count = 0;
for (Event<T> event : queue) {
if (event.getTimestamp() <= referenceTime) {
++count;
}
}
return count;
} | [
"public",
"int",
"getEventCount",
"(",
"long",
"referenceTime",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"Event",
"<",
"T",
">",
"event",
":",
"queue",
")",
"{",
"if",
"(",
"event",
".",
"getTimestamp",
"(",
")",
"<=",
"referenceTime",
")",
"{",
"++",
"count",
";",
"}",
"}",
"return",
"count",
";",
"}"
] | Scans the event queue and returns number of events having
timestamp less than or equal to the reference time.
@param referenceTime the reference timestamp in millis
@return the count of events with timestamp less than or equal to referenceTime | [
"Scans",
"the",
"event",
"queue",
"and",
"returns",
"number",
"of",
"events",
"having",
"timestamp",
"less",
"than",
"or",
"equal",
"to",
"the",
"reference",
"time",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/windowing/WindowManager.java#L242-L250 |
25,408 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusServer.java | NimbusServer.mkRefreshConfThread | private void mkRefreshConfThread(final NimbusData nimbusData) {
nimbusData.getScheduExec().scheduleAtFixedRate(new RunnableCallback() {
@Override
public void run() {
LOG.debug("checking changes in storm.yaml...");
Map newConf = Utils.readStormConfig();
if (Utils.isConfigChanged(nimbusData.getConf(), newConf)) {
LOG.warn("detected changes in storm.yaml, updating...");
synchronized (nimbusData.getConf()) {
nimbusData.getConf().clear();
nimbusData.getConf().putAll(newConf);
}
RefreshableComponents.refresh(newConf);
} else {
LOG.debug("no changes detected, stay put.");
}
}
@Override
public Object getResult() {
return 15;
}
}, 15, 15, TimeUnit.SECONDS);
LOG.info("Successfully init configuration refresh thread");
} | java | private void mkRefreshConfThread(final NimbusData nimbusData) {
nimbusData.getScheduExec().scheduleAtFixedRate(new RunnableCallback() {
@Override
public void run() {
LOG.debug("checking changes in storm.yaml...");
Map newConf = Utils.readStormConfig();
if (Utils.isConfigChanged(nimbusData.getConf(), newConf)) {
LOG.warn("detected changes in storm.yaml, updating...");
synchronized (nimbusData.getConf()) {
nimbusData.getConf().clear();
nimbusData.getConf().putAll(newConf);
}
RefreshableComponents.refresh(newConf);
} else {
LOG.debug("no changes detected, stay put.");
}
}
@Override
public Object getResult() {
return 15;
}
}, 15, 15, TimeUnit.SECONDS);
LOG.info("Successfully init configuration refresh thread");
} | [
"private",
"void",
"mkRefreshConfThread",
"(",
"final",
"NimbusData",
"nimbusData",
")",
"{",
"nimbusData",
".",
"getScheduExec",
"(",
")",
".",
"scheduleAtFixedRate",
"(",
"new",
"RunnableCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"checking changes in storm.yaml...\"",
")",
";",
"Map",
"newConf",
"=",
"Utils",
".",
"readStormConfig",
"(",
")",
";",
"if",
"(",
"Utils",
".",
"isConfigChanged",
"(",
"nimbusData",
".",
"getConf",
"(",
")",
",",
"newConf",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"detected changes in storm.yaml, updating...\"",
")",
";",
"synchronized",
"(",
"nimbusData",
".",
"getConf",
"(",
")",
")",
"{",
"nimbusData",
".",
"getConf",
"(",
")",
".",
"clear",
"(",
")",
";",
"nimbusData",
".",
"getConf",
"(",
")",
".",
"putAll",
"(",
"newConf",
")",
";",
"}",
"RefreshableComponents",
".",
"refresh",
"(",
"newConf",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"no changes detected, stay put.\"",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"Object",
"getResult",
"(",
")",
"{",
"return",
"15",
";",
"}",
"}",
",",
"15",
",",
"15",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"LOG",
".",
"info",
"(",
"\"Successfully init configuration refresh thread\"",
")",
";",
"}"
] | handle manual conf changes, check every 15 sec | [
"handle",
"manual",
"conf",
"changes",
"check",
"every",
"15",
"sec"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusServer.java#L141-L168 |
25,409 | alibaba/jstorm | jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/ZookeeperUtils.java | ZookeeperUtils.splitToHostsAndPorts | public static List<HostAndPort> splitToHostsAndPorts(String hostPortQuorumList) {
// split an address hot
String[] strings = StringUtils.getStrings(hostPortQuorumList);
int len = 0;
if (strings != null) {
len = strings.length;
}
List<HostAndPort> list = new ArrayList<HostAndPort>(len);
if (strings != null) {
for (String s : strings) {
list.add(HostAndPort.fromString(s.trim()).withDefaultPort(DEFAULT_PORT));
}
}
return list;
} | java | public static List<HostAndPort> splitToHostsAndPorts(String hostPortQuorumList) {
// split an address hot
String[] strings = StringUtils.getStrings(hostPortQuorumList);
int len = 0;
if (strings != null) {
len = strings.length;
}
List<HostAndPort> list = new ArrayList<HostAndPort>(len);
if (strings != null) {
for (String s : strings) {
list.add(HostAndPort.fromString(s.trim()).withDefaultPort(DEFAULT_PORT));
}
}
return list;
} | [
"public",
"static",
"List",
"<",
"HostAndPort",
">",
"splitToHostsAndPorts",
"(",
"String",
"hostPortQuorumList",
")",
"{",
"// split an address hot",
"String",
"[",
"]",
"strings",
"=",
"StringUtils",
".",
"getStrings",
"(",
"hostPortQuorumList",
")",
";",
"int",
"len",
"=",
"0",
";",
"if",
"(",
"strings",
"!=",
"null",
")",
"{",
"len",
"=",
"strings",
".",
"length",
";",
"}",
"List",
"<",
"HostAndPort",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"HostAndPort",
">",
"(",
"len",
")",
";",
"if",
"(",
"strings",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"s",
":",
"strings",
")",
"{",
"list",
".",
"add",
"(",
"HostAndPort",
".",
"fromString",
"(",
"s",
".",
"trim",
"(",
")",
")",
".",
"withDefaultPort",
"(",
"DEFAULT_PORT",
")",
")",
";",
"}",
"}",
"return",
"list",
";",
"}"
] | Split a quorum list into a list of hostnames and ports
@param hostPortQuorumList split to a list of hosts and ports
@return a list of values | [
"Split",
"a",
"quorum",
"list",
"into",
"a",
"list",
"of",
"hostnames",
"and",
"ports"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/ZookeeperUtils.java#L65-L79 |
25,410 | alibaba/jstorm | jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/ZookeeperUtils.java | ZookeeperUtils.buildHostsOnlyList | public static String buildHostsOnlyList(List<HostAndPort> hostAndPorts) {
StringBuilder sb = new StringBuilder();
for (HostAndPort hostAndPort : hostAndPorts) {
sb.append(hostAndPort.getHostText()).append(",");
}
if (sb.length() > 0) {
sb.delete(sb.length() - 1, sb.length());
}
return sb.toString();
} | java | public static String buildHostsOnlyList(List<HostAndPort> hostAndPorts) {
StringBuilder sb = new StringBuilder();
for (HostAndPort hostAndPort : hostAndPorts) {
sb.append(hostAndPort.getHostText()).append(",");
}
if (sb.length() > 0) {
sb.delete(sb.length() - 1, sb.length());
}
return sb.toString();
} | [
"public",
"static",
"String",
"buildHostsOnlyList",
"(",
"List",
"<",
"HostAndPort",
">",
"hostAndPorts",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"HostAndPort",
"hostAndPort",
":",
"hostAndPorts",
")",
"{",
"sb",
".",
"append",
"(",
"hostAndPort",
".",
"getHostText",
"(",
")",
")",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"delete",
"(",
"sb",
".",
"length",
"(",
")",
"-",
"1",
",",
"sb",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Build up to a hosts only list
@param hostAndPorts
@return a list of the hosts only | [
"Build",
"up",
"to",
"a",
"hosts",
"only",
"list"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/utils/ZookeeperUtils.java#L86-L95 |
25,411 | alibaba/jstorm | jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java | FluxBuilder.buildConfig | public static Config buildConfig(TopologyDef topologyDef) {
// merge contents of `config` into topology config
Config conf = new Config();
conf.putAll(topologyDef.getConfig());
return conf;
} | java | public static Config buildConfig(TopologyDef topologyDef) {
// merge contents of `config` into topology config
Config conf = new Config();
conf.putAll(topologyDef.getConfig());
return conf;
} | [
"public",
"static",
"Config",
"buildConfig",
"(",
"TopologyDef",
"topologyDef",
")",
"{",
"// merge contents of `config` into topology config",
"Config",
"conf",
"=",
"new",
"Config",
"(",
")",
";",
"conf",
".",
"putAll",
"(",
"topologyDef",
".",
"getConfig",
"(",
")",
")",
";",
"return",
"conf",
";",
"}"
] | Given a topology definition, return a populated `org.apache.storm.Config` instance.
@param topologyDef
@return | [
"Given",
"a",
"topology",
"definition",
"return",
"a",
"populated",
"org",
".",
"apache",
".",
"storm",
".",
"Config",
"instance",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L44-L49 |
25,412 | alibaba/jstorm | jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java | FluxBuilder.buildTopology | public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException,
InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if(!topologyDef.validate()){
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " +
"defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if(topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
} | java | public static StormTopology buildTopology(ExecutionContext context) throws IllegalAccessException,
InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
StormTopology topology = null;
TopologyDef topologyDef = context.getTopologyDef();
if(!topologyDef.validate()){
throw new IllegalArgumentException("Invalid topology config. Spouts, bolts and streams cannot be " +
"defined in the same configuration as a topologySource.");
}
// build components that may be referenced by spouts, bolts, etc.
// the map will be a String --> Object where the object is a fully
// constructed class instance
buildComponents(context);
if(topologyDef.isDslTopology()) {
// This is a DSL (YAML, etc.) topology...
LOG.info("Detected DSL topology...");
TopologyBuilder builder = new TopologyBuilder();
// create spouts
buildSpouts(context, builder);
// we need to be able to lookup bolts by id, then switch based
// on whether they are IBasicBolt or IRichBolt instances
buildBolts(context);
// process stream definitions
buildStreamDefinitions(context, builder);
topology = builder.createTopology();
} else {
// user class supplied...
// this also provides a bridge to Trident...
LOG.info("A topology source has been specified...");
ObjectDef def = topologyDef.getTopologySource();
topology = buildExternalTopology(def, context);
}
return topology;
} | [
"public",
"static",
"StormTopology",
"buildTopology",
"(",
"ExecutionContext",
"context",
")",
"throws",
"IllegalAccessException",
",",
"InstantiationException",
",",
"ClassNotFoundException",
",",
"NoSuchMethodException",
",",
"InvocationTargetException",
"{",
"StormTopology",
"topology",
"=",
"null",
";",
"TopologyDef",
"topologyDef",
"=",
"context",
".",
"getTopologyDef",
"(",
")",
";",
"if",
"(",
"!",
"topologyDef",
".",
"validate",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid topology config. Spouts, bolts and streams cannot be \"",
"+",
"\"defined in the same configuration as a topologySource.\"",
")",
";",
"}",
"// build components that may be referenced by spouts, bolts, etc.",
"// the map will be a String --> Object where the object is a fully",
"// constructed class instance",
"buildComponents",
"(",
"context",
")",
";",
"if",
"(",
"topologyDef",
".",
"isDslTopology",
"(",
")",
")",
"{",
"// This is a DSL (YAML, etc.) topology...",
"LOG",
".",
"info",
"(",
"\"Detected DSL topology...\"",
")",
";",
"TopologyBuilder",
"builder",
"=",
"new",
"TopologyBuilder",
"(",
")",
";",
"// create spouts",
"buildSpouts",
"(",
"context",
",",
"builder",
")",
";",
"// we need to be able to lookup bolts by id, then switch based",
"// on whether they are IBasicBolt or IRichBolt instances",
"buildBolts",
"(",
"context",
")",
";",
"// process stream definitions",
"buildStreamDefinitions",
"(",
"context",
",",
"builder",
")",
";",
"topology",
"=",
"builder",
".",
"createTopology",
"(",
")",
";",
"}",
"else",
"{",
"// user class supplied...",
"// this also provides a bridge to Trident...",
"LOG",
".",
"info",
"(",
"\"A topology source has been specified...\"",
")",
";",
"ObjectDef",
"def",
"=",
"topologyDef",
".",
"getTopologySource",
"(",
")",
";",
"topology",
"=",
"buildExternalTopology",
"(",
"def",
",",
"context",
")",
";",
"}",
"return",
"topology",
";",
"}"
] | Given a topology definition, return a Storm topology that can be run either locally or remotely.
@param context
@return
@throws IllegalAccessException
@throws InstantiationException
@throws ClassNotFoundException
@throws NoSuchMethodException
@throws InvocationTargetException | [
"Given",
"a",
"topology",
"definition",
"return",
"a",
"Storm",
"topology",
"that",
"can",
"be",
"run",
"either",
"locally",
"or",
"remotely",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L62-L103 |
25,413 | alibaba/jstorm | jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java | FluxBuilder.buildComponents | private static void buildComponents(ExecutionContext context) throws ClassNotFoundException, NoSuchMethodException,
IllegalAccessException, InvocationTargetException, InstantiationException {
Collection<BeanDef> cDefs = context.getTopologyDef().getComponents();
if (cDefs != null) {
for (BeanDef bean : cDefs) {
Object obj = buildObject(bean, context);
context.addComponent(bean.getId(), obj);
}
}
} | java | private static void buildComponents(ExecutionContext context) throws ClassNotFoundException, NoSuchMethodException,
IllegalAccessException, InvocationTargetException, InstantiationException {
Collection<BeanDef> cDefs = context.getTopologyDef().getComponents();
if (cDefs != null) {
for (BeanDef bean : cDefs) {
Object obj = buildObject(bean, context);
context.addComponent(bean.getId(), obj);
}
}
} | [
"private",
"static",
"void",
"buildComponents",
"(",
"ExecutionContext",
"context",
")",
"throws",
"ClassNotFoundException",
",",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
",",
"InstantiationException",
"{",
"Collection",
"<",
"BeanDef",
">",
"cDefs",
"=",
"context",
".",
"getTopologyDef",
"(",
")",
".",
"getComponents",
"(",
")",
";",
"if",
"(",
"cDefs",
"!=",
"null",
")",
"{",
"for",
"(",
"BeanDef",
"bean",
":",
"cDefs",
")",
"{",
"Object",
"obj",
"=",
"buildObject",
"(",
"bean",
",",
"context",
")",
";",
"context",
".",
"addComponent",
"(",
"bean",
".",
"getId",
"(",
")",
",",
"obj",
")",
";",
"}",
"}",
"}"
] | Given a topology definition, resolve and instantiate all components found and return a map
keyed by the component id. | [
"Given",
"a",
"topology",
"definition",
"resolve",
"and",
"instantiate",
"all",
"components",
"found",
"and",
"return",
"a",
"map",
"keyed",
"by",
"the",
"component",
"id",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L351-L360 |
25,414 | alibaba/jstorm | jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java | FluxBuilder.buildSpout | private static IRichSpout buildSpout(SpoutDef def, ExecutionContext context) throws ClassNotFoundException,
IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
return (IRichSpout)buildObject(def, context);
} | java | private static IRichSpout buildSpout(SpoutDef def, ExecutionContext context) throws ClassNotFoundException,
IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
return (IRichSpout)buildObject(def, context);
} | [
"private",
"static",
"IRichSpout",
"buildSpout",
"(",
"SpoutDef",
"def",
",",
"ExecutionContext",
"context",
")",
"throws",
"ClassNotFoundException",
",",
"IllegalAccessException",
",",
"InstantiationException",
",",
"NoSuchMethodException",
",",
"InvocationTargetException",
"{",
"return",
"(",
"IRichSpout",
")",
"buildObject",
"(",
"def",
",",
"context",
")",
";",
"}"
] | Given a spout definition, return a Storm spout implementation by attempting to find a matching constructor
in the given spout class. Perform list to array conversion as necessary. | [
"Given",
"a",
"spout",
"definition",
"return",
"a",
"Storm",
"spout",
"implementation",
"by",
"attempting",
"to",
"find",
"a",
"matching",
"constructor",
"in",
"the",
"given",
"spout",
"class",
".",
"Perform",
"list",
"to",
"array",
"conversion",
"as",
"necessary",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L376-L379 |
25,415 | alibaba/jstorm | jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java | FluxBuilder.buildBolts | private static void buildBolts(ExecutionContext context) throws ClassNotFoundException, IllegalAccessException,
InstantiationException, NoSuchMethodException, InvocationTargetException {
for (BoltDef def : context.getTopologyDef().getBolts()) {
Class clazz = Class.forName(def.getClassName());
Object bolt = buildObject(def, context);
context.addBolt(def.getId(), bolt);
}
} | java | private static void buildBolts(ExecutionContext context) throws ClassNotFoundException, IllegalAccessException,
InstantiationException, NoSuchMethodException, InvocationTargetException {
for (BoltDef def : context.getTopologyDef().getBolts()) {
Class clazz = Class.forName(def.getClassName());
Object bolt = buildObject(def, context);
context.addBolt(def.getId(), bolt);
}
} | [
"private",
"static",
"void",
"buildBolts",
"(",
"ExecutionContext",
"context",
")",
"throws",
"ClassNotFoundException",
",",
"IllegalAccessException",
",",
"InstantiationException",
",",
"NoSuchMethodException",
",",
"InvocationTargetException",
"{",
"for",
"(",
"BoltDef",
"def",
":",
"context",
".",
"getTopologyDef",
"(",
")",
".",
"getBolts",
"(",
")",
")",
"{",
"Class",
"clazz",
"=",
"Class",
".",
"forName",
"(",
"def",
".",
"getClassName",
"(",
")",
")",
";",
"Object",
"bolt",
"=",
"buildObject",
"(",
"def",
",",
"context",
")",
";",
"context",
".",
"addBolt",
"(",
"def",
".",
"getId",
"(",
")",
",",
"bolt",
")",
";",
"}",
"}"
] | Given a list of bolt definitions, build a map of Storm bolts with the bolt definition id as the key.
Attempt to coerce the given constructor arguments to a matching bolt constructor as much as possible. | [
"Given",
"a",
"list",
"of",
"bolt",
"definitions",
"build",
"a",
"map",
"of",
"Storm",
"bolts",
"with",
"the",
"bolt",
"definition",
"id",
"as",
"the",
"key",
".",
"Attempt",
"to",
"coerce",
"the",
"given",
"constructor",
"arguments",
"to",
"a",
"matching",
"bolt",
"constructor",
"as",
"much",
"as",
"possible",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-utility/jstorm-flux/flux-core/src/main/java/com/alibaba/jstorm/flux/FluxBuilder.java#L385-L392 |
25,416 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusUtils.java | NimbusUtils.mapifySerializations | private static Map mapifySerializations(List sers) {
Map rtn = new HashMap();
if (sers != null) {
int size = sers.size();
for (int i = 0; i < size; i++) {
if (sers.get(i) instanceof Map) {
rtn.putAll((Map) sers.get(i));
} else {
rtn.put(sers.get(i), null);
}
}
}
return rtn;
} | java | private static Map mapifySerializations(List sers) {
Map rtn = new HashMap();
if (sers != null) {
int size = sers.size();
for (int i = 0; i < size; i++) {
if (sers.get(i) instanceof Map) {
rtn.putAll((Map) sers.get(i));
} else {
rtn.put(sers.get(i), null);
}
}
}
return rtn;
} | [
"private",
"static",
"Map",
"mapifySerializations",
"(",
"List",
"sers",
")",
"{",
"Map",
"rtn",
"=",
"new",
"HashMap",
"(",
")",
";",
"if",
"(",
"sers",
"!=",
"null",
")",
"{",
"int",
"size",
"=",
"sers",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sers",
".",
"get",
"(",
"i",
")",
"instanceof",
"Map",
")",
"{",
"rtn",
".",
"putAll",
"(",
"(",
"Map",
")",
"sers",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"else",
"{",
"rtn",
".",
"put",
"(",
"sers",
".",
"get",
"(",
"i",
")",
",",
"null",
")",
";",
"}",
"}",
"}",
"return",
"rtn",
";",
"}"
] | add custom KRYO serialization | [
"add",
"custom",
"KRYO",
"serialization"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusUtils.java#L76-L90 |
25,417 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusUtils.java | NimbusUtils.normalizeTopology | public static StormTopology normalizeTopology(Map stormConf, StormTopology topology, boolean fromConf) {
StormTopology ret = topology.deepCopy();
Map<String, Object> rawComponents = ThriftTopologyUtils.getComponents(topology);
Map<String, Object> components = ThriftTopologyUtils.getComponents(ret);
if (!rawComponents.keySet().equals(components.keySet())) {
String errMsg = "Failed to normalize topology binary!";
LOG.info(errMsg + " raw components:" + rawComponents.keySet() + ", normalized " + components.keySet());
throw new InvalidParameterException(errMsg);
}
for (Entry<String, Object> entry : components.entrySet()) {
Object component = entry.getValue();
String componentName = entry.getKey();
ComponentCommon common = null;
if (component instanceof Bolt) {
common = ((Bolt) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getBoltParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
if (component instanceof SpoutSpec) {
common = ((SpoutSpec) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getSpoutParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
if (component instanceof StateSpoutSpec) {
common = ((StateSpoutSpec) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getSpoutParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
Map componentMap = new HashMap();
String jsonConfString = common.get_json_conf();
if (jsonConfString != null) {
componentMap.putAll((Map) JStormUtils.from_json(jsonConfString));
}
Integer taskNum = componentParalism(stormConf, common);
componentMap.put(Config.TOPOLOGY_TASKS, taskNum);
// change the executor's task number
common.set_parallelism_hint(taskNum);
LOG.info("Set " + componentName + " parallelism " + taskNum);
common.set_json_conf(JStormUtils.to_json(componentMap));
}
return ret;
} | java | public static StormTopology normalizeTopology(Map stormConf, StormTopology topology, boolean fromConf) {
StormTopology ret = topology.deepCopy();
Map<String, Object> rawComponents = ThriftTopologyUtils.getComponents(topology);
Map<String, Object> components = ThriftTopologyUtils.getComponents(ret);
if (!rawComponents.keySet().equals(components.keySet())) {
String errMsg = "Failed to normalize topology binary!";
LOG.info(errMsg + " raw components:" + rawComponents.keySet() + ", normalized " + components.keySet());
throw new InvalidParameterException(errMsg);
}
for (Entry<String, Object> entry : components.entrySet()) {
Object component = entry.getValue();
String componentName = entry.getKey();
ComponentCommon common = null;
if (component instanceof Bolt) {
common = ((Bolt) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getBoltParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
if (component instanceof SpoutSpec) {
common = ((SpoutSpec) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getSpoutParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
if (component instanceof StateSpoutSpec) {
common = ((StateSpoutSpec) component).get_common();
if (fromConf) {
Integer paraNum = ConfigExtension.getSpoutParallelism(stormConf, componentName);
if (paraNum != null) {
LOG.info("Set " + componentName + " as " + paraNum);
common.set_parallelism_hint(paraNum);
}
}
}
Map componentMap = new HashMap();
String jsonConfString = common.get_json_conf();
if (jsonConfString != null) {
componentMap.putAll((Map) JStormUtils.from_json(jsonConfString));
}
Integer taskNum = componentParalism(stormConf, common);
componentMap.put(Config.TOPOLOGY_TASKS, taskNum);
// change the executor's task number
common.set_parallelism_hint(taskNum);
LOG.info("Set " + componentName + " parallelism " + taskNum);
common.set_json_conf(JStormUtils.to_json(componentMap));
}
return ret;
} | [
"public",
"static",
"StormTopology",
"normalizeTopology",
"(",
"Map",
"stormConf",
",",
"StormTopology",
"topology",
",",
"boolean",
"fromConf",
")",
"{",
"StormTopology",
"ret",
"=",
"topology",
".",
"deepCopy",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"rawComponents",
"=",
"ThriftTopologyUtils",
".",
"getComponents",
"(",
"topology",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"components",
"=",
"ThriftTopologyUtils",
".",
"getComponents",
"(",
"ret",
")",
";",
"if",
"(",
"!",
"rawComponents",
".",
"keySet",
"(",
")",
".",
"equals",
"(",
"components",
".",
"keySet",
"(",
")",
")",
")",
"{",
"String",
"errMsg",
"=",
"\"Failed to normalize topology binary!\"",
";",
"LOG",
".",
"info",
"(",
"errMsg",
"+",
"\" raw components:\"",
"+",
"rawComponents",
".",
"keySet",
"(",
")",
"+",
"\", normalized \"",
"+",
"components",
".",
"keySet",
"(",
")",
")",
";",
"throw",
"new",
"InvalidParameterException",
"(",
"errMsg",
")",
";",
"}",
"for",
"(",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"components",
".",
"entrySet",
"(",
")",
")",
"{",
"Object",
"component",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"String",
"componentName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"ComponentCommon",
"common",
"=",
"null",
";",
"if",
"(",
"component",
"instanceof",
"Bolt",
")",
"{",
"common",
"=",
"(",
"(",
"Bolt",
")",
"component",
")",
".",
"get_common",
"(",
")",
";",
"if",
"(",
"fromConf",
")",
"{",
"Integer",
"paraNum",
"=",
"ConfigExtension",
".",
"getBoltParallelism",
"(",
"stormConf",
",",
"componentName",
")",
";",
"if",
"(",
"paraNum",
"!=",
"null",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Set \"",
"+",
"componentName",
"+",
"\" as \"",
"+",
"paraNum",
")",
";",
"common",
".",
"set_parallelism_hint",
"(",
"paraNum",
")",
";",
"}",
"}",
"}",
"if",
"(",
"component",
"instanceof",
"SpoutSpec",
")",
"{",
"common",
"=",
"(",
"(",
"SpoutSpec",
")",
"component",
")",
".",
"get_common",
"(",
")",
";",
"if",
"(",
"fromConf",
")",
"{",
"Integer",
"paraNum",
"=",
"ConfigExtension",
".",
"getSpoutParallelism",
"(",
"stormConf",
",",
"componentName",
")",
";",
"if",
"(",
"paraNum",
"!=",
"null",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Set \"",
"+",
"componentName",
"+",
"\" as \"",
"+",
"paraNum",
")",
";",
"common",
".",
"set_parallelism_hint",
"(",
"paraNum",
")",
";",
"}",
"}",
"}",
"if",
"(",
"component",
"instanceof",
"StateSpoutSpec",
")",
"{",
"common",
"=",
"(",
"(",
"StateSpoutSpec",
")",
"component",
")",
".",
"get_common",
"(",
")",
";",
"if",
"(",
"fromConf",
")",
"{",
"Integer",
"paraNum",
"=",
"ConfigExtension",
".",
"getSpoutParallelism",
"(",
"stormConf",
",",
"componentName",
")",
";",
"if",
"(",
"paraNum",
"!=",
"null",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Set \"",
"+",
"componentName",
"+",
"\" as \"",
"+",
"paraNum",
")",
";",
"common",
".",
"set_parallelism_hint",
"(",
"paraNum",
")",
";",
"}",
"}",
"}",
"Map",
"componentMap",
"=",
"new",
"HashMap",
"(",
")",
";",
"String",
"jsonConfString",
"=",
"common",
".",
"get_json_conf",
"(",
")",
";",
"if",
"(",
"jsonConfString",
"!=",
"null",
")",
"{",
"componentMap",
".",
"putAll",
"(",
"(",
"Map",
")",
"JStormUtils",
".",
"from_json",
"(",
"jsonConfString",
")",
")",
";",
"}",
"Integer",
"taskNum",
"=",
"componentParalism",
"(",
"stormConf",
",",
"common",
")",
";",
"componentMap",
".",
"put",
"(",
"Config",
".",
"TOPOLOGY_TASKS",
",",
"taskNum",
")",
";",
"// change the executor's task number",
"common",
".",
"set_parallelism_hint",
"(",
"taskNum",
")",
";",
"LOG",
".",
"info",
"(",
"\"Set \"",
"+",
"componentName",
"+",
"\" parallelism \"",
"+",
"taskNum",
")",
";",
"common",
".",
"set_json_conf",
"(",
"JStormUtils",
".",
"to_json",
"(",
"componentMap",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | finalize component's task parallelism
@param stormConf storm conf
@param topology storm topology
@param fromConf means if the parallelism is read from conf file instead of reading from topology code
@return normalized topology | [
"finalize",
"component",
"s",
"task",
"parallelism"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusUtils.java#L227-L295 |
25,418 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusUtils.java | NimbusUtils.cleanupCorruptTopologies | public static void cleanupCorruptTopologies(NimbusData data) throws Exception {
BlobStore blobStore = data.getBlobStore();
// we have only topology relative files , so we don't need filter
Set<String> code_ids = Sets.newHashSet(BlobStoreUtils.code_ids(blobStore.listKeys()));
// get topology in ZK /storms
Set<String> active_ids = Sets.newHashSet(data.getStormClusterState().active_storms());
//get topology in zk by blobs
Set<String> blobsIdsOnZk = Sets.newHashSet(data.getStormClusterState().blobstore(null));
Set<String> topologyIdsOnZkbyBlobs = BlobStoreUtils.code_ids(blobsIdsOnZk.iterator());
Set<String> corrupt_ids = Sets.difference(active_ids, code_ids);
Set<String> redundantIds = Sets.difference(topologyIdsOnZkbyBlobs, code_ids);
Set<String> unionIds = Sets.union(corrupt_ids, redundantIds);
// clean the topology which is in ZK but not in local dir
for (String corrupt : unionIds) {
LOG.info("Corrupt topology {} has state on zookeeper but doesn't have a local dir on nimbus. Cleaning up...", corrupt);
try {
cleanupTopology(data, corrupt);
} catch (Exception e) {
LOG.warn("Failed to cleanup topology {}, {}", corrupt, e);
}
}
LOG.info("Successfully cleaned up all old topologies");
} | java | public static void cleanupCorruptTopologies(NimbusData data) throws Exception {
BlobStore blobStore = data.getBlobStore();
// we have only topology relative files , so we don't need filter
Set<String> code_ids = Sets.newHashSet(BlobStoreUtils.code_ids(blobStore.listKeys()));
// get topology in ZK /storms
Set<String> active_ids = Sets.newHashSet(data.getStormClusterState().active_storms());
//get topology in zk by blobs
Set<String> blobsIdsOnZk = Sets.newHashSet(data.getStormClusterState().blobstore(null));
Set<String> topologyIdsOnZkbyBlobs = BlobStoreUtils.code_ids(blobsIdsOnZk.iterator());
Set<String> corrupt_ids = Sets.difference(active_ids, code_ids);
Set<String> redundantIds = Sets.difference(topologyIdsOnZkbyBlobs, code_ids);
Set<String> unionIds = Sets.union(corrupt_ids, redundantIds);
// clean the topology which is in ZK but not in local dir
for (String corrupt : unionIds) {
LOG.info("Corrupt topology {} has state on zookeeper but doesn't have a local dir on nimbus. Cleaning up...", corrupt);
try {
cleanupTopology(data, corrupt);
} catch (Exception e) {
LOG.warn("Failed to cleanup topology {}, {}", corrupt, e);
}
}
LOG.info("Successfully cleaned up all old topologies");
} | [
"public",
"static",
"void",
"cleanupCorruptTopologies",
"(",
"NimbusData",
"data",
")",
"throws",
"Exception",
"{",
"BlobStore",
"blobStore",
"=",
"data",
".",
"getBlobStore",
"(",
")",
";",
"// we have only topology relative files , so we don't need filter",
"Set",
"<",
"String",
">",
"code_ids",
"=",
"Sets",
".",
"newHashSet",
"(",
"BlobStoreUtils",
".",
"code_ids",
"(",
"blobStore",
".",
"listKeys",
"(",
")",
")",
")",
";",
"// get topology in ZK /storms",
"Set",
"<",
"String",
">",
"active_ids",
"=",
"Sets",
".",
"newHashSet",
"(",
"data",
".",
"getStormClusterState",
"(",
")",
".",
"active_storms",
"(",
")",
")",
";",
"//get topology in zk by blobs",
"Set",
"<",
"String",
">",
"blobsIdsOnZk",
"=",
"Sets",
".",
"newHashSet",
"(",
"data",
".",
"getStormClusterState",
"(",
")",
".",
"blobstore",
"(",
"null",
")",
")",
";",
"Set",
"<",
"String",
">",
"topologyIdsOnZkbyBlobs",
"=",
"BlobStoreUtils",
".",
"code_ids",
"(",
"blobsIdsOnZk",
".",
"iterator",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"corrupt_ids",
"=",
"Sets",
".",
"difference",
"(",
"active_ids",
",",
"code_ids",
")",
";",
"Set",
"<",
"String",
">",
"redundantIds",
"=",
"Sets",
".",
"difference",
"(",
"topologyIdsOnZkbyBlobs",
",",
"code_ids",
")",
";",
"Set",
"<",
"String",
">",
"unionIds",
"=",
"Sets",
".",
"union",
"(",
"corrupt_ids",
",",
"redundantIds",
")",
";",
"// clean the topology which is in ZK but not in local dir",
"for",
"(",
"String",
"corrupt",
":",
"unionIds",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Corrupt topology {} has state on zookeeper but doesn't have a local dir on nimbus. Cleaning up...\"",
",",
"corrupt",
")",
";",
"try",
"{",
"cleanupTopology",
"(",
"data",
",",
"corrupt",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to cleanup topology {}, {}\"",
",",
"corrupt",
",",
"e",
")",
";",
"}",
"}",
"LOG",
".",
"info",
"(",
"\"Successfully cleaned up all old topologies\"",
")",
";",
"}"
] | clean the topology which is in ZK but not in local dir | [
"clean",
"the",
"topology",
"which",
"is",
"in",
"ZK",
"but",
"not",
"in",
"local",
"dir"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/NimbusUtils.java#L313-L338 |
25,419 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/security/auth/ShellBasedGroupsMapping.java | ShellBasedGroupsMapping.getGroups | @Override
public Set<String> getGroups(String user) throws IOException {
if (cachedGroups.containsKey(user)) {
return cachedGroups.get(user);
}
Set<String> groups = getUnixGroups(user);
if (!groups.isEmpty())
cachedGroups.put(user, groups);
return groups;
} | java | @Override
public Set<String> getGroups(String user) throws IOException {
if (cachedGroups.containsKey(user)) {
return cachedGroups.get(user);
}
Set<String> groups = getUnixGroups(user);
if (!groups.isEmpty())
cachedGroups.put(user, groups);
return groups;
} | [
"@",
"Override",
"public",
"Set",
"<",
"String",
">",
"getGroups",
"(",
"String",
"user",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cachedGroups",
".",
"containsKey",
"(",
"user",
")",
")",
"{",
"return",
"cachedGroups",
".",
"get",
"(",
"user",
")",
";",
"}",
"Set",
"<",
"String",
">",
"groups",
"=",
"getUnixGroups",
"(",
"user",
")",
";",
"if",
"(",
"!",
"groups",
".",
"isEmpty",
"(",
")",
")",
"cachedGroups",
".",
"put",
"(",
"user",
",",
"groups",
")",
";",
"return",
"groups",
";",
"}"
] | Returns list of groups for a user
@param user get groups for this user
@return list of groups for a given user | [
"Returns",
"list",
"of",
"groups",
"for",
"a",
"user"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/security/auth/ShellBasedGroupsMapping.java#L56-L65 |
25,420 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/security/auth/ShellBasedGroupsMapping.java | ShellBasedGroupsMapping.getUnixGroups | private static Set<String> getUnixGroups(final String user) throws IOException {
String result = "";
try {
result = ShellUtils.execCommand(ShellUtils.getGroupsForUserCommand(user));
} catch (ExitCodeException e) {
// if we didn't get the group - just return empty list;
LOG.warn("got exception trying to get groups for user " + user, e);
return new HashSet<String>();
}
StringTokenizer tokenizer = new StringTokenizer(result, ShellUtils.TOKEN_SEPARATOR_REGEX);
Set<String> groups = new HashSet<String>();
while (tokenizer.hasMoreTokens()) {
groups.add(tokenizer.nextToken());
}
return groups;
} | java | private static Set<String> getUnixGroups(final String user) throws IOException {
String result = "";
try {
result = ShellUtils.execCommand(ShellUtils.getGroupsForUserCommand(user));
} catch (ExitCodeException e) {
// if we didn't get the group - just return empty list;
LOG.warn("got exception trying to get groups for user " + user, e);
return new HashSet<String>();
}
StringTokenizer tokenizer = new StringTokenizer(result, ShellUtils.TOKEN_SEPARATOR_REGEX);
Set<String> groups = new HashSet<String>();
while (tokenizer.hasMoreTokens()) {
groups.add(tokenizer.nextToken());
}
return groups;
} | [
"private",
"static",
"Set",
"<",
"String",
">",
"getUnixGroups",
"(",
"final",
"String",
"user",
")",
"throws",
"IOException",
"{",
"String",
"result",
"=",
"\"\"",
";",
"try",
"{",
"result",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"ShellUtils",
".",
"getGroupsForUserCommand",
"(",
"user",
")",
")",
";",
"}",
"catch",
"(",
"ExitCodeException",
"e",
")",
"{",
"// if we didn't get the group - just return empty list;",
"LOG",
".",
"warn",
"(",
"\"got exception trying to get groups for user \"",
"+",
"user",
",",
"e",
")",
";",
"return",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"}",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"result",
",",
"ShellUtils",
".",
"TOKEN_SEPARATOR_REGEX",
")",
";",
"Set",
"<",
"String",
">",
"groups",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"while",
"(",
"tokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"groups",
".",
"add",
"(",
"tokenizer",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"return",
"groups",
";",
"}"
] | Get the current user's group list from Unix by running the command 'groups' NOTE. For non-existing user it will return EMPTY list
@param user user name
@return the groups set that the <code>user</code> belongs to
@throws IOException if encounter any error when running the command | [
"Get",
"the",
"current",
"user",
"s",
"group",
"list",
"from",
"Unix",
"by",
"running",
"the",
"command",
"groups",
"NOTE",
".",
"For",
"non",
"-",
"existing",
"user",
"it",
"will",
"return",
"EMPTY",
"list"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/security/auth/ShellBasedGroupsMapping.java#L74-L90 |
25,421 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/uploader/TopologyMetricDataInfo.java | TopologyMetricDataInfo.toMap | public Map<String, Object> toMap() {
Map<String, Object> ret = new HashMap<>();
ret.put(MetricUploader.METRIC_TIME, timestamp);
ret.put(MetricUploader.METRIC_TYPE, type);
return ret;
} | java | public Map<String, Object> toMap() {
Map<String, Object> ret = new HashMap<>();
ret.put(MetricUploader.METRIC_TIME, timestamp);
ret.put(MetricUploader.METRIC_TYPE, type);
return ret;
} | [
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"toMap",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"ret",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"ret",
".",
"put",
"(",
"MetricUploader",
".",
"METRIC_TIME",
",",
"timestamp",
")",
";",
"ret",
".",
"put",
"(",
"MetricUploader",
".",
"METRIC_TYPE",
",",
"type",
")",
";",
"return",
"ret",
";",
"}"
] | metrics report time | [
"metrics",
"report",
"time"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/uploader/TopologyMetricDataInfo.java#L34-L40 |
25,422 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/Metric.java | Metric.update | @Override
public void update(Number obj) {
if (enable == false) {
return;
}
if (intervalCheck.check()) {
flush();
}
synchronized (this) {
unflushed = updater.update(obj, unflushed);
}
} | java | @Override
public void update(Number obj) {
if (enable == false) {
return;
}
if (intervalCheck.check()) {
flush();
}
synchronized (this) {
unflushed = updater.update(obj, unflushed);
}
} | [
"@",
"Override",
"public",
"void",
"update",
"(",
"Number",
"obj",
")",
"{",
"if",
"(",
"enable",
"==",
"false",
")",
"{",
"return",
";",
"}",
"if",
"(",
"intervalCheck",
".",
"check",
"(",
")",
")",
"{",
"flush",
"(",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"unflushed",
"=",
"updater",
".",
"update",
"(",
"obj",
",",
"unflushed",
")",
";",
"}",
"}"
] | In order to improve performance Do | [
"In",
"order",
"to",
"improve",
"performance",
"Do"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/Metric.java#L119-L131 |
25,423 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/utils/DisruptorRunable.java | DisruptorRunable.onEvent | @Override
public void onEvent(Object event, long sequence, boolean endOfBatch) throws Exception {
if (event == null) {
return;
}
handleEvent(event, endOfBatch);
} | java | @Override
public void onEvent(Object event, long sequence, boolean endOfBatch) throws Exception {
if (event == null) {
return;
}
handleEvent(event, endOfBatch);
} | [
"@",
"Override",
"public",
"void",
"onEvent",
"(",
"Object",
"event",
",",
"long",
"sequence",
",",
"boolean",
"endOfBatch",
")",
"throws",
"Exception",
"{",
"if",
"(",
"event",
"==",
"null",
")",
"{",
"return",
";",
"}",
"handleEvent",
"(",
"event",
",",
"endOfBatch",
")",
";",
"}"
] | This function need to be implements
@see com.lmax.disruptor.EventHandler#onEvent(java.lang.Object, long, boolean) | [
"This",
"function",
"need",
"to",
"be",
"implements"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/utils/DisruptorRunable.java#L52-L58 |
25,424 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/refresh/RefreshEvent.java | RefreshEvent.refreshTopologies | public void refreshTopologies() {
TimeTicker ticker = new TimeTicker(TimeUnit.MILLISECONDS, true);
try {
doRefreshTopologies();
LOG.debug("Refresh topologies, cost:{}", ticker.stopAndRestart());
if (!context.getNimbusData().isLeader()) { // won't hit...
syncTopologyMetaForFollower();
LOG.debug("Sync topology meta, cost:{}", ticker.stop());
}
} catch (Exception ex) {
LOG.error("handleRefreshEvent error:", ex);
}
} | java | public void refreshTopologies() {
TimeTicker ticker = new TimeTicker(TimeUnit.MILLISECONDS, true);
try {
doRefreshTopologies();
LOG.debug("Refresh topologies, cost:{}", ticker.stopAndRestart());
if (!context.getNimbusData().isLeader()) { // won't hit...
syncTopologyMetaForFollower();
LOG.debug("Sync topology meta, cost:{}", ticker.stop());
}
} catch (Exception ex) {
LOG.error("handleRefreshEvent error:", ex);
}
} | [
"public",
"void",
"refreshTopologies",
"(",
")",
"{",
"TimeTicker",
"ticker",
"=",
"new",
"TimeTicker",
"(",
"TimeUnit",
".",
"MILLISECONDS",
",",
"true",
")",
";",
"try",
"{",
"doRefreshTopologies",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Refresh topologies, cost:{}\"",
",",
"ticker",
".",
"stopAndRestart",
"(",
")",
")",
";",
"if",
"(",
"!",
"context",
".",
"getNimbusData",
"(",
")",
".",
"isLeader",
"(",
")",
")",
"{",
"// won't hit...",
"syncTopologyMetaForFollower",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Sync topology meta, cost:{}\"",
",",
"ticker",
".",
"stop",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"\"handleRefreshEvent error:\"",
",",
"ex",
")",
";",
"}",
"}"
] | refresh metric settings of topologies & metric meta | [
"refresh",
"metric",
"settings",
"of",
"topologies",
"&",
"metric",
"meta"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/refresh/RefreshEvent.java#L83-L96 |
25,425 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/refresh/RefreshEvent.java | RefreshEvent.syncMetaFromCache | private void syncMetaFromCache(String topology, TopologyMetricContext tmContext) {
if (!tmContext.syncMeta()) {
Map<String, Long> meta = context.getMetricCache().getMeta(topology);
if (meta != null) {
tmContext.getMemMeta().putAll(meta);
}
tmContext.setSyncMeta(true);
}
} | java | private void syncMetaFromCache(String topology, TopologyMetricContext tmContext) {
if (!tmContext.syncMeta()) {
Map<String, Long> meta = context.getMetricCache().getMeta(topology);
if (meta != null) {
tmContext.getMemMeta().putAll(meta);
}
tmContext.setSyncMeta(true);
}
} | [
"private",
"void",
"syncMetaFromCache",
"(",
"String",
"topology",
",",
"TopologyMetricContext",
"tmContext",
")",
"{",
"if",
"(",
"!",
"tmContext",
".",
"syncMeta",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"Long",
">",
"meta",
"=",
"context",
".",
"getMetricCache",
"(",
")",
".",
"getMeta",
"(",
"topology",
")",
";",
"if",
"(",
"meta",
"!=",
"null",
")",
"{",
"tmContext",
".",
"getMemMeta",
"(",
")",
".",
"putAll",
"(",
"meta",
")",
";",
"}",
"tmContext",
".",
"setSyncMeta",
"(",
"true",
")",
";",
"}",
"}"
] | sync metric meta from rocks db into mem cache on startup | [
"sync",
"metric",
"meta",
"from",
"rocks",
"db",
"into",
"mem",
"cache",
"on",
"startup"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/refresh/RefreshEvent.java#L221-L229 |
25,426 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/refresh/RefreshEvent.java | RefreshEvent.syncSysMetaFromRemote | private void syncSysMetaFromRemote() {
for (String topology : JStormMetrics.SYS_TOPOLOGIES) {
if (context.getTopologyMetricContexts().containsKey(topology)) {
syncMetaFromRemote(topology,
context.getTopologyMetricContexts().get(topology),
Lists.newArrayList(MetaType.TOPOLOGY, MetaType.WORKER, MetaType.NIMBUS));
}
}
} | java | private void syncSysMetaFromRemote() {
for (String topology : JStormMetrics.SYS_TOPOLOGIES) {
if (context.getTopologyMetricContexts().containsKey(topology)) {
syncMetaFromRemote(topology,
context.getTopologyMetricContexts().get(topology),
Lists.newArrayList(MetaType.TOPOLOGY, MetaType.WORKER, MetaType.NIMBUS));
}
}
} | [
"private",
"void",
"syncSysMetaFromRemote",
"(",
")",
"{",
"for",
"(",
"String",
"topology",
":",
"JStormMetrics",
".",
"SYS_TOPOLOGIES",
")",
"{",
"if",
"(",
"context",
".",
"getTopologyMetricContexts",
"(",
")",
".",
"containsKey",
"(",
"topology",
")",
")",
"{",
"syncMetaFromRemote",
"(",
"topology",
",",
"context",
".",
"getTopologyMetricContexts",
"(",
")",
".",
"get",
"(",
"topology",
")",
",",
"Lists",
".",
"newArrayList",
"(",
"MetaType",
".",
"TOPOLOGY",
",",
"MetaType",
".",
"WORKER",
",",
"MetaType",
".",
"NIMBUS",
")",
")",
";",
"}",
"}",
"}"
] | sync sys topologies from remote because we want to keep all historic metric data
thus metric id cannot be changed. | [
"sync",
"sys",
"topologies",
"from",
"remote",
"because",
"we",
"want",
"to",
"keep",
"all",
"historic",
"metric",
"data",
"thus",
"metric",
"id",
"cannot",
"be",
"changed",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/refresh/RefreshEvent.java#L235-L243 |
25,427 | alibaba/jstorm | jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/registry/SlotPortsView.java | SlotPortsView.tryHostLock | private void tryHostLock(String hostPath) throws Exception {
//if path has created 60 seconds ago, then delete
if (registryOperations.exists(hostPath)) {
try {
ServiceRecord host = registryOperations.resolve(hostPath);
Long cTime = Long.parseLong(host.get(JOYConstants.CTIME, JOYConstants.DEFAULT_CTIME));
Date now = new Date();
if (now.getTime() - cTime > JOYConstants.HOST_LOCK_TIMEOUT || cTime > now.getTime())
registryOperations.delete(hostPath, true);
} catch (Exception ex) {
LOG.error(ex);
}
}
int failedCount = JOYConstants.RETRY_TIMES;
while (!registryOperations.mknode(hostPath, true)) {
Thread.sleep(JOYConstants.SLEEP_INTERVAL);
failedCount--;
if (failedCount <= 0)
break;
}
if (failedCount > 0) {
ServiceRecord sr = new ServiceRecord();
Date date = new Date();
date.getTime();
sr.set(JOYConstants.CTIME, String.valueOf(date.getTime()));
registryOperations.bind(hostPath, sr, BindFlags.OVERWRITE);
return;
}
throw new Exception("can't get host lock");
} | java | private void tryHostLock(String hostPath) throws Exception {
//if path has created 60 seconds ago, then delete
if (registryOperations.exists(hostPath)) {
try {
ServiceRecord host = registryOperations.resolve(hostPath);
Long cTime = Long.parseLong(host.get(JOYConstants.CTIME, JOYConstants.DEFAULT_CTIME));
Date now = new Date();
if (now.getTime() - cTime > JOYConstants.HOST_LOCK_TIMEOUT || cTime > now.getTime())
registryOperations.delete(hostPath, true);
} catch (Exception ex) {
LOG.error(ex);
}
}
int failedCount = JOYConstants.RETRY_TIMES;
while (!registryOperations.mknode(hostPath, true)) {
Thread.sleep(JOYConstants.SLEEP_INTERVAL);
failedCount--;
if (failedCount <= 0)
break;
}
if (failedCount > 0) {
ServiceRecord sr = new ServiceRecord();
Date date = new Date();
date.getTime();
sr.set(JOYConstants.CTIME, String.valueOf(date.getTime()));
registryOperations.bind(hostPath, sr, BindFlags.OVERWRITE);
return;
}
throw new Exception("can't get host lock");
} | [
"private",
"void",
"tryHostLock",
"(",
"String",
"hostPath",
")",
"throws",
"Exception",
"{",
"//if path has created 60 seconds ago, then delete",
"if",
"(",
"registryOperations",
".",
"exists",
"(",
"hostPath",
")",
")",
"{",
"try",
"{",
"ServiceRecord",
"host",
"=",
"registryOperations",
".",
"resolve",
"(",
"hostPath",
")",
";",
"Long",
"cTime",
"=",
"Long",
".",
"parseLong",
"(",
"host",
".",
"get",
"(",
"JOYConstants",
".",
"CTIME",
",",
"JOYConstants",
".",
"DEFAULT_CTIME",
")",
")",
";",
"Date",
"now",
"=",
"new",
"Date",
"(",
")",
";",
"if",
"(",
"now",
".",
"getTime",
"(",
")",
"-",
"cTime",
">",
"JOYConstants",
".",
"HOST_LOCK_TIMEOUT",
"||",
"cTime",
">",
"now",
".",
"getTime",
"(",
")",
")",
"registryOperations",
".",
"delete",
"(",
"hostPath",
",",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"LOG",
".",
"error",
"(",
"ex",
")",
";",
"}",
"}",
"int",
"failedCount",
"=",
"JOYConstants",
".",
"RETRY_TIMES",
";",
"while",
"(",
"!",
"registryOperations",
".",
"mknode",
"(",
"hostPath",
",",
"true",
")",
")",
"{",
"Thread",
".",
"sleep",
"(",
"JOYConstants",
".",
"SLEEP_INTERVAL",
")",
";",
"failedCount",
"--",
";",
"if",
"(",
"failedCount",
"<=",
"0",
")",
"break",
";",
"}",
"if",
"(",
"failedCount",
">",
"0",
")",
"{",
"ServiceRecord",
"sr",
"=",
"new",
"ServiceRecord",
"(",
")",
";",
"Date",
"date",
"=",
"new",
"Date",
"(",
")",
";",
"date",
".",
"getTime",
"(",
")",
";",
"sr",
".",
"set",
"(",
"JOYConstants",
".",
"CTIME",
",",
"String",
".",
"valueOf",
"(",
"date",
".",
"getTime",
"(",
")",
")",
")",
";",
"registryOperations",
".",
"bind",
"(",
"hostPath",
",",
"sr",
",",
"BindFlags",
".",
"OVERWRITE",
")",
";",
"return",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"can't get host lock\"",
")",
";",
"}"
] | see if anyone is updating host's port list, if not start , update this host itself
timeout is 45 seconds
@param hostPath
@throws InterruptedException
@throws IOException | [
"see",
"if",
"anyone",
"is",
"updating",
"host",
"s",
"port",
"list",
"if",
"not",
"start",
"update",
"this",
"host",
"itself",
"timeout",
"is",
"45",
"seconds"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-on-yarn/src/main/java/com/alibaba/jstorm/yarn/registry/SlotPortsView.java#L193-L225 |
25,428 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.getTaskEntities | public static List<TaskEntity> getTaskEntities(TopologyInfo topologyInfo) {
Map<Integer, TaskEntity> tasks = new HashMap<>();
for (TaskSummary ts : topologyInfo.get_tasks()) {
tasks.put(ts.get_taskId(), new TaskEntity(ts));
}
for (ComponentSummary cs : topologyInfo.get_components()) {
String compName = cs.get_name();
String type = cs.get_type();
for (int id : cs.get_taskIds()) {
if (tasks.containsKey(id)) {
tasks.get(id).setComponent(compName);
tasks.get(id).setType(type);
} else {
LOG.debug("missing task id:{}", id);
}
}
}
return new ArrayList<>(tasks.values());
} | java | public static List<TaskEntity> getTaskEntities(TopologyInfo topologyInfo) {
Map<Integer, TaskEntity> tasks = new HashMap<>();
for (TaskSummary ts : topologyInfo.get_tasks()) {
tasks.put(ts.get_taskId(), new TaskEntity(ts));
}
for (ComponentSummary cs : topologyInfo.get_components()) {
String compName = cs.get_name();
String type = cs.get_type();
for (int id : cs.get_taskIds()) {
if (tasks.containsKey(id)) {
tasks.get(id).setComponent(compName);
tasks.get(id).setType(type);
} else {
LOG.debug("missing task id:{}", id);
}
}
}
return new ArrayList<>(tasks.values());
} | [
"public",
"static",
"List",
"<",
"TaskEntity",
">",
"getTaskEntities",
"(",
"TopologyInfo",
"topologyInfo",
")",
"{",
"Map",
"<",
"Integer",
",",
"TaskEntity",
">",
"tasks",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"TaskSummary",
"ts",
":",
"topologyInfo",
".",
"get_tasks",
"(",
")",
")",
"{",
"tasks",
".",
"put",
"(",
"ts",
".",
"get_taskId",
"(",
")",
",",
"new",
"TaskEntity",
"(",
"ts",
")",
")",
";",
"}",
"for",
"(",
"ComponentSummary",
"cs",
":",
"topologyInfo",
".",
"get_components",
"(",
")",
")",
"{",
"String",
"compName",
"=",
"cs",
".",
"get_name",
"(",
")",
";",
"String",
"type",
"=",
"cs",
".",
"get_type",
"(",
")",
";",
"for",
"(",
"int",
"id",
":",
"cs",
".",
"get_taskIds",
"(",
")",
")",
"{",
"if",
"(",
"tasks",
".",
"containsKey",
"(",
"id",
")",
")",
"{",
"tasks",
".",
"get",
"(",
"id",
")",
".",
"setComponent",
"(",
"compName",
")",
";",
"tasks",
".",
"get",
"(",
"id",
")",
".",
"setType",
"(",
"type",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"missing task id:{}\"",
",",
"id",
")",
";",
"}",
"}",
"}",
"return",
"new",
"ArrayList",
"<>",
"(",
"tasks",
".",
"values",
"(",
")",
")",
";",
"}"
] | get all task entities in the specific topology
@param topologyInfo topology info
@return the list of task entities | [
"get",
"all",
"task",
"entities",
"in",
"the",
"specific",
"topology"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L228-L246 |
25,429 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.getTaskEntities | public static List<TaskEntity> getTaskEntities(TopologyInfo topologyInfo, String componentName) {
TreeMap<Integer, TaskEntity> tasks = new TreeMap<>();
for (ComponentSummary cs : topologyInfo.get_components()) {
String compName = cs.get_name();
String type = cs.get_type();
if (componentName.equals(compName)) {
for (int id : cs.get_taskIds()) {
tasks.put(id, new TaskEntity(id, compName, type));
}
}
}
for (TaskSummary ts : topologyInfo.get_tasks()) {
if (tasks.containsKey(ts.get_taskId())) {
TaskEntity te = tasks.get(ts.get_taskId());
te.setHost(ts.get_host());
te.setPort(ts.get_port());
te.setStatus(ts.get_status());
te.setUptime(ts.get_uptime());
te.setErrors(ts.get_errors());
}
}
return new ArrayList<>(tasks.values());
} | java | public static List<TaskEntity> getTaskEntities(TopologyInfo topologyInfo, String componentName) {
TreeMap<Integer, TaskEntity> tasks = new TreeMap<>();
for (ComponentSummary cs : topologyInfo.get_components()) {
String compName = cs.get_name();
String type = cs.get_type();
if (componentName.equals(compName)) {
for (int id : cs.get_taskIds()) {
tasks.put(id, new TaskEntity(id, compName, type));
}
}
}
for (TaskSummary ts : topologyInfo.get_tasks()) {
if (tasks.containsKey(ts.get_taskId())) {
TaskEntity te = tasks.get(ts.get_taskId());
te.setHost(ts.get_host());
te.setPort(ts.get_port());
te.setStatus(ts.get_status());
te.setUptime(ts.get_uptime());
te.setErrors(ts.get_errors());
}
}
return new ArrayList<>(tasks.values());
} | [
"public",
"static",
"List",
"<",
"TaskEntity",
">",
"getTaskEntities",
"(",
"TopologyInfo",
"topologyInfo",
",",
"String",
"componentName",
")",
"{",
"TreeMap",
"<",
"Integer",
",",
"TaskEntity",
">",
"tasks",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"for",
"(",
"ComponentSummary",
"cs",
":",
"topologyInfo",
".",
"get_components",
"(",
")",
")",
"{",
"String",
"compName",
"=",
"cs",
".",
"get_name",
"(",
")",
";",
"String",
"type",
"=",
"cs",
".",
"get_type",
"(",
")",
";",
"if",
"(",
"componentName",
".",
"equals",
"(",
"compName",
")",
")",
"{",
"for",
"(",
"int",
"id",
":",
"cs",
".",
"get_taskIds",
"(",
")",
")",
"{",
"tasks",
".",
"put",
"(",
"id",
",",
"new",
"TaskEntity",
"(",
"id",
",",
"compName",
",",
"type",
")",
")",
";",
"}",
"}",
"}",
"for",
"(",
"TaskSummary",
"ts",
":",
"topologyInfo",
".",
"get_tasks",
"(",
")",
")",
"{",
"if",
"(",
"tasks",
".",
"containsKey",
"(",
"ts",
".",
"get_taskId",
"(",
")",
")",
")",
"{",
"TaskEntity",
"te",
"=",
"tasks",
".",
"get",
"(",
"ts",
".",
"get_taskId",
"(",
")",
")",
";",
"te",
".",
"setHost",
"(",
"ts",
".",
"get_host",
"(",
")",
")",
";",
"te",
".",
"setPort",
"(",
"ts",
".",
"get_port",
"(",
")",
")",
";",
"te",
".",
"setStatus",
"(",
"ts",
".",
"get_status",
"(",
")",
")",
";",
"te",
".",
"setUptime",
"(",
"ts",
".",
"get_uptime",
"(",
")",
")",
";",
"te",
".",
"setErrors",
"(",
"ts",
".",
"get_errors",
"(",
")",
")",
";",
"}",
"}",
"return",
"new",
"ArrayList",
"<>",
"(",
"tasks",
".",
"values",
"(",
")",
")",
";",
"}"
] | get the task entities in the specific component
@param topologyInfo topology info
@param componentName component name
@return the list of task entities | [
"get",
"the",
"task",
"entities",
"in",
"the",
"specific",
"component"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L254-L279 |
25,430 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.getTaskEntity | public static TaskEntity getTaskEntity(List<TaskSummary> tasks, int taskId) {
TaskEntity entity = null;
for (TaskSummary task : tasks) {
if (task.get_taskId() == taskId) {
entity = new TaskEntity(task);
break;
}
}
return entity;
} | java | public static TaskEntity getTaskEntity(List<TaskSummary> tasks, int taskId) {
TaskEntity entity = null;
for (TaskSummary task : tasks) {
if (task.get_taskId() == taskId) {
entity = new TaskEntity(task);
break;
}
}
return entity;
} | [
"public",
"static",
"TaskEntity",
"getTaskEntity",
"(",
"List",
"<",
"TaskSummary",
">",
"tasks",
",",
"int",
"taskId",
")",
"{",
"TaskEntity",
"entity",
"=",
"null",
";",
"for",
"(",
"TaskSummary",
"task",
":",
"tasks",
")",
"{",
"if",
"(",
"task",
".",
"get_taskId",
"(",
")",
"==",
"taskId",
")",
"{",
"entity",
"=",
"new",
"TaskEntity",
"(",
"task",
")",
";",
"break",
";",
"}",
"}",
"return",
"entity",
";",
"}"
] | get the specific task entity
@param tasks list of task summaries
@param taskId task id
@return | [
"get",
"the",
"specific",
"task",
"entity"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L288-L297 |
25,431 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.resetZKConfig | public static Map resetZKConfig(Map conf, String clusterName) {
ClusterConfig nimbus = clusterConfig.get(clusterName);
if (nimbus == null) return conf;
conf.put(Config.STORM_ZOOKEEPER_ROOT, nimbus.getZkRoot());
conf.put(Config.STORM_ZOOKEEPER_SERVERS, nimbus.getZkServers());
conf.put(Config.STORM_ZOOKEEPER_PORT, nimbus.getZkPort());
return conf;
} | java | public static Map resetZKConfig(Map conf, String clusterName) {
ClusterConfig nimbus = clusterConfig.get(clusterName);
if (nimbus == null) return conf;
conf.put(Config.STORM_ZOOKEEPER_ROOT, nimbus.getZkRoot());
conf.put(Config.STORM_ZOOKEEPER_SERVERS, nimbus.getZkServers());
conf.put(Config.STORM_ZOOKEEPER_PORT, nimbus.getZkPort());
return conf;
} | [
"public",
"static",
"Map",
"resetZKConfig",
"(",
"Map",
"conf",
",",
"String",
"clusterName",
")",
"{",
"ClusterConfig",
"nimbus",
"=",
"clusterConfig",
".",
"get",
"(",
"clusterName",
")",
";",
"if",
"(",
"nimbus",
"==",
"null",
")",
"return",
"conf",
";",
"conf",
".",
"put",
"(",
"Config",
".",
"STORM_ZOOKEEPER_ROOT",
",",
"nimbus",
".",
"getZkRoot",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"Config",
".",
"STORM_ZOOKEEPER_SERVERS",
",",
"nimbus",
".",
"getZkServers",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"Config",
".",
"STORM_ZOOKEEPER_PORT",
",",
"nimbus",
".",
"getZkPort",
"(",
")",
")",
";",
"return",
"conf",
";",
"}"
] | to get nimbus client, we should reset ZK config | [
"to",
"get",
"nimbus",
"client",
"we",
"should",
"reset",
"ZK",
"config"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L417-L424 |
25,432 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.prettyUptime | public static String prettyUptime(int secs) {
String[][] PRETTYSECDIVIDERS = { new String[] { "s", "60" }, new String[] { "m", "60" }, new String[] { "h", "24" },
new String[] { "d", null } };
int diversize = PRETTYSECDIVIDERS.length;
LinkedList<String> tmp = new LinkedList<>();
int div = secs;
for (int i = 0; i < diversize; i++) {
if (PRETTYSECDIVIDERS[i][1] != null) {
Integer d = Integer.parseInt(PRETTYSECDIVIDERS[i][1]);
tmp.addFirst(div % d + PRETTYSECDIVIDERS[i][0]);
div = div / d;
} else {
tmp.addFirst(div + PRETTYSECDIVIDERS[i][0]);
}
if (div <= 0 ) break;
}
Joiner joiner = Joiner.on(" ");
return joiner.join(tmp);
} | java | public static String prettyUptime(int secs) {
String[][] PRETTYSECDIVIDERS = { new String[] { "s", "60" }, new String[] { "m", "60" }, new String[] { "h", "24" },
new String[] { "d", null } };
int diversize = PRETTYSECDIVIDERS.length;
LinkedList<String> tmp = new LinkedList<>();
int div = secs;
for (int i = 0; i < diversize; i++) {
if (PRETTYSECDIVIDERS[i][1] != null) {
Integer d = Integer.parseInt(PRETTYSECDIVIDERS[i][1]);
tmp.addFirst(div % d + PRETTYSECDIVIDERS[i][0]);
div = div / d;
} else {
tmp.addFirst(div + PRETTYSECDIVIDERS[i][0]);
}
if (div <= 0 ) break;
}
Joiner joiner = Joiner.on(" ");
return joiner.join(tmp);
} | [
"public",
"static",
"String",
"prettyUptime",
"(",
"int",
"secs",
")",
"{",
"String",
"[",
"]",
"[",
"]",
"PRETTYSECDIVIDERS",
"=",
"{",
"new",
"String",
"[",
"]",
"{",
"\"s\"",
",",
"\"60\"",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"\"m\"",
",",
"\"60\"",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"\"h\"",
",",
"\"24\"",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"\"d\"",
",",
"null",
"}",
"}",
";",
"int",
"diversize",
"=",
"PRETTYSECDIVIDERS",
".",
"length",
";",
"LinkedList",
"<",
"String",
">",
"tmp",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"int",
"div",
"=",
"secs",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"diversize",
";",
"i",
"++",
")",
"{",
"if",
"(",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"1",
"]",
"!=",
"null",
")",
"{",
"Integer",
"d",
"=",
"Integer",
".",
"parseInt",
"(",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"tmp",
".",
"addFirst",
"(",
"div",
"%",
"d",
"+",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"0",
"]",
")",
";",
"div",
"=",
"div",
"/",
"d",
";",
"}",
"else",
"{",
"tmp",
".",
"addFirst",
"(",
"div",
"+",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"div",
"<=",
"0",
")",
"break",
";",
"}",
"Joiner",
"joiner",
"=",
"Joiner",
".",
"on",
"(",
"\" \"",
")",
";",
"return",
"joiner",
".",
"join",
"(",
"tmp",
")",
";",
"}"
] | seconds to string like '30m 40s' and '1d 20h 30m 40s'
@param secs
@return | [
"seconds",
"to",
"string",
"like",
"30m",
"40s",
"and",
"1d",
"20h",
"30m",
"40s"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L458-L478 |
25,433 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.parseLong | public static Long parseLong(String s, long defaultValue) {
try {
Long value = Long.parseLong(s);
return value;
} catch (NumberFormatException e) {
//do nothing
}
return defaultValue;
} | java | public static Long parseLong(String s, long defaultValue) {
try {
Long value = Long.parseLong(s);
return value;
} catch (NumberFormatException e) {
//do nothing
}
return defaultValue;
} | [
"public",
"static",
"Long",
"parseLong",
"(",
"String",
"s",
",",
"long",
"defaultValue",
")",
"{",
"try",
"{",
"Long",
"value",
"=",
"Long",
".",
"parseLong",
"(",
"s",
")",
";",
"return",
"value",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"//do nothing",
"}",
"return",
"defaultValue",
";",
"}"
] | return the default value instead of throw an exception | [
"return",
"the",
"default",
"value",
"instead",
"of",
"throw",
"an",
"exception"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L497-L505 |
25,434 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.fillValue2Node | private static void fillValue2Node(List<MetricInfo> componentMetrics, Map<String, TopologyNode> nodes) {
String NODE_DIM = MetricDef.EMMITTED_NUM;
List<String> FILTER = Arrays.asList(MetricDef.EMMITTED_NUM, MetricDef.SEND_TPS, MetricDef.RECV_TPS);
for (MetricInfo info : componentMetrics) {
if (info == null) continue;
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
String name = metric.getKey();
String[] split_name = name.split("@");
String metricName = UIMetricUtils.extractMetricName(split_name);
String compName = UIMetricUtils.extractComponentName(split_name);
TopologyNode node = nodes.get(compName);
if (node != null && FILTER.contains(metricName)) {
for (Map.Entry<Integer, MetricSnapshot> winData : metric.getValue().entrySet()) {
node.putMapValue(metricName, winData.getKey(),
UIMetricUtils.getMetricValue(winData.getValue()));
}
}
if (metricName == null || !metricName.equals(NODE_DIM)) {
continue;
}
//get 60 window metric
MetricSnapshot snapshot = metric.getValue().get(AsmWindow.M1_WINDOW);
if (node != null) {
node.setValue(snapshot.get_longValue());
nodes.get(compName).setTitle("Emitted: " + UIMetricUtils.getMetricValue(snapshot));
}
}
}
} | java | private static void fillValue2Node(List<MetricInfo> componentMetrics, Map<String, TopologyNode> nodes) {
String NODE_DIM = MetricDef.EMMITTED_NUM;
List<String> FILTER = Arrays.asList(MetricDef.EMMITTED_NUM, MetricDef.SEND_TPS, MetricDef.RECV_TPS);
for (MetricInfo info : componentMetrics) {
if (info == null) continue;
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
String name = metric.getKey();
String[] split_name = name.split("@");
String metricName = UIMetricUtils.extractMetricName(split_name);
String compName = UIMetricUtils.extractComponentName(split_name);
TopologyNode node = nodes.get(compName);
if (node != null && FILTER.contains(metricName)) {
for (Map.Entry<Integer, MetricSnapshot> winData : metric.getValue().entrySet()) {
node.putMapValue(metricName, winData.getKey(),
UIMetricUtils.getMetricValue(winData.getValue()));
}
}
if (metricName == null || !metricName.equals(NODE_DIM)) {
continue;
}
//get 60 window metric
MetricSnapshot snapshot = metric.getValue().get(AsmWindow.M1_WINDOW);
if (node != null) {
node.setValue(snapshot.get_longValue());
nodes.get(compName).setTitle("Emitted: " + UIMetricUtils.getMetricValue(snapshot));
}
}
}
} | [
"private",
"static",
"void",
"fillValue2Node",
"(",
"List",
"<",
"MetricInfo",
">",
"componentMetrics",
",",
"Map",
"<",
"String",
",",
"TopologyNode",
">",
"nodes",
")",
"{",
"String",
"NODE_DIM",
"=",
"MetricDef",
".",
"EMMITTED_NUM",
";",
"List",
"<",
"String",
">",
"FILTER",
"=",
"Arrays",
".",
"asList",
"(",
"MetricDef",
".",
"EMMITTED_NUM",
",",
"MetricDef",
".",
"SEND_TPS",
",",
"MetricDef",
".",
"RECV_TPS",
")",
";",
"for",
"(",
"MetricInfo",
"info",
":",
"componentMetrics",
")",
"{",
"if",
"(",
"info",
"==",
"null",
")",
"continue",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
">",
"metric",
":",
"info",
".",
"get_metrics",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"name",
"=",
"metric",
".",
"getKey",
"(",
")",
";",
"String",
"[",
"]",
"split_name",
"=",
"name",
".",
"split",
"(",
"\"@\"",
")",
";",
"String",
"metricName",
"=",
"UIMetricUtils",
".",
"extractMetricName",
"(",
"split_name",
")",
";",
"String",
"compName",
"=",
"UIMetricUtils",
".",
"extractComponentName",
"(",
"split_name",
")",
";",
"TopologyNode",
"node",
"=",
"nodes",
".",
"get",
"(",
"compName",
")",
";",
"if",
"(",
"node",
"!=",
"null",
"&&",
"FILTER",
".",
"contains",
"(",
"metricName",
")",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"winData",
":",
"metric",
".",
"getValue",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"node",
".",
"putMapValue",
"(",
"metricName",
",",
"winData",
".",
"getKey",
"(",
")",
",",
"UIMetricUtils",
".",
"getMetricValue",
"(",
"winData",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"metricName",
"==",
"null",
"||",
"!",
"metricName",
".",
"equals",
"(",
"NODE_DIM",
")",
")",
"{",
"continue",
";",
"}",
"//get 60 window metric",
"MetricSnapshot",
"snapshot",
"=",
"metric",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"AsmWindow",
".",
"M1_WINDOW",
")",
";",
"if",
"(",
"node",
"!=",
"null",
")",
"{",
"node",
".",
"setValue",
"(",
"snapshot",
".",
"get_longValue",
"(",
")",
")",
";",
"nodes",
".",
"get",
"(",
"compName",
")",
".",
"setTitle",
"(",
"\"Emitted: \"",
"+",
"UIMetricUtils",
".",
"getMetricValue",
"(",
"snapshot",
")",
")",
";",
"}",
"}",
"}",
"}"
] | fill emitted num to nodes | [
"fill",
"emitted",
"num",
"to",
"nodes"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L752-L784 |
25,435 | alibaba/jstorm | jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java | UIUtils.fillTLCValue2Edge | private static void fillTLCValue2Edge(List<MetricInfo> componentMetrics, Map<String, TopologyEdge> edges) {
String EDGE_DIM = "." + MetricDef.TUPLE_LIEF_CYCLE;
for (MetricInfo info : componentMetrics) {
if (info == null) continue;
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
String name = metric.getKey();
String[] split_name = name.split("@");
String metricName = UIMetricUtils.extractMetricName(split_name);
// only handle with `.TupleLifeCycle` metrics
if (metricName == null || !metricName.contains(EDGE_DIM)) {
continue;
}
String componentId = UIMetricUtils.extractComponentName(split_name);
String src = metricName.split("\\.")[0];
String key = src + ":" + componentId;
//get 60 window metric
MetricSnapshot snapshot = metric.getValue().get(AsmWindow.M1_WINDOW);
TopologyEdge edge = edges.get(key);
if (edge != null) {
double value = snapshot.get_mean() / 1000;
edge.setCycleValue(value);
edge.appendTitle("TupleLifeCycle: " +
UIMetricUtils.format.format(value) + "ms");
for (Map.Entry<Integer, MetricSnapshot> winData : metric.getValue().entrySet()) {
// put the tuple life cycle time , unit is ms
double v = winData.getValue().get_mean() / 1000;
edge.putMapValue(MetricDef.TUPLE_LIEF_CYCLE + "(ms)", winData.getKey(),
UIMetricUtils.format.format(v));
}
}
}
}
} | java | private static void fillTLCValue2Edge(List<MetricInfo> componentMetrics, Map<String, TopologyEdge> edges) {
String EDGE_DIM = "." + MetricDef.TUPLE_LIEF_CYCLE;
for (MetricInfo info : componentMetrics) {
if (info == null) continue;
for (Map.Entry<String, Map<Integer, MetricSnapshot>> metric : info.get_metrics().entrySet()) {
String name = metric.getKey();
String[] split_name = name.split("@");
String metricName = UIMetricUtils.extractMetricName(split_name);
// only handle with `.TupleLifeCycle` metrics
if (metricName == null || !metricName.contains(EDGE_DIM)) {
continue;
}
String componentId = UIMetricUtils.extractComponentName(split_name);
String src = metricName.split("\\.")[0];
String key = src + ":" + componentId;
//get 60 window metric
MetricSnapshot snapshot = metric.getValue().get(AsmWindow.M1_WINDOW);
TopologyEdge edge = edges.get(key);
if (edge != null) {
double value = snapshot.get_mean() / 1000;
edge.setCycleValue(value);
edge.appendTitle("TupleLifeCycle: " +
UIMetricUtils.format.format(value) + "ms");
for (Map.Entry<Integer, MetricSnapshot> winData : metric.getValue().entrySet()) {
// put the tuple life cycle time , unit is ms
double v = winData.getValue().get_mean() / 1000;
edge.putMapValue(MetricDef.TUPLE_LIEF_CYCLE + "(ms)", winData.getKey(),
UIMetricUtils.format.format(v));
}
}
}
}
} | [
"private",
"static",
"void",
"fillTLCValue2Edge",
"(",
"List",
"<",
"MetricInfo",
">",
"componentMetrics",
",",
"Map",
"<",
"String",
",",
"TopologyEdge",
">",
"edges",
")",
"{",
"String",
"EDGE_DIM",
"=",
"\".\"",
"+",
"MetricDef",
".",
"TUPLE_LIEF_CYCLE",
";",
"for",
"(",
"MetricInfo",
"info",
":",
"componentMetrics",
")",
"{",
"if",
"(",
"info",
"==",
"null",
")",
"continue",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
">",
"metric",
":",
"info",
".",
"get_metrics",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"name",
"=",
"metric",
".",
"getKey",
"(",
")",
";",
"String",
"[",
"]",
"split_name",
"=",
"name",
".",
"split",
"(",
"\"@\"",
")",
";",
"String",
"metricName",
"=",
"UIMetricUtils",
".",
"extractMetricName",
"(",
"split_name",
")",
";",
"// only handle with `.TupleLifeCycle` metrics",
"if",
"(",
"metricName",
"==",
"null",
"||",
"!",
"metricName",
".",
"contains",
"(",
"EDGE_DIM",
")",
")",
"{",
"continue",
";",
"}",
"String",
"componentId",
"=",
"UIMetricUtils",
".",
"extractComponentName",
"(",
"split_name",
")",
";",
"String",
"src",
"=",
"metricName",
".",
"split",
"(",
"\"\\\\.\"",
")",
"[",
"0",
"]",
";",
"String",
"key",
"=",
"src",
"+",
"\":\"",
"+",
"componentId",
";",
"//get 60 window metric",
"MetricSnapshot",
"snapshot",
"=",
"metric",
".",
"getValue",
"(",
")",
".",
"get",
"(",
"AsmWindow",
".",
"M1_WINDOW",
")",
";",
"TopologyEdge",
"edge",
"=",
"edges",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"edge",
"!=",
"null",
")",
"{",
"double",
"value",
"=",
"snapshot",
".",
"get_mean",
"(",
")",
"/",
"1000",
";",
"edge",
".",
"setCycleValue",
"(",
"value",
")",
";",
"edge",
".",
"appendTitle",
"(",
"\"TupleLifeCycle: \"",
"+",
"UIMetricUtils",
".",
"format",
".",
"format",
"(",
"value",
")",
"+",
"\"ms\"",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"winData",
":",
"metric",
".",
"getValue",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"// put the tuple life cycle time , unit is ms",
"double",
"v",
"=",
"winData",
".",
"getValue",
"(",
")",
".",
"get_mean",
"(",
")",
"/",
"1000",
";",
"edge",
".",
"putMapValue",
"(",
"MetricDef",
".",
"TUPLE_LIEF_CYCLE",
"+",
"\"(ms)\"",
",",
"winData",
".",
"getKey",
"(",
")",
",",
"UIMetricUtils",
".",
"format",
".",
"format",
"(",
"v",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | fill tuple life cycle time to edges | [
"fill",
"tuple",
"life",
"cycle",
"time",
"to",
"edges"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-ui/src/main/java/com/alibaba/jstorm/ui/utils/UIUtils.java#L787-L822 |
25,436 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.setBolt | public BoltDeclarer setBolt(String id, BaseWindowedBolt<Tuple> bolt, Number parallelism_hint) throws
IllegalArgumentException {
boolean isEventTime = WindowAssigner.isEventTime(bolt.getWindowAssigner());
if (isEventTime && bolt.getTimestampExtractor() == null) {
throw new IllegalArgumentException("timestamp extractor must be defined in event time!");
}
return setBolt(id, new WindowedBoltExecutor(bolt), parallelism_hint);
} | java | public BoltDeclarer setBolt(String id, BaseWindowedBolt<Tuple> bolt, Number parallelism_hint) throws
IllegalArgumentException {
boolean isEventTime = WindowAssigner.isEventTime(bolt.getWindowAssigner());
if (isEventTime && bolt.getTimestampExtractor() == null) {
throw new IllegalArgumentException("timestamp extractor must be defined in event time!");
}
return setBolt(id, new WindowedBoltExecutor(bolt), parallelism_hint);
} | [
"public",
"BoltDeclarer",
"setBolt",
"(",
"String",
"id",
",",
"BaseWindowedBolt",
"<",
"Tuple",
">",
"bolt",
",",
"Number",
"parallelism_hint",
")",
"throws",
"IllegalArgumentException",
"{",
"boolean",
"isEventTime",
"=",
"WindowAssigner",
".",
"isEventTime",
"(",
"bolt",
".",
"getWindowAssigner",
"(",
")",
")",
";",
"if",
"(",
"isEventTime",
"&&",
"bolt",
".",
"getTimestampExtractor",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"timestamp extractor must be defined in event time!\"",
")",
";",
"}",
"return",
"setBolt",
"(",
"id",
",",
"new",
"WindowedBoltExecutor",
"(",
"bolt",
")",
",",
"parallelism_hint",
")",
";",
"}"
] | Define a new bolt in this topology. This defines a windowed bolt, intended
for windowing operations.
@param id the id of this component. This id is referenced by other components that want to consume this bolt's outputs.
@param bolt the windowed bolt
@param parallelism_hint the number of tasks that should be assigned to execute this bolt. Each task will run on a thread in a process somwehere around the cluster.
@return use the returned object to declare the inputs to this component
@throws IllegalArgumentException if {@code parallelism_hint} is not positive | [
"Define",
"a",
"new",
"bolt",
"in",
"this",
"topology",
".",
"This",
"defines",
"a",
"windowed",
"bolt",
"intended",
"for",
"windowing",
"operations",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L253-L260 |
25,437 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.setSpout | public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism_hint) throws IllegalArgumentException {
validateUnusedId(id);
initCommon(id, spout, parallelism_hint);
_spouts.put(id, spout);
return new SpoutGetter(id);
} | java | public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelism_hint) throws IllegalArgumentException {
validateUnusedId(id);
initCommon(id, spout, parallelism_hint);
_spouts.put(id, spout);
return new SpoutGetter(id);
} | [
"public",
"SpoutDeclarer",
"setSpout",
"(",
"String",
"id",
",",
"IRichSpout",
"spout",
",",
"Number",
"parallelism_hint",
")",
"throws",
"IllegalArgumentException",
"{",
"validateUnusedId",
"(",
"id",
")",
";",
"initCommon",
"(",
"id",
",",
"spout",
",",
"parallelism_hint",
")",
";",
"_spouts",
".",
"put",
"(",
"id",
",",
"spout",
")",
";",
"return",
"new",
"SpoutGetter",
"(",
"id",
")",
";",
"}"
] | Define a new spout in this topology with the specified parallelism. If the spout declares
itself as non-distributed, the parallelism_hint will be ignored and only one task
will be allocated to this component.
@param id the id of this component. This id is referenced by other components that want to consume this spout's outputs.
@param parallelism_hint the number of tasks that should be assigned to execute this spout. Each task will run on a thread in a process somewhere around the cluster.
@param spout the spout
@throws IllegalArgumentException if {@code parallelism_hint} is not positive | [
"Define",
"a",
"new",
"spout",
"in",
"this",
"topology",
"with",
"the",
"specified",
"parallelism",
".",
"If",
"the",
"spout",
"declares",
"itself",
"as",
"non",
"-",
"distributed",
"the",
"parallelism_hint",
"will",
"be",
"ignored",
"and",
"only",
"one",
"task",
"will",
"be",
"allocated",
"to",
"this",
"component",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L321-L326 |
25,438 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.setSpout | public SpoutDeclarer setSpout(String id, IControlSpout spout) {
return setSpout(id, spout, null);
} | java | public SpoutDeclarer setSpout(String id, IControlSpout spout) {
return setSpout(id, spout, null);
} | [
"public",
"SpoutDeclarer",
"setSpout",
"(",
"String",
"id",
",",
"IControlSpout",
"spout",
")",
"{",
"return",
"setSpout",
"(",
"id",
",",
"spout",
",",
"null",
")",
";",
"}"
] | Define a new bolt in this topology. This defines a control spout, which is a simpler to use but more restricted kind of bolt. Control spouts are intended for
making sending control message more simply
@param id the id of this component.
@param spout the control spout | [
"Define",
"a",
"new",
"bolt",
"in",
"this",
"topology",
".",
"This",
"defines",
"a",
"control",
"spout",
"which",
"is",
"a",
"simpler",
"to",
"use",
"but",
"more",
"restricted",
"kind",
"of",
"bolt",
".",
"Control",
"spouts",
"are",
"intended",
"for",
"making",
"sending",
"control",
"message",
"more",
"simply"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L335-L337 |
25,439 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.setBolt | public BoltDeclarer setBolt(String id, IControlBolt bolt, Number parallelism_hint) {
return setBolt(id, new ControlBoltExecutor(bolt), parallelism_hint);
} | java | public BoltDeclarer setBolt(String id, IControlBolt bolt, Number parallelism_hint) {
return setBolt(id, new ControlBoltExecutor(bolt), parallelism_hint);
} | [
"public",
"BoltDeclarer",
"setBolt",
"(",
"String",
"id",
",",
"IControlBolt",
"bolt",
",",
"Number",
"parallelism_hint",
")",
"{",
"return",
"setBolt",
"(",
"id",
",",
"new",
"ControlBoltExecutor",
"(",
"bolt",
")",
",",
"parallelism_hint",
")",
";",
"}"
] | Define a new bolt in this topology. This defines a control bolt, which is a simpler to use but more restricted kind of bolt. Control bolts are intended for
making sending control message more simply
@param id the id of this component. This id is referenced by other components that want to consume this bolt's outputs.
@param bolt the control bolt
@param parallelism_hint the number of tasks that should be assigned to execute this bolt. Each task will run on a thread in a process somwehere around
the cluster.
@return use the returned object to declare the inputs to this component | [
"Define",
"a",
"new",
"bolt",
"in",
"this",
"topology",
".",
"This",
"defines",
"a",
"control",
"bolt",
"which",
"is",
"a",
"simpler",
"to",
"use",
"but",
"more",
"restricted",
"kind",
"of",
"bolt",
".",
"Control",
"bolts",
"are",
"intended",
"for",
"making",
"sending",
"control",
"message",
"more",
"simply"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L350-L352 |
25,440 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.addWorkerHook | public void addWorkerHook(IWorkerHook workerHook) {
if(null == workerHook) {
throw new IllegalArgumentException("WorkerHook must not be null.");
}
_workerHooks.add(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));
} | java | public void addWorkerHook(IWorkerHook workerHook) {
if(null == workerHook) {
throw new IllegalArgumentException("WorkerHook must not be null.");
}
_workerHooks.add(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));
} | [
"public",
"void",
"addWorkerHook",
"(",
"IWorkerHook",
"workerHook",
")",
"{",
"if",
"(",
"null",
"==",
"workerHook",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"WorkerHook must not be null.\"",
")",
";",
"}",
"_workerHooks",
".",
"add",
"(",
"ByteBuffer",
".",
"wrap",
"(",
"Utils",
".",
"javaSerialize",
"(",
"workerHook",
")",
")",
")",
";",
"}"
] | Add a new worker lifecycle hook
@param workerHook the lifecycle hook to add | [
"Add",
"a",
"new",
"worker",
"lifecycle",
"hook"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L372-L378 |
25,441 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java | TopologyBuilder.maybeAddWatermarkInputs | private void maybeAddWatermarkInputs(ComponentCommon common, IRichBolt bolt) {
if (bolt instanceof WindowedBoltExecutor) {
Set<String> comps = new HashSet<>();
for (GlobalStreamId globalStreamId : common.get_inputs().keySet()) {
comps.add(globalStreamId.get_componentId());
}
for (String comp : comps) {
common.put_to_inputs(
new GlobalStreamId(comp, Common.WATERMARK_STREAM_ID),
Grouping.all(new NullStruct()));
}
}
} | java | private void maybeAddWatermarkInputs(ComponentCommon common, IRichBolt bolt) {
if (bolt instanceof WindowedBoltExecutor) {
Set<String> comps = new HashSet<>();
for (GlobalStreamId globalStreamId : common.get_inputs().keySet()) {
comps.add(globalStreamId.get_componentId());
}
for (String comp : comps) {
common.put_to_inputs(
new GlobalStreamId(comp, Common.WATERMARK_STREAM_ID),
Grouping.all(new NullStruct()));
}
}
} | [
"private",
"void",
"maybeAddWatermarkInputs",
"(",
"ComponentCommon",
"common",
",",
"IRichBolt",
"bolt",
")",
"{",
"if",
"(",
"bolt",
"instanceof",
"WindowedBoltExecutor",
")",
"{",
"Set",
"<",
"String",
">",
"comps",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"GlobalStreamId",
"globalStreamId",
":",
"common",
".",
"get_inputs",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"comps",
".",
"add",
"(",
"globalStreamId",
".",
"get_componentId",
"(",
")",
")",
";",
"}",
"for",
"(",
"String",
"comp",
":",
"comps",
")",
"{",
"common",
".",
"put_to_inputs",
"(",
"new",
"GlobalStreamId",
"(",
"comp",
",",
"Common",
".",
"WATERMARK_STREAM_ID",
")",
",",
"Grouping",
".",
"all",
"(",
"new",
"NullStruct",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Add watermark stream to source components of window bolts | [
"Add",
"watermark",
"stream",
"to",
"source",
"components",
"of",
"window",
"bolts"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/TopologyBuilder.java#L412-L425 |
25,442 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/StatBuckets.java | StatBuckets.getShowTimeStr | public static String getShowTimeStr(Integer time) {
if (time == null) {
return MINUTE_WINDOW_STR;
} else if (time.equals(MINUTE_WINDOW)) {
return MINUTE_WINDOW_STR;
} else if (time.equals(HOUR_WINDOW)) {
return HOUR_WINDOW_STR;
} else if (time.equals(DAY_WINDOW)) {
return DAY_WINDOW_STR;
} else if (time.equals(ALL_TIME_WINDOW)) {
return ALL_WINDOW_STR;
} else {
return MINUTE_WINDOW_STR;
}
} | java | public static String getShowTimeStr(Integer time) {
if (time == null) {
return MINUTE_WINDOW_STR;
} else if (time.equals(MINUTE_WINDOW)) {
return MINUTE_WINDOW_STR;
} else if (time.equals(HOUR_WINDOW)) {
return HOUR_WINDOW_STR;
} else if (time.equals(DAY_WINDOW)) {
return DAY_WINDOW_STR;
} else if (time.equals(ALL_TIME_WINDOW)) {
return ALL_WINDOW_STR;
} else {
return MINUTE_WINDOW_STR;
}
} | [
"public",
"static",
"String",
"getShowTimeStr",
"(",
"Integer",
"time",
")",
"{",
"if",
"(",
"time",
"==",
"null",
")",
"{",
"return",
"MINUTE_WINDOW_STR",
";",
"}",
"else",
"if",
"(",
"time",
".",
"equals",
"(",
"MINUTE_WINDOW",
")",
")",
"{",
"return",
"MINUTE_WINDOW_STR",
";",
"}",
"else",
"if",
"(",
"time",
".",
"equals",
"(",
"HOUR_WINDOW",
")",
")",
"{",
"return",
"HOUR_WINDOW_STR",
";",
"}",
"else",
"if",
"(",
"time",
".",
"equals",
"(",
"DAY_WINDOW",
")",
")",
"{",
"return",
"DAY_WINDOW_STR",
";",
"}",
"else",
"if",
"(",
"time",
".",
"equals",
"(",
"ALL_TIME_WINDOW",
")",
")",
"{",
"return",
"ALL_WINDOW_STR",
";",
"}",
"else",
"{",
"return",
"MINUTE_WINDOW_STR",
";",
"}",
"}"
] | Default is the latest result
@param showStr
@return | [
"Default",
"is",
"the",
"latest",
"result"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/StatBuckets.java#L96-L111 |
25,443 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/StatBuckets.java | StatBuckets.prettyUptimeStr | public static String prettyUptimeStr(int secs) {
int diversize = PRETTYSECDIVIDERS.length;
List<String> tmp = new ArrayList<String>();
int div = secs;
for (int i = 0; i < diversize; i++) {
if (PRETTYSECDIVIDERS[i][1] != null) {
Integer d = Integer.parseInt(PRETTYSECDIVIDERS[i][1]);
tmp.add(div % d + PRETTYSECDIVIDERS[i][0]);
div = div / d;
} else {
tmp.add(div + PRETTYSECDIVIDERS[i][0]);
}
}
String rtn = "";
int tmpSzie = tmp.size();
for (int j = tmpSzie - 1; j > -1; j--) {
rtn += tmp.get(j);
}
return rtn;
} | java | public static String prettyUptimeStr(int secs) {
int diversize = PRETTYSECDIVIDERS.length;
List<String> tmp = new ArrayList<String>();
int div = secs;
for (int i = 0; i < diversize; i++) {
if (PRETTYSECDIVIDERS[i][1] != null) {
Integer d = Integer.parseInt(PRETTYSECDIVIDERS[i][1]);
tmp.add(div % d + PRETTYSECDIVIDERS[i][0]);
div = div / d;
} else {
tmp.add(div + PRETTYSECDIVIDERS[i][0]);
}
}
String rtn = "";
int tmpSzie = tmp.size();
for (int j = tmpSzie - 1; j > -1; j--) {
rtn += tmp.get(j);
}
return rtn;
} | [
"public",
"static",
"String",
"prettyUptimeStr",
"(",
"int",
"secs",
")",
"{",
"int",
"diversize",
"=",
"PRETTYSECDIVIDERS",
".",
"length",
";",
"List",
"<",
"String",
">",
"tmp",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"int",
"div",
"=",
"secs",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"diversize",
";",
"i",
"++",
")",
"{",
"if",
"(",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"1",
"]",
"!=",
"null",
")",
"{",
"Integer",
"d",
"=",
"Integer",
".",
"parseInt",
"(",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"tmp",
".",
"add",
"(",
"div",
"%",
"d",
"+",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"0",
"]",
")",
";",
"div",
"=",
"div",
"/",
"d",
";",
"}",
"else",
"{",
"tmp",
".",
"add",
"(",
"div",
"+",
"PRETTYSECDIVIDERS",
"[",
"i",
"]",
"[",
"0",
"]",
")",
";",
"}",
"}",
"String",
"rtn",
"=",
"\"\"",
";",
"int",
"tmpSzie",
"=",
"tmp",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"tmpSzie",
"-",
"1",
";",
"j",
">",
"-",
"1",
";",
"j",
"--",
")",
"{",
"rtn",
"+=",
"tmp",
".",
"get",
"(",
"j",
")",
";",
"}",
"return",
"rtn",
";",
"}"
] | seconds to string like 1d20h30m40s
@param secs
@return | [
"seconds",
"to",
"string",
"like",
"1d20h30m40s"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/StatBuckets.java#L119-L140 |
25,444 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/util/TridentUtils.java | TridentUtils.getParents | public static <T> List<T> getParents(DirectedGraph g, T n) {
List<IndexedEdge> incoming = new ArrayList(g.incomingEdgesOf(n));
Collections.sort(incoming);
List<T> ret = new ArrayList();
for(IndexedEdge e: incoming) {
ret.add((T)e.source);
}
return ret;
} | java | public static <T> List<T> getParents(DirectedGraph g, T n) {
List<IndexedEdge> incoming = new ArrayList(g.incomingEdgesOf(n));
Collections.sort(incoming);
List<T> ret = new ArrayList();
for(IndexedEdge e: incoming) {
ret.add((T)e.source);
}
return ret;
} | [
"public",
"static",
"<",
"T",
">",
"List",
"<",
"T",
">",
"getParents",
"(",
"DirectedGraph",
"g",
",",
"T",
"n",
")",
"{",
"List",
"<",
"IndexedEdge",
">",
"incoming",
"=",
"new",
"ArrayList",
"(",
"g",
".",
"incomingEdgesOf",
"(",
"n",
")",
")",
";",
"Collections",
".",
"sort",
"(",
"incoming",
")",
";",
"List",
"<",
"T",
">",
"ret",
"=",
"new",
"ArrayList",
"(",
")",
";",
"for",
"(",
"IndexedEdge",
"e",
":",
"incoming",
")",
"{",
"ret",
".",
"add",
"(",
"(",
"T",
")",
"e",
".",
"source",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | Assumes edge contains an index | [
"Assumes",
"edge",
"contains",
"an",
"index"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/util/TridentUtils.java#L79-L87 |
25,445 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/schedule/default_assign/DefaultTopologyScheduler.java | DefaultTopologyScheduler.getKeepAssign | public Set<ResourceWorkerSlot> getKeepAssign(DefaultTopologyAssignContext defaultContext, Set<Integer> needAssigns) {
Set<Integer> keepAssignIds = new HashSet<>();
keepAssignIds.addAll(defaultContext.getAllTaskIds());
keepAssignIds.removeAll(defaultContext.getUnstoppedTaskIds());
keepAssignIds.removeAll(needAssigns);
Set<ResourceWorkerSlot> keeps = new HashSet<>();
if (keepAssignIds.isEmpty()) {
return keeps;
}
Assignment oldAssignment = defaultContext.getOldAssignment();
if (oldAssignment == null) {
return keeps;
}
keeps.addAll(defaultContext.getOldWorkers());
for (ResourceWorkerSlot worker : defaultContext.getOldWorkers()) {
for (Integer task : worker.getTasks()) {
if (!keepAssignIds.contains(task)) {
keeps.remove(worker);
break;
}
}
}
return keeps;
} | java | public Set<ResourceWorkerSlot> getKeepAssign(DefaultTopologyAssignContext defaultContext, Set<Integer> needAssigns) {
Set<Integer> keepAssignIds = new HashSet<>();
keepAssignIds.addAll(defaultContext.getAllTaskIds());
keepAssignIds.removeAll(defaultContext.getUnstoppedTaskIds());
keepAssignIds.removeAll(needAssigns);
Set<ResourceWorkerSlot> keeps = new HashSet<>();
if (keepAssignIds.isEmpty()) {
return keeps;
}
Assignment oldAssignment = defaultContext.getOldAssignment();
if (oldAssignment == null) {
return keeps;
}
keeps.addAll(defaultContext.getOldWorkers());
for (ResourceWorkerSlot worker : defaultContext.getOldWorkers()) {
for (Integer task : worker.getTasks()) {
if (!keepAssignIds.contains(task)) {
keeps.remove(worker);
break;
}
}
}
return keeps;
} | [
"public",
"Set",
"<",
"ResourceWorkerSlot",
">",
"getKeepAssign",
"(",
"DefaultTopologyAssignContext",
"defaultContext",
",",
"Set",
"<",
"Integer",
">",
"needAssigns",
")",
"{",
"Set",
"<",
"Integer",
">",
"keepAssignIds",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"keepAssignIds",
".",
"addAll",
"(",
"defaultContext",
".",
"getAllTaskIds",
"(",
")",
")",
";",
"keepAssignIds",
".",
"removeAll",
"(",
"defaultContext",
".",
"getUnstoppedTaskIds",
"(",
")",
")",
";",
"keepAssignIds",
".",
"removeAll",
"(",
"needAssigns",
")",
";",
"Set",
"<",
"ResourceWorkerSlot",
">",
"keeps",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"if",
"(",
"keepAssignIds",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"keeps",
";",
"}",
"Assignment",
"oldAssignment",
"=",
"defaultContext",
".",
"getOldAssignment",
"(",
")",
";",
"if",
"(",
"oldAssignment",
"==",
"null",
")",
"{",
"return",
"keeps",
";",
"}",
"keeps",
".",
"addAll",
"(",
"defaultContext",
".",
"getOldWorkers",
"(",
")",
")",
";",
"for",
"(",
"ResourceWorkerSlot",
"worker",
":",
"defaultContext",
".",
"getOldWorkers",
"(",
")",
")",
"{",
"for",
"(",
"Integer",
"task",
":",
"worker",
".",
"getTasks",
"(",
")",
")",
"{",
"if",
"(",
"!",
"keepAssignIds",
".",
"contains",
"(",
"task",
")",
")",
"{",
"keeps",
".",
"remove",
"(",
"worker",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"keeps",
";",
"}"
] | Get the task Map which the task is alive and will be kept only when type is ASSIGN_TYPE_MONITOR, it is valid
@param defaultContext default topology context
@param needAssigns a set of tasks to be assigned
@return a set of assigned slots | [
"Get",
"the",
"task",
"Map",
"which",
"the",
"task",
"is",
"alive",
"and",
"will",
"be",
"kept",
"only",
"when",
"type",
"is",
"ASSIGN_TYPE_MONITOR",
"it",
"is",
"valid"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/schedule/default_assign/DefaultTopologyScheduler.java#L97-L121 |
25,446 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/metric/JStormMetricCache.java | JStormMetricCache.putMetricData | public JStormCache putMetricData(String topologyId, TopologyMetric tpMetric) {
// map<key, [ts, metric_info]>
Map<String, Object> batchData = new HashMap<>();
long ts = System.currentTimeMillis();
int tp = 0, comp = 0, compStream = 0, task = 0, stream = 0, worker = 0, netty = 0;
if (tpMetric.get_componentMetric().get_metrics_size() > 0) {
batchData.put(METRIC_DATA_30M_COMPONENT + topologyId, new Object[]{ts, tpMetric.get_componentMetric()});
comp += tpMetric.get_componentMetric().get_metrics_size();
}
if (tpMetric.is_set_compStreamMetric() && tpMetric.get_compStreamMetric().get_metrics_size() > 0) {
batchData.put(METRIC_DATA_30M_COMP_STREAM + topologyId, new Object[]{ts, tpMetric.get_compStreamMetric()});
compStream += tpMetric.get_compStreamMetric().get_metrics_size();
}
if (tpMetric.get_taskMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_TASK + topologyId, tpMetric.get_taskMetric(), MetaType.TASK, ts);
task += tpMetric.get_taskMetric().get_metrics_size();
}
if (tpMetric.get_streamMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_STREAM + topologyId, tpMetric.get_streamMetric(), MetaType.STREAM, ts);
stream += tpMetric.get_streamMetric().get_metrics_size();
}
if (tpMetric.get_workerMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_WORKER + topologyId, tpMetric.get_workerMetric(), MetaType.WORKER, ts);
worker += tpMetric.get_workerMetric().get_metrics_size();
}
if (tpMetric.get_nettyMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_NETTY + topologyId, tpMetric.get_nettyMetric(), MetaType.NETTY, ts);
netty += tpMetric.get_nettyMetric().get_metrics_size();
}
// store 30 snapshots of topology metrics
if (tpMetric.get_topologyMetric().get_metrics_size() > 0) {
String keyPrefix = METRIC_DATA_30M_TOPOLOGY + topologyId + "-";
int page = getRingAvailableIndex(keyPrefix);
batchData.put(keyPrefix + page, new Object[]{ts, tpMetric.get_topologyMetric()});
tp += tpMetric.get_topologyMetric().get_metrics_size();
}
LOG.info("caching metric data for topology:{},tp:{},comp:{},comp_stream:{},task:{},stream:{},worker:{},netty:{},cost:{}",
topologyId, tp, comp, compStream, task, stream, worker, netty, System.currentTimeMillis() - ts);
return putBatch(batchData);
} | java | public JStormCache putMetricData(String topologyId, TopologyMetric tpMetric) {
// map<key, [ts, metric_info]>
Map<String, Object> batchData = new HashMap<>();
long ts = System.currentTimeMillis();
int tp = 0, comp = 0, compStream = 0, task = 0, stream = 0, worker = 0, netty = 0;
if (tpMetric.get_componentMetric().get_metrics_size() > 0) {
batchData.put(METRIC_DATA_30M_COMPONENT + topologyId, new Object[]{ts, tpMetric.get_componentMetric()});
comp += tpMetric.get_componentMetric().get_metrics_size();
}
if (tpMetric.is_set_compStreamMetric() && tpMetric.get_compStreamMetric().get_metrics_size() > 0) {
batchData.put(METRIC_DATA_30M_COMP_STREAM + topologyId, new Object[]{ts, tpMetric.get_compStreamMetric()});
compStream += tpMetric.get_compStreamMetric().get_metrics_size();
}
if (tpMetric.get_taskMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_TASK + topologyId, tpMetric.get_taskMetric(), MetaType.TASK, ts);
task += tpMetric.get_taskMetric().get_metrics_size();
}
if (tpMetric.get_streamMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_STREAM + topologyId, tpMetric.get_streamMetric(), MetaType.STREAM, ts);
stream += tpMetric.get_streamMetric().get_metrics_size();
}
if (tpMetric.get_workerMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_WORKER + topologyId, tpMetric.get_workerMetric(), MetaType.WORKER, ts);
worker += tpMetric.get_workerMetric().get_metrics_size();
}
if (tpMetric.get_nettyMetric().get_metrics_size() > 0) {
tryCombineMetricInfo(METRIC_DATA_30M_NETTY + topologyId, tpMetric.get_nettyMetric(), MetaType.NETTY, ts);
netty += tpMetric.get_nettyMetric().get_metrics_size();
}
// store 30 snapshots of topology metrics
if (tpMetric.get_topologyMetric().get_metrics_size() > 0) {
String keyPrefix = METRIC_DATA_30M_TOPOLOGY + topologyId + "-";
int page = getRingAvailableIndex(keyPrefix);
batchData.put(keyPrefix + page, new Object[]{ts, tpMetric.get_topologyMetric()});
tp += tpMetric.get_topologyMetric().get_metrics_size();
}
LOG.info("caching metric data for topology:{},tp:{},comp:{},comp_stream:{},task:{},stream:{},worker:{},netty:{},cost:{}",
topologyId, tp, comp, compStream, task, stream, worker, netty, System.currentTimeMillis() - ts);
return putBatch(batchData);
} | [
"public",
"JStormCache",
"putMetricData",
"(",
"String",
"topologyId",
",",
"TopologyMetric",
"tpMetric",
")",
"{",
"// map<key, [ts, metric_info]>",
"Map",
"<",
"String",
",",
"Object",
">",
"batchData",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"long",
"ts",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"int",
"tp",
"=",
"0",
",",
"comp",
"=",
"0",
",",
"compStream",
"=",
"0",
",",
"task",
"=",
"0",
",",
"stream",
"=",
"0",
",",
"worker",
"=",
"0",
",",
"netty",
"=",
"0",
";",
"if",
"(",
"tpMetric",
".",
"get_componentMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"batchData",
".",
"put",
"(",
"METRIC_DATA_30M_COMPONENT",
"+",
"topologyId",
",",
"new",
"Object",
"[",
"]",
"{",
"ts",
",",
"tpMetric",
".",
"get_componentMetric",
"(",
")",
"}",
")",
";",
"comp",
"+=",
"tpMetric",
".",
"get_componentMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"if",
"(",
"tpMetric",
".",
"is_set_compStreamMetric",
"(",
")",
"&&",
"tpMetric",
".",
"get_compStreamMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"batchData",
".",
"put",
"(",
"METRIC_DATA_30M_COMP_STREAM",
"+",
"topologyId",
",",
"new",
"Object",
"[",
"]",
"{",
"ts",
",",
"tpMetric",
".",
"get_compStreamMetric",
"(",
")",
"}",
")",
";",
"compStream",
"+=",
"tpMetric",
".",
"get_compStreamMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"if",
"(",
"tpMetric",
".",
"get_taskMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"tryCombineMetricInfo",
"(",
"METRIC_DATA_30M_TASK",
"+",
"topologyId",
",",
"tpMetric",
".",
"get_taskMetric",
"(",
")",
",",
"MetaType",
".",
"TASK",
",",
"ts",
")",
";",
"task",
"+=",
"tpMetric",
".",
"get_taskMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"if",
"(",
"tpMetric",
".",
"get_streamMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"tryCombineMetricInfo",
"(",
"METRIC_DATA_30M_STREAM",
"+",
"topologyId",
",",
"tpMetric",
".",
"get_streamMetric",
"(",
")",
",",
"MetaType",
".",
"STREAM",
",",
"ts",
")",
";",
"stream",
"+=",
"tpMetric",
".",
"get_streamMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"if",
"(",
"tpMetric",
".",
"get_workerMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"tryCombineMetricInfo",
"(",
"METRIC_DATA_30M_WORKER",
"+",
"topologyId",
",",
"tpMetric",
".",
"get_workerMetric",
"(",
")",
",",
"MetaType",
".",
"WORKER",
",",
"ts",
")",
";",
"worker",
"+=",
"tpMetric",
".",
"get_workerMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"if",
"(",
"tpMetric",
".",
"get_nettyMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"tryCombineMetricInfo",
"(",
"METRIC_DATA_30M_NETTY",
"+",
"topologyId",
",",
"tpMetric",
".",
"get_nettyMetric",
"(",
")",
",",
"MetaType",
".",
"NETTY",
",",
"ts",
")",
";",
"netty",
"+=",
"tpMetric",
".",
"get_nettyMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"// store 30 snapshots of topology metrics",
"if",
"(",
"tpMetric",
".",
"get_topologyMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
">",
"0",
")",
"{",
"String",
"keyPrefix",
"=",
"METRIC_DATA_30M_TOPOLOGY",
"+",
"topologyId",
"+",
"\"-\"",
";",
"int",
"page",
"=",
"getRingAvailableIndex",
"(",
"keyPrefix",
")",
";",
"batchData",
".",
"put",
"(",
"keyPrefix",
"+",
"page",
",",
"new",
"Object",
"[",
"]",
"{",
"ts",
",",
"tpMetric",
".",
"get_topologyMetric",
"(",
")",
"}",
")",
";",
"tp",
"+=",
"tpMetric",
".",
"get_topologyMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
";",
"}",
"LOG",
".",
"info",
"(",
"\"caching metric data for topology:{},tp:{},comp:{},comp_stream:{},task:{},stream:{},worker:{},netty:{},cost:{}\"",
",",
"topologyId",
",",
"tp",
",",
"comp",
",",
"compStream",
",",
"task",
",",
"stream",
",",
"worker",
",",
"netty",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"ts",
")",
";",
"return",
"putBatch",
"(",
"batchData",
")",
";",
"}"
] | store 30min metric data. the metric data is stored in a ring. | [
"store",
"30min",
"metric",
"data",
".",
"the",
"metric",
"data",
"is",
"stored",
"in",
"a",
"ring",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/metric/JStormMetricCache.java#L133-L175 |
25,447 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.setMemoryLoad | @Override
public Stream setMemoryLoad(Number onHeap, Number offHeap) {
_node.setMemoryLoad(onHeap, offHeap);
return this;
} | java | @Override
public Stream setMemoryLoad(Number onHeap, Number offHeap) {
_node.setMemoryLoad(onHeap, offHeap);
return this;
} | [
"@",
"Override",
"public",
"Stream",
"setMemoryLoad",
"(",
"Number",
"onHeap",
",",
"Number",
"offHeap",
")",
"{",
"_node",
".",
"setMemoryLoad",
"(",
"onHeap",
",",
"offHeap",
")",
";",
"return",
"this",
";",
"}"
] | Sets the Memory Load resources for the current operation. | [
"Sets",
"the",
"Memory",
"Load",
"resources",
"for",
"the",
"current",
"operation",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L145-L149 |
25,448 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.project | public Stream project(Fields keepFields) {
projectionValidation(keepFields);
return _topology.addSourcedNode(this, new ProcessorNode(_topology.getUniqueStreamId(), _name, keepFields, new Fields(), new ProjectedProcessor(keepFields)));
} | java | public Stream project(Fields keepFields) {
projectionValidation(keepFields);
return _topology.addSourcedNode(this, new ProcessorNode(_topology.getUniqueStreamId(), _name, keepFields, new Fields(), new ProjectedProcessor(keepFields)));
} | [
"public",
"Stream",
"project",
"(",
"Fields",
"keepFields",
")",
"{",
"projectionValidation",
"(",
"keepFields",
")",
";",
"return",
"_topology",
".",
"addSourcedNode",
"(",
"this",
",",
"new",
"ProcessorNode",
"(",
"_topology",
".",
"getUniqueStreamId",
"(",
")",
",",
"_name",
",",
"keepFields",
",",
"new",
"Fields",
"(",
")",
",",
"new",
"ProjectedProcessor",
"(",
"keepFields",
")",
")",
")",
";",
"}"
] | Filters out fields from a stream, resulting in a Stream containing only the fields specified by `keepFields`.
For example, if you had a Stream `mystream` containing the fields `["a", "b", "c","d"]`, calling"
```java
mystream.project(new Fields("b", "d"))
```
would produce a stream containing only the fields `["b", "d"]`.
@param keepFields The fields in the Stream to keep
@return | [
"Filters",
"out",
"fields",
"from",
"a",
"stream",
"resulting",
"in",
"a",
"Stream",
"containing",
"only",
"the",
"fields",
"specified",
"by",
"keepFields",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L166-L169 |
25,449 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.partitionAggregate | @Override
public Stream partitionAggregate(Fields inputFields, Aggregator agg, Fields functionFields) {
projectionValidation(inputFields);
return _topology.addSourcedNode(this,
new ProcessorNode(_topology.getUniqueStreamId(),
_name,
functionFields,
functionFields,
new AggregateProcessor(inputFields, agg)));
} | java | @Override
public Stream partitionAggregate(Fields inputFields, Aggregator agg, Fields functionFields) {
projectionValidation(inputFields);
return _topology.addSourcedNode(this,
new ProcessorNode(_topology.getUniqueStreamId(),
_name,
functionFields,
functionFields,
new AggregateProcessor(inputFields, agg)));
} | [
"@",
"Override",
"public",
"Stream",
"partitionAggregate",
"(",
"Fields",
"inputFields",
",",
"Aggregator",
"agg",
",",
"Fields",
"functionFields",
")",
"{",
"projectionValidation",
"(",
"inputFields",
")",
";",
"return",
"_topology",
".",
"addSourcedNode",
"(",
"this",
",",
"new",
"ProcessorNode",
"(",
"_topology",
".",
"getUniqueStreamId",
"(",
")",
",",
"_name",
",",
"functionFields",
",",
"functionFields",
",",
"new",
"AggregateProcessor",
"(",
"inputFields",
",",
"agg",
")",
")",
")",
";",
"}"
] | creates brand new tuples with brand new fields | [
"creates",
"brand",
"new",
"tuples",
"with",
"brand",
"new",
"fields"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L312-L321 |
25,450 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.map | public Stream map(MapFunction function) {
projectionValidation(getOutputFields());
return _topology.addSourcedNode(this,
new ProcessorNode(
_topology.getUniqueStreamId(),
_name,
getOutputFields(),
getOutputFields(),
new MapProcessor(getOutputFields(), new MapFunctionExecutor(function))));
} | java | public Stream map(MapFunction function) {
projectionValidation(getOutputFields());
return _topology.addSourcedNode(this,
new ProcessorNode(
_topology.getUniqueStreamId(),
_name,
getOutputFields(),
getOutputFields(),
new MapProcessor(getOutputFields(), new MapFunctionExecutor(function))));
} | [
"public",
"Stream",
"map",
"(",
"MapFunction",
"function",
")",
"{",
"projectionValidation",
"(",
"getOutputFields",
"(",
")",
")",
";",
"return",
"_topology",
".",
"addSourcedNode",
"(",
"this",
",",
"new",
"ProcessorNode",
"(",
"_topology",
".",
"getUniqueStreamId",
"(",
")",
",",
"_name",
",",
"getOutputFields",
"(",
")",
",",
"getOutputFields",
"(",
")",
",",
"new",
"MapProcessor",
"(",
"getOutputFields",
"(",
")",
",",
"new",
"MapFunctionExecutor",
"(",
"function",
")",
")",
")",
")",
";",
"}"
] | Returns a stream consisting of the result of applying the given mapping function to the values of this stream.
@param function a mapping function to be applied to each value in this stream.
@return the new stream | [
"Returns",
"a",
"stream",
"consisting",
"of",
"the",
"result",
"of",
"applying",
"the",
"given",
"mapping",
"function",
"to",
"the",
"values",
"of",
"this",
"stream",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L395-L404 |
25,451 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.flatMap | public Stream flatMap(FlatMapFunction function) {
projectionValidation(getOutputFields());
return _topology.addSourcedNode(this,
new ProcessorNode(
_topology.getUniqueStreamId(),
_name,
getOutputFields(),
getOutputFields(),
new MapProcessor(getOutputFields(), new FlatMapFunctionExecutor(function))));
} | java | public Stream flatMap(FlatMapFunction function) {
projectionValidation(getOutputFields());
return _topology.addSourcedNode(this,
new ProcessorNode(
_topology.getUniqueStreamId(),
_name,
getOutputFields(),
getOutputFields(),
new MapProcessor(getOutputFields(), new FlatMapFunctionExecutor(function))));
} | [
"public",
"Stream",
"flatMap",
"(",
"FlatMapFunction",
"function",
")",
"{",
"projectionValidation",
"(",
"getOutputFields",
"(",
")",
")",
";",
"return",
"_topology",
".",
"addSourcedNode",
"(",
"this",
",",
"new",
"ProcessorNode",
"(",
"_topology",
".",
"getUniqueStreamId",
"(",
")",
",",
"_name",
",",
"getOutputFields",
"(",
")",
",",
"getOutputFields",
"(",
")",
",",
"new",
"MapProcessor",
"(",
"getOutputFields",
"(",
")",
",",
"new",
"FlatMapFunctionExecutor",
"(",
"function",
")",
")",
")",
")",
";",
"}"
] | Returns a stream consisting of the results of replacing each value of this stream with the contents
produced by applying the provided mapping function to each value. This has the effect of applying
a one-to-many transformation to the values of the stream, and then flattening the resulting elements into a new stream.
@param function a mapping function to be applied to each value in this stream which produces new values.
@return the new stream | [
"Returns",
"a",
"stream",
"consisting",
"of",
"the",
"results",
"of",
"replacing",
"each",
"value",
"of",
"this",
"stream",
"with",
"the",
"contents",
"produced",
"by",
"applying",
"the",
"provided",
"mapping",
"function",
"to",
"each",
"value",
".",
"This",
"has",
"the",
"effect",
"of",
"applying",
"a",
"one",
"-",
"to",
"-",
"many",
"transformation",
"to",
"the",
"values",
"of",
"the",
"stream",
"and",
"then",
"flattening",
"the",
"resulting",
"elements",
"into",
"a",
"new",
"stream",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L414-L423 |
25,452 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.peek | public Stream peek(Consumer action) {
projectionValidation(getOutputFields());
return _topology.addSourcedNode(this,
new ProcessorNode(
_topology.getUniqueStreamId(),
_name,
getOutputFields(),
getOutputFields(),
new MapProcessor(getOutputFields(), new ConsumerExecutor(action))));
} | java | public Stream peek(Consumer action) {
projectionValidation(getOutputFields());
return _topology.addSourcedNode(this,
new ProcessorNode(
_topology.getUniqueStreamId(),
_name,
getOutputFields(),
getOutputFields(),
new MapProcessor(getOutputFields(), new ConsumerExecutor(action))));
} | [
"public",
"Stream",
"peek",
"(",
"Consumer",
"action",
")",
"{",
"projectionValidation",
"(",
"getOutputFields",
"(",
")",
")",
";",
"return",
"_topology",
".",
"addSourcedNode",
"(",
"this",
",",
"new",
"ProcessorNode",
"(",
"_topology",
".",
"getUniqueStreamId",
"(",
")",
",",
"_name",
",",
"getOutputFields",
"(",
")",
",",
"getOutputFields",
"(",
")",
",",
"new",
"MapProcessor",
"(",
"getOutputFields",
"(",
")",
",",
"new",
"ConsumerExecutor",
"(",
"action",
")",
")",
")",
")",
";",
"}"
] | Returns a stream consisting of the trident tuples of this stream, additionally performing the provided action on
each trident tuple as they are consumed from the resulting stream. This is mostly useful for debugging
to see the tuples as they flow past a certain point in a pipeline.
@param action the action to perform on the trident tuple as they are consumed from the stream
@return the new stream | [
"Returns",
"a",
"stream",
"consisting",
"of",
"the",
"trident",
"tuples",
"of",
"this",
"stream",
"additionally",
"performing",
"the",
"provided",
"action",
"on",
"each",
"trident",
"tuple",
"as",
"they",
"are",
"consumed",
"from",
"the",
"resulting",
"stream",
".",
"This",
"is",
"mostly",
"useful",
"for",
"debugging",
"to",
"see",
"the",
"tuples",
"as",
"they",
"flow",
"past",
"a",
"certain",
"point",
"in",
"a",
"pipeline",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L433-L442 |
25,453 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.window | public Stream window(WindowConfig windowConfig, Fields inputFields, Aggregator aggregator, Fields functionFields) {
// this store is used only for storing triggered aggregated results but not tuples as storeTuplesInStore is set
// as false int he below call.
InMemoryWindowsStoreFactory inMemoryWindowsStoreFactory = new InMemoryWindowsStoreFactory();
return window(windowConfig, inMemoryWindowsStoreFactory, inputFields, aggregator, functionFields, false);
} | java | public Stream window(WindowConfig windowConfig, Fields inputFields, Aggregator aggregator, Fields functionFields) {
// this store is used only for storing triggered aggregated results but not tuples as storeTuplesInStore is set
// as false int he below call.
InMemoryWindowsStoreFactory inMemoryWindowsStoreFactory = new InMemoryWindowsStoreFactory();
return window(windowConfig, inMemoryWindowsStoreFactory, inputFields, aggregator, functionFields, false);
} | [
"public",
"Stream",
"window",
"(",
"WindowConfig",
"windowConfig",
",",
"Fields",
"inputFields",
",",
"Aggregator",
"aggregator",
",",
"Fields",
"functionFields",
")",
"{",
"// this store is used only for storing triggered aggregated results but not tuples as storeTuplesInStore is set",
"// as false int he below call.",
"InMemoryWindowsStoreFactory",
"inMemoryWindowsStoreFactory",
"=",
"new",
"InMemoryWindowsStoreFactory",
"(",
")",
";",
"return",
"window",
"(",
"windowConfig",
",",
"inMemoryWindowsStoreFactory",
",",
"inputFields",
",",
"aggregator",
",",
"functionFields",
",",
"false",
")",
";",
"}"
] | Returns a stream of aggregated results based on the given window configuration which uses inmemory windowing tuple store.
@param windowConfig window configuration like window length and slide length.
@param inputFields input fields
@param aggregator aggregator to run on the window of tuples to compute the result and emit to the stream.
@param functionFields fields of values to emit with aggregation.
@return the new stream with this operation. | [
"Returns",
"a",
"stream",
"of",
"aggregated",
"results",
"based",
"on",
"the",
"given",
"window",
"configuration",
"which",
"uses",
"inmemory",
"windowing",
"tuple",
"store",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L668-L673 |
25,454 | alibaba/jstorm | jstorm-core/src/main/java/storm/trident/Stream.java | Stream.window | public Stream window(WindowConfig windowConfig, WindowsStoreFactory windowStoreFactory, Fields inputFields,
Aggregator aggregator, Fields functionFields) {
return window(windowConfig, windowStoreFactory, inputFields, aggregator, functionFields, true);
} | java | public Stream window(WindowConfig windowConfig, WindowsStoreFactory windowStoreFactory, Fields inputFields,
Aggregator aggregator, Fields functionFields) {
return window(windowConfig, windowStoreFactory, inputFields, aggregator, functionFields, true);
} | [
"public",
"Stream",
"window",
"(",
"WindowConfig",
"windowConfig",
",",
"WindowsStoreFactory",
"windowStoreFactory",
",",
"Fields",
"inputFields",
",",
"Aggregator",
"aggregator",
",",
"Fields",
"functionFields",
")",
"{",
"return",
"window",
"(",
"windowConfig",
",",
"windowStoreFactory",
",",
"inputFields",
",",
"aggregator",
",",
"functionFields",
",",
"true",
")",
";",
"}"
] | Returns stream of aggregated results based on the given window configuration.
@param windowConfig window configuration like window length and slide length.
@param windowStoreFactory intermediary tuple store for storing tuples for windowing
@param inputFields input fields
@param aggregator aggregator to run on the window of tuples to compute the result and emit to the stream.
@param functionFields fields of values to emit with aggregation.
@return the new stream with this operation. | [
"Returns",
"stream",
"of",
"aggregated",
"results",
"based",
"on",
"the",
"given",
"window",
"configuration",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/storm/trident/Stream.java#L686-L689 |
25,455 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java | Cluster.get_topology_id | public static String get_topology_id(StormClusterState zkCluster, String storm_name) throws Exception {
List<String> active_storms = zkCluster.active_storms();
String rtn = null;
if (active_storms != null) {
for (String topology_id : active_storms) {
if (!topology_id.contains(storm_name)) {
continue;
}
StormBase base = zkCluster.storm_base(topology_id, null);
if (base != null && storm_name.equals(Common.getTopologyNameById(topology_id))) {
rtn = topology_id;
break;
}
}
}
return rtn;
} | java | public static String get_topology_id(StormClusterState zkCluster, String storm_name) throws Exception {
List<String> active_storms = zkCluster.active_storms();
String rtn = null;
if (active_storms != null) {
for (String topology_id : active_storms) {
if (!topology_id.contains(storm_name)) {
continue;
}
StormBase base = zkCluster.storm_base(topology_id, null);
if (base != null && storm_name.equals(Common.getTopologyNameById(topology_id))) {
rtn = topology_id;
break;
}
}
}
return rtn;
} | [
"public",
"static",
"String",
"get_topology_id",
"(",
"StormClusterState",
"zkCluster",
",",
"String",
"storm_name",
")",
"throws",
"Exception",
"{",
"List",
"<",
"String",
">",
"active_storms",
"=",
"zkCluster",
".",
"active_storms",
"(",
")",
";",
"String",
"rtn",
"=",
"null",
";",
"if",
"(",
"active_storms",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"topology_id",
":",
"active_storms",
")",
"{",
"if",
"(",
"!",
"topology_id",
".",
"contains",
"(",
"storm_name",
")",
")",
"{",
"continue",
";",
"}",
"StormBase",
"base",
"=",
"zkCluster",
".",
"storm_base",
"(",
"topology_id",
",",
"null",
")",
";",
"if",
"(",
"base",
"!=",
"null",
"&&",
"storm_name",
".",
"equals",
"(",
"Common",
".",
"getTopologyNameById",
"(",
"topology_id",
")",
")",
")",
"{",
"rtn",
"=",
"topology_id",
";",
"break",
";",
"}",
"}",
"}",
"return",
"rtn",
";",
"}"
] | if a topology's name is equal to the input storm_name, then return the topology id, otherwise return null | [
"if",
"a",
"topology",
"s",
"name",
"is",
"equal",
"to",
"the",
"input",
"storm_name",
"then",
"return",
"the",
"topology",
"id",
"otherwise",
"return",
"null"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java#L224-L241 |
25,456 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java | Cluster.get_all_StormBase | public static HashMap<String, StormBase> get_all_StormBase(StormClusterState zkCluster) throws Exception {
HashMap<String, StormBase> rtn = new HashMap<>();
List<String> active_storms = zkCluster.active_storms();
if (active_storms != null) {
for (String topology_id : active_storms) {
StormBase base = zkCluster.storm_base(topology_id, null);
if (base != null) {
rtn.put(topology_id, base);
}
}
}
return rtn;
} | java | public static HashMap<String, StormBase> get_all_StormBase(StormClusterState zkCluster) throws Exception {
HashMap<String, StormBase> rtn = new HashMap<>();
List<String> active_storms = zkCluster.active_storms();
if (active_storms != null) {
for (String topology_id : active_storms) {
StormBase base = zkCluster.storm_base(topology_id, null);
if (base != null) {
rtn.put(topology_id, base);
}
}
}
return rtn;
} | [
"public",
"static",
"HashMap",
"<",
"String",
",",
"StormBase",
">",
"get_all_StormBase",
"(",
"StormClusterState",
"zkCluster",
")",
"throws",
"Exception",
"{",
"HashMap",
"<",
"String",
",",
"StormBase",
">",
"rtn",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"List",
"<",
"String",
">",
"active_storms",
"=",
"zkCluster",
".",
"active_storms",
"(",
")",
";",
"if",
"(",
"active_storms",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"topology_id",
":",
"active_storms",
")",
"{",
"StormBase",
"base",
"=",
"zkCluster",
".",
"storm_base",
"(",
"topology_id",
",",
"null",
")",
";",
"if",
"(",
"base",
"!=",
"null",
")",
"{",
"rtn",
".",
"put",
"(",
"topology_id",
",",
"base",
")",
";",
"}",
"}",
"}",
"return",
"rtn",
";",
"}"
] | get all topology's StormBase
@param zkCluster zk cluster state
@return map[topology_id, StormBase] | [
"get",
"all",
"topology",
"s",
"StormBase"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java#L249-L261 |
25,457 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java | Cluster.get_all_SupervisorInfo | public static Map<String, SupervisorInfo> get_all_SupervisorInfo(
StormClusterState stormClusterState, RunnableCallback callback) throws Exception {
Map<String, SupervisorInfo> rtn = new TreeMap<>();
// get /ZK/supervisors
List<String> supervisorIds = stormClusterState.supervisors(callback);
// ignore any supervisors in blacklist
List<String> blacklist = stormClusterState.get_blacklist();
if (supervisorIds != null) {
for (Iterator<String> iter = supervisorIds.iterator(); iter.hasNext(); ) {
String supervisorId = iter.next();
// get /supervisors/supervisorid
SupervisorInfo supervisorInfo = stormClusterState.supervisor_info(supervisorId);
if (supervisorInfo == null) {
LOG.warn("Failed to get SupervisorInfo of " + supervisorId);
} else if (blacklist.contains(supervisorInfo.getHostName())) {
LOG.warn(" hostname:" + supervisorInfo.getHostName() + " is in blacklist");
} else {
rtn.put(supervisorId, supervisorInfo);
}
}
} else {
LOG.info("No alive supervisor");
}
return rtn;
} | java | public static Map<String, SupervisorInfo> get_all_SupervisorInfo(
StormClusterState stormClusterState, RunnableCallback callback) throws Exception {
Map<String, SupervisorInfo> rtn = new TreeMap<>();
// get /ZK/supervisors
List<String> supervisorIds = stormClusterState.supervisors(callback);
// ignore any supervisors in blacklist
List<String> blacklist = stormClusterState.get_blacklist();
if (supervisorIds != null) {
for (Iterator<String> iter = supervisorIds.iterator(); iter.hasNext(); ) {
String supervisorId = iter.next();
// get /supervisors/supervisorid
SupervisorInfo supervisorInfo = stormClusterState.supervisor_info(supervisorId);
if (supervisorInfo == null) {
LOG.warn("Failed to get SupervisorInfo of " + supervisorId);
} else if (blacklist.contains(supervisorInfo.getHostName())) {
LOG.warn(" hostname:" + supervisorInfo.getHostName() + " is in blacklist");
} else {
rtn.put(supervisorId, supervisorInfo);
}
}
} else {
LOG.info("No alive supervisor");
}
return rtn;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"SupervisorInfo",
">",
"get_all_SupervisorInfo",
"(",
"StormClusterState",
"stormClusterState",
",",
"RunnableCallback",
"callback",
")",
"throws",
"Exception",
"{",
"Map",
"<",
"String",
",",
"SupervisorInfo",
">",
"rtn",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"// get /ZK/supervisors",
"List",
"<",
"String",
">",
"supervisorIds",
"=",
"stormClusterState",
".",
"supervisors",
"(",
"callback",
")",
";",
"// ignore any supervisors in blacklist",
"List",
"<",
"String",
">",
"blacklist",
"=",
"stormClusterState",
".",
"get_blacklist",
"(",
")",
";",
"if",
"(",
"supervisorIds",
"!=",
"null",
")",
"{",
"for",
"(",
"Iterator",
"<",
"String",
">",
"iter",
"=",
"supervisorIds",
".",
"iterator",
"(",
")",
";",
"iter",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"String",
"supervisorId",
"=",
"iter",
".",
"next",
"(",
")",
";",
"// get /supervisors/supervisorid",
"SupervisorInfo",
"supervisorInfo",
"=",
"stormClusterState",
".",
"supervisor_info",
"(",
"supervisorId",
")",
";",
"if",
"(",
"supervisorInfo",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to get SupervisorInfo of \"",
"+",
"supervisorId",
")",
";",
"}",
"else",
"if",
"(",
"blacklist",
".",
"contains",
"(",
"supervisorInfo",
".",
"getHostName",
"(",
")",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\" hostname:\"",
"+",
"supervisorInfo",
".",
"getHostName",
"(",
")",
"+",
"\" is in blacklist\"",
")",
";",
"}",
"else",
"{",
"rtn",
".",
"put",
"(",
"supervisorId",
",",
"supervisorInfo",
")",
";",
"}",
"}",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"No alive supervisor\"",
")",
";",
"}",
"return",
"rtn",
";",
"}"
] | get all SupervisorInfo of storm cluster
@param stormClusterState storm cluster state
@param callback watcher callback
@return Map[supervisorId, SupervisorInfo] | [
"get",
"all",
"SupervisorInfo",
"of",
"storm",
"cluster"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/cluster/Cluster.java#L270-L296 |
25,458 | alibaba/jstorm | jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/spout/DirLock.java | DirLock.tryLock | public static DirLock tryLock(FileSystem fs, Path dir) throws IOException {
Path lockFile = getDirLockFile(dir);
try {
FSDataOutputStream ostream = HdfsUtils.tryCreateFile(fs, lockFile);
if (ostream!=null) {
LOG.debug("Thread ({}) Acquired lock on dir {}", threadInfo(), dir);
ostream.close();
return new DirLock(fs, lockFile);
} else {
LOG.debug("Thread ({}) cannot lock dir {} as its already locked.", threadInfo(), dir);
return null;
}
} catch (IOException e) {
LOG.error("Error when acquiring lock on dir " + dir, e);
throw e;
}
} | java | public static DirLock tryLock(FileSystem fs, Path dir) throws IOException {
Path lockFile = getDirLockFile(dir);
try {
FSDataOutputStream ostream = HdfsUtils.tryCreateFile(fs, lockFile);
if (ostream!=null) {
LOG.debug("Thread ({}) Acquired lock on dir {}", threadInfo(), dir);
ostream.close();
return new DirLock(fs, lockFile);
} else {
LOG.debug("Thread ({}) cannot lock dir {} as its already locked.", threadInfo(), dir);
return null;
}
} catch (IOException e) {
LOG.error("Error when acquiring lock on dir " + dir, e);
throw e;
}
} | [
"public",
"static",
"DirLock",
"tryLock",
"(",
"FileSystem",
"fs",
",",
"Path",
"dir",
")",
"throws",
"IOException",
"{",
"Path",
"lockFile",
"=",
"getDirLockFile",
"(",
"dir",
")",
";",
"try",
"{",
"FSDataOutputStream",
"ostream",
"=",
"HdfsUtils",
".",
"tryCreateFile",
"(",
"fs",
",",
"lockFile",
")",
";",
"if",
"(",
"ostream",
"!=",
"null",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Thread ({}) Acquired lock on dir {}\"",
",",
"threadInfo",
"(",
")",
",",
"dir",
")",
";",
"ostream",
".",
"close",
"(",
")",
";",
"return",
"new",
"DirLock",
"(",
"fs",
",",
"lockFile",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"Thread ({}) cannot lock dir {} as its already locked.\"",
",",
"threadInfo",
"(",
")",
",",
"dir",
")",
";",
"return",
"null",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error when acquiring lock on dir \"",
"+",
"dir",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"}"
] | Get a lock on file if not already locked
@param fs
@param dir the dir on which to get a lock
@return The lock object if it the lock was acquired. Returns null if the dir is already locked.
@throws IOException if there were errors | [
"Get",
"a",
"lock",
"on",
"file",
"if",
"not",
"already",
"locked"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/spout/DirLock.java#L55-L72 |
25,459 | alibaba/jstorm | jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/spout/DirLock.java | DirLock.release | public void release() throws IOException {
if(!fs.delete(lockFile, false)) {
LOG.error("Thread {} could not delete dir lock {} ", threadInfo(), lockFile);
}
else {
LOG.debug("Thread {} Released dir lock {} ", threadInfo(), lockFile);
}
} | java | public void release() throws IOException {
if(!fs.delete(lockFile, false)) {
LOG.error("Thread {} could not delete dir lock {} ", threadInfo(), lockFile);
}
else {
LOG.debug("Thread {} Released dir lock {} ", threadInfo(), lockFile);
}
} | [
"public",
"void",
"release",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"fs",
".",
"delete",
"(",
"lockFile",
",",
"false",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Thread {} could not delete dir lock {} \"",
",",
"threadInfo",
"(",
")",
",",
"lockFile",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"debug",
"(",
"\"Thread {} Released dir lock {} \"",
",",
"threadInfo",
"(",
")",
",",
"lockFile",
")",
";",
"}",
"}"
] | Release lock on dir by deleting the lock file | [
"Release",
"lock",
"on",
"dir",
"by",
"deleting",
"the",
"lock",
"file"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/spout/DirLock.java#L84-L91 |
25,460 | alibaba/jstorm | jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/spout/DirLock.java | DirLock.takeOwnershipIfStale | public static DirLock takeOwnershipIfStale(FileSystem fs, Path dirToLock, int lockTimeoutSec) {
Path dirLockFile = getDirLockFile(dirToLock);
long now = System.currentTimeMillis();
long expiryTime = now - (lockTimeoutSec*1000);
try {
long modTime = fs.getFileStatus(dirLockFile).getModificationTime();
if(modTime <= expiryTime) {
return takeOwnership(fs, dirLockFile);
}
return null;
} catch (IOException e) {
return null;
}
} | java | public static DirLock takeOwnershipIfStale(FileSystem fs, Path dirToLock, int lockTimeoutSec) {
Path dirLockFile = getDirLockFile(dirToLock);
long now = System.currentTimeMillis();
long expiryTime = now - (lockTimeoutSec*1000);
try {
long modTime = fs.getFileStatus(dirLockFile).getModificationTime();
if(modTime <= expiryTime) {
return takeOwnership(fs, dirLockFile);
}
return null;
} catch (IOException e) {
return null;
}
} | [
"public",
"static",
"DirLock",
"takeOwnershipIfStale",
"(",
"FileSystem",
"fs",
",",
"Path",
"dirToLock",
",",
"int",
"lockTimeoutSec",
")",
"{",
"Path",
"dirLockFile",
"=",
"getDirLockFile",
"(",
"dirToLock",
")",
";",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"expiryTime",
"=",
"now",
"-",
"(",
"lockTimeoutSec",
"*",
"1000",
")",
";",
"try",
"{",
"long",
"modTime",
"=",
"fs",
".",
"getFileStatus",
"(",
"dirLockFile",
")",
".",
"getModificationTime",
"(",
")",
";",
"if",
"(",
"modTime",
"<=",
"expiryTime",
")",
"{",
"return",
"takeOwnership",
"(",
"fs",
",",
"dirLockFile",
")",
";",
"}",
"return",
"null",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | if the lock on the directory is stale, take ownership | [
"if",
"the",
"lock",
"on",
"the",
"directory",
"is",
"stale",
"take",
"ownership"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/spout/DirLock.java#L94-L109 |
25,461 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/schedule/FollowerRunnable.java | FollowerRunnable.setupBlobstore | private void setupBlobstore() throws Exception {
BlobStore blobStore = data.getBlobStore();
StormClusterState clusterState = data.getStormClusterState();
Set<String> localSetOfKeys = Sets.newHashSet(blobStore.listKeys());
Set<String> allKeys = Sets.newHashSet(clusterState.active_keys());
Set<String> localAvailableActiveKeys = Sets.intersection(localSetOfKeys, allKeys);
// keys on local but not on zk, we will delete it
Set<String> keysToDelete = Sets.difference(localSetOfKeys, allKeys);
LOG.debug("deleting keys not on zookeeper {}", keysToDelete);
for (String key : keysToDelete) {
blobStore.deleteBlob(key);
}
LOG.debug("Creating list of key entries for blobstore inside zookeeper {} local {}",
allKeys, localAvailableActiveKeys);
for (String key : localAvailableActiveKeys) {
int versionForKey = BlobStoreUtils.getVersionForKey(key, data.getNimbusHostPortInfo(), data.getConf());
clusterState.setup_blobstore(key, data.getNimbusHostPortInfo(), versionForKey);
}
} | java | private void setupBlobstore() throws Exception {
BlobStore blobStore = data.getBlobStore();
StormClusterState clusterState = data.getStormClusterState();
Set<String> localSetOfKeys = Sets.newHashSet(blobStore.listKeys());
Set<String> allKeys = Sets.newHashSet(clusterState.active_keys());
Set<String> localAvailableActiveKeys = Sets.intersection(localSetOfKeys, allKeys);
// keys on local but not on zk, we will delete it
Set<String> keysToDelete = Sets.difference(localSetOfKeys, allKeys);
LOG.debug("deleting keys not on zookeeper {}", keysToDelete);
for (String key : keysToDelete) {
blobStore.deleteBlob(key);
}
LOG.debug("Creating list of key entries for blobstore inside zookeeper {} local {}",
allKeys, localAvailableActiveKeys);
for (String key : localAvailableActiveKeys) {
int versionForKey = BlobStoreUtils.getVersionForKey(key, data.getNimbusHostPortInfo(), data.getConf());
clusterState.setup_blobstore(key, data.getNimbusHostPortInfo(), versionForKey);
}
} | [
"private",
"void",
"setupBlobstore",
"(",
")",
"throws",
"Exception",
"{",
"BlobStore",
"blobStore",
"=",
"data",
".",
"getBlobStore",
"(",
")",
";",
"StormClusterState",
"clusterState",
"=",
"data",
".",
"getStormClusterState",
"(",
")",
";",
"Set",
"<",
"String",
">",
"localSetOfKeys",
"=",
"Sets",
".",
"newHashSet",
"(",
"blobStore",
".",
"listKeys",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"allKeys",
"=",
"Sets",
".",
"newHashSet",
"(",
"clusterState",
".",
"active_keys",
"(",
")",
")",
";",
"Set",
"<",
"String",
">",
"localAvailableActiveKeys",
"=",
"Sets",
".",
"intersection",
"(",
"localSetOfKeys",
",",
"allKeys",
")",
";",
"// keys on local but not on zk, we will delete it",
"Set",
"<",
"String",
">",
"keysToDelete",
"=",
"Sets",
".",
"difference",
"(",
"localSetOfKeys",
",",
"allKeys",
")",
";",
"LOG",
".",
"debug",
"(",
"\"deleting keys not on zookeeper {}\"",
",",
"keysToDelete",
")",
";",
"for",
"(",
"String",
"key",
":",
"keysToDelete",
")",
"{",
"blobStore",
".",
"deleteBlob",
"(",
"key",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"Creating list of key entries for blobstore inside zookeeper {} local {}\"",
",",
"allKeys",
",",
"localAvailableActiveKeys",
")",
";",
"for",
"(",
"String",
"key",
":",
"localAvailableActiveKeys",
")",
"{",
"int",
"versionForKey",
"=",
"BlobStoreUtils",
".",
"getVersionForKey",
"(",
"key",
",",
"data",
".",
"getNimbusHostPortInfo",
"(",
")",
",",
"data",
".",
"getConf",
"(",
")",
")",
";",
"clusterState",
".",
"setup_blobstore",
"(",
"key",
",",
"data",
".",
"getNimbusHostPortInfo",
"(",
")",
",",
"versionForKey",
")",
";",
"}",
"}"
] | sets up blobstore state for all current keys | [
"sets",
"up",
"blobstore",
"state",
"for",
"all",
"current",
"keys"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/schedule/FollowerRunnable.java#L134-L152 |
25,462 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/schedule/FollowerRunnable.java | FollowerRunnable.check_nimbus_priority | private boolean check_nimbus_priority() throws Exception {
int gap = update_nimbus_detail();
if (gap == 0) {
return true;
}
int left = SLAVE_NIMBUS_WAIT_TIME;
while (left > 0) {
LOG.info("nimbus.differ.count.zk is {}, so after {} seconds, nimbus will try to be leader!", gap, left);
Thread.sleep(10 * 1000);
left -= 10;
}
StormClusterState zkClusterState = data.getStormClusterState();
List<String> followers = zkClusterState.list_dirs(Cluster.NIMBUS_SLAVE_DETAIL_SUBTREE, false);
if (followers == null || followers.size() == 0) {
return false;
}
for (String follower : followers) {
if (follower != null && !follower.equals(hostPort)) {
Map bMap = zkClusterState.get_nimbus_detail(follower, false);
if (bMap != null) {
Object object = bMap.get(NIMBUS_DIFFER_COUNT_ZK);
if (object != null && (JStormUtils.parseInt(object)) < gap) {
LOG.info("Current node can't be leader, due to {} has higher priority", follower);
return false;
}
}
}
}
return true;
} | java | private boolean check_nimbus_priority() throws Exception {
int gap = update_nimbus_detail();
if (gap == 0) {
return true;
}
int left = SLAVE_NIMBUS_WAIT_TIME;
while (left > 0) {
LOG.info("nimbus.differ.count.zk is {}, so after {} seconds, nimbus will try to be leader!", gap, left);
Thread.sleep(10 * 1000);
left -= 10;
}
StormClusterState zkClusterState = data.getStormClusterState();
List<String> followers = zkClusterState.list_dirs(Cluster.NIMBUS_SLAVE_DETAIL_SUBTREE, false);
if (followers == null || followers.size() == 0) {
return false;
}
for (String follower : followers) {
if (follower != null && !follower.equals(hostPort)) {
Map bMap = zkClusterState.get_nimbus_detail(follower, false);
if (bMap != null) {
Object object = bMap.get(NIMBUS_DIFFER_COUNT_ZK);
if (object != null && (JStormUtils.parseInt(object)) < gap) {
LOG.info("Current node can't be leader, due to {} has higher priority", follower);
return false;
}
}
}
}
return true;
} | [
"private",
"boolean",
"check_nimbus_priority",
"(",
")",
"throws",
"Exception",
"{",
"int",
"gap",
"=",
"update_nimbus_detail",
"(",
")",
";",
"if",
"(",
"gap",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"int",
"left",
"=",
"SLAVE_NIMBUS_WAIT_TIME",
";",
"while",
"(",
"left",
">",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"nimbus.differ.count.zk is {}, so after {} seconds, nimbus will try to be leader!\"",
",",
"gap",
",",
"left",
")",
";",
"Thread",
".",
"sleep",
"(",
"10",
"*",
"1000",
")",
";",
"left",
"-=",
"10",
";",
"}",
"StormClusterState",
"zkClusterState",
"=",
"data",
".",
"getStormClusterState",
"(",
")",
";",
"List",
"<",
"String",
">",
"followers",
"=",
"zkClusterState",
".",
"list_dirs",
"(",
"Cluster",
".",
"NIMBUS_SLAVE_DETAIL_SUBTREE",
",",
"false",
")",
";",
"if",
"(",
"followers",
"==",
"null",
"||",
"followers",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"String",
"follower",
":",
"followers",
")",
"{",
"if",
"(",
"follower",
"!=",
"null",
"&&",
"!",
"follower",
".",
"equals",
"(",
"hostPort",
")",
")",
"{",
"Map",
"bMap",
"=",
"zkClusterState",
".",
"get_nimbus_detail",
"(",
"follower",
",",
"false",
")",
";",
"if",
"(",
"bMap",
"!=",
"null",
")",
"{",
"Object",
"object",
"=",
"bMap",
".",
"get",
"(",
"NIMBUS_DIFFER_COUNT_ZK",
")",
";",
"if",
"(",
"object",
"!=",
"null",
"&&",
"(",
"JStormUtils",
".",
"parseInt",
"(",
"object",
")",
")",
"<",
"gap",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Current node can't be leader, due to {} has higher priority\"",
",",
"follower",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Compared with other nimbus to get priority of this nimbus | [
"Compared",
"with",
"other",
"nimbus",
"to",
"get",
"priority",
"of",
"this",
"nimbus"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/schedule/FollowerRunnable.java#L264-L298 |
25,463 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/schedule/FollowerRunnable.java | FollowerRunnable.checkOwnMaster | private void checkOwnMaster() throws Exception {
int retry_times = 10;
StormClusterState zkClient = data.getStormClusterState();
for (int i = 0; i < retry_times; i++, JStormUtils.sleepMs(sleepTime)) {
if (!zkClient.leader_existed()) {
continue;
}
String zkHost = zkClient.get_leader_host();
if (hostPort.equals(zkHost)) {
// current process own master
return;
}
LOG.warn("Current nimbus has started thrift, but fail to set as leader in zk:" + zkHost);
}
String err = "Current nimbus failed to set as leader in zk, halting process";
LOG.error(err);
JStormUtils.halt_process(0, err);
} | java | private void checkOwnMaster() throws Exception {
int retry_times = 10;
StormClusterState zkClient = data.getStormClusterState();
for (int i = 0; i < retry_times; i++, JStormUtils.sleepMs(sleepTime)) {
if (!zkClient.leader_existed()) {
continue;
}
String zkHost = zkClient.get_leader_host();
if (hostPort.equals(zkHost)) {
// current process own master
return;
}
LOG.warn("Current nimbus has started thrift, but fail to set as leader in zk:" + zkHost);
}
String err = "Current nimbus failed to set as leader in zk, halting process";
LOG.error(err);
JStormUtils.halt_process(0, err);
} | [
"private",
"void",
"checkOwnMaster",
"(",
")",
"throws",
"Exception",
"{",
"int",
"retry_times",
"=",
"10",
";",
"StormClusterState",
"zkClient",
"=",
"data",
".",
"getStormClusterState",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"retry_times",
";",
"i",
"++",
",",
"JStormUtils",
".",
"sleepMs",
"(",
"sleepTime",
")",
")",
"{",
"if",
"(",
"!",
"zkClient",
".",
"leader_existed",
"(",
")",
")",
"{",
"continue",
";",
"}",
"String",
"zkHost",
"=",
"zkClient",
".",
"get_leader_host",
"(",
")",
";",
"if",
"(",
"hostPort",
".",
"equals",
"(",
"zkHost",
")",
")",
"{",
"// current process own master",
"return",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Current nimbus has started thrift, but fail to set as leader in zk:\"",
"+",
"zkHost",
")",
";",
"}",
"String",
"err",
"=",
"\"Current nimbus failed to set as leader in zk, halting process\"",
";",
"LOG",
".",
"error",
"(",
"err",
")",
";",
"JStormUtils",
".",
"halt_process",
"(",
"0",
",",
"err",
")",
";",
"}"
] | Check whether current node is master | [
"Check",
"whether",
"current",
"node",
"is",
"master"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/schedule/FollowerRunnable.java#L328-L350 |
25,464 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/AsmHistogram.java | AsmHistogram.doFlush | protected void doFlush() {
long[] values = unFlushed.getSnapshot().getValues();
for (JHistogram histogram : histogramMap.values()) {
for (long val : values) {
histogram.update(val);
}
}
if (MetricUtils.metricAccurateCal) {
for (long val : values) {
for (AsmMetric metric : this.assocMetrics) {
metric.updateDirectly(val);
}
}
}
this.unFlushed = newHistogram();
} | java | protected void doFlush() {
long[] values = unFlushed.getSnapshot().getValues();
for (JHistogram histogram : histogramMap.values()) {
for (long val : values) {
histogram.update(val);
}
}
if (MetricUtils.metricAccurateCal) {
for (long val : values) {
for (AsmMetric metric : this.assocMetrics) {
metric.updateDirectly(val);
}
}
}
this.unFlushed = newHistogram();
} | [
"protected",
"void",
"doFlush",
"(",
")",
"{",
"long",
"[",
"]",
"values",
"=",
"unFlushed",
".",
"getSnapshot",
"(",
")",
".",
"getValues",
"(",
")",
";",
"for",
"(",
"JHistogram",
"histogram",
":",
"histogramMap",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"long",
"val",
":",
"values",
")",
"{",
"histogram",
".",
"update",
"(",
"val",
")",
";",
"}",
"}",
"if",
"(",
"MetricUtils",
".",
"metricAccurateCal",
")",
"{",
"for",
"(",
"long",
"val",
":",
"values",
")",
"{",
"for",
"(",
"AsmMetric",
"metric",
":",
"this",
".",
"assocMetrics",
")",
"{",
"metric",
".",
"updateDirectly",
"(",
"val",
")",
";",
"}",
"}",
"}",
"this",
".",
"unFlushed",
"=",
"newHistogram",
"(",
")",
";",
"}"
] | flush temp histogram data to all windows & assoc metrics. | [
"flush",
"temp",
"histogram",
"data",
"to",
"all",
"windows",
"&",
"assoc",
"metrics",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/AsmHistogram.java#L159-L174 |
25,465 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/spout/SpoutOutputCollector.java | SpoutOutputCollector.emitDirect | public void emitDirect(int taskId, String streamId, List<Object> tuple,
Object messageId) {
_delegate.emitDirect(taskId, streamId, tuple, messageId);
} | java | public void emitDirect(int taskId, String streamId, List<Object> tuple,
Object messageId) {
_delegate.emitDirect(taskId, streamId, tuple, messageId);
} | [
"public",
"void",
"emitDirect",
"(",
"int",
"taskId",
",",
"String",
"streamId",
",",
"List",
"<",
"Object",
">",
"tuple",
",",
"Object",
"messageId",
")",
"{",
"_delegate",
".",
"emitDirect",
"(",
"taskId",
",",
"streamId",
",",
"tuple",
",",
"messageId",
")",
";",
"}"
] | Emits a tuple to the specified task on the specified output stream. This
output stream must have been declared as a direct stream, and the
specified task must use a direct grouping on this stream to receive the
message. The emitted values must be immutable. | [
"Emits",
"a",
"tuple",
"to",
"the",
"specified",
"task",
"on",
"the",
"specified",
"output",
"stream",
".",
"This",
"output",
"stream",
"must",
"have",
"been",
"declared",
"as",
"a",
"direct",
"stream",
"and",
"the",
"specified",
"task",
"must",
"use",
"a",
"direct",
"grouping",
"on",
"this",
"stream",
"to",
"receive",
"the",
"message",
".",
"The",
"emitted",
"values",
"must",
"be",
"immutable",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/spout/SpoutOutputCollector.java#L150-L153 |
25,466 | alibaba/jstorm | jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/blobstore/HdfsBlobStoreImpl.java | HdfsBlobStoreImpl.exists | public boolean exists(String key) {
Path dir = getKeyDir(key);
boolean res = false;
try {
_fs = dir.getFileSystem(_hadoopConf);
res = _fs.exists(dir);
} catch (IOException e) {
LOG.warn("Exception checking for exists on: " + key);
}
return res;
} | java | public boolean exists(String key) {
Path dir = getKeyDir(key);
boolean res = false;
try {
_fs = dir.getFileSystem(_hadoopConf);
res = _fs.exists(dir);
} catch (IOException e) {
LOG.warn("Exception checking for exists on: " + key);
}
return res;
} | [
"public",
"boolean",
"exists",
"(",
"String",
"key",
")",
"{",
"Path",
"dir",
"=",
"getKeyDir",
"(",
"key",
")",
";",
"boolean",
"res",
"=",
"false",
";",
"try",
"{",
"_fs",
"=",
"dir",
".",
"getFileSystem",
"(",
"_hadoopConf",
")",
";",
"res",
"=",
"_fs",
".",
"exists",
"(",
"dir",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Exception checking for exists on: \"",
"+",
"key",
")",
";",
"}",
"return",
"res",
";",
"}"
] | Check if the key exists in the blob store.
@param key the key to check for
@return true if it exists else false. | [
"Check",
"if",
"the",
"key",
"exists",
"in",
"the",
"blob",
"store",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-hdfs/src/main/java/com/alibaba/jstorm/hdfs/blobstore/HdfsBlobStoreImpl.java#L224-L234 |
25,467 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/utils/OSInfo.java | OSInfo.getOSname | public static EPlatform getOSname() {
if (isAix()) {
_instance.platform = EPlatform.AIX;
} else if (isDigitalUnix()) {
_instance.platform = EPlatform.Digital_Unix;
} else if (isFreeBSD()) {
_instance.platform = EPlatform.FreeBSD;
} else if (isHPUX()) {
_instance.platform = EPlatform.HP_UX;
} else if (isIrix()) {
_instance.platform = EPlatform.Irix;
} else if (isLinux()) {
_instance.platform = EPlatform.Linux;
} else if (isMacOS()) {
_instance.platform = EPlatform.Mac_OS;
} else if (isMacOSX()) {
_instance.platform = EPlatform.Mac_OS_X;
} else if (isMPEiX()) {
_instance.platform = EPlatform.MPEiX;
} else if (isNetWare()) {
_instance.platform = EPlatform.NetWare_411;
} else if (isOpenVMS()) {
_instance.platform = EPlatform.OpenVMS;
} else if (isOS2()) {
_instance.platform = EPlatform.OS2;
} else if (isOS390()) {
_instance.platform = EPlatform.OS390;
} else if (isOSF1()) {
_instance.platform = EPlatform.OSF1;
} else if (isSolaris()) {
_instance.platform = EPlatform.Solaris;
} else if (isSunOS()) {
_instance.platform = EPlatform.SunOS;
} else if (isWindows()) {
_instance.platform = EPlatform.Windows;
} else {
_instance.platform = EPlatform.Others;
}
return _instance.platform;
} | java | public static EPlatform getOSname() {
if (isAix()) {
_instance.platform = EPlatform.AIX;
} else if (isDigitalUnix()) {
_instance.platform = EPlatform.Digital_Unix;
} else if (isFreeBSD()) {
_instance.platform = EPlatform.FreeBSD;
} else if (isHPUX()) {
_instance.platform = EPlatform.HP_UX;
} else if (isIrix()) {
_instance.platform = EPlatform.Irix;
} else if (isLinux()) {
_instance.platform = EPlatform.Linux;
} else if (isMacOS()) {
_instance.platform = EPlatform.Mac_OS;
} else if (isMacOSX()) {
_instance.platform = EPlatform.Mac_OS_X;
} else if (isMPEiX()) {
_instance.platform = EPlatform.MPEiX;
} else if (isNetWare()) {
_instance.platform = EPlatform.NetWare_411;
} else if (isOpenVMS()) {
_instance.platform = EPlatform.OpenVMS;
} else if (isOS2()) {
_instance.platform = EPlatform.OS2;
} else if (isOS390()) {
_instance.platform = EPlatform.OS390;
} else if (isOSF1()) {
_instance.platform = EPlatform.OSF1;
} else if (isSolaris()) {
_instance.platform = EPlatform.Solaris;
} else if (isSunOS()) {
_instance.platform = EPlatform.SunOS;
} else if (isWindows()) {
_instance.platform = EPlatform.Windows;
} else {
_instance.platform = EPlatform.Others;
}
return _instance.platform;
} | [
"public",
"static",
"EPlatform",
"getOSname",
"(",
")",
"{",
"if",
"(",
"isAix",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"AIX",
";",
"}",
"else",
"if",
"(",
"isDigitalUnix",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Digital_Unix",
";",
"}",
"else",
"if",
"(",
"isFreeBSD",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"FreeBSD",
";",
"}",
"else",
"if",
"(",
"isHPUX",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"HP_UX",
";",
"}",
"else",
"if",
"(",
"isIrix",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Irix",
";",
"}",
"else",
"if",
"(",
"isLinux",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Linux",
";",
"}",
"else",
"if",
"(",
"isMacOS",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Mac_OS",
";",
"}",
"else",
"if",
"(",
"isMacOSX",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Mac_OS_X",
";",
"}",
"else",
"if",
"(",
"isMPEiX",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"MPEiX",
";",
"}",
"else",
"if",
"(",
"isNetWare",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"NetWare_411",
";",
"}",
"else",
"if",
"(",
"isOpenVMS",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"OpenVMS",
";",
"}",
"else",
"if",
"(",
"isOS2",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"OS2",
";",
"}",
"else",
"if",
"(",
"isOS390",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"OS390",
";",
"}",
"else",
"if",
"(",
"isOSF1",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"OSF1",
";",
"}",
"else",
"if",
"(",
"isSolaris",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Solaris",
";",
"}",
"else",
"if",
"(",
"isSunOS",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"SunOS",
";",
"}",
"else",
"if",
"(",
"isWindows",
"(",
")",
")",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Windows",
";",
"}",
"else",
"{",
"_instance",
".",
"platform",
"=",
"EPlatform",
".",
"Others",
";",
"}",
"return",
"_instance",
".",
"platform",
";",
"}"
] | Get OS name
@return OS name | [
"Get",
"OS",
"name"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/utils/OSInfo.java#L108-L147 |
25,468 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/message/netty/StormClientHandler.java | StormClientHandler.channelConnected | @Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
// register the newly established channel
Channel channel = event.getChannel();
LOG.info("connection established to :{}, local port:{}", client.getRemoteAddr(), channel.getLocalAddress());
client.connectChannel(ctx.getChannel());
client.handleResponse(ctx.getChannel(), null);
} | java | @Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
// register the newly established channel
Channel channel = event.getChannel();
LOG.info("connection established to :{}, local port:{}", client.getRemoteAddr(), channel.getLocalAddress());
client.connectChannel(ctx.getChannel());
client.handleResponse(ctx.getChannel(), null);
} | [
"@",
"Override",
"public",
"void",
"channelConnected",
"(",
"ChannelHandlerContext",
"ctx",
",",
"ChannelStateEvent",
"event",
")",
"{",
"// register the newly established channel",
"Channel",
"channel",
"=",
"event",
".",
"getChannel",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"connection established to :{}, local port:{}\"",
",",
"client",
".",
"getRemoteAddr",
"(",
")",
",",
"channel",
".",
"getLocalAddress",
"(",
")",
")",
";",
"client",
".",
"connectChannel",
"(",
"ctx",
".",
"getChannel",
"(",
")",
")",
";",
"client",
".",
"handleResponse",
"(",
"ctx",
".",
"getChannel",
"(",
")",
",",
"null",
")",
";",
"}"
] | Sometime when connecting to a bad channel which isn't writable, this method will be called | [
"Sometime",
"when",
"connecting",
"to",
"a",
"bad",
"channel",
"which",
"isn",
"t",
"writable",
"this",
"method",
"will",
"be",
"called"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/message/netty/StormClientHandler.java#L53-L61 |
25,469 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/supervisor/Supervisor.java | Supervisor.main | public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
JStormServerUtils.startTaobaoJvmMonitor();
Supervisor instance = new Supervisor();
instance.run();
} | java | public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
JStormServerUtils.startTaobaoJvmMonitor();
Supervisor instance = new Supervisor();
instance.run();
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"Thread",
".",
"setDefaultUncaughtExceptionHandler",
"(",
"new",
"DefaultUncaughtExceptionHandler",
"(",
")",
")",
";",
"JStormServerUtils",
".",
"startTaobaoJvmMonitor",
"(",
")",
";",
"Supervisor",
"instance",
"=",
"new",
"Supervisor",
"(",
")",
";",
"instance",
".",
"run",
"(",
")",
";",
"}"
] | start supervisor daemon | [
"start",
"supervisor",
"daemon"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/supervisor/Supervisor.java#L236-L241 |
25,470 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/task/group/MkLocalShuffer.java | MkLocalShuffer.refreshLocalNodeTasks | private void refreshLocalNodeTasks() {
Set<Integer> localNodeTasks = workerData.getLocalNodeTasks();
if (localNodeTasks == null || localNodeTasks.equals(lastLocalNodeTasks)) {
return;
}
LOG.info("Old localNodeTasks:" + lastLocalNodeTasks + ", new:"
+ localNodeTasks);
lastLocalNodeTasks = localNodeTasks;
List<Integer> localNodeOutTasks = new ArrayList<>();
for (Integer outTask : allTargetTasks) {
if (localNodeTasks.contains(outTask)) {
localNodeOutTasks.add(outTask);
}
}
if (!localNodeOutTasks.isEmpty()) {
this.outTasks = localNodeOutTasks;
}
randomrange = new RandomRange(outTasks.size());
} | java | private void refreshLocalNodeTasks() {
Set<Integer> localNodeTasks = workerData.getLocalNodeTasks();
if (localNodeTasks == null || localNodeTasks.equals(lastLocalNodeTasks)) {
return;
}
LOG.info("Old localNodeTasks:" + lastLocalNodeTasks + ", new:"
+ localNodeTasks);
lastLocalNodeTasks = localNodeTasks;
List<Integer> localNodeOutTasks = new ArrayList<>();
for (Integer outTask : allTargetTasks) {
if (localNodeTasks.contains(outTask)) {
localNodeOutTasks.add(outTask);
}
}
if (!localNodeOutTasks.isEmpty()) {
this.outTasks = localNodeOutTasks;
}
randomrange = new RandomRange(outTasks.size());
} | [
"private",
"void",
"refreshLocalNodeTasks",
"(",
")",
"{",
"Set",
"<",
"Integer",
">",
"localNodeTasks",
"=",
"workerData",
".",
"getLocalNodeTasks",
"(",
")",
";",
"if",
"(",
"localNodeTasks",
"==",
"null",
"||",
"localNodeTasks",
".",
"equals",
"(",
"lastLocalNodeTasks",
")",
")",
"{",
"return",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Old localNodeTasks:\"",
"+",
"lastLocalNodeTasks",
"+",
"\", new:\"",
"+",
"localNodeTasks",
")",
";",
"lastLocalNodeTasks",
"=",
"localNodeTasks",
";",
"List",
"<",
"Integer",
">",
"localNodeOutTasks",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Integer",
"outTask",
":",
"allTargetTasks",
")",
"{",
"if",
"(",
"localNodeTasks",
".",
"contains",
"(",
"outTask",
")",
")",
"{",
"localNodeOutTasks",
".",
"add",
"(",
"outTask",
")",
";",
"}",
"}",
"if",
"(",
"!",
"localNodeOutTasks",
".",
"isEmpty",
"(",
")",
")",
"{",
"this",
".",
"outTasks",
"=",
"localNodeOutTasks",
";",
"}",
"randomrange",
"=",
"new",
"RandomRange",
"(",
"outTasks",
".",
"size",
"(",
")",
")",
";",
"}"
] | Don't need to take care of multiple thread racing condition, one thread per task | [
"Don",
"t",
"need",
"to",
"take",
"care",
"of",
"multiple",
"thread",
"racing",
"condition",
"one",
"thread",
"per",
"task"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/task/group/MkLocalShuffer.java#L70-L92 |
25,471 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/update/UpdateEvent.java | UpdateEvent.updateClusterMetrics | private void updateClusterMetrics(String topologyId, TopologyMetric tpMetric) {
if (tpMetric.get_topologyMetric().get_metrics_size() == 0) {
return;
}
MetricInfo topologyMetrics = tpMetric.get_topologyMetric();
// make a new MetricInfo to save the topologyId's metric
MetricInfo clusterMetrics = MetricUtils.mkMetricInfo();
Set<String> metricNames = new HashSet<>();
for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : topologyMetrics.get_metrics().entrySet()) {
String metricName = MetricUtils.topo2clusterName(entry.getKey());
MetricType metricType = MetricUtils.metricType(metricName);
Map<Integer, MetricSnapshot> winData = new HashMap<>();
for (Map.Entry<Integer, MetricSnapshot> entryData : entry.getValue().entrySet()) {
MetricSnapshot snapshot = entryData.getValue().deepCopy();
winData.put(entryData.getKey(), snapshot);
if (metricType == MetricType.HISTOGRAM) {
// reset topology metric points
entryData.getValue().set_points(new byte[0]);
entryData.getValue().set_pointSize(0);
}
}
clusterMetrics.put_to_metrics(metricName, winData);
metricNames.add(metricName);
}
// save to local cache, waiting for merging
TopologyMetricContext clusterTpMetricContext = context.getClusterTopologyMetricContext();
clusterTpMetricContext.addToMemCache(topologyId, clusterMetrics);
context.registerMetrics(JStormMetrics.CLUSTER_METRIC_KEY, metricNames);
} | java | private void updateClusterMetrics(String topologyId, TopologyMetric tpMetric) {
if (tpMetric.get_topologyMetric().get_metrics_size() == 0) {
return;
}
MetricInfo topologyMetrics = tpMetric.get_topologyMetric();
// make a new MetricInfo to save the topologyId's metric
MetricInfo clusterMetrics = MetricUtils.mkMetricInfo();
Set<String> metricNames = new HashSet<>();
for (Map.Entry<String, Map<Integer, MetricSnapshot>> entry : topologyMetrics.get_metrics().entrySet()) {
String metricName = MetricUtils.topo2clusterName(entry.getKey());
MetricType metricType = MetricUtils.metricType(metricName);
Map<Integer, MetricSnapshot> winData = new HashMap<>();
for (Map.Entry<Integer, MetricSnapshot> entryData : entry.getValue().entrySet()) {
MetricSnapshot snapshot = entryData.getValue().deepCopy();
winData.put(entryData.getKey(), snapshot);
if (metricType == MetricType.HISTOGRAM) {
// reset topology metric points
entryData.getValue().set_points(new byte[0]);
entryData.getValue().set_pointSize(0);
}
}
clusterMetrics.put_to_metrics(metricName, winData);
metricNames.add(metricName);
}
// save to local cache, waiting for merging
TopologyMetricContext clusterTpMetricContext = context.getClusterTopologyMetricContext();
clusterTpMetricContext.addToMemCache(topologyId, clusterMetrics);
context.registerMetrics(JStormMetrics.CLUSTER_METRIC_KEY, metricNames);
} | [
"private",
"void",
"updateClusterMetrics",
"(",
"String",
"topologyId",
",",
"TopologyMetric",
"tpMetric",
")",
"{",
"if",
"(",
"tpMetric",
".",
"get_topologyMetric",
"(",
")",
".",
"get_metrics_size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"MetricInfo",
"topologyMetrics",
"=",
"tpMetric",
".",
"get_topologyMetric",
"(",
")",
";",
"// make a new MetricInfo to save the topologyId's metric",
"MetricInfo",
"clusterMetrics",
"=",
"MetricUtils",
".",
"mkMetricInfo",
"(",
")",
";",
"Set",
"<",
"String",
">",
"metricNames",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
">",
"entry",
":",
"topologyMetrics",
".",
"get_metrics",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"metricName",
"=",
"MetricUtils",
".",
"topo2clusterName",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"MetricType",
"metricType",
"=",
"MetricUtils",
".",
"metricType",
"(",
"metricName",
")",
";",
"Map",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"winData",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"MetricSnapshot",
">",
"entryData",
":",
"entry",
".",
"getValue",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"MetricSnapshot",
"snapshot",
"=",
"entryData",
".",
"getValue",
"(",
")",
".",
"deepCopy",
"(",
")",
";",
"winData",
".",
"put",
"(",
"entryData",
".",
"getKey",
"(",
")",
",",
"snapshot",
")",
";",
"if",
"(",
"metricType",
"==",
"MetricType",
".",
"HISTOGRAM",
")",
"{",
"// reset topology metric points",
"entryData",
".",
"getValue",
"(",
")",
".",
"set_points",
"(",
"new",
"byte",
"[",
"0",
"]",
")",
";",
"entryData",
".",
"getValue",
"(",
")",
".",
"set_pointSize",
"(",
"0",
")",
";",
"}",
"}",
"clusterMetrics",
".",
"put_to_metrics",
"(",
"metricName",
",",
"winData",
")",
";",
"metricNames",
".",
"add",
"(",
"metricName",
")",
";",
"}",
"// save to local cache, waiting for merging",
"TopologyMetricContext",
"clusterTpMetricContext",
"=",
"context",
".",
"getClusterTopologyMetricContext",
"(",
")",
";",
"clusterTpMetricContext",
".",
"addToMemCache",
"(",
"topologyId",
",",
"clusterMetrics",
")",
";",
"context",
".",
"registerMetrics",
"(",
"JStormMetrics",
".",
"CLUSTER_METRIC_KEY",
",",
"metricNames",
")",
";",
"}"
] | update cluster metrics local cache | [
"update",
"cluster",
"metrics",
"local",
"cache"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/nimbus/metric/update/UpdateEvent.java#L133-L166 |
25,472 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java | Node.freeAllSlots | public void freeAllSlots(Cluster cluster) {
if (!_isAlive) {
LOG.warn("Freeing all slots on a dead node {} ", _nodeId);
}
for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
cluster.freeSlots(entry.getValue());
if (_isAlive) {
_freeSlots.addAll(entry.getValue());
}
}
_topIdToUsedSlots = new HashMap<>();
} | java | public void freeAllSlots(Cluster cluster) {
if (!_isAlive) {
LOG.warn("Freeing all slots on a dead node {} ", _nodeId);
}
for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
cluster.freeSlots(entry.getValue());
if (_isAlive) {
_freeSlots.addAll(entry.getValue());
}
}
_topIdToUsedSlots = new HashMap<>();
} | [
"public",
"void",
"freeAllSlots",
"(",
"Cluster",
"cluster",
")",
"{",
"if",
"(",
"!",
"_isAlive",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Freeing all slots on a dead node {} \"",
",",
"_nodeId",
")",
";",
"}",
"for",
"(",
"Entry",
"<",
"String",
",",
"Set",
"<",
"WorkerSlot",
">",
">",
"entry",
":",
"_topIdToUsedSlots",
".",
"entrySet",
"(",
")",
")",
"{",
"cluster",
".",
"freeSlots",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"_isAlive",
")",
"{",
"_freeSlots",
".",
"addAll",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"_topIdToUsedSlots",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}"
] | Free all slots on this node. This will update the Cluster too.
@param cluster the cluster to be updated | [
"Free",
"all",
"slots",
"on",
"this",
"node",
".",
"This",
"will",
"update",
"the",
"Cluster",
"too",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java#L154-L165 |
25,473 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java | Node.free | public void free(WorkerSlot ws, Cluster cluster, boolean forceFree) {
if (_freeSlots.contains(ws))
return;
boolean wasFound = false;
for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
Set<WorkerSlot> slots = entry.getValue();
if (slots.remove(ws)) {
cluster.freeSlot(ws);
if (_isAlive) {
_freeSlots.add(ws);
}
wasFound = true;
}
}
if (!wasFound) {
if (forceFree) {
LOG.info("Forcefully freeing the " + ws);
cluster.freeSlot(ws);
_freeSlots.add(ws);
} else {
throw new IllegalArgumentException("Tried to free a slot that was not" + " part of this node " + _nodeId);
}
}
} | java | public void free(WorkerSlot ws, Cluster cluster, boolean forceFree) {
if (_freeSlots.contains(ws))
return;
boolean wasFound = false;
for (Entry<String, Set<WorkerSlot>> entry : _topIdToUsedSlots.entrySet()) {
Set<WorkerSlot> slots = entry.getValue();
if (slots.remove(ws)) {
cluster.freeSlot(ws);
if (_isAlive) {
_freeSlots.add(ws);
}
wasFound = true;
}
}
if (!wasFound) {
if (forceFree) {
LOG.info("Forcefully freeing the " + ws);
cluster.freeSlot(ws);
_freeSlots.add(ws);
} else {
throw new IllegalArgumentException("Tried to free a slot that was not" + " part of this node " + _nodeId);
}
}
} | [
"public",
"void",
"free",
"(",
"WorkerSlot",
"ws",
",",
"Cluster",
"cluster",
",",
"boolean",
"forceFree",
")",
"{",
"if",
"(",
"_freeSlots",
".",
"contains",
"(",
"ws",
")",
")",
"return",
";",
"boolean",
"wasFound",
"=",
"false",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Set",
"<",
"WorkerSlot",
">",
">",
"entry",
":",
"_topIdToUsedSlots",
".",
"entrySet",
"(",
")",
")",
"{",
"Set",
"<",
"WorkerSlot",
">",
"slots",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"slots",
".",
"remove",
"(",
"ws",
")",
")",
"{",
"cluster",
".",
"freeSlot",
"(",
"ws",
")",
";",
"if",
"(",
"_isAlive",
")",
"{",
"_freeSlots",
".",
"add",
"(",
"ws",
")",
";",
"}",
"wasFound",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"wasFound",
")",
"{",
"if",
"(",
"forceFree",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Forcefully freeing the \"",
"+",
"ws",
")",
";",
"cluster",
".",
"freeSlot",
"(",
"ws",
")",
";",
"_freeSlots",
".",
"add",
"(",
"ws",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tried to free a slot that was not\"",
"+",
"\" part of this node \"",
"+",
"_nodeId",
")",
";",
"}",
"}",
"}"
] | Frees a single slot in this node
@param ws the slot to free
@param cluster the cluster to update | [
"Frees",
"a",
"single",
"slot",
"in",
"this",
"node"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java#L173-L196 |
25,474 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java | Node.freeTopology | public void freeTopology(String topId, Cluster cluster) {
Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
if (slots == null || slots.isEmpty())
return;
for (WorkerSlot ws : slots) {
cluster.freeSlot(ws);
if (_isAlive) {
_freeSlots.add(ws);
}
}
_topIdToUsedSlots.remove(topId);
} | java | public void freeTopology(String topId, Cluster cluster) {
Set<WorkerSlot> slots = _topIdToUsedSlots.get(topId);
if (slots == null || slots.isEmpty())
return;
for (WorkerSlot ws : slots) {
cluster.freeSlot(ws);
if (_isAlive) {
_freeSlots.add(ws);
}
}
_topIdToUsedSlots.remove(topId);
} | [
"public",
"void",
"freeTopology",
"(",
"String",
"topId",
",",
"Cluster",
"cluster",
")",
"{",
"Set",
"<",
"WorkerSlot",
">",
"slots",
"=",
"_topIdToUsedSlots",
".",
"get",
"(",
"topId",
")",
";",
"if",
"(",
"slots",
"==",
"null",
"||",
"slots",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"for",
"(",
"WorkerSlot",
"ws",
":",
"slots",
")",
"{",
"cluster",
".",
"freeSlot",
"(",
"ws",
")",
";",
"if",
"(",
"_isAlive",
")",
"{",
"_freeSlots",
".",
"add",
"(",
"ws",
")",
";",
"}",
"}",
"_topIdToUsedSlots",
".",
"remove",
"(",
"topId",
")",
";",
"}"
] | Frees all the slots for a topology.
@param topId the topology to free slots for
@param cluster the cluster to update | [
"Frees",
"all",
"the",
"slots",
"for",
"a",
"topology",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java#L204-L215 |
25,475 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java | Node.assign | public void assign(String topId, Collection<ExecutorDetails> executors, Cluster cluster) {
if (!_isAlive) {
throw new IllegalStateException("Trying to adding to a dead node " + _nodeId);
}
if (_freeSlots.isEmpty()) {
throw new IllegalStateException("Trying to assign to a full node " + _nodeId);
}
if (executors.size() == 0) {
LOG.warn("Trying to assign nothing from " + topId + " to " + _nodeId + " (Ignored)");
} else {
WorkerSlot slot = _freeSlots.iterator().next();
cluster.assign(slot, topId, executors);
assignInternal(slot, topId, false);
}
} | java | public void assign(String topId, Collection<ExecutorDetails> executors, Cluster cluster) {
if (!_isAlive) {
throw new IllegalStateException("Trying to adding to a dead node " + _nodeId);
}
if (_freeSlots.isEmpty()) {
throw new IllegalStateException("Trying to assign to a full node " + _nodeId);
}
if (executors.size() == 0) {
LOG.warn("Trying to assign nothing from " + topId + " to " + _nodeId + " (Ignored)");
} else {
WorkerSlot slot = _freeSlots.iterator().next();
cluster.assign(slot, topId, executors);
assignInternal(slot, topId, false);
}
} | [
"public",
"void",
"assign",
"(",
"String",
"topId",
",",
"Collection",
"<",
"ExecutorDetails",
">",
"executors",
",",
"Cluster",
"cluster",
")",
"{",
"if",
"(",
"!",
"_isAlive",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Trying to adding to a dead node \"",
"+",
"_nodeId",
")",
";",
"}",
"if",
"(",
"_freeSlots",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Trying to assign to a full node \"",
"+",
"_nodeId",
")",
";",
"}",
"if",
"(",
"executors",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Trying to assign nothing from \"",
"+",
"topId",
"+",
"\" to \"",
"+",
"_nodeId",
"+",
"\" (Ignored)\"",
")",
";",
"}",
"else",
"{",
"WorkerSlot",
"slot",
"=",
"_freeSlots",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"cluster",
".",
"assign",
"(",
"slot",
",",
"topId",
",",
"executors",
")",
";",
"assignInternal",
"(",
"slot",
",",
"topId",
",",
"false",
")",
";",
"}",
"}"
] | Assign a free slot on the node to the following topology and executors. This will update the cluster too.
@param topId the topology to assign a free slot to.
@param executors the executors to run in that slot.
@param cluster the cluster to be updated | [
"Assign",
"a",
"free",
"slot",
"on",
"the",
"node",
"to",
"the",
"following",
"topology",
"and",
"executors",
".",
"This",
"will",
"update",
"the",
"cluster",
"too",
"."
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/scheduler/multitenant/Node.java#L224-L238 |
25,476 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/StatefulWindowedBoltExecutor.java | StatefulWindowedBoltExecutor.updateStreamState | private void updateStreamState(Map<TaskStream, WindowState> state) {
for (Map.Entry<TaskStream, WindowState> entry : state.entrySet()) {
TaskStream taskStream = entry.getKey();
WindowState newState = entry.getValue();
WindowState curState = streamState.get(taskStream);
if (curState == null) {
streamState.put(taskStream, newState);
} else {
WindowState updatedState = new WindowState(Math.max(newState.lastExpired, curState.lastExpired),
Math.max(newState.lastEvaluated, curState.lastEvaluated));
LOG.debug("Update window state, taskStream {}, curState {}, newState {}", taskStream, curState, updatedState);
streamState.put(taskStream, updatedState);
}
}
} | java | private void updateStreamState(Map<TaskStream, WindowState> state) {
for (Map.Entry<TaskStream, WindowState> entry : state.entrySet()) {
TaskStream taskStream = entry.getKey();
WindowState newState = entry.getValue();
WindowState curState = streamState.get(taskStream);
if (curState == null) {
streamState.put(taskStream, newState);
} else {
WindowState updatedState = new WindowState(Math.max(newState.lastExpired, curState.lastExpired),
Math.max(newState.lastEvaluated, curState.lastEvaluated));
LOG.debug("Update window state, taskStream {}, curState {}, newState {}", taskStream, curState, updatedState);
streamState.put(taskStream, updatedState);
}
}
} | [
"private",
"void",
"updateStreamState",
"(",
"Map",
"<",
"TaskStream",
",",
"WindowState",
">",
"state",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"TaskStream",
",",
"WindowState",
">",
"entry",
":",
"state",
".",
"entrySet",
"(",
")",
")",
"{",
"TaskStream",
"taskStream",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"WindowState",
"newState",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"WindowState",
"curState",
"=",
"streamState",
".",
"get",
"(",
"taskStream",
")",
";",
"if",
"(",
"curState",
"==",
"null",
")",
"{",
"streamState",
".",
"put",
"(",
"taskStream",
",",
"newState",
")",
";",
"}",
"else",
"{",
"WindowState",
"updatedState",
"=",
"new",
"WindowState",
"(",
"Math",
".",
"max",
"(",
"newState",
".",
"lastExpired",
",",
"curState",
".",
"lastExpired",
")",
",",
"Math",
".",
"max",
"(",
"newState",
".",
"lastEvaluated",
",",
"curState",
".",
"lastEvaluated",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Update window state, taskStream {}, curState {}, newState {}\"",
",",
"taskStream",
",",
"curState",
",",
"updatedState",
")",
";",
"streamState",
".",
"put",
"(",
"taskStream",
",",
"updatedState",
")",
";",
"}",
"}",
"}"
] | update streamState based on stateUpdates | [
"update",
"streamState",
"based",
"on",
"stateUpdates"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/StatefulWindowedBoltExecutor.java#L245-L259 |
25,477 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/blobstore/BlobSynchronizer.java | BlobSynchronizer.updateKeySetForBlobStore | private void updateKeySetForBlobStore(Set<String> keySetBlobStore, CuratorFramework zkClient) {
try {
for (String key : keySetBlobStore) {
LOG.debug("updating blob");
BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClient, key, nimbusInfo);
}
} catch (Exception exp) {
throw new RuntimeException(exp);
}
} | java | private void updateKeySetForBlobStore(Set<String> keySetBlobStore, CuratorFramework zkClient) {
try {
for (String key : keySetBlobStore) {
LOG.debug("updating blob");
BlobStoreUtils.updateKeyForBlobStore(conf, blobStore, zkClient, key, nimbusInfo);
}
} catch (Exception exp) {
throw new RuntimeException(exp);
}
} | [
"private",
"void",
"updateKeySetForBlobStore",
"(",
"Set",
"<",
"String",
">",
"keySetBlobStore",
",",
"CuratorFramework",
"zkClient",
")",
"{",
"try",
"{",
"for",
"(",
"String",
"key",
":",
"keySetBlobStore",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"updating blob\"",
")",
";",
"BlobStoreUtils",
".",
"updateKeyForBlobStore",
"(",
"conf",
",",
"blobStore",
",",
"zkClient",
",",
"key",
",",
"nimbusInfo",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"exp",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"exp",
")",
";",
"}",
"}"
] | Update current key list inside the blobstore if the version changes | [
"Update",
"current",
"key",
"list",
"inside",
"the",
"blobstore",
"if",
"the",
"version",
"changes"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/blobstore/BlobSynchronizer.java#L110-L119 |
25,478 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/blobstore/BlobSynchronizer.java | BlobSynchronizer.getKeySetToDownload | public Set<String> getKeySetToDownload(Set<String> blobStoreKeySet, Set<String> zookeeperKeySet) {
zookeeperKeySet.removeAll(blobStoreKeySet);
LOG.debug("Key list to download {}", zookeeperKeySet);
return zookeeperKeySet;
} | java | public Set<String> getKeySetToDownload(Set<String> blobStoreKeySet, Set<String> zookeeperKeySet) {
zookeeperKeySet.removeAll(blobStoreKeySet);
LOG.debug("Key list to download {}", zookeeperKeySet);
return zookeeperKeySet;
} | [
"public",
"Set",
"<",
"String",
">",
"getKeySetToDownload",
"(",
"Set",
"<",
"String",
">",
"blobStoreKeySet",
",",
"Set",
"<",
"String",
">",
"zookeeperKeySet",
")",
"{",
"zookeeperKeySet",
".",
"removeAll",
"(",
"blobStoreKeySet",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Key list to download {}\"",
",",
"zookeeperKeySet",
")",
";",
"return",
"zookeeperKeySet",
";",
"}"
] | Make a key list to download | [
"Make",
"a",
"key",
"list",
"to",
"download"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/blobstore/BlobSynchronizer.java#L122-L126 |
25,479 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/RollingWindow.java | RollingWindow.updateBatch | public void updateBatch(V batch) {
if (intervalCheck.check()) {
rolling();
}
synchronized (this) {
unflushed = updater.updateBatch(batch, unflushed);
}
} | java | public void updateBatch(V batch) {
if (intervalCheck.check()) {
rolling();
}
synchronized (this) {
unflushed = updater.updateBatch(batch, unflushed);
}
} | [
"public",
"void",
"updateBatch",
"(",
"V",
"batch",
")",
"{",
"if",
"(",
"intervalCheck",
".",
"check",
"(",
")",
")",
"{",
"rolling",
"(",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"unflushed",
"=",
"updater",
".",
"updateBatch",
"(",
"batch",
",",
"unflushed",
")",
";",
"}",
"}"
] | In order to improve performance Flush one batch to rollingWindow | [
"In",
"order",
"to",
"improve",
"performance",
"Flush",
"one",
"batch",
"to",
"rollingWindow"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/old/window/RollingWindow.java#L89-L98 |
25,480 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/worker/Worker.java | Worker.worker_output_tasks | public static Set<Integer> worker_output_tasks(WorkerData workerData) {
ContextMaker context_maker = workerData.getContextMaker();
Set<Integer> taskIds = workerData.getTaskIds();
StormTopology topology = workerData.getSysTopology();
Set<Integer> rtn = new HashSet<>();
for (Integer taskId : taskIds) {
TopologyContext context = context_maker.makeTopologyContext(topology, taskId, null);
// <StreamId, <ComponentId, Grouping>>
Map<String, Map<String, Grouping>> targets = context.getThisTargets();
for (Map<String, Grouping> e : targets.values()) {
for (String componentId : e.keySet()) {
List<Integer> tasks = context.getComponentTasks(componentId);
rtn.addAll(tasks);
}
}
}
return rtn;
} | java | public static Set<Integer> worker_output_tasks(WorkerData workerData) {
ContextMaker context_maker = workerData.getContextMaker();
Set<Integer> taskIds = workerData.getTaskIds();
StormTopology topology = workerData.getSysTopology();
Set<Integer> rtn = new HashSet<>();
for (Integer taskId : taskIds) {
TopologyContext context = context_maker.makeTopologyContext(topology, taskId, null);
// <StreamId, <ComponentId, Grouping>>
Map<String, Map<String, Grouping>> targets = context.getThisTargets();
for (Map<String, Grouping> e : targets.values()) {
for (String componentId : e.keySet()) {
List<Integer> tasks = context.getComponentTasks(componentId);
rtn.addAll(tasks);
}
}
}
return rtn;
} | [
"public",
"static",
"Set",
"<",
"Integer",
">",
"worker_output_tasks",
"(",
"WorkerData",
"workerData",
")",
"{",
"ContextMaker",
"context_maker",
"=",
"workerData",
".",
"getContextMaker",
"(",
")",
";",
"Set",
"<",
"Integer",
">",
"taskIds",
"=",
"workerData",
".",
"getTaskIds",
"(",
")",
";",
"StormTopology",
"topology",
"=",
"workerData",
".",
"getSysTopology",
"(",
")",
";",
"Set",
"<",
"Integer",
">",
"rtn",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"Integer",
"taskId",
":",
"taskIds",
")",
"{",
"TopologyContext",
"context",
"=",
"context_maker",
".",
"makeTopologyContext",
"(",
"topology",
",",
"taskId",
",",
"null",
")",
";",
"// <StreamId, <ComponentId, Grouping>>",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Grouping",
">",
">",
"targets",
"=",
"context",
".",
"getThisTargets",
"(",
")",
";",
"for",
"(",
"Map",
"<",
"String",
",",
"Grouping",
">",
"e",
":",
"targets",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"String",
"componentId",
":",
"e",
".",
"keySet",
"(",
")",
")",
"{",
"List",
"<",
"Integer",
">",
"tasks",
"=",
"context",
".",
"getComponentTasks",
"(",
"componentId",
")",
";",
"rtn",
".",
"addAll",
"(",
"tasks",
")",
";",
"}",
"}",
"}",
"return",
"rtn",
";",
"}"
] | get current task's output task list | [
"get",
"current",
"task",
"s",
"output",
"task",
"list"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/worker/Worker.java#L74-L95 |
25,481 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/worker/Worker.java | Worker.mk_worker | @SuppressWarnings("rawtypes")
public static WorkerShutdown mk_worker(Map conf, IContext context, String topologyId, String supervisorId,
int port, String workerId, String jarPath) throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("topologyId:").append(topologyId).append(", ");
sb.append("port:").append(port).append(", ");
sb.append("workerId:").append(workerId).append(", ");
sb.append("jarPath:").append(jarPath).append("\n");
LOG.info("Begin to run worker:" + sb.toString());
Worker w = new Worker(conf, context, topologyId, supervisorId, port, workerId, jarPath);
// w.redirectOutput();
return w.execute();
} | java | @SuppressWarnings("rawtypes")
public static WorkerShutdown mk_worker(Map conf, IContext context, String topologyId, String supervisorId,
int port, String workerId, String jarPath) throws Exception {
StringBuilder sb = new StringBuilder();
sb.append("topologyId:").append(topologyId).append(", ");
sb.append("port:").append(port).append(", ");
sb.append("workerId:").append(workerId).append(", ");
sb.append("jarPath:").append(jarPath).append("\n");
LOG.info("Begin to run worker:" + sb.toString());
Worker w = new Worker(conf, context, topologyId, supervisorId, port, workerId, jarPath);
// w.redirectOutput();
return w.execute();
} | [
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"public",
"static",
"WorkerShutdown",
"mk_worker",
"(",
"Map",
"conf",
",",
"IContext",
"context",
",",
"String",
"topologyId",
",",
"String",
"supervisorId",
",",
"int",
"port",
",",
"String",
"workerId",
",",
"String",
"jarPath",
")",
"throws",
"Exception",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"topologyId:\"",
")",
".",
"append",
"(",
"topologyId",
")",
".",
"append",
"(",
"\", \"",
")",
";",
"sb",
".",
"append",
"(",
"\"port:\"",
")",
".",
"append",
"(",
"port",
")",
".",
"append",
"(",
"\", \"",
")",
";",
"sb",
".",
"append",
"(",
"\"workerId:\"",
")",
".",
"append",
"(",
"workerId",
")",
".",
"append",
"(",
"\", \"",
")",
";",
"sb",
".",
"append",
"(",
"\"jarPath:\"",
")",
".",
"append",
"(",
"jarPath",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"LOG",
".",
"info",
"(",
"\"Begin to run worker:\"",
"+",
"sb",
".",
"toString",
"(",
")",
")",
";",
"Worker",
"w",
"=",
"new",
"Worker",
"(",
"conf",
",",
"context",
",",
"topologyId",
",",
"supervisorId",
",",
"port",
",",
"workerId",
",",
"jarPath",
")",
";",
"// w.redirectOutput();",
"return",
"w",
".",
"execute",
"(",
")",
";",
"}"
] | create worker instance and run it
@param conf storm conf
@param topologyId topology id
@param supervisorId supervisor iid
@param port worker port
@param workerId worker id
@return WorkerShutDown
@throws Exception | [
"create",
"worker",
"instance",
"and",
"run",
"it"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/worker/Worker.java#L227-L241 |
25,482 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/daemon/worker/Worker.java | Worker.getOldPortPids | public static List<Integer> getOldPortPids(String port) {
String currPid = JStormUtils.process_pid();
List<Integer> ret = new ArrayList<>();
StringBuilder sb = new StringBuilder();
sb.append("ps -Af ");
// sb.append(" | grep ");
// sb.append(Worker.class.getName());
// sb.append(" |grep ");
// sb.append(port);
// sb.append(" |grep -v grep");
try {
LOG.info("Begin to execute " + sb.toString());
String output = JStormUtils.launchProcess(sb.toString(), new HashMap<String, String>(), false);
BufferedReader reader = new BufferedReader(new StringReader(output));
JStormUtils.sleepMs(1000);
// if (process.exitValue() != 0) {
// LOG.info("Failed to execute " + sb.toString());
// return null;
// }
String str;
while ((str = reader.readLine()) != null) {
if (StringUtils.isBlank(str)) {
// LOG.info(str + " is Blank");
continue;
}
// LOG.info("Output:" + str);
if (!str.contains(Worker.class.getName())) {
continue;
} else if (str.contains(ProcessLauncher.class.getName())) {
continue;
} else if (!str.contains(port)) {
continue;
}
LOG.info("Find :" + str);
String[] fields = StringUtils.split(str);
boolean find = false;
int i = 0;
for (; i < fields.length; i++) {
String field = fields[i];
LOG.debug("Found, " + i + ":" + field);
if (field.contains(Worker.class.getName())) {
if (i + 3 >= fields.length) {
LOG.info("Failed to find port ");
} else if (fields[i + 3].equals(String.valueOf(port))) {
find = true;
}
break;
}
}
if (!find) {
LOG.info("No old port worker");
continue;
}
if (fields.length >= 2) {
try {
if (currPid.equals(fields[1])) {
LOG.info("Skip killing myself");
continue;
}
Integer pid = Integer.valueOf(fields[1]);
LOG.info("Find one process :" + pid.toString());
ret.add(pid);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
return ret;
} catch (IOException e) {
LOG.info("Failed to execute " + sb.toString());
return ret;
} catch (Exception e) {
LOG.info(e.getMessage(), e);
return ret;
}
} | java | public static List<Integer> getOldPortPids(String port) {
String currPid = JStormUtils.process_pid();
List<Integer> ret = new ArrayList<>();
StringBuilder sb = new StringBuilder();
sb.append("ps -Af ");
// sb.append(" | grep ");
// sb.append(Worker.class.getName());
// sb.append(" |grep ");
// sb.append(port);
// sb.append(" |grep -v grep");
try {
LOG.info("Begin to execute " + sb.toString());
String output = JStormUtils.launchProcess(sb.toString(), new HashMap<String, String>(), false);
BufferedReader reader = new BufferedReader(new StringReader(output));
JStormUtils.sleepMs(1000);
// if (process.exitValue() != 0) {
// LOG.info("Failed to execute " + sb.toString());
// return null;
// }
String str;
while ((str = reader.readLine()) != null) {
if (StringUtils.isBlank(str)) {
// LOG.info(str + " is Blank");
continue;
}
// LOG.info("Output:" + str);
if (!str.contains(Worker.class.getName())) {
continue;
} else if (str.contains(ProcessLauncher.class.getName())) {
continue;
} else if (!str.contains(port)) {
continue;
}
LOG.info("Find :" + str);
String[] fields = StringUtils.split(str);
boolean find = false;
int i = 0;
for (; i < fields.length; i++) {
String field = fields[i];
LOG.debug("Found, " + i + ":" + field);
if (field.contains(Worker.class.getName())) {
if (i + 3 >= fields.length) {
LOG.info("Failed to find port ");
} else if (fields[i + 3].equals(String.valueOf(port))) {
find = true;
}
break;
}
}
if (!find) {
LOG.info("No old port worker");
continue;
}
if (fields.length >= 2) {
try {
if (currPid.equals(fields[1])) {
LOG.info("Skip killing myself");
continue;
}
Integer pid = Integer.valueOf(fields[1]);
LOG.info("Find one process :" + pid.toString());
ret.add(pid);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}
return ret;
} catch (IOException e) {
LOG.info("Failed to execute " + sb.toString());
return ret;
} catch (Exception e) {
LOG.info(e.getMessage(), e);
return ret;
}
} | [
"public",
"static",
"List",
"<",
"Integer",
">",
"getOldPortPids",
"(",
"String",
"port",
")",
"{",
"String",
"currPid",
"=",
"JStormUtils",
".",
"process_pid",
"(",
")",
";",
"List",
"<",
"Integer",
">",
"ret",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"ps -Af \"",
")",
";",
"// sb.append(\" | grep \");",
"// sb.append(Worker.class.getName());",
"// sb.append(\" |grep \");",
"// sb.append(port);",
"// sb.append(\" |grep -v grep\");",
"try",
"{",
"LOG",
".",
"info",
"(",
"\"Begin to execute \"",
"+",
"sb",
".",
"toString",
"(",
")",
")",
";",
"String",
"output",
"=",
"JStormUtils",
".",
"launchProcess",
"(",
"sb",
".",
"toString",
"(",
")",
",",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
",",
"false",
")",
";",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"StringReader",
"(",
"output",
")",
")",
";",
"JStormUtils",
".",
"sleepMs",
"(",
"1000",
")",
";",
"// if (process.exitValue() != 0) {",
"// LOG.info(\"Failed to execute \" + sb.toString());",
"// return null;",
"// }",
"String",
"str",
";",
"while",
"(",
"(",
"str",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"StringUtils",
".",
"isBlank",
"(",
"str",
")",
")",
"{",
"// LOG.info(str + \" is Blank\");",
"continue",
";",
"}",
"// LOG.info(\"Output:\" + str);",
"if",
"(",
"!",
"str",
".",
"contains",
"(",
"Worker",
".",
"class",
".",
"getName",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"str",
".",
"contains",
"(",
"ProcessLauncher",
".",
"class",
".",
"getName",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"else",
"if",
"(",
"!",
"str",
".",
"contains",
"(",
"port",
")",
")",
"{",
"continue",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Find :\"",
"+",
"str",
")",
";",
"String",
"[",
"]",
"fields",
"=",
"StringUtils",
".",
"split",
"(",
"str",
")",
";",
"boolean",
"find",
"=",
"false",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"fields",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"field",
"=",
"fields",
"[",
"i",
"]",
";",
"LOG",
".",
"debug",
"(",
"\"Found, \"",
"+",
"i",
"+",
"\":\"",
"+",
"field",
")",
";",
"if",
"(",
"field",
".",
"contains",
"(",
"Worker",
".",
"class",
".",
"getName",
"(",
")",
")",
")",
"{",
"if",
"(",
"i",
"+",
"3",
">=",
"fields",
".",
"length",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Failed to find port \"",
")",
";",
"}",
"else",
"if",
"(",
"fields",
"[",
"i",
"+",
"3",
"]",
".",
"equals",
"(",
"String",
".",
"valueOf",
"(",
"port",
")",
")",
")",
"{",
"find",
"=",
"true",
";",
"}",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"find",
")",
"{",
"LOG",
".",
"info",
"(",
"\"No old port worker\"",
")",
";",
"continue",
";",
"}",
"if",
"(",
"fields",
".",
"length",
">=",
"2",
")",
"{",
"try",
"{",
"if",
"(",
"currPid",
".",
"equals",
"(",
"fields",
"[",
"1",
"]",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Skip killing myself\"",
")",
";",
"continue",
";",
"}",
"Integer",
"pid",
"=",
"Integer",
".",
"valueOf",
"(",
"fields",
"[",
"1",
"]",
")",
";",
"LOG",
".",
"info",
"(",
"\"Find one process :\"",
"+",
"pid",
".",
"toString",
"(",
")",
")",
";",
"ret",
".",
"add",
"(",
"pid",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"return",
"ret",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Failed to execute \"",
"+",
"sb",
".",
"toString",
"(",
")",
")",
";",
"return",
"ret",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"info",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"ret",
";",
"}",
"}"
] | Note that if the worker's start parameter length is longer than 4096,
ps -ef|grep com.alibaba.jstorm.daemon.worker.Worker can't find worker
@param port worker port | [
"Note",
"that",
"if",
"the",
"worker",
"s",
"start",
"parameter",
"length",
"is",
"longer",
"than",
"4096",
"ps",
"-",
"ef|grep",
"com",
".",
"alibaba",
".",
"jstorm",
".",
"daemon",
".",
"worker",
".",
"Worker",
"can",
"t",
"find",
"worker"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/daemon/worker/Worker.java#L293-L385 |
25,483 | alibaba/jstorm | jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/AsmMetric.java | AsmMetric.sample | protected boolean sample() {
if (curr.increment() >= freq) {
curr.set(0);
target.set(rand.nextInt(freq));
}
return curr.get() == target.get();
} | java | protected boolean sample() {
if (curr.increment() >= freq) {
curr.set(0);
target.set(rand.nextInt(freq));
}
return curr.get() == target.get();
} | [
"protected",
"boolean",
"sample",
"(",
")",
"{",
"if",
"(",
"curr",
".",
"increment",
"(",
")",
">=",
"freq",
")",
"{",
"curr",
".",
"set",
"(",
"0",
")",
";",
"target",
".",
"set",
"(",
"rand",
".",
"nextInt",
"(",
"freq",
")",
")",
";",
"}",
"return",
"curr",
".",
"get",
"(",
")",
"==",
"target",
".",
"get",
"(",
")",
";",
"}"
] | a faster sampling way | [
"a",
"faster",
"sampling",
"way"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/com/alibaba/jstorm/common/metric/AsmMetric.java#L90-L96 |
25,484 | alibaba/jstorm | jstorm-core/src/main/java/backtype/storm/topology/base/BaseStatefulWindowedBolt.java | BaseStatefulWindowedBolt.withMessageIdField | public BaseStatefulWindowedBolt<T> withMessageIdField(String fieldName) {
windowConfiguration.put(Config.TOPOLOGY_BOLTS_MESSAGE_ID_FIELD_NAME, fieldName);
return this;
} | java | public BaseStatefulWindowedBolt<T> withMessageIdField(String fieldName) {
windowConfiguration.put(Config.TOPOLOGY_BOLTS_MESSAGE_ID_FIELD_NAME, fieldName);
return this;
} | [
"public",
"BaseStatefulWindowedBolt",
"<",
"T",
">",
"withMessageIdField",
"(",
"String",
"fieldName",
")",
"{",
"windowConfiguration",
".",
"put",
"(",
"Config",
".",
"TOPOLOGY_BOLTS_MESSAGE_ID_FIELD_NAME",
",",
"fieldName",
")",
";",
"return",
"this",
";",
"}"
] | Specify the name of the field in the tuple that holds the message id. This is used to track
the windowing boundaries and re-evaluating the windowing operation during recovery of IStatefulWindowedBolt
@param fieldName the name of the field that contains the message id | [
"Specify",
"the",
"name",
"of",
"the",
"field",
"in",
"the",
"tuple",
"that",
"holds",
"the",
"message",
"id",
".",
"This",
"is",
"used",
"to",
"track",
"the",
"windowing",
"boundaries",
"and",
"re",
"-",
"evaluating",
"the",
"windowing",
"operation",
"during",
"recovery",
"of",
"IStatefulWindowedBolt"
] | 5d6cde22dbca7df3d6e6830bf94f98a6639ab559 | https://github.com/alibaba/jstorm/blob/5d6cde22dbca7df3d6e6830bf94f98a6639ab559/jstorm-core/src/main/java/backtype/storm/topology/base/BaseStatefulWindowedBolt.java#L131-L134 |
25,485 | aspnet/SignalR | clients/java/signalr/src/main/java/com/microsoft/signalr/Subscription.java | Subscription.unsubscribe | public void unsubscribe() {
List<InvocationHandler> handler = this.handlers.get(target);
if (handler != null) {
handler.remove(this.handler);
}
} | java | public void unsubscribe() {
List<InvocationHandler> handler = this.handlers.get(target);
if (handler != null) {
handler.remove(this.handler);
}
} | [
"public",
"void",
"unsubscribe",
"(",
")",
"{",
"List",
"<",
"InvocationHandler",
">",
"handler",
"=",
"this",
".",
"handlers",
".",
"get",
"(",
"target",
")",
";",
"if",
"(",
"handler",
"!=",
"null",
")",
"{",
"handler",
".",
"remove",
"(",
"this",
".",
"handler",
")",
";",
"}",
"}"
] | Removes the client method handler represented by this subscription. | [
"Removes",
"the",
"client",
"method",
"handler",
"represented",
"by",
"this",
"subscription",
"."
] | 8c6ed160d84f58ce8edf06a1c74221ddc8983ee9 | https://github.com/aspnet/SignalR/blob/8c6ed160d84f58ce8edf06a1c74221ddc8983ee9/clients/java/signalr/src/main/java/com/microsoft/signalr/Subscription.java#L25-L30 |
25,486 | getsentry/sentry-java | sentry/src/main/java/io/sentry/connection/RandomEventSampler.java | RandomEventSampler.shouldSendEvent | @Override
public boolean shouldSendEvent(Event event) {
double randomDouble = random.nextDouble();
return sampleRate >= Math.abs(randomDouble);
} | java | @Override
public boolean shouldSendEvent(Event event) {
double randomDouble = random.nextDouble();
return sampleRate >= Math.abs(randomDouble);
} | [
"@",
"Override",
"public",
"boolean",
"shouldSendEvent",
"(",
"Event",
"event",
")",
"{",
"double",
"randomDouble",
"=",
"random",
".",
"nextDouble",
"(",
")",
";",
"return",
"sampleRate",
">=",
"Math",
".",
"abs",
"(",
"randomDouble",
")",
";",
"}"
] | Handles event sampling logic.
@param event Event to be checked against the sampling logic.
@return True if the event should be sent to the server, else False. | [
"Handles",
"event",
"sampling",
"logic",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/connection/RandomEventSampler.java#L45-L49 |
25,487 | getsentry/sentry-java | sentry/src/main/java/io/sentry/util/Util.java | Util.parseMdcTags | public static Set<String> parseMdcTags(String mdcTagsString) {
if (isNullOrEmpty(mdcTagsString)) {
return Collections.emptySet();
}
return new HashSet<>(Arrays.asList(mdcTagsString.split(",")));
} | java | public static Set<String> parseMdcTags(String mdcTagsString) {
if (isNullOrEmpty(mdcTagsString)) {
return Collections.emptySet();
}
return new HashSet<>(Arrays.asList(mdcTagsString.split(",")));
} | [
"public",
"static",
"Set",
"<",
"String",
">",
"parseMdcTags",
"(",
"String",
"mdcTagsString",
")",
"{",
"if",
"(",
"isNullOrEmpty",
"(",
"mdcTagsString",
")",
")",
"{",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"}",
"return",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"mdcTagsString",
".",
"split",
"(",
"\",\"",
")",
")",
")",
";",
"}"
] | Parses the provided Strings into a Set of Strings.
@param mdcTagsString comma-delimited tags
@return Set of Strings representing mdc tags | [
"Parses",
"the",
"provided",
"Strings",
"into",
"a",
"Set",
"of",
"Strings",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/util/Util.java#L85-L91 |
25,488 | getsentry/sentry-java | sentry/src/main/java/io/sentry/util/Util.java | Util.trimString | public static String trimString(String string, int maxMessageLength) {
if (string == null) {
return null;
} else if (string.length() > maxMessageLength) {
// CHECKSTYLE.OFF: MagicNumber
return string.substring(0, maxMessageLength - 3) + "...";
// CHECKSTYLE.ON: MagicNumber
} else {
return string;
}
} | java | public static String trimString(String string, int maxMessageLength) {
if (string == null) {
return null;
} else if (string.length() > maxMessageLength) {
// CHECKSTYLE.OFF: MagicNumber
return string.substring(0, maxMessageLength - 3) + "...";
// CHECKSTYLE.ON: MagicNumber
} else {
return string;
}
} | [
"public",
"static",
"String",
"trimString",
"(",
"String",
"string",
",",
"int",
"maxMessageLength",
")",
"{",
"if",
"(",
"string",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"string",
".",
"length",
"(",
")",
">",
"maxMessageLength",
")",
"{",
"// CHECKSTYLE.OFF: MagicNumber",
"return",
"string",
".",
"substring",
"(",
"0",
",",
"maxMessageLength",
"-",
"3",
")",
"+",
"\"...\"",
";",
"// CHECKSTYLE.ON: MagicNumber",
"}",
"else",
"{",
"return",
"string",
";",
"}",
"}"
] | Trims a String, ensuring that the maximum length isn't reached.
@param string string to trim
@param maxMessageLength maximum length of the string
@return trimmed string | [
"Trims",
"a",
"String",
"ensuring",
"that",
"the",
"maximum",
"length",
"isn",
"t",
"reached",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/util/Util.java#L146-L156 |
25,489 | getsentry/sentry-java | sentry/src/main/java/io/sentry/util/Util.java | Util.safelyRemoveShutdownHook | public static boolean safelyRemoveShutdownHook(Thread shutDownHook) {
try {
return Runtime.getRuntime().removeShutdownHook(shutDownHook);
} catch (IllegalStateException e) {
// CHECKSTYLE.OFF: EmptyBlock
if (e.getMessage().equals("Shutdown in progress")) {
// ignore
} else {
throw e;
}
// CHECKSTYLE.ON: EmptyBlock
}
return false;
} | java | public static boolean safelyRemoveShutdownHook(Thread shutDownHook) {
try {
return Runtime.getRuntime().removeShutdownHook(shutDownHook);
} catch (IllegalStateException e) {
// CHECKSTYLE.OFF: EmptyBlock
if (e.getMessage().equals("Shutdown in progress")) {
// ignore
} else {
throw e;
}
// CHECKSTYLE.ON: EmptyBlock
}
return false;
} | [
"public",
"static",
"boolean",
"safelyRemoveShutdownHook",
"(",
"Thread",
"shutDownHook",
")",
"{",
"try",
"{",
"return",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"removeShutdownHook",
"(",
"shutDownHook",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"// CHECKSTYLE.OFF: EmptyBlock",
"if",
"(",
"e",
".",
"getMessage",
"(",
")",
".",
"equals",
"(",
"\"Shutdown in progress\"",
")",
")",
"{",
"// ignore",
"}",
"else",
"{",
"throw",
"e",
";",
"}",
"// CHECKSTYLE.ON: EmptyBlock",
"}",
"return",
"false",
";",
"}"
] | Try to remove the shutDownHook, handling the case where the VM is in shutdown process.
@param shutDownHook the shutDownHook to remove
@return true if the hook was removed, false otherwise | [
"Try",
"to",
"remove",
"the",
"shutDownHook",
"handling",
"the",
"case",
"where",
"the",
"VM",
"is",
"in",
"shutdown",
"process",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/util/Util.java#L163-L176 |
25,490 | getsentry/sentry-java | sentry/src/main/java/io/sentry/time/FixedClock.java | FixedClock.tick | public void tick(long duration, TimeUnit unit) {
this.date = new Date(date.getTime() + unit.toMillis(duration));
} | java | public void tick(long duration, TimeUnit unit) {
this.date = new Date(date.getTime() + unit.toMillis(duration));
} | [
"public",
"void",
"tick",
"(",
"long",
"duration",
",",
"TimeUnit",
"unit",
")",
"{",
"this",
".",
"date",
"=",
"new",
"Date",
"(",
"date",
".",
"getTime",
"(",
")",
"+",
"unit",
".",
"toMillis",
"(",
"duration",
")",
")",
";",
"}"
] | Adjust the FixedClock by the given amount.
@param duration Duration of time to adjust the clock by.
@param unit Unit of time to adjust the clock by. | [
"Adjust",
"the",
"FixedClock",
"by",
"the",
"given",
"amount",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/time/FixedClock.java#L42-L44 |
25,491 | getsentry/sentry-java | sentry/src/main/java/io/sentry/event/UserBuilder.java | UserBuilder.withData | public UserBuilder withData(String name, Object value) {
if (this.data == null) {
this.data = new HashMap<>();
}
this.data.put(name, value);
return this;
} | java | public UserBuilder withData(String name, Object value) {
if (this.data == null) {
this.data = new HashMap<>();
}
this.data.put(name, value);
return this;
} | [
"public",
"UserBuilder",
"withData",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"this",
".",
"data",
"==",
"null",
")",
"{",
"this",
".",
"data",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"}",
"this",
".",
"data",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Adds to the extra data for the user.
@param name Name of the data
@param value Value of the data
@return current instance of UserBuilder | [
"Adds",
"to",
"the",
"extra",
"data",
"for",
"the",
"user",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/event/UserBuilder.java#L78-L85 |
25,492 | getsentry/sentry-java | sentry/src/main/java/io/sentry/config/JndiLookup.java | JndiLookup.jndiLookup | public static String jndiLookup(String key) {
String value = null;
try {
Context c = new InitialContext();
value = (String) c.lookup(JNDI_PREFIX + key);
} catch (NoInitialContextException e) {
logger.trace("JNDI not configured for Sentry (NoInitialContextEx)");
} catch (NamingException e) {
logger.trace("No /sentry/" + key + " in JNDI");
} catch (RuntimeException e) {
logger.warn("Odd RuntimeException while testing for JNDI", e);
}
return value;
} | java | public static String jndiLookup(String key) {
String value = null;
try {
Context c = new InitialContext();
value = (String) c.lookup(JNDI_PREFIX + key);
} catch (NoInitialContextException e) {
logger.trace("JNDI not configured for Sentry (NoInitialContextEx)");
} catch (NamingException e) {
logger.trace("No /sentry/" + key + " in JNDI");
} catch (RuntimeException e) {
logger.warn("Odd RuntimeException while testing for JNDI", e);
}
return value;
} | [
"public",
"static",
"String",
"jndiLookup",
"(",
"String",
"key",
")",
"{",
"String",
"value",
"=",
"null",
";",
"try",
"{",
"Context",
"c",
"=",
"new",
"InitialContext",
"(",
")",
";",
"value",
"=",
"(",
"String",
")",
"c",
".",
"lookup",
"(",
"JNDI_PREFIX",
"+",
"key",
")",
";",
"}",
"catch",
"(",
"NoInitialContextException",
"e",
")",
"{",
"logger",
".",
"trace",
"(",
"\"JNDI not configured for Sentry (NoInitialContextEx)\"",
")",
";",
"}",
"catch",
"(",
"NamingException",
"e",
")",
"{",
"logger",
".",
"trace",
"(",
"\"No /sentry/\"",
"+",
"key",
"+",
"\" in JNDI\"",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Odd RuntimeException while testing for JNDI\"",
",",
"e",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Looks up for a JNDI definition of the provided key.
@param key name of configuration key, e.g. "dsn"
@return the value as defined in JNDI or null if it isn't defined. | [
"Looks",
"up",
"for",
"a",
"JNDI",
"definition",
"of",
"the",
"provided",
"key",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/config/JndiLookup.java#L31-L44 |
25,493 | getsentry/sentry-java | sentry/src/main/java/io/sentry/jul/SentryHandler.java | SentryHandler.retrieveProperties | protected void retrieveProperties() {
LogManager manager = LogManager.getLogManager();
String className = SentryHandler.class.getName();
setPrintfStyle(Boolean.valueOf(manager.getProperty(className + ".printfStyle")));
setLevel(parseLevelOrDefault(manager.getProperty(className + ".level")));
} | java | protected void retrieveProperties() {
LogManager manager = LogManager.getLogManager();
String className = SentryHandler.class.getName();
setPrintfStyle(Boolean.valueOf(manager.getProperty(className + ".printfStyle")));
setLevel(parseLevelOrDefault(manager.getProperty(className + ".level")));
} | [
"protected",
"void",
"retrieveProperties",
"(",
")",
"{",
"LogManager",
"manager",
"=",
"LogManager",
".",
"getLogManager",
"(",
")",
";",
"String",
"className",
"=",
"SentryHandler",
".",
"class",
".",
"getName",
"(",
")",
";",
"setPrintfStyle",
"(",
"Boolean",
".",
"valueOf",
"(",
"manager",
".",
"getProperty",
"(",
"className",
"+",
"\".printfStyle\"",
")",
")",
")",
";",
"setLevel",
"(",
"parseLevelOrDefault",
"(",
"manager",
".",
"getProperty",
"(",
"className",
"+",
"\".level\"",
")",
")",
")",
";",
"}"
] | Retrieves the properties of the logger. | [
"Retrieves",
"the",
"properties",
"of",
"the",
"logger",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/jul/SentryHandler.java#L80-L85 |
25,494 | getsentry/sentry-java | sentry/src/main/java/io/sentry/jul/SentryHandler.java | SentryHandler.createEventBuilder | protected EventBuilder createEventBuilder(LogRecord record) {
EventBuilder eventBuilder = new EventBuilder()
.withSdkIntegration("java.util.logging")
.withLevel(getLevel(record.getLevel()))
.withTimestamp(new Date(record.getMillis()))
.withLogger(record.getLoggerName());
String message = record.getMessage();
if (record.getResourceBundle() != null && record.getResourceBundle().containsKey(record.getMessage())) {
message = record.getResourceBundle().getString(record.getMessage());
}
String topLevelMessage = message;
if (record.getParameters() == null) {
eventBuilder.withSentryInterface(new MessageInterface(message));
} else {
String formatted;
List<String> parameters = formatMessageParameters(record.getParameters());
try {
formatted = formatMessage(message, record.getParameters());
topLevelMessage = formatted; // write out formatted as Event's message key
} catch (Exception e) {
// local formatting failed, send message and parameters without formatted string
formatted = null;
}
eventBuilder.withSentryInterface(new MessageInterface(message, parameters, formatted));
}
eventBuilder.withMessage(topLevelMessage);
Throwable throwable = record.getThrown();
if (throwable != null) {
eventBuilder.withSentryInterface(new ExceptionInterface(throwable));
}
Map<String, String> mdc = MDC.getMDCAdapter().getCopyOfContextMap();
if (mdc != null) {
for (Map.Entry<String, String> mdcEntry : mdc.entrySet()) {
if (Sentry.getStoredClient().getMdcTags().contains(mdcEntry.getKey())) {
eventBuilder.withTag(mdcEntry.getKey(), mdcEntry.getValue());
} else {
eventBuilder.withExtra(mdcEntry.getKey(), mdcEntry.getValue());
}
}
}
eventBuilder.withExtra(THREAD_ID, record.getThreadID());
return eventBuilder;
} | java | protected EventBuilder createEventBuilder(LogRecord record) {
EventBuilder eventBuilder = new EventBuilder()
.withSdkIntegration("java.util.logging")
.withLevel(getLevel(record.getLevel()))
.withTimestamp(new Date(record.getMillis()))
.withLogger(record.getLoggerName());
String message = record.getMessage();
if (record.getResourceBundle() != null && record.getResourceBundle().containsKey(record.getMessage())) {
message = record.getResourceBundle().getString(record.getMessage());
}
String topLevelMessage = message;
if (record.getParameters() == null) {
eventBuilder.withSentryInterface(new MessageInterface(message));
} else {
String formatted;
List<String> parameters = formatMessageParameters(record.getParameters());
try {
formatted = formatMessage(message, record.getParameters());
topLevelMessage = formatted; // write out formatted as Event's message key
} catch (Exception e) {
// local formatting failed, send message and parameters without formatted string
formatted = null;
}
eventBuilder.withSentryInterface(new MessageInterface(message, parameters, formatted));
}
eventBuilder.withMessage(topLevelMessage);
Throwable throwable = record.getThrown();
if (throwable != null) {
eventBuilder.withSentryInterface(new ExceptionInterface(throwable));
}
Map<String, String> mdc = MDC.getMDCAdapter().getCopyOfContextMap();
if (mdc != null) {
for (Map.Entry<String, String> mdcEntry : mdc.entrySet()) {
if (Sentry.getStoredClient().getMdcTags().contains(mdcEntry.getKey())) {
eventBuilder.withTag(mdcEntry.getKey(), mdcEntry.getValue());
} else {
eventBuilder.withExtra(mdcEntry.getKey(), mdcEntry.getValue());
}
}
}
eventBuilder.withExtra(THREAD_ID, record.getThreadID());
return eventBuilder;
} | [
"protected",
"EventBuilder",
"createEventBuilder",
"(",
"LogRecord",
"record",
")",
"{",
"EventBuilder",
"eventBuilder",
"=",
"new",
"EventBuilder",
"(",
")",
".",
"withSdkIntegration",
"(",
"\"java.util.logging\"",
")",
".",
"withLevel",
"(",
"getLevel",
"(",
"record",
".",
"getLevel",
"(",
")",
")",
")",
".",
"withTimestamp",
"(",
"new",
"Date",
"(",
"record",
".",
"getMillis",
"(",
")",
")",
")",
".",
"withLogger",
"(",
"record",
".",
"getLoggerName",
"(",
")",
")",
";",
"String",
"message",
"=",
"record",
".",
"getMessage",
"(",
")",
";",
"if",
"(",
"record",
".",
"getResourceBundle",
"(",
")",
"!=",
"null",
"&&",
"record",
".",
"getResourceBundle",
"(",
")",
".",
"containsKey",
"(",
"record",
".",
"getMessage",
"(",
")",
")",
")",
"{",
"message",
"=",
"record",
".",
"getResourceBundle",
"(",
")",
".",
"getString",
"(",
"record",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"String",
"topLevelMessage",
"=",
"message",
";",
"if",
"(",
"record",
".",
"getParameters",
"(",
")",
"==",
"null",
")",
"{",
"eventBuilder",
".",
"withSentryInterface",
"(",
"new",
"MessageInterface",
"(",
"message",
")",
")",
";",
"}",
"else",
"{",
"String",
"formatted",
";",
"List",
"<",
"String",
">",
"parameters",
"=",
"formatMessageParameters",
"(",
"record",
".",
"getParameters",
"(",
")",
")",
";",
"try",
"{",
"formatted",
"=",
"formatMessage",
"(",
"message",
",",
"record",
".",
"getParameters",
"(",
")",
")",
";",
"topLevelMessage",
"=",
"formatted",
";",
"// write out formatted as Event's message key",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// local formatting failed, send message and parameters without formatted string",
"formatted",
"=",
"null",
";",
"}",
"eventBuilder",
".",
"withSentryInterface",
"(",
"new",
"MessageInterface",
"(",
"message",
",",
"parameters",
",",
"formatted",
")",
")",
";",
"}",
"eventBuilder",
".",
"withMessage",
"(",
"topLevelMessage",
")",
";",
"Throwable",
"throwable",
"=",
"record",
".",
"getThrown",
"(",
")",
";",
"if",
"(",
"throwable",
"!=",
"null",
")",
"{",
"eventBuilder",
".",
"withSentryInterface",
"(",
"new",
"ExceptionInterface",
"(",
"throwable",
")",
")",
";",
"}",
"Map",
"<",
"String",
",",
"String",
">",
"mdc",
"=",
"MDC",
".",
"getMDCAdapter",
"(",
")",
".",
"getCopyOfContextMap",
"(",
")",
";",
"if",
"(",
"mdc",
"!=",
"null",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"mdcEntry",
":",
"mdc",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"Sentry",
".",
"getStoredClient",
"(",
")",
".",
"getMdcTags",
"(",
")",
".",
"contains",
"(",
"mdcEntry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"eventBuilder",
".",
"withTag",
"(",
"mdcEntry",
".",
"getKey",
"(",
")",
",",
"mdcEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"eventBuilder",
".",
"withExtra",
"(",
"mdcEntry",
".",
"getKey",
"(",
")",
",",
"mdcEntry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"}",
"eventBuilder",
".",
"withExtra",
"(",
"THREAD_ID",
",",
"record",
".",
"getThreadID",
"(",
")",
")",
";",
"return",
"eventBuilder",
";",
"}"
] | Builds an EventBuilder based on the log record.
@param record Log generated.
@return EventBuilder containing details provided by the logging system. | [
"Builds",
"an",
"EventBuilder",
"based",
"on",
"the",
"log",
"record",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/jul/SentryHandler.java#L119-L167 |
25,495 | getsentry/sentry-java | sentry/src/main/java/io/sentry/jul/SentryHandler.java | SentryHandler.formatMessage | protected String formatMessage(String message, Object[] parameters) {
String formatted;
if (printfStyle) {
formatted = String.format(message, parameters);
} else {
formatted = MessageFormat.format(message, parameters);
}
return formatted;
} | java | protected String formatMessage(String message, Object[] parameters) {
String formatted;
if (printfStyle) {
formatted = String.format(message, parameters);
} else {
formatted = MessageFormat.format(message, parameters);
}
return formatted;
} | [
"protected",
"String",
"formatMessage",
"(",
"String",
"message",
",",
"Object",
"[",
"]",
"parameters",
")",
"{",
"String",
"formatted",
";",
"if",
"(",
"printfStyle",
")",
"{",
"formatted",
"=",
"String",
".",
"format",
"(",
"message",
",",
"parameters",
")",
";",
"}",
"else",
"{",
"formatted",
"=",
"MessageFormat",
".",
"format",
"(",
"message",
",",
"parameters",
")",
";",
"}",
"return",
"formatted",
";",
"}"
] | Returns formatted Event message when provided the message template and
parameters.
@param message Message template body.
@param parameters Array of parameters for the message.
@return Formatted message. | [
"Returns",
"formatted",
"Event",
"message",
"when",
"provided",
"the",
"message",
"template",
"and",
"parameters",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry/src/main/java/io/sentry/jul/SentryHandler.java#L177-L185 |
25,496 | getsentry/sentry-java | sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java | AndroidEventBuilderHelper.getPackageInfo | protected static PackageInfo getPackageInfo(Context ctx) {
try {
return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Error getting package info.", e);
return null;
}
} | java | protected static PackageInfo getPackageInfo(Context ctx) {
try {
return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Error getting package info.", e);
return null;
}
} | [
"protected",
"static",
"PackageInfo",
"getPackageInfo",
"(",
"Context",
"ctx",
")",
"{",
"try",
"{",
"return",
"ctx",
".",
"getPackageManager",
"(",
")",
".",
"getPackageInfo",
"(",
"ctx",
".",
"getPackageName",
"(",
")",
",",
"0",
")",
";",
"}",
"catch",
"(",
"PackageManager",
".",
"NameNotFoundException",
"e",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Error getting package info.\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Return the Application's PackageInfo if possible, or null.
@param ctx Android application context
@return the Application's PackageInfo if possible, or null | [
"Return",
"the",
"Application",
"s",
"PackageInfo",
"if",
"possible",
"or",
"null",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java#L186-L193 |
25,497 | getsentry/sentry-java | sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java | AndroidEventBuilderHelper.getFamily | protected static String getFamily() {
try {
return Build.MODEL.split(" ")[0];
} catch (Exception e) {
Log.e(TAG, "Error getting device family.", e);
return null;
}
} | java | protected static String getFamily() {
try {
return Build.MODEL.split(" ")[0];
} catch (Exception e) {
Log.e(TAG, "Error getting device family.", e);
return null;
}
} | [
"protected",
"static",
"String",
"getFamily",
"(",
")",
"{",
"try",
"{",
"return",
"Build",
".",
"MODEL",
".",
"split",
"(",
"\" \"",
")",
"[",
"0",
"]",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Error getting device family.\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Fake the device family by using the first word in the Build.MODEL. Works
well in most cases... "Nexus 6P" -> "Nexus", "Galaxy S7" -> "Galaxy".
@return family name of the device, as best we can tell | [
"Fake",
"the",
"device",
"family",
"by",
"using",
"the",
"first",
"word",
"in",
"the",
"Build",
".",
"MODEL",
".",
"Works",
"well",
"in",
"most",
"cases",
"...",
"Nexus",
"6P",
"-",
">",
"Nexus",
"Galaxy",
"S7",
"-",
">",
"Galaxy",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java#L201-L208 |
25,498 | getsentry/sentry-java | sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java | AndroidEventBuilderHelper.getMemInfo | protected static ActivityManager.MemoryInfo getMemInfo(Context ctx) {
try {
ActivityManager actManager = (ActivityManager) ctx.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
actManager.getMemoryInfo(memInfo);
return memInfo;
} catch (Exception e) {
Log.e(TAG, "Error getting MemoryInfo.", e);
return null;
}
} | java | protected static ActivityManager.MemoryInfo getMemInfo(Context ctx) {
try {
ActivityManager actManager = (ActivityManager) ctx.getSystemService(ACTIVITY_SERVICE);
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
actManager.getMemoryInfo(memInfo);
return memInfo;
} catch (Exception e) {
Log.e(TAG, "Error getting MemoryInfo.", e);
return null;
}
} | [
"protected",
"static",
"ActivityManager",
".",
"MemoryInfo",
"getMemInfo",
"(",
"Context",
"ctx",
")",
"{",
"try",
"{",
"ActivityManager",
"actManager",
"=",
"(",
"ActivityManager",
")",
"ctx",
".",
"getSystemService",
"(",
"ACTIVITY_SERVICE",
")",
";",
"ActivityManager",
".",
"MemoryInfo",
"memInfo",
"=",
"new",
"ActivityManager",
".",
"MemoryInfo",
"(",
")",
";",
"actManager",
".",
"getMemoryInfo",
"(",
"memInfo",
")",
";",
"return",
"memInfo",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Error getting MemoryInfo.\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Get MemoryInfo object representing the memory state of the application.
@param ctx Android application context
@return MemoryInfo object representing the memory state of the application | [
"Get",
"MemoryInfo",
"object",
"representing",
"the",
"memory",
"state",
"of",
"the",
"application",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java#L237-L247 |
25,499 | getsentry/sentry-java | sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java | AndroidEventBuilderHelper.getOrientation | protected static String getOrientation(Context ctx) {
try {
String o;
switch (ctx.getResources().getConfiguration().orientation) {
case android.content.res.Configuration.ORIENTATION_LANDSCAPE:
o = "landscape";
break;
case android.content.res.Configuration.ORIENTATION_PORTRAIT:
o = "portrait";
break;
default:
o = null;
break;
}
return o;
} catch (Exception e) {
Log.e(TAG, "Error getting device orientation.", e);
return null;
}
} | java | protected static String getOrientation(Context ctx) {
try {
String o;
switch (ctx.getResources().getConfiguration().orientation) {
case android.content.res.Configuration.ORIENTATION_LANDSCAPE:
o = "landscape";
break;
case android.content.res.Configuration.ORIENTATION_PORTRAIT:
o = "portrait";
break;
default:
o = null;
break;
}
return o;
} catch (Exception e) {
Log.e(TAG, "Error getting device orientation.", e);
return null;
}
} | [
"protected",
"static",
"String",
"getOrientation",
"(",
"Context",
"ctx",
")",
"{",
"try",
"{",
"String",
"o",
";",
"switch",
"(",
"ctx",
".",
"getResources",
"(",
")",
".",
"getConfiguration",
"(",
")",
".",
"orientation",
")",
"{",
"case",
"android",
".",
"content",
".",
"res",
".",
"Configuration",
".",
"ORIENTATION_LANDSCAPE",
":",
"o",
"=",
"\"landscape\"",
";",
"break",
";",
"case",
"android",
".",
"content",
".",
"res",
".",
"Configuration",
".",
"ORIENTATION_PORTRAIT",
":",
"o",
"=",
"\"portrait\"",
";",
"break",
";",
"default",
":",
"o",
"=",
"null",
";",
"break",
";",
"}",
"return",
"o",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"Error getting device orientation.\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Get the device's current screen orientation.
@param ctx Android application context
@return the device's current screen orientation, or null if unknown | [
"Get",
"the",
"device",
"s",
"current",
"screen",
"orientation",
"."
] | 2e01461775cbd5951ff82b566069c349146d8aca | https://github.com/getsentry/sentry-java/blob/2e01461775cbd5951ff82b566069c349146d8aca/sentry-android/src/main/java/io/sentry/android/event/helper/AndroidEventBuilderHelper.java#L255-L274 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.