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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,000 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.setExecutionState | public Boolean setExecutionState(
ExecutionEnvironment.ExecutionState executionState, String topologyName) {
return awaitResult(delegate.setExecutionState(executionState, topologyName));
} | java | public Boolean setExecutionState(
ExecutionEnvironment.ExecutionState executionState, String topologyName) {
return awaitResult(delegate.setExecutionState(executionState, topologyName));
} | [
"public",
"Boolean",
"setExecutionState",
"(",
"ExecutionEnvironment",
".",
"ExecutionState",
"executionState",
",",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"setExecutionState",
"(",
"executionState",
",",
"topologyName",
")",
")",
";",
"}"
] | Set the execution state for the given topology
@return Boolean - Success or Failure | [
"Set",
"the",
"execution",
"state",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L107-L110 |
28,001 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.setTopology | public Boolean setTopology(TopologyAPI.Topology topology, String topologyName) {
return awaitResult(delegate.setTopology(topology, topologyName));
} | java | public Boolean setTopology(TopologyAPI.Topology topology, String topologyName) {
return awaitResult(delegate.setTopology(topology, topologyName));
} | [
"public",
"Boolean",
"setTopology",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
",",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"setTopology",
"(",
"topology",
",",
"topologyName",
")",
")",
";",
"}"
] | Set the topology definition for the given topology
@param topologyName the name of the topology
@return Boolean - Success or Failure | [
"Set",
"the",
"topology",
"definition",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L118-L120 |
28,002 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.updateTopology | public Boolean updateTopology(TopologyAPI.Topology topology, String topologyName) {
if (getTopology(topologyName) != null) {
deleteTopology(topologyName);
}
return setTopology(topology, topologyName);
} | java | public Boolean updateTopology(TopologyAPI.Topology topology, String topologyName) {
if (getTopology(topologyName) != null) {
deleteTopology(topologyName);
}
return setTopology(topology, topologyName);
} | [
"public",
"Boolean",
"updateTopology",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
",",
"String",
"topologyName",
")",
"{",
"if",
"(",
"getTopology",
"(",
"topologyName",
")",
"!=",
"null",
")",
"{",
"deleteTopology",
"(",
"topologyName",
")",
";",
"}",
"return",
"setTopology",
"(",
"topology",
",",
"topologyName",
")",
";",
"}"
] | Update the topology definition for the given topology. If the topology doesn't exist,
create it. If it does, update it.
@param topologyName the name of the topology
@return Boolean - Success or Failure | [
"Update",
"the",
"topology",
"definition",
"for",
"the",
"given",
"topology",
".",
"If",
"the",
"topology",
"doesn",
"t",
"exist",
"create",
"it",
".",
"If",
"it",
"does",
"update",
"it",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L129-L134 |
28,003 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.setSchedulerLocation | public Boolean setSchedulerLocation(
Scheduler.SchedulerLocation location,
String topologyName) {
return awaitResult(delegate.setSchedulerLocation(location, topologyName));
} | java | public Boolean setSchedulerLocation(
Scheduler.SchedulerLocation location,
String topologyName) {
return awaitResult(delegate.setSchedulerLocation(location, topologyName));
} | [
"public",
"Boolean",
"setSchedulerLocation",
"(",
"Scheduler",
".",
"SchedulerLocation",
"location",
",",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"setSchedulerLocation",
"(",
"location",
",",
"topologyName",
")",
")",
";",
"}"
] | Set the scheduler location for the given topology
@return Boolean - Success or Failure | [
"Set",
"the",
"scheduler",
"location",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L141-L145 |
28,004 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.setPackingPlan | public Boolean setPackingPlan(PackingPlans.PackingPlan packingPlan, String topologyName) {
return awaitResult(delegate.setPackingPlan(packingPlan, topologyName));
} | java | public Boolean setPackingPlan(PackingPlans.PackingPlan packingPlan, String topologyName) {
return awaitResult(delegate.setPackingPlan(packingPlan, topologyName));
} | [
"public",
"Boolean",
"setPackingPlan",
"(",
"PackingPlans",
".",
"PackingPlan",
"packingPlan",
",",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"setPackingPlan",
"(",
"packingPlan",
",",
"topologyName",
")",
")",
";",
"}"
] | Set the packing plan for the given topology
@param packingPlan the packing plan of the topology
@return Boolean - Success or Failure | [
"Set",
"the",
"packing",
"plan",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L153-L155 |
28,005 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.updatePackingPlan | public Boolean updatePackingPlan(PackingPlans.PackingPlan packingPlan, String topologyName) {
if (getPackingPlan(topologyName) != null) {
deletePackingPlan(topologyName);
}
return setPackingPlan(packingPlan, topologyName);
} | java | public Boolean updatePackingPlan(PackingPlans.PackingPlan packingPlan, String topologyName) {
if (getPackingPlan(topologyName) != null) {
deletePackingPlan(topologyName);
}
return setPackingPlan(packingPlan, topologyName);
} | [
"public",
"Boolean",
"updatePackingPlan",
"(",
"PackingPlans",
".",
"PackingPlan",
"packingPlan",
",",
"String",
"topologyName",
")",
"{",
"if",
"(",
"getPackingPlan",
"(",
"topologyName",
")",
"!=",
"null",
")",
"{",
"deletePackingPlan",
"(",
"topologyName",
")",
";",
"}",
"return",
"setPackingPlan",
"(",
"packingPlan",
",",
"topologyName",
")",
";",
"}"
] | Update the packing plan for the given topology. If the packing plan doesn't exist, create it.
If it does, update it.
@param packingPlan the packing plan of the topology
@return Boolean - Success or Failure | [
"Update",
"the",
"packing",
"plan",
"for",
"the",
"given",
"topology",
".",
"If",
"the",
"packing",
"plan",
"doesn",
"t",
"exist",
"create",
"it",
".",
"If",
"it",
"does",
"update",
"it",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L164-L169 |
28,006 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getTMasterLocation | public TopologyMaster.TMasterLocation getTMasterLocation(String topologyName) {
return awaitResult(delegate.getTMasterLocation(null, topologyName));
} | java | public TopologyMaster.TMasterLocation getTMasterLocation(String topologyName) {
return awaitResult(delegate.getTMasterLocation(null, topologyName));
} | [
"public",
"TopologyMaster",
".",
"TMasterLocation",
"getTMasterLocation",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getTMasterLocation",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the tmaster location for the given topology
@return TMasterLocation | [
"Get",
"the",
"tmaster",
"location",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L247-L249 |
28,007 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getSchedulerLocation | public Scheduler.SchedulerLocation getSchedulerLocation(String topologyName) {
return awaitResult(delegate.getSchedulerLocation(null, topologyName));
} | java | public Scheduler.SchedulerLocation getSchedulerLocation(String topologyName) {
return awaitResult(delegate.getSchedulerLocation(null, topologyName));
} | [
"public",
"Scheduler",
".",
"SchedulerLocation",
"getSchedulerLocation",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getSchedulerLocation",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the scheduler location for the given topology
@return SchedulerLocation | [
"Get",
"the",
"scheduler",
"location",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L256-L258 |
28,008 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getMetricsCacheLocation | public TopologyMaster.MetricsCacheLocation getMetricsCacheLocation(String topologyName) {
return awaitResult(delegate.getMetricsCacheLocation(null, topologyName));
} | java | public TopologyMaster.MetricsCacheLocation getMetricsCacheLocation(String topologyName) {
return awaitResult(delegate.getMetricsCacheLocation(null, topologyName));
} | [
"public",
"TopologyMaster",
".",
"MetricsCacheLocation",
"getMetricsCacheLocation",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getMetricsCacheLocation",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the metricscache location for the given topology
@return MetricsCacheLocation | [
"Get",
"the",
"metricscache",
"location",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L265-L267 |
28,009 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getTopology | public TopologyAPI.Topology getTopology(String topologyName) {
return awaitResult(delegate.getTopology(null, topologyName));
} | java | public TopologyAPI.Topology getTopology(String topologyName) {
return awaitResult(delegate.getTopology(null, topologyName));
} | [
"public",
"TopologyAPI",
".",
"Topology",
"getTopology",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getTopology",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the topology definition for the given topology
@return Topology | [
"Get",
"the",
"topology",
"definition",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L275-L277 |
28,010 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getExecutionState | public ExecutionEnvironment.ExecutionState getExecutionState(String topologyName) {
return awaitResult(delegate.getExecutionState(null, topologyName));
} | java | public ExecutionEnvironment.ExecutionState getExecutionState(String topologyName) {
return awaitResult(delegate.getExecutionState(null, topologyName));
} | [
"public",
"ExecutionEnvironment",
".",
"ExecutionState",
"getExecutionState",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getExecutionState",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the execution state for the given topology
@return ExecutionState | [
"Get",
"the",
"execution",
"state",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L284-L286 |
28,011 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getPhysicalPlan | public PhysicalPlans.PhysicalPlan getPhysicalPlan(String topologyName) {
return awaitResult(delegate.getPhysicalPlan(null, topologyName));
} | java | public PhysicalPlans.PhysicalPlan getPhysicalPlan(String topologyName) {
return awaitResult(delegate.getPhysicalPlan(null, topologyName));
} | [
"public",
"PhysicalPlans",
".",
"PhysicalPlan",
"getPhysicalPlan",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getPhysicalPlan",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the physical plan for the given topology
@return PhysicalPlans.PhysicalPlan | [
"Get",
"the",
"physical",
"plan",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L293-L295 |
28,012 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java | SchedulerStateManagerAdaptor.getPackingPlan | public PackingPlans.PackingPlan getPackingPlan(String topologyName) {
return awaitResult(delegate.getPackingPlan(null, topologyName));
} | java | public PackingPlans.PackingPlan getPackingPlan(String topologyName) {
return awaitResult(delegate.getPackingPlan(null, topologyName));
} | [
"public",
"PackingPlans",
".",
"PackingPlan",
"getPackingPlan",
"(",
"String",
"topologyName",
")",
"{",
"return",
"awaitResult",
"(",
"delegate",
".",
"getPackingPlan",
"(",
"null",
",",
"topologyName",
")",
")",
";",
"}"
] | Get the packing plan for the given topology
@return PackingPlans.PackingPlan | [
"Get",
"the",
"packing",
"plan",
"for",
"the",
"given",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/statemgr/SchedulerStateManagerAdaptor.java#L302-L304 |
28,013 | apache/incubator-heron | heron/instance/src/java/org/apache/heron/instance/OutgoingTupleCollection.java | OutgoingTupleCollection.sendOutState | public void sendOutState(State<Serializable, Serializable> state,
String checkpointId,
boolean spillState,
String location) {
lock.lock();
try {
// flush all the current data before sending the state
flushRemaining();
// serialize the state
byte[] serializedState = serializer.serialize(state);
CheckpointManager.InstanceStateCheckpoint.Builder instanceStateBuilder =
CheckpointManager.InstanceStateCheckpoint.newBuilder();
instanceStateBuilder.setCheckpointId(checkpointId);
if (spillState) {
FileUtils.cleanDir(location);
String stateLocation = location + checkpointId + "-" + UUID.randomUUID();
if (!FileUtils.writeToFile(stateLocation, serializedState, true)) {
throw new RuntimeException("failed to spill state. Bailing out...");
}
instanceStateBuilder.setStateLocation(stateLocation);
} else {
instanceStateBuilder.setState(ByteString.copyFrom(serializedState));
}
CheckpointManager.StoreInstanceStateCheckpoint storeRequest =
CheckpointManager.StoreInstanceStateCheckpoint.newBuilder()
.setState(instanceStateBuilder.build())
.build();
// Put the checkpoint to out stream queue
outQueue.offer(storeRequest);
} finally {
lock.unlock();
}
} | java | public void sendOutState(State<Serializable, Serializable> state,
String checkpointId,
boolean spillState,
String location) {
lock.lock();
try {
// flush all the current data before sending the state
flushRemaining();
// serialize the state
byte[] serializedState = serializer.serialize(state);
CheckpointManager.InstanceStateCheckpoint.Builder instanceStateBuilder =
CheckpointManager.InstanceStateCheckpoint.newBuilder();
instanceStateBuilder.setCheckpointId(checkpointId);
if (spillState) {
FileUtils.cleanDir(location);
String stateLocation = location + checkpointId + "-" + UUID.randomUUID();
if (!FileUtils.writeToFile(stateLocation, serializedState, true)) {
throw new RuntimeException("failed to spill state. Bailing out...");
}
instanceStateBuilder.setStateLocation(stateLocation);
} else {
instanceStateBuilder.setState(ByteString.copyFrom(serializedState));
}
CheckpointManager.StoreInstanceStateCheckpoint storeRequest =
CheckpointManager.StoreInstanceStateCheckpoint.newBuilder()
.setState(instanceStateBuilder.build())
.build();
// Put the checkpoint to out stream queue
outQueue.offer(storeRequest);
} finally {
lock.unlock();
}
} | [
"public",
"void",
"sendOutState",
"(",
"State",
"<",
"Serializable",
",",
"Serializable",
">",
"state",
",",
"String",
"checkpointId",
",",
"boolean",
"spillState",
",",
"String",
"location",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"// flush all the current data before sending the state",
"flushRemaining",
"(",
")",
";",
"// serialize the state",
"byte",
"[",
"]",
"serializedState",
"=",
"serializer",
".",
"serialize",
"(",
"state",
")",
";",
"CheckpointManager",
".",
"InstanceStateCheckpoint",
".",
"Builder",
"instanceStateBuilder",
"=",
"CheckpointManager",
".",
"InstanceStateCheckpoint",
".",
"newBuilder",
"(",
")",
";",
"instanceStateBuilder",
".",
"setCheckpointId",
"(",
"checkpointId",
")",
";",
"if",
"(",
"spillState",
")",
"{",
"FileUtils",
".",
"cleanDir",
"(",
"location",
")",
";",
"String",
"stateLocation",
"=",
"location",
"+",
"checkpointId",
"+",
"\"-\"",
"+",
"UUID",
".",
"randomUUID",
"(",
")",
";",
"if",
"(",
"!",
"FileUtils",
".",
"writeToFile",
"(",
"stateLocation",
",",
"serializedState",
",",
"true",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"failed to spill state. Bailing out...\"",
")",
";",
"}",
"instanceStateBuilder",
".",
"setStateLocation",
"(",
"stateLocation",
")",
";",
"}",
"else",
"{",
"instanceStateBuilder",
".",
"setState",
"(",
"ByteString",
".",
"copyFrom",
"(",
"serializedState",
")",
")",
";",
"}",
"CheckpointManager",
".",
"StoreInstanceStateCheckpoint",
"storeRequest",
"=",
"CheckpointManager",
".",
"StoreInstanceStateCheckpoint",
".",
"newBuilder",
"(",
")",
".",
"setState",
"(",
"instanceStateBuilder",
".",
"build",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"// Put the checkpoint to out stream queue",
"outQueue",
".",
"offer",
"(",
"storeRequest",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Send out the instance's state with corresponding checkpointId. If spillState is True,
the actual state is spill to disk and only the state location is sent out.
@param state instance's state
@param checkpointId the checkpointId
@param spillState spill the state to local disk if true
@param location the location where state is spilled | [
"Send",
"out",
"the",
"instance",
"s",
"state",
"with",
"corresponding",
"checkpointId",
".",
"If",
"spillState",
"is",
"True",
"the",
"actual",
"state",
"is",
"spill",
"to",
"disk",
"and",
"only",
"the",
"state",
"location",
"is",
"sent",
"out",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/instance/src/java/org/apache/heron/instance/OutgoingTupleCollection.java#L119-L157 |
28,014 | apache/incubator-heron | heron/instance/src/java/org/apache/heron/instance/OutgoingTupleCollection.java | OutgoingTupleCollection.clear | public void clear() {
lock.lock();
try {
currentControlTuple = null;
currentDataTuple = null;
outQueue.clear();
} finally {
lock.unlock();
}
} | java | public void clear() {
lock.lock();
try {
currentControlTuple = null;
currentDataTuple = null;
outQueue.clear();
} finally {
lock.unlock();
}
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"currentControlTuple",
"=",
"null",
";",
"currentDataTuple",
"=",
"null",
";",
"outQueue",
".",
"clear",
"(",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Clean the internal state of OutgoingTupleCollection | [
"Clean",
"the",
"internal",
"state",
"of",
"OutgoingTupleCollection"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/instance/src/java/org/apache/heron/instance/OutgoingTupleCollection.java#L277-L287 |
28,015 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/KubernetesScheduler.java | KubernetesScheduler.addContainers | @Override
public Set<PackingPlan.ContainerPlan>
addContainers(Set<PackingPlan.ContainerPlan> containersToAdd) {
controller.addContainers(containersToAdd);
return containersToAdd;
} | java | @Override
public Set<PackingPlan.ContainerPlan>
addContainers(Set<PackingPlan.ContainerPlan> containersToAdd) {
controller.addContainers(containersToAdd);
return containersToAdd;
} | [
"@",
"Override",
"public",
"Set",
"<",
"PackingPlan",
".",
"ContainerPlan",
">",
"addContainers",
"(",
"Set",
"<",
"PackingPlan",
".",
"ContainerPlan",
">",
"containersToAdd",
")",
"{",
"controller",
".",
"addContainers",
"(",
"containersToAdd",
")",
";",
"return",
"containersToAdd",
";",
"}"
] | Add containers for a scale-up event from an update command
@param containersToAdd the list of containers that need to be added
NOTE: Due to the mechanics of Kubernetes pod creation, each container must be created on
a one-by-one basis. If one container out of many containers to be deployed failed, it will
leave the topology in a bad state.
TODO (jrcrawfo) -- (https://github.com/apache/incubator-heron/issues/1981) | [
"Add",
"containers",
"for",
"a",
"scale",
"-",
"up",
"event",
"from",
"an",
"update",
"command"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/kubernetes/KubernetesScheduler.java#L145-L150 |
28,016 | apache/incubator-heron | heron/simulator/src/java/org/apache/heron/simulator/utils/XORManager.java | XORManager.anchor | public boolean anchor(int taskId, long key, long value) {
return spoutTasksToRotatingMap.get(taskId).anchor(key, value);
} | java | public boolean anchor(int taskId, long key, long value) {
return spoutTasksToRotatingMap.get(taskId).anchor(key, value);
} | [
"public",
"boolean",
"anchor",
"(",
"int",
"taskId",
",",
"long",
"key",
",",
"long",
"value",
")",
"{",
"return",
"spoutTasksToRotatingMap",
".",
"get",
"(",
"taskId",
")",
".",
"anchor",
"(",
"key",
",",
"value",
")",
";",
"}"
] | Else return false | [
"Else",
"return",
"false"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/simulator/src/java/org/apache/heron/simulator/utils/XORManager.java#L78-L80 |
28,017 | apache/incubator-heron | heron/simulator/src/java/org/apache/heron/simulator/utils/XORManager.java | XORManager.rotate | protected void rotate() {
for (RotatingMap map : spoutTasksToRotatingMap.values()) {
map.rotate();
}
Runnable r = new Runnable() {
@Override
public void run() {
rotate();
}
};
looper.registerTimerEvent(rotateInterval, r);
} | java | protected void rotate() {
for (RotatingMap map : spoutTasksToRotatingMap.values()) {
map.rotate();
}
Runnable r = new Runnable() {
@Override
public void run() {
rotate();
}
};
looper.registerTimerEvent(rotateInterval, r);
} | [
"protected",
"void",
"rotate",
"(",
")",
"{",
"for",
"(",
"RotatingMap",
"map",
":",
"spoutTasksToRotatingMap",
".",
"values",
"(",
")",
")",
"{",
"map",
".",
"rotate",
"(",
")",
";",
"}",
"Runnable",
"r",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"rotate",
"(",
")",
";",
"}",
"}",
";",
"looper",
".",
"registerTimerEvent",
"(",
"rotateInterval",
",",
"r",
")",
";",
"}"
] | Protected method for unit test | [
"Protected",
"method",
"for",
"unit",
"test"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/simulator/src/java/org/apache/heron/simulator/utils/XORManager.java#L90-L102 |
28,018 | apache/incubator-heron | heron/healthmgr/src/java/org/apache/heron/healthmgr/detectors/BackPressureDetector.java | BackPressureDetector.detect | @Override
public Collection<Symptom> detect(Collection<Measurement> measurements) {
publishingMetrics.executeDetectorIncr(BACK_PRESSURE_DETECTOR);
Collection<Symptom> result = new ArrayList<>();
Instant now = context.checkpoint();
MeasurementsTable bpMetrics
= MeasurementsTable.of(measurements).type(METRIC_BACK_PRESSURE.text());
for (String component : bpMetrics.uniqueComponents()) {
double compBackPressure = bpMetrics.component(component).sum();
if (compBackPressure > noiseFilterMillis) {
LOG.info(String.format("Detected component back-pressure for %s, total back pressure is %f",
component, compBackPressure));
List<String> addresses = Collections.singletonList(component);
result.add(new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), now, addresses));
}
}
for (String instance : bpMetrics.uniqueInstances()) {
double totalBP = bpMetrics.instance(instance).sum();
if (totalBP > noiseFilterMillis) {
LOG.info(String.format("Detected instance back-pressure for %s, total back pressure is %f",
instance, totalBP));
List<String> addresses = Collections.singletonList(instance);
result.add(new Symptom(SYMPTOM_INSTANCE_BACK_PRESSURE.text(), now, addresses));
}
}
return result;
} | java | @Override
public Collection<Symptom> detect(Collection<Measurement> measurements) {
publishingMetrics.executeDetectorIncr(BACK_PRESSURE_DETECTOR);
Collection<Symptom> result = new ArrayList<>();
Instant now = context.checkpoint();
MeasurementsTable bpMetrics
= MeasurementsTable.of(measurements).type(METRIC_BACK_PRESSURE.text());
for (String component : bpMetrics.uniqueComponents()) {
double compBackPressure = bpMetrics.component(component).sum();
if (compBackPressure > noiseFilterMillis) {
LOG.info(String.format("Detected component back-pressure for %s, total back pressure is %f",
component, compBackPressure));
List<String> addresses = Collections.singletonList(component);
result.add(new Symptom(SYMPTOM_COMP_BACK_PRESSURE.text(), now, addresses));
}
}
for (String instance : bpMetrics.uniqueInstances()) {
double totalBP = bpMetrics.instance(instance).sum();
if (totalBP > noiseFilterMillis) {
LOG.info(String.format("Detected instance back-pressure for %s, total back pressure is %f",
instance, totalBP));
List<String> addresses = Collections.singletonList(instance);
result.add(new Symptom(SYMPTOM_INSTANCE_BACK_PRESSURE.text(), now, addresses));
}
}
return result;
} | [
"@",
"Override",
"public",
"Collection",
"<",
"Symptom",
">",
"detect",
"(",
"Collection",
"<",
"Measurement",
">",
"measurements",
")",
"{",
"publishingMetrics",
".",
"executeDetectorIncr",
"(",
"BACK_PRESSURE_DETECTOR",
")",
";",
"Collection",
"<",
"Symptom",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Instant",
"now",
"=",
"context",
".",
"checkpoint",
"(",
")",
";",
"MeasurementsTable",
"bpMetrics",
"=",
"MeasurementsTable",
".",
"of",
"(",
"measurements",
")",
".",
"type",
"(",
"METRIC_BACK_PRESSURE",
".",
"text",
"(",
")",
")",
";",
"for",
"(",
"String",
"component",
":",
"bpMetrics",
".",
"uniqueComponents",
"(",
")",
")",
"{",
"double",
"compBackPressure",
"=",
"bpMetrics",
".",
"component",
"(",
"component",
")",
".",
"sum",
"(",
")",
";",
"if",
"(",
"compBackPressure",
">",
"noiseFilterMillis",
")",
"{",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Detected component back-pressure for %s, total back pressure is %f\"",
",",
"component",
",",
"compBackPressure",
")",
")",
";",
"List",
"<",
"String",
">",
"addresses",
"=",
"Collections",
".",
"singletonList",
"(",
"component",
")",
";",
"result",
".",
"add",
"(",
"new",
"Symptom",
"(",
"SYMPTOM_COMP_BACK_PRESSURE",
".",
"text",
"(",
")",
",",
"now",
",",
"addresses",
")",
")",
";",
"}",
"}",
"for",
"(",
"String",
"instance",
":",
"bpMetrics",
".",
"uniqueInstances",
"(",
")",
")",
"{",
"double",
"totalBP",
"=",
"bpMetrics",
".",
"instance",
"(",
"instance",
")",
".",
"sum",
"(",
")",
";",
"if",
"(",
"totalBP",
">",
"noiseFilterMillis",
")",
"{",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Detected instance back-pressure for %s, total back pressure is %f\"",
",",
"instance",
",",
"totalBP",
")",
")",
";",
"List",
"<",
"String",
">",
"addresses",
"=",
"Collections",
".",
"singletonList",
"(",
"instance",
")",
";",
"result",
".",
"add",
"(",
"new",
"Symptom",
"(",
"SYMPTOM_INSTANCE_BACK_PRESSURE",
".",
"text",
"(",
")",
",",
"now",
",",
"addresses",
")",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Detects all components initiating backpressure above the configured limit. Normally there
will be only one component
@return A collection of symptoms each one corresponding to a components with backpressure. | [
"Detects",
"all",
"components",
"initiating",
"backpressure",
"above",
"the",
"configured",
"limit",
".",
"Normally",
"there",
"will",
"be",
"only",
"one",
"component"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/healthmgr/src/java/org/apache/heron/healthmgr/detectors/BackPressureDetector.java#L63-L91 |
28,019 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraScheduler.java | AuroraScheduler.getController | protected AuroraController getController()
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
Boolean cliController = config.getBooleanValue(Key.AURORA_CONTROLLER_CLASS);
Config localConfig = Config.toLocalMode(this.config);
if (cliController) {
return new AuroraCLIController(
Runtime.topologyName(runtime),
Context.cluster(localConfig),
Context.role(localConfig),
Context.environ(localConfig),
AuroraContext.getHeronAuroraPath(localConfig),
Context.verbose(localConfig));
} else {
return new AuroraHeronShellController(
Runtime.topologyName(runtime),
Context.cluster(localConfig),
Context.role(localConfig),
Context.environ(localConfig),
AuroraContext.getHeronAuroraPath(localConfig),
Context.verbose(localConfig),
localConfig);
}
} | java | protected AuroraController getController()
throws ClassNotFoundException, InstantiationException, IllegalAccessException {
Boolean cliController = config.getBooleanValue(Key.AURORA_CONTROLLER_CLASS);
Config localConfig = Config.toLocalMode(this.config);
if (cliController) {
return new AuroraCLIController(
Runtime.topologyName(runtime),
Context.cluster(localConfig),
Context.role(localConfig),
Context.environ(localConfig),
AuroraContext.getHeronAuroraPath(localConfig),
Context.verbose(localConfig));
} else {
return new AuroraHeronShellController(
Runtime.topologyName(runtime),
Context.cluster(localConfig),
Context.role(localConfig),
Context.environ(localConfig),
AuroraContext.getHeronAuroraPath(localConfig),
Context.verbose(localConfig),
localConfig);
}
} | [
"protected",
"AuroraController",
"getController",
"(",
")",
"throws",
"ClassNotFoundException",
",",
"InstantiationException",
",",
"IllegalAccessException",
"{",
"Boolean",
"cliController",
"=",
"config",
".",
"getBooleanValue",
"(",
"Key",
".",
"AURORA_CONTROLLER_CLASS",
")",
";",
"Config",
"localConfig",
"=",
"Config",
".",
"toLocalMode",
"(",
"this",
".",
"config",
")",
";",
"if",
"(",
"cliController",
")",
"{",
"return",
"new",
"AuroraCLIController",
"(",
"Runtime",
".",
"topologyName",
"(",
"runtime",
")",
",",
"Context",
".",
"cluster",
"(",
"localConfig",
")",
",",
"Context",
".",
"role",
"(",
"localConfig",
")",
",",
"Context",
".",
"environ",
"(",
"localConfig",
")",
",",
"AuroraContext",
".",
"getHeronAuroraPath",
"(",
"localConfig",
")",
",",
"Context",
".",
"verbose",
"(",
"localConfig",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"AuroraHeronShellController",
"(",
"Runtime",
".",
"topologyName",
"(",
"runtime",
")",
",",
"Context",
".",
"cluster",
"(",
"localConfig",
")",
",",
"Context",
".",
"role",
"(",
"localConfig",
")",
",",
"Context",
".",
"environ",
"(",
"localConfig",
")",
",",
"AuroraContext",
".",
"getHeronAuroraPath",
"(",
"localConfig",
")",
",",
"Context",
".",
"verbose",
"(",
"localConfig",
")",
",",
"localConfig",
")",
";",
"}",
"}"
] | Get an AuroraController based on the config and runtime
@return AuroraController | [
"Get",
"an",
"AuroraController",
"based",
"on",
"the",
"config",
"and",
"runtime"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraScheduler.java#L78-L100 |
28,020 | apache/incubator-heron | heron/statefulstorages/src/java/org/apache/heron/statefulstorage/hdfs/HDFSStorage.java | HDFSStorage.createDir | protected void createDir(String dir) throws StatefulStorageException {
Path path = new Path(dir);
try {
fileSystem.mkdirs(path);
if (!fileSystem.exists(path)) {
throw new StatefulStorageException("Failed to create dir: " + dir);
}
} catch (IOException e) {
throw new StatefulStorageException("Failed to create dir: " + dir, e);
}
} | java | protected void createDir(String dir) throws StatefulStorageException {
Path path = new Path(dir);
try {
fileSystem.mkdirs(path);
if (!fileSystem.exists(path)) {
throw new StatefulStorageException("Failed to create dir: " + dir);
}
} catch (IOException e) {
throw new StatefulStorageException("Failed to create dir: " + dir, e);
}
} | [
"protected",
"void",
"createDir",
"(",
"String",
"dir",
")",
"throws",
"StatefulStorageException",
"{",
"Path",
"path",
"=",
"new",
"Path",
"(",
"dir",
")",
";",
"try",
"{",
"fileSystem",
".",
"mkdirs",
"(",
"path",
")",
";",
"if",
"(",
"!",
"fileSystem",
".",
"exists",
"(",
"path",
")",
")",
"{",
"throw",
"new",
"StatefulStorageException",
"(",
"\"Failed to create dir: \"",
"+",
"dir",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"StatefulStorageException",
"(",
"\"Failed to create dir: \"",
"+",
"dir",
",",
"e",
")",
";",
"}",
"}"
] | Creates the directory if it does not exist.
@param dir The path of dir to ensure existence | [
"Creates",
"the",
"directory",
"if",
"it",
"does",
"not",
"exist",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/statefulstorages/src/java/org/apache/heron/statefulstorage/hdfs/HDFSStorage.java#L183-L194 |
28,021 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/metricsmgr/metrics/MetricsFilter.java | MetricsFilter.filter | public Iterable<MetricsInfo> filter(Iterable<MetricsInfo> metricsInfos) {
List<MetricsInfo> metricsFiltered = new ArrayList<MetricsInfo>();
for (MetricsInfo metricsInfo : metricsInfos) {
if (contains(metricsInfo.getName())) {
metricsFiltered.add(metricsInfo);
}
}
return metricsFiltered;
} | java | public Iterable<MetricsInfo> filter(Iterable<MetricsInfo> metricsInfos) {
List<MetricsInfo> metricsFiltered = new ArrayList<MetricsInfo>();
for (MetricsInfo metricsInfo : metricsInfos) {
if (contains(metricsInfo.getName())) {
metricsFiltered.add(metricsInfo);
}
}
return metricsFiltered;
} | [
"public",
"Iterable",
"<",
"MetricsInfo",
">",
"filter",
"(",
"Iterable",
"<",
"MetricsInfo",
">",
"metricsInfos",
")",
"{",
"List",
"<",
"MetricsInfo",
">",
"metricsFiltered",
"=",
"new",
"ArrayList",
"<",
"MetricsInfo",
">",
"(",
")",
";",
"for",
"(",
"MetricsInfo",
"metricsInfo",
":",
"metricsInfos",
")",
"{",
"if",
"(",
"contains",
"(",
"metricsInfo",
".",
"getName",
"(",
")",
")",
")",
"{",
"metricsFiltered",
".",
"add",
"(",
"metricsInfo",
")",
";",
"}",
"}",
"return",
"metricsFiltered",
";",
"}"
] | Return an immutable view of filtered metrics | [
"Return",
"an",
"immutable",
"view",
"of",
"filtered",
"metrics"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/metricsmgr/metrics/MetricsFilter.java#L61-L70 |
28,022 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/marathon/MarathonScheduler.java | MarathonScheduler.getContainer | protected ObjectNode getContainer(ObjectMapper mapper) {
ObjectNode containerNode = mapper.createObjectNode();
containerNode.put(MarathonConstants.CONTAINER_TYPE, "DOCKER");
containerNode.set("docker", getDockerContainer(mapper));
return containerNode;
} | java | protected ObjectNode getContainer(ObjectMapper mapper) {
ObjectNode containerNode = mapper.createObjectNode();
containerNode.put(MarathonConstants.CONTAINER_TYPE, "DOCKER");
containerNode.set("docker", getDockerContainer(mapper));
return containerNode;
} | [
"protected",
"ObjectNode",
"getContainer",
"(",
"ObjectMapper",
"mapper",
")",
"{",
"ObjectNode",
"containerNode",
"=",
"mapper",
".",
"createObjectNode",
"(",
")",
";",
"containerNode",
".",
"put",
"(",
"MarathonConstants",
".",
"CONTAINER_TYPE",
",",
"\"DOCKER\"",
")",
";",
"containerNode",
".",
"set",
"(",
"\"docker\"",
",",
"getDockerContainer",
"(",
"mapper",
")",
")",
";",
"return",
"containerNode",
";",
"}"
] | build the container object | [
"build",
"the",
"container",
"object"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/marathon/MarathonScheduler.java#L160-L166 |
28,023 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/client/HttpServiceSchedulerClient.java | HttpServiceSchedulerClient.requestSchedulerService | protected boolean requestSchedulerService(Command command, byte[] data) {
String endpoint = getCommandEndpoint(schedulerHttpEndpoint, command);
final HttpURLConnection connection = NetworkUtils.getHttpConnection(endpoint);
if (connection == null) {
LOG.severe("Scheduler not found.");
return false;
}
// now, we have a valid connection
try {
// send the actual http request
if (!NetworkUtils.sendHttpPostRequest(connection, NetworkUtils.URL_ENCODE_TYPE, data)) {
LOG.log(Level.SEVERE, "Failed to send http request to scheduler");
return false;
}
// receive the response for manage topology
Common.StatusCode statusCode;
LOG.fine("Receiving response from scheduler...");
try {
statusCode = Scheduler.SchedulerResponse.newBuilder()
.mergeFrom(NetworkUtils.readHttpResponse(connection))
.build().getStatus().getStatus();
} catch (InvalidProtocolBufferException e) {
LOG.log(Level.SEVERE, "Failed to parse response", e);
return false;
}
if (!statusCode.equals(Common.StatusCode.OK)) {
LOG.severe("Received not OK response from scheduler");
return false;
}
} finally {
connection.disconnect();
}
return true;
} | java | protected boolean requestSchedulerService(Command command, byte[] data) {
String endpoint = getCommandEndpoint(schedulerHttpEndpoint, command);
final HttpURLConnection connection = NetworkUtils.getHttpConnection(endpoint);
if (connection == null) {
LOG.severe("Scheduler not found.");
return false;
}
// now, we have a valid connection
try {
// send the actual http request
if (!NetworkUtils.sendHttpPostRequest(connection, NetworkUtils.URL_ENCODE_TYPE, data)) {
LOG.log(Level.SEVERE, "Failed to send http request to scheduler");
return false;
}
// receive the response for manage topology
Common.StatusCode statusCode;
LOG.fine("Receiving response from scheduler...");
try {
statusCode = Scheduler.SchedulerResponse.newBuilder()
.mergeFrom(NetworkUtils.readHttpResponse(connection))
.build().getStatus().getStatus();
} catch (InvalidProtocolBufferException e) {
LOG.log(Level.SEVERE, "Failed to parse response", e);
return false;
}
if (!statusCode.equals(Common.StatusCode.OK)) {
LOG.severe("Received not OK response from scheduler");
return false;
}
} finally {
connection.disconnect();
}
return true;
} | [
"protected",
"boolean",
"requestSchedulerService",
"(",
"Command",
"command",
",",
"byte",
"[",
"]",
"data",
")",
"{",
"String",
"endpoint",
"=",
"getCommandEndpoint",
"(",
"schedulerHttpEndpoint",
",",
"command",
")",
";",
"final",
"HttpURLConnection",
"connection",
"=",
"NetworkUtils",
".",
"getHttpConnection",
"(",
"endpoint",
")",
";",
"if",
"(",
"connection",
"==",
"null",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Scheduler not found.\"",
")",
";",
"return",
"false",
";",
"}",
"// now, we have a valid connection",
"try",
"{",
"// send the actual http request",
"if",
"(",
"!",
"NetworkUtils",
".",
"sendHttpPostRequest",
"(",
"connection",
",",
"NetworkUtils",
".",
"URL_ENCODE_TYPE",
",",
"data",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to send http request to scheduler\"",
")",
";",
"return",
"false",
";",
"}",
"// receive the response for manage topology",
"Common",
".",
"StatusCode",
"statusCode",
";",
"LOG",
".",
"fine",
"(",
"\"Receiving response from scheduler...\"",
")",
";",
"try",
"{",
"statusCode",
"=",
"Scheduler",
".",
"SchedulerResponse",
".",
"newBuilder",
"(",
")",
".",
"mergeFrom",
"(",
"NetworkUtils",
".",
"readHttpResponse",
"(",
"connection",
")",
")",
".",
"build",
"(",
")",
".",
"getStatus",
"(",
")",
".",
"getStatus",
"(",
")",
";",
"}",
"catch",
"(",
"InvalidProtocolBufferException",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to parse response\"",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"statusCode",
".",
"equals",
"(",
"Common",
".",
"StatusCode",
".",
"OK",
")",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Received not OK response from scheduler\"",
")",
";",
"return",
"false",
";",
"}",
"}",
"finally",
"{",
"connection",
".",
"disconnect",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Send payload to target HTTP connection to request a service
@param data the byte[] to send
@return true if got OK response successfully | [
"Send",
"payload",
"to",
"target",
"HTTP",
"connection",
"to",
"request",
"a",
"service"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/client/HttpServiceSchedulerClient.java#L74-L112 |
28,024 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/client/HttpServiceSchedulerClient.java | HttpServiceSchedulerClient.getCommandEndpoint | protected String getCommandEndpoint(String schedulerEndpoint, Command command) {
// Currently the server side receives command request in lower case
return String.format("http://%s/%s", schedulerEndpoint, command.name().toLowerCase());
} | java | protected String getCommandEndpoint(String schedulerEndpoint, Command command) {
// Currently the server side receives command request in lower case
return String.format("http://%s/%s", schedulerEndpoint, command.name().toLowerCase());
} | [
"protected",
"String",
"getCommandEndpoint",
"(",
"String",
"schedulerEndpoint",
",",
"Command",
"command",
")",
"{",
"// Currently the server side receives command request in lower case",
"return",
"String",
".",
"format",
"(",
"\"http://%s/%s\"",
",",
"schedulerEndpoint",
",",
"command",
".",
"name",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] | Construct the endpoint to send http request for a particular command
Make sure the construction matches server sides.
@param schedulerEndpoint The scheduler http endpoint
@param command The command to request
@return The http endpoint for particular command | [
"Construct",
"the",
"endpoint",
"to",
"send",
"http",
"request",
"for",
"a",
"particular",
"command",
"Make",
"sure",
"the",
"construction",
"matches",
"server",
"sides",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/client/HttpServiceSchedulerClient.java#L122-L125 |
28,025 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java | LauncherUtils.createPackingPlan | public PackingPlan createPackingPlan(final Config config, final Config runtime)
throws PackingException {
// Create an instance of the packing class
String packingClass = Context.packingClass(config);
IPacking packing;
try {
// create an instance of the packing class
packing = ReflectionUtils.newInstance(packingClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new PackingException(String.format(
"Failed to instantiate packing instance using packing class %s", packingClass), e);
}
try {
TopologyAPI.Topology topology = Runtime.topology(runtime);
packing.initialize(config, topology);
return packing.pack();
} finally {
SysUtils.closeIgnoringExceptions(packing);
}
} | java | public PackingPlan createPackingPlan(final Config config, final Config runtime)
throws PackingException {
// Create an instance of the packing class
String packingClass = Context.packingClass(config);
IPacking packing;
try {
// create an instance of the packing class
packing = ReflectionUtils.newInstance(packingClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new PackingException(String.format(
"Failed to instantiate packing instance using packing class %s", packingClass), e);
}
try {
TopologyAPI.Topology topology = Runtime.topology(runtime);
packing.initialize(config, topology);
return packing.pack();
} finally {
SysUtils.closeIgnoringExceptions(packing);
}
} | [
"public",
"PackingPlan",
"createPackingPlan",
"(",
"final",
"Config",
"config",
",",
"final",
"Config",
"runtime",
")",
"throws",
"PackingException",
"{",
"// Create an instance of the packing class",
"String",
"packingClass",
"=",
"Context",
".",
"packingClass",
"(",
"config",
")",
";",
"IPacking",
"packing",
";",
"try",
"{",
"// create an instance of the packing class",
"packing",
"=",
"ReflectionUtils",
".",
"newInstance",
"(",
"packingClass",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InstantiationException",
"|",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"PackingException",
"(",
"String",
".",
"format",
"(",
"\"Failed to instantiate packing instance using packing class %s\"",
",",
"packingClass",
")",
",",
"e",
")",
";",
"}",
"try",
"{",
"TopologyAPI",
".",
"Topology",
"topology",
"=",
"Runtime",
".",
"topology",
"(",
"runtime",
")",
";",
"packing",
".",
"initialize",
"(",
"config",
",",
"topology",
")",
";",
"return",
"packing",
".",
"pack",
"(",
")",
";",
"}",
"finally",
"{",
"SysUtils",
".",
"closeIgnoringExceptions",
"(",
"packing",
")",
";",
"}",
"}"
] | Returns a packing plan generated by configured packing class | [
"Returns",
"a",
"packing",
"plan",
"generated",
"by",
"configured",
"packing",
"class"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java#L55-L75 |
28,026 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java | LauncherUtils.getSchedulerInstance | public IScheduler getSchedulerInstance(Config config, Config runtime)
throws SchedulerException {
String schedulerClass = Context.schedulerClass(config);
IScheduler scheduler;
try {
// create an instance of scheduler
scheduler = ReflectionUtils.newInstance(schedulerClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new SchedulerException(String.format("Failed to instantiate scheduler using class '%s'",
schedulerClass));
}
scheduler.initialize(config, runtime);
return scheduler;
} | java | public IScheduler getSchedulerInstance(Config config, Config runtime)
throws SchedulerException {
String schedulerClass = Context.schedulerClass(config);
IScheduler scheduler;
try {
// create an instance of scheduler
scheduler = ReflectionUtils.newInstance(schedulerClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new SchedulerException(String.format("Failed to instantiate scheduler using class '%s'",
schedulerClass));
}
scheduler.initialize(config, runtime);
return scheduler;
} | [
"public",
"IScheduler",
"getSchedulerInstance",
"(",
"Config",
"config",
",",
"Config",
"runtime",
")",
"throws",
"SchedulerException",
"{",
"String",
"schedulerClass",
"=",
"Context",
".",
"schedulerClass",
"(",
"config",
")",
";",
"IScheduler",
"scheduler",
";",
"try",
"{",
"// create an instance of scheduler",
"scheduler",
"=",
"ReflectionUtils",
".",
"newInstance",
"(",
"schedulerClass",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InstantiationException",
"|",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"SchedulerException",
"(",
"String",
".",
"format",
"(",
"\"Failed to instantiate scheduler using class '%s'\"",
",",
"schedulerClass",
")",
")",
";",
"}",
"scheduler",
".",
"initialize",
"(",
"config",
",",
"runtime",
")",
";",
"return",
"scheduler",
";",
"}"
] | Creates and initializes scheduler instance
@return initialized scheduler instances | [
"Creates",
"and",
"initializes",
"scheduler",
"instance"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java#L117-L131 |
28,027 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java | LauncherUtils.createPrimaryRuntime | public Config createPrimaryRuntime(TopologyAPI.Topology topology) {
return Config.newBuilder()
.put(Key.TOPOLOGY_ID, topology.getId())
.put(Key.TOPOLOGY_NAME, topology.getName())
.put(Key.TOPOLOGY_DEFINITION, topology)
.put(Key.NUM_CONTAINERS, 1 + TopologyUtils.getNumContainers(topology))
.build();
} | java | public Config createPrimaryRuntime(TopologyAPI.Topology topology) {
return Config.newBuilder()
.put(Key.TOPOLOGY_ID, topology.getId())
.put(Key.TOPOLOGY_NAME, topology.getName())
.put(Key.TOPOLOGY_DEFINITION, topology)
.put(Key.NUM_CONTAINERS, 1 + TopologyUtils.getNumContainers(topology))
.build();
} | [
"public",
"Config",
"createPrimaryRuntime",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
")",
"{",
"return",
"Config",
".",
"newBuilder",
"(",
")",
".",
"put",
"(",
"Key",
".",
"TOPOLOGY_ID",
",",
"topology",
".",
"getId",
"(",
")",
")",
".",
"put",
"(",
"Key",
".",
"TOPOLOGY_NAME",
",",
"topology",
".",
"getName",
"(",
")",
")",
".",
"put",
"(",
"Key",
".",
"TOPOLOGY_DEFINITION",
",",
"topology",
")",
".",
"put",
"(",
"Key",
".",
"NUM_CONTAINERS",
",",
"1",
"+",
"TopologyUtils",
".",
"getNumContainers",
"(",
"topology",
")",
")",
".",
"build",
"(",
")",
";",
"}"
] | Creates initial runtime config instance using topology information.
@return initial runtime config instance | [
"Creates",
"initial",
"runtime",
"config",
"instance",
"using",
"topology",
"information",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java#L138-L145 |
28,028 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java | LauncherUtils.createAdaptorRuntime | public Config createAdaptorRuntime(SchedulerStateManagerAdaptor adaptor) {
return Config.newBuilder()
.put(Key.SCHEDULER_STATE_MANAGER_ADAPTOR, adaptor).build();
} | java | public Config createAdaptorRuntime(SchedulerStateManagerAdaptor adaptor) {
return Config.newBuilder()
.put(Key.SCHEDULER_STATE_MANAGER_ADAPTOR, adaptor).build();
} | [
"public",
"Config",
"createAdaptorRuntime",
"(",
"SchedulerStateManagerAdaptor",
"adaptor",
")",
"{",
"return",
"Config",
".",
"newBuilder",
"(",
")",
".",
"put",
"(",
"Key",
".",
"SCHEDULER_STATE_MANAGER_ADAPTOR",
",",
"adaptor",
")",
".",
"build",
"(",
")",
";",
"}"
] | Creates initial runtime config of scheduler state manager adaptor
@return adaptor config | [
"Creates",
"initial",
"runtime",
"config",
"of",
"scheduler",
"state",
"manager",
"adaptor"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java#L152-L155 |
28,029 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java | LauncherUtils.createConfigWithPackingDetails | public Config createConfigWithPackingDetails(Config runtime, PackingPlan packing) {
return Config.newBuilder()
.putAll(runtime)
.put(Key.COMPONENT_RAMMAP, packing.getComponentRamDistribution())
.put(Key.NUM_CONTAINERS, 1 + packing.getContainers().size())
.build();
} | java | public Config createConfigWithPackingDetails(Config runtime, PackingPlan packing) {
return Config.newBuilder()
.putAll(runtime)
.put(Key.COMPONENT_RAMMAP, packing.getComponentRamDistribution())
.put(Key.NUM_CONTAINERS, 1 + packing.getContainers().size())
.build();
} | [
"public",
"Config",
"createConfigWithPackingDetails",
"(",
"Config",
"runtime",
",",
"PackingPlan",
"packing",
")",
"{",
"return",
"Config",
".",
"newBuilder",
"(",
")",
".",
"putAll",
"(",
"runtime",
")",
".",
"put",
"(",
"Key",
".",
"COMPONENT_RAMMAP",
",",
"packing",
".",
"getComponentRamDistribution",
"(",
")",
")",
".",
"put",
"(",
"Key",
".",
"NUM_CONTAINERS",
",",
"1",
"+",
"packing",
".",
"getContainers",
"(",
")",
".",
"size",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"}"
] | Creates a config instance with packing plan info added to runtime config
@return packing details config | [
"Creates",
"a",
"config",
"instance",
"with",
"packing",
"plan",
"info",
"added",
"to",
"runtime",
"config"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/utils/LauncherUtils.java#L162-L168 |
28,030 | apache/incubator-heron | eco-heron-examples/src/java/org/apache/heron/examples/eco/StatefulRandomIntSpout.java | StatefulRandomIntSpout.preSave | @Override
public void preSave(String checkpointId) {
System.out.println(String.format("Saving spout state at checkpoint %s", checkpointId));
} | java | @Override
public void preSave(String checkpointId) {
System.out.println(String.format("Saving spout state at checkpoint %s", checkpointId));
} | [
"@",
"Override",
"public",
"void",
"preSave",
"(",
"String",
"checkpointId",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"Saving spout state at checkpoint %s\"",
",",
"checkpointId",
")",
")",
";",
"}"
] | These two methods are required to implement the IStatefulComponent interface | [
"These",
"two",
"methods",
"are",
"required",
"to",
"implement",
"the",
"IStatefulComponent",
"interface"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/eco-heron-examples/src/java/org/apache/heron/examples/eco/StatefulRandomIntSpout.java#L50-L53 |
28,031 | apache/incubator-heron | eco-heron-examples/src/java/org/apache/heron/examples/eco/StatefulRandomIntSpout.java | StatefulRandomIntSpout.open | @Override
public void open(Map<String, Object> map, TopologyContext ctx, SpoutOutputCollector collector) {
spoutOutputCollector = collector;
} | java | @Override
public void open(Map<String, Object> map, TopologyContext ctx, SpoutOutputCollector collector) {
spoutOutputCollector = collector;
} | [
"@",
"Override",
"public",
"void",
"open",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
",",
"TopologyContext",
"ctx",
",",
"SpoutOutputCollector",
"collector",
")",
"{",
"spoutOutputCollector",
"=",
"collector",
";",
"}"
] | These three methods are required to extend the BaseRichSpout abstract class | [
"These",
"three",
"methods",
"are",
"required",
"to",
"extend",
"the",
"BaseRichSpout",
"abstract",
"class"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/eco-heron-examples/src/java/org/apache/heron/examples/eco/StatefulRandomIntSpout.java#L61-L64 |
28,032 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java | ShellUtils.runSyncProcess | private static int runSyncProcess(
boolean isVerbose, boolean isInheritIO, String[] cmdline,
StringBuilder outputBuilder, File workingDirectory, Map<String, String> envs) {
final StringBuilder builder = outputBuilder == null ? new StringBuilder() : outputBuilder;
// Log the command for debugging
LOG.log(Level.FINE, "Running synced process: ``{0}''''", joinString(cmdline));
ProcessBuilder pb = getProcessBuilder(isInheritIO, cmdline, workingDirectory, envs);
/* combine input stream and error stream into stderr because
1. this preserves order of process's stdout/stderr message
2. there is no need to distinguish stderr from stdout
3. follow one basic pattern of the design of Python<~>Java I/O redirection:
stdout contains useful messages Java program needs to propagate back, stderr
contains all other information */
pb.redirectErrorStream(true);
Process process;
try {
process = pb.start();
} catch (IOException e) {
LOG.log(Level.SEVERE, "Failed to run synced process", e);
return -1;
}
// Launching threads to consume combined stdout and stderr before "waitFor".
// Otherwise, output from the "process" can exhaust the available buffer for the combined stream
// because stream is not read while waiting for the process to complete.
// If buffer becomes full, it can block the "process" as well,
// preventing all progress for both the "process" and the current thread.
Thread outputsThread = createAsyncStreamThread(process.getInputStream(), builder, isVerbose);
try {
outputsThread.start();
int exitValue = process.waitFor();
outputsThread.join();
return exitValue;
} catch (InterruptedException e) {
// The current thread is interrupted, so try to interrupt reading threads and kill
// the process to return quickly.
outputsThread.interrupt();
process.destroy();
LOG.log(Level.SEVERE, "Running synced process was interrupted", e);
// Reset the interrupt status to allow other codes noticing it.
Thread.currentThread().interrupt();
return -1;
}
} | java | private static int runSyncProcess(
boolean isVerbose, boolean isInheritIO, String[] cmdline,
StringBuilder outputBuilder, File workingDirectory, Map<String, String> envs) {
final StringBuilder builder = outputBuilder == null ? new StringBuilder() : outputBuilder;
// Log the command for debugging
LOG.log(Level.FINE, "Running synced process: ``{0}''''", joinString(cmdline));
ProcessBuilder pb = getProcessBuilder(isInheritIO, cmdline, workingDirectory, envs);
/* combine input stream and error stream into stderr because
1. this preserves order of process's stdout/stderr message
2. there is no need to distinguish stderr from stdout
3. follow one basic pattern of the design of Python<~>Java I/O redirection:
stdout contains useful messages Java program needs to propagate back, stderr
contains all other information */
pb.redirectErrorStream(true);
Process process;
try {
process = pb.start();
} catch (IOException e) {
LOG.log(Level.SEVERE, "Failed to run synced process", e);
return -1;
}
// Launching threads to consume combined stdout and stderr before "waitFor".
// Otherwise, output from the "process" can exhaust the available buffer for the combined stream
// because stream is not read while waiting for the process to complete.
// If buffer becomes full, it can block the "process" as well,
// preventing all progress for both the "process" and the current thread.
Thread outputsThread = createAsyncStreamThread(process.getInputStream(), builder, isVerbose);
try {
outputsThread.start();
int exitValue = process.waitFor();
outputsThread.join();
return exitValue;
} catch (InterruptedException e) {
// The current thread is interrupted, so try to interrupt reading threads and kill
// the process to return quickly.
outputsThread.interrupt();
process.destroy();
LOG.log(Level.SEVERE, "Running synced process was interrupted", e);
// Reset the interrupt status to allow other codes noticing it.
Thread.currentThread().interrupt();
return -1;
}
} | [
"private",
"static",
"int",
"runSyncProcess",
"(",
"boolean",
"isVerbose",
",",
"boolean",
"isInheritIO",
",",
"String",
"[",
"]",
"cmdline",
",",
"StringBuilder",
"outputBuilder",
",",
"File",
"workingDirectory",
",",
"Map",
"<",
"String",
",",
"String",
">",
"envs",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"outputBuilder",
"==",
"null",
"?",
"new",
"StringBuilder",
"(",
")",
":",
"outputBuilder",
";",
"// Log the command for debugging",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Running synced process: ``{0}''''\"",
",",
"joinString",
"(",
"cmdline",
")",
")",
";",
"ProcessBuilder",
"pb",
"=",
"getProcessBuilder",
"(",
"isInheritIO",
",",
"cmdline",
",",
"workingDirectory",
",",
"envs",
")",
";",
"/* combine input stream and error stream into stderr because\n 1. this preserves order of process's stdout/stderr message\n 2. there is no need to distinguish stderr from stdout\n 3. follow one basic pattern of the design of Python<~>Java I/O redirection:\n stdout contains useful messages Java program needs to propagate back, stderr\n contains all other information */",
"pb",
".",
"redirectErrorStream",
"(",
"true",
")",
";",
"Process",
"process",
";",
"try",
"{",
"process",
"=",
"pb",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to run synced process\"",
",",
"e",
")",
";",
"return",
"-",
"1",
";",
"}",
"// Launching threads to consume combined stdout and stderr before \"waitFor\".",
"// Otherwise, output from the \"process\" can exhaust the available buffer for the combined stream",
"// because stream is not read while waiting for the process to complete.",
"// If buffer becomes full, it can block the \"process\" as well,",
"// preventing all progress for both the \"process\" and the current thread.",
"Thread",
"outputsThread",
"=",
"createAsyncStreamThread",
"(",
"process",
".",
"getInputStream",
"(",
")",
",",
"builder",
",",
"isVerbose",
")",
";",
"try",
"{",
"outputsThread",
".",
"start",
"(",
")",
";",
"int",
"exitValue",
"=",
"process",
".",
"waitFor",
"(",
")",
";",
"outputsThread",
".",
"join",
"(",
")",
";",
"return",
"exitValue",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// The current thread is interrupted, so try to interrupt reading threads and kill",
"// the process to return quickly.",
"outputsThread",
".",
"interrupt",
"(",
")",
";",
"process",
".",
"destroy",
"(",
")",
";",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Running synced process was interrupted\"",
",",
"e",
")",
";",
"// Reset the interrupt status to allow other codes noticing it.",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"return",
"-",
"1",
";",
"}",
"}"
] | run sync process | [
"run",
"sync",
"process"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java#L135-L181 |
28,033 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java | ShellUtils.splitTokens | protected static String[] splitTokens(String command) {
if (command.length() == 0) {
throw new IllegalArgumentException("Empty command");
}
StringTokenizer st = new StringTokenizer(command);
String[] cmdarray = new String[st.countTokens()];
for (int i = 0; st.hasMoreTokens(); i++) {
cmdarray[i] = st.nextToken();
}
return cmdarray;
} | java | protected static String[] splitTokens(String command) {
if (command.length() == 0) {
throw new IllegalArgumentException("Empty command");
}
StringTokenizer st = new StringTokenizer(command);
String[] cmdarray = new String[st.countTokens()];
for (int i = 0; st.hasMoreTokens(); i++) {
cmdarray[i] = st.nextToken();
}
return cmdarray;
} | [
"protected",
"static",
"String",
"[",
"]",
"splitTokens",
"(",
"String",
"command",
")",
"{",
"if",
"(",
"command",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Empty command\"",
")",
";",
"}",
"StringTokenizer",
"st",
"=",
"new",
"StringTokenizer",
"(",
"command",
")",
";",
"String",
"[",
"]",
"cmdarray",
"=",
"new",
"String",
"[",
"st",
".",
"countTokens",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"st",
".",
"hasMoreTokens",
"(",
")",
";",
"i",
"++",
")",
"{",
"cmdarray",
"[",
"i",
"]",
"=",
"st",
".",
"nextToken",
"(",
")",
";",
"}",
"return",
"cmdarray",
";",
"}"
] | argument contains space. | [
"argument",
"contains",
"space",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java#L240-L251 |
28,034 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java | ShellUtils.curlPackage | public static boolean curlPackage(
String uri, String destination, boolean isVerbose, boolean isInheritIO) {
// get the directory containing the target file
File parentDirectory = Paths.get(destination).getParent().toFile();
// using curl copy the url to the target file
String cmd = String.format("curl %s -o %s", uri, destination);
int ret = runSyncProcess(isVerbose, isInheritIO,
splitTokens(cmd), new StringBuilder(), parentDirectory);
return ret == 0;
} | java | public static boolean curlPackage(
String uri, String destination, boolean isVerbose, boolean isInheritIO) {
// get the directory containing the target file
File parentDirectory = Paths.get(destination).getParent().toFile();
// using curl copy the url to the target file
String cmd = String.format("curl %s -o %s", uri, destination);
int ret = runSyncProcess(isVerbose, isInheritIO,
splitTokens(cmd), new StringBuilder(), parentDirectory);
return ret == 0;
} | [
"public",
"static",
"boolean",
"curlPackage",
"(",
"String",
"uri",
",",
"String",
"destination",
",",
"boolean",
"isVerbose",
",",
"boolean",
"isInheritIO",
")",
"{",
"// get the directory containing the target file",
"File",
"parentDirectory",
"=",
"Paths",
".",
"get",
"(",
"destination",
")",
".",
"getParent",
"(",
")",
".",
"toFile",
"(",
")",
";",
"// using curl copy the url to the target file",
"String",
"cmd",
"=",
"String",
".",
"format",
"(",
"\"curl %s -o %s\"",
",",
"uri",
",",
"destination",
")",
";",
"int",
"ret",
"=",
"runSyncProcess",
"(",
"isVerbose",
",",
"isInheritIO",
",",
"splitTokens",
"(",
"cmd",
")",
",",
"new",
"StringBuilder",
"(",
")",
",",
"parentDirectory",
")",
";",
"return",
"ret",
"==",
"0",
";",
"}"
] | Copy a URL package to a target folder
@param uri the URI to download core release package
@param destination the target filename to download the release package to
@param isVerbose display verbose output or not
@return true if successful | [
"Copy",
"a",
"URL",
"package",
"to",
"a",
"target",
"folder"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java#L294-L306 |
28,035 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java | ShellUtils.extractPackage | public static boolean extractPackage(
String packageName, String targetFolder, boolean isVerbose, boolean isInheritIO) {
String cmd = String.format("tar -xvf %s", packageName);
int ret = runSyncProcess(isVerbose, isInheritIO,
splitTokens(cmd), new StringBuilder(), new File(targetFolder));
return ret == 0;
} | java | public static boolean extractPackage(
String packageName, String targetFolder, boolean isVerbose, boolean isInheritIO) {
String cmd = String.format("tar -xvf %s", packageName);
int ret = runSyncProcess(isVerbose, isInheritIO,
splitTokens(cmd), new StringBuilder(), new File(targetFolder));
return ret == 0;
} | [
"public",
"static",
"boolean",
"extractPackage",
"(",
"String",
"packageName",
",",
"String",
"targetFolder",
",",
"boolean",
"isVerbose",
",",
"boolean",
"isInheritIO",
")",
"{",
"String",
"cmd",
"=",
"String",
".",
"format",
"(",
"\"tar -xvf %s\"",
",",
"packageName",
")",
";",
"int",
"ret",
"=",
"runSyncProcess",
"(",
"isVerbose",
",",
"isInheritIO",
",",
"splitTokens",
"(",
"cmd",
")",
",",
"new",
"StringBuilder",
"(",
")",
",",
"new",
"File",
"(",
"targetFolder",
")",
")",
";",
"return",
"ret",
"==",
"0",
";",
"}"
] | Extract a tar package to a target folder
@param packageName the tar package
@param targetFolder the target folder
@param isVerbose display verbose output or not
@return true if untar successfully | [
"Extract",
"a",
"tar",
"package",
"to",
"a",
"target",
"folder"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/utils/ShellUtils.java#L316-L324 |
28,036 | apache/incubator-heron | heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/metricscache/CacheCore.java | CacheCore.startPurge | public void startPurge(WakeableLooper wakeableLooper) {
synchronized (CacheCore.class) {
if (looper == null) {
looper = wakeableLooper;
}
looper.registerTimerEvent(interval, new Runnable() {
@Override
public void run() {
purge();
}
});
}
} | java | public void startPurge(WakeableLooper wakeableLooper) {
synchronized (CacheCore.class) {
if (looper == null) {
looper = wakeableLooper;
}
looper.registerTimerEvent(interval, new Runnable() {
@Override
public void run() {
purge();
}
});
}
} | [
"public",
"void",
"startPurge",
"(",
"WakeableLooper",
"wakeableLooper",
")",
"{",
"synchronized",
"(",
"CacheCore",
".",
"class",
")",
"{",
"if",
"(",
"looper",
"==",
"null",
")",
"{",
"looper",
"=",
"wakeableLooper",
";",
"}",
"looper",
".",
"registerTimerEvent",
"(",
"interval",
",",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"purge",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | start purge looper task
@param wakeableLooper the looper to run timer | [
"start",
"purge",
"looper",
"task"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/metricscache/CacheCore.java#L525-L538 |
28,037 | apache/incubator-heron | heron/instance/src/java/org/apache/heron/network/StreamManagerClient.java | StreamManagerClient.sendRegisterRequest | private void sendRegisterRequest() {
StreamManager.RegisterInstanceRequest request =
StreamManager.RegisterInstanceRequest.newBuilder().
setInstance(instance).setTopologyName(topologyName).setTopologyId(topologyId).
build();
// The timeout would be the reconnect-interval-seconds
sendRequest(request, null,
StreamManager.RegisterInstanceResponse.newBuilder(),
systemConfig.getInstanceReconnectStreammgrInterval());
} | java | private void sendRegisterRequest() {
StreamManager.RegisterInstanceRequest request =
StreamManager.RegisterInstanceRequest.newBuilder().
setInstance(instance).setTopologyName(topologyName).setTopologyId(topologyId).
build();
// The timeout would be the reconnect-interval-seconds
sendRequest(request, null,
StreamManager.RegisterInstanceResponse.newBuilder(),
systemConfig.getInstanceReconnectStreammgrInterval());
} | [
"private",
"void",
"sendRegisterRequest",
"(",
")",
"{",
"StreamManager",
".",
"RegisterInstanceRequest",
"request",
"=",
"StreamManager",
".",
"RegisterInstanceRequest",
".",
"newBuilder",
"(",
")",
".",
"setInstance",
"(",
"instance",
")",
".",
"setTopologyName",
"(",
"topologyName",
")",
".",
"setTopologyId",
"(",
"topologyId",
")",
".",
"build",
"(",
")",
";",
"// The timeout would be the reconnect-interval-seconds",
"sendRequest",
"(",
"request",
",",
"null",
",",
"StreamManager",
".",
"RegisterInstanceResponse",
".",
"newBuilder",
"(",
")",
",",
"systemConfig",
".",
"getInstanceReconnectStreammgrInterval",
"(",
")",
")",
";",
"}"
] | Build register request and send to stream mgr | [
"Build",
"register",
"request",
"and",
"send",
"to",
"stream",
"mgr"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/instance/src/java/org/apache/heron/network/StreamManagerClient.java#L164-L174 |
28,038 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.createJob | public boolean createJob(Map<Integer, BaseContainer> jobDefinition) {
synchronized (this) {
if (isTerminated) {
LOG.severe("Job has been killed");
return false;
}
// Record the jobDefinition
containersInfo.putAll(jobDefinition);
// To scheduler them with 0 attempt
for (Map.Entry<Integer, BaseContainer> entry : jobDefinition.entrySet()) {
Integer containerIndex = entry.getKey();
BaseContainer container = entry.getValue();
String taskId = TaskUtils.getTaskId(container.name, 0);
scheduleNewTask(taskId);
}
}
return true;
} | java | public boolean createJob(Map<Integer, BaseContainer> jobDefinition) {
synchronized (this) {
if (isTerminated) {
LOG.severe("Job has been killed");
return false;
}
// Record the jobDefinition
containersInfo.putAll(jobDefinition);
// To scheduler them with 0 attempt
for (Map.Entry<Integer, BaseContainer> entry : jobDefinition.entrySet()) {
Integer containerIndex = entry.getKey();
BaseContainer container = entry.getValue();
String taskId = TaskUtils.getTaskId(container.name, 0);
scheduleNewTask(taskId);
}
}
return true;
} | [
"public",
"boolean",
"createJob",
"(",
"Map",
"<",
"Integer",
",",
"BaseContainer",
">",
"jobDefinition",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isTerminated",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Job has been killed\"",
")",
";",
"return",
"false",
";",
"}",
"// Record the jobDefinition",
"containersInfo",
".",
"putAll",
"(",
"jobDefinition",
")",
";",
"// To scheduler them with 0 attempt",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Integer",
",",
"BaseContainer",
">",
"entry",
":",
"jobDefinition",
".",
"entrySet",
"(",
")",
")",
"{",
"Integer",
"containerIndex",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"BaseContainer",
"container",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"String",
"taskId",
"=",
"TaskUtils",
".",
"getTaskId",
"(",
"container",
".",
"name",
",",
"0",
")",
";",
"scheduleNewTask",
"(",
"taskId",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Create a topology | [
"Create",
"a",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L95-L115 |
28,039 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.killJob | public boolean killJob() {
synchronized (this) {
if (isTerminated) {
LOG.info("Job has been killed");
return false;
}
isTerminated = true;
LOG.info(String.format("Kill job: %s", Context.topologyName(heronConfig)));
LOG.info("Remove all tasks to schedule");
toScheduleTasks.clear();
// Kill all the tasks
for (String taskId : tasksId.values()) {
driver.killTask(Protos.TaskID.newBuilder().setValue(taskId).build());
}
containersInfo.clear();
tasksId.clear();
return true;
}
} | java | public boolean killJob() {
synchronized (this) {
if (isTerminated) {
LOG.info("Job has been killed");
return false;
}
isTerminated = true;
LOG.info(String.format("Kill job: %s", Context.topologyName(heronConfig)));
LOG.info("Remove all tasks to schedule");
toScheduleTasks.clear();
// Kill all the tasks
for (String taskId : tasksId.values()) {
driver.killTask(Protos.TaskID.newBuilder().setValue(taskId).build());
}
containersInfo.clear();
tasksId.clear();
return true;
}
} | [
"public",
"boolean",
"killJob",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isTerminated",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Job has been killed\"",
")",
";",
"return",
"false",
";",
"}",
"isTerminated",
"=",
"true",
";",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Kill job: %s\"",
",",
"Context",
".",
"topologyName",
"(",
"heronConfig",
")",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Remove all tasks to schedule\"",
")",
";",
"toScheduleTasks",
".",
"clear",
"(",
")",
";",
"// Kill all the tasks",
"for",
"(",
"String",
"taskId",
":",
"tasksId",
".",
"values",
"(",
")",
")",
"{",
"driver",
".",
"killTask",
"(",
"Protos",
".",
"TaskID",
".",
"newBuilder",
"(",
")",
".",
"setValue",
"(",
"taskId",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"containersInfo",
".",
"clear",
"(",
")",
";",
"tasksId",
".",
"clear",
"(",
")",
";",
"return",
"true",
";",
"}",
"}"
] | Kill a topology | [
"Kill",
"a",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L118-L140 |
28,040 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.restartJob | public boolean restartJob(int containerIndex) {
synchronized (this) {
if (isTerminated) {
LOG.severe("Job has been killed");
return false;
}
// List of tasks to restart
List<String> tasksToRestart = new ArrayList<>();
if (containerIndex == -1) {
// Restart all tasks
tasksToRestart.addAll(tasksId.values());
} else {
tasksToRestart.add(tasksId.get(containerIndex));
}
// Kill the task -- the framework will automatically restart it
for (String taskId : tasksToRestart) {
driver.killTask(Protos.TaskID.newBuilder().setValue(taskId).build());
}
return true;
}
} | java | public boolean restartJob(int containerIndex) {
synchronized (this) {
if (isTerminated) {
LOG.severe("Job has been killed");
return false;
}
// List of tasks to restart
List<String> tasksToRestart = new ArrayList<>();
if (containerIndex == -1) {
// Restart all tasks
tasksToRestart.addAll(tasksId.values());
} else {
tasksToRestart.add(tasksId.get(containerIndex));
}
// Kill the task -- the framework will automatically restart it
for (String taskId : tasksToRestart) {
driver.killTask(Protos.TaskID.newBuilder().setValue(taskId).build());
}
return true;
}
} | [
"public",
"boolean",
"restartJob",
"(",
"int",
"containerIndex",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"isTerminated",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Job has been killed\"",
")",
";",
"return",
"false",
";",
"}",
"// List of tasks to restart",
"List",
"<",
"String",
">",
"tasksToRestart",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"containerIndex",
"==",
"-",
"1",
")",
"{",
"// Restart all tasks",
"tasksToRestart",
".",
"addAll",
"(",
"tasksId",
".",
"values",
"(",
")",
")",
";",
"}",
"else",
"{",
"tasksToRestart",
".",
"add",
"(",
"tasksId",
".",
"get",
"(",
"containerIndex",
")",
")",
";",
"}",
"// Kill the task -- the framework will automatically restart it",
"for",
"(",
"String",
"taskId",
":",
"tasksToRestart",
")",
"{",
"driver",
".",
"killTask",
"(",
"Protos",
".",
"TaskID",
".",
"newBuilder",
"(",
")",
".",
"setValue",
"(",
"taskId",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"}"
] | Restart a topology | [
"Restart",
"a",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L143-L166 |
28,041 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.waitForRegistered | public boolean waitForRegistered(long timeout, TimeUnit unit) {
try {
if (this.registeredLatch.await(timeout, unit)) {
return true;
}
} catch (InterruptedException e) {
LOG.severe("Failed to wait for mesos framework got registered");
return false;
}
return false;
} | java | public boolean waitForRegistered(long timeout, TimeUnit unit) {
try {
if (this.registeredLatch.await(timeout, unit)) {
return true;
}
} catch (InterruptedException e) {
LOG.severe("Failed to wait for mesos framework got registered");
return false;
}
return false;
} | [
"public",
"boolean",
"waitForRegistered",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"try",
"{",
"if",
"(",
"this",
".",
"registeredLatch",
".",
"await",
"(",
"timeout",
",",
"unit",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Failed to wait for mesos framework got registered\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] | Causes the current thread to wait for MesosFramework got registered,
unless the thread is interrupted, or the specified waiting time elapses.
@param timeout the maximum time to wait
@param unit the time unit of the timeout argument
@return true MesosFramework got registered,
and false if the waiting time elapsed before the count reached zero | [
"Causes",
"the",
"current",
"thread",
"to",
"wait",
"for",
"MesosFramework",
"got",
"registered",
"unless",
"the",
"thread",
"is",
"interrupted",
"or",
"the",
"specified",
"waiting",
"time",
"elapses",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L186-L197 |
28,042 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.handleMesosFailure | protected void handleMesosFailure(String taskId) {
int attempt = TaskUtils.getAttemptForTaskId(taskId);
BaseContainer container = containersInfo.get(TaskUtils.getContainerIndexForTaskId(taskId));
boolean hasAttemptsLeft = attempt < container.retries;
if (hasAttemptsLeft) {
LOG.warning(String.format("Retrying task: %s, attempt: %d", container.name, attempt + 1));
String newTaskId = TaskUtils.getTaskId(container.name, attempt + 1);
scheduleNewTask(newTaskId);
} else {
LOG.severe("Would not restart the job since it is beyond retries: " + attempt);
}
} | java | protected void handleMesosFailure(String taskId) {
int attempt = TaskUtils.getAttemptForTaskId(taskId);
BaseContainer container = containersInfo.get(TaskUtils.getContainerIndexForTaskId(taskId));
boolean hasAttemptsLeft = attempt < container.retries;
if (hasAttemptsLeft) {
LOG.warning(String.format("Retrying task: %s, attempt: %d", container.name, attempt + 1));
String newTaskId = TaskUtils.getTaskId(container.name, attempt + 1);
scheduleNewTask(newTaskId);
} else {
LOG.severe("Would not restart the job since it is beyond retries: " + attempt);
}
} | [
"protected",
"void",
"handleMesosFailure",
"(",
"String",
"taskId",
")",
"{",
"int",
"attempt",
"=",
"TaskUtils",
".",
"getAttemptForTaskId",
"(",
"taskId",
")",
";",
"BaseContainer",
"container",
"=",
"containersInfo",
".",
"get",
"(",
"TaskUtils",
".",
"getContainerIndexForTaskId",
"(",
"taskId",
")",
")",
";",
"boolean",
"hasAttemptsLeft",
"=",
"attempt",
"<",
"container",
".",
"retries",
";",
"if",
"(",
"hasAttemptsLeft",
")",
"{",
"LOG",
".",
"warning",
"(",
"String",
".",
"format",
"(",
"\"Retrying task: %s, attempt: %d\"",
",",
"container",
".",
"name",
",",
"attempt",
"+",
"1",
")",
")",
";",
"String",
"newTaskId",
"=",
"TaskUtils",
".",
"getTaskId",
"(",
"container",
".",
"name",
",",
"attempt",
"+",
"1",
")",
";",
"scheduleNewTask",
"(",
"newTaskId",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"severe",
"(",
"\"Would not restart the job since it is beyond retries: \"",
"+",
"attempt",
")",
";",
"}",
"}"
] | Restart a failed task unless exceeding the retires limitation
@param taskId the taskId of container to handle | [
"Restart",
"a",
"failed",
"task",
"unless",
"exceeding",
"the",
"retires",
"limitation"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L365-L379 |
28,043 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.scheduleNewTask | protected boolean scheduleNewTask(String taskId) {
// Put it to the pending start queue
LOG.info(String.format("We are to schedule task: [%s]", taskId));
// Update the tasksId
int containerIndex = TaskUtils.getContainerIndexForTaskId(taskId);
tasksId.put(containerIndex, taskId);
// Re-schedule it
toScheduleTasks.add(taskId);
LOG.info(String.format("Added task: %s into the to-schedule-tasks queue: ", taskId));
return true;
} | java | protected boolean scheduleNewTask(String taskId) {
// Put it to the pending start queue
LOG.info(String.format("We are to schedule task: [%s]", taskId));
// Update the tasksId
int containerIndex = TaskUtils.getContainerIndexForTaskId(taskId);
tasksId.put(containerIndex, taskId);
// Re-schedule it
toScheduleTasks.add(taskId);
LOG.info(String.format("Added task: %s into the to-schedule-tasks queue: ", taskId));
return true;
} | [
"protected",
"boolean",
"scheduleNewTask",
"(",
"String",
"taskId",
")",
"{",
"// Put it to the pending start queue",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"We are to schedule task: [%s]\"",
",",
"taskId",
")",
")",
";",
"// Update the tasksId",
"int",
"containerIndex",
"=",
"TaskUtils",
".",
"getContainerIndexForTaskId",
"(",
"taskId",
")",
";",
"tasksId",
".",
"put",
"(",
"containerIndex",
",",
"taskId",
")",
";",
"// Re-schedule it",
"toScheduleTasks",
".",
"add",
"(",
"taskId",
")",
";",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Added task: %s into the to-schedule-tasks queue: \"",
",",
"taskId",
")",
")",
";",
"return",
"true",
";",
"}"
] | Schedule a new task
@param taskId the taskId of container to handle | [
"Schedule",
"a",
"new",
"task"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L386-L398 |
28,044 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java | MesosFramework.generateLaunchableTasks | protected List<LaunchableTask> generateLaunchableTasks(
Map<Protos.Offer, TaskResources> offerResources) {
List<LaunchableTask> tasks = new LinkedList<>();
if (isTerminated) {
LOG.info("Job has been killed");
return tasks;
}
while (!toScheduleTasks.isEmpty()) {
String taskId = toScheduleTasks.poll();
BaseContainer baseContainer =
containersInfo.get(TaskUtils.getContainerIndexForTaskId(taskId));
TaskResources neededResources =
new TaskResources(
baseContainer.cpu,
baseContainer.memInMB,
baseContainer.diskInMB,
baseContainer.ports);
boolean isMatched = false;
Iterator<Map.Entry<Protos.Offer, TaskResources>> it = offerResources.entrySet()
.iterator();
while (it.hasNext()) {
Map.Entry<Protos.Offer, TaskResources> kv = it.next();
Protos.Offer offer = kv.getKey();
TaskResources resources = kv.getValue();
if (resources.canSatisfy(neededResources)) {
resources.consume(neededResources);
// Construct the list of free ports to use for a heron executor.
List<Integer> freePorts = new ArrayList<>();
for (int port = (int) (neededResources.getPortsHold().get(0).rangeStart);
port <= (int) (neededResources.getPortsHold().get(0).rangeEnd); port++) {
freePorts.add(port);
}
// Add the tasks
tasks.add(new LaunchableTask(taskId, baseContainer, offer, freePorts));
// Set the flag
isMatched = true;
// Matched baseContainer, break;
break;
}
}
if (!isMatched) {
LOG.info(String.format("Insufficient resources remaining for baseContainer: %s, "
+ "will append to queue. Need: [%s]",
taskId, neededResources.toString()));
toScheduleTasks.add(taskId);
// Offer will not be able to satisfy resources needed for any rest container,
// since all containers are homogeneous.
// Break the loop
break;
}
}
return tasks;
} | java | protected List<LaunchableTask> generateLaunchableTasks(
Map<Protos.Offer, TaskResources> offerResources) {
List<LaunchableTask> tasks = new LinkedList<>();
if (isTerminated) {
LOG.info("Job has been killed");
return tasks;
}
while (!toScheduleTasks.isEmpty()) {
String taskId = toScheduleTasks.poll();
BaseContainer baseContainer =
containersInfo.get(TaskUtils.getContainerIndexForTaskId(taskId));
TaskResources neededResources =
new TaskResources(
baseContainer.cpu,
baseContainer.memInMB,
baseContainer.diskInMB,
baseContainer.ports);
boolean isMatched = false;
Iterator<Map.Entry<Protos.Offer, TaskResources>> it = offerResources.entrySet()
.iterator();
while (it.hasNext()) {
Map.Entry<Protos.Offer, TaskResources> kv = it.next();
Protos.Offer offer = kv.getKey();
TaskResources resources = kv.getValue();
if (resources.canSatisfy(neededResources)) {
resources.consume(neededResources);
// Construct the list of free ports to use for a heron executor.
List<Integer> freePorts = new ArrayList<>();
for (int port = (int) (neededResources.getPortsHold().get(0).rangeStart);
port <= (int) (neededResources.getPortsHold().get(0).rangeEnd); port++) {
freePorts.add(port);
}
// Add the tasks
tasks.add(new LaunchableTask(taskId, baseContainer, offer, freePorts));
// Set the flag
isMatched = true;
// Matched baseContainer, break;
break;
}
}
if (!isMatched) {
LOG.info(String.format("Insufficient resources remaining for baseContainer: %s, "
+ "will append to queue. Need: [%s]",
taskId, neededResources.toString()));
toScheduleTasks.add(taskId);
// Offer will not be able to satisfy resources needed for any rest container,
// since all containers are homogeneous.
// Break the loop
break;
}
}
return tasks;
} | [
"protected",
"List",
"<",
"LaunchableTask",
">",
"generateLaunchableTasks",
"(",
"Map",
"<",
"Protos",
".",
"Offer",
",",
"TaskResources",
">",
"offerResources",
")",
"{",
"List",
"<",
"LaunchableTask",
">",
"tasks",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"if",
"(",
"isTerminated",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Job has been killed\"",
")",
";",
"return",
"tasks",
";",
"}",
"while",
"(",
"!",
"toScheduleTasks",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"taskId",
"=",
"toScheduleTasks",
".",
"poll",
"(",
")",
";",
"BaseContainer",
"baseContainer",
"=",
"containersInfo",
".",
"get",
"(",
"TaskUtils",
".",
"getContainerIndexForTaskId",
"(",
"taskId",
")",
")",
";",
"TaskResources",
"neededResources",
"=",
"new",
"TaskResources",
"(",
"baseContainer",
".",
"cpu",
",",
"baseContainer",
".",
"memInMB",
",",
"baseContainer",
".",
"diskInMB",
",",
"baseContainer",
".",
"ports",
")",
";",
"boolean",
"isMatched",
"=",
"false",
";",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"Protos",
".",
"Offer",
",",
"TaskResources",
">",
">",
"it",
"=",
"offerResources",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Map",
".",
"Entry",
"<",
"Protos",
".",
"Offer",
",",
"TaskResources",
">",
"kv",
"=",
"it",
".",
"next",
"(",
")",
";",
"Protos",
".",
"Offer",
"offer",
"=",
"kv",
".",
"getKey",
"(",
")",
";",
"TaskResources",
"resources",
"=",
"kv",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"resources",
".",
"canSatisfy",
"(",
"neededResources",
")",
")",
"{",
"resources",
".",
"consume",
"(",
"neededResources",
")",
";",
"// Construct the list of free ports to use for a heron executor.",
"List",
"<",
"Integer",
">",
"freePorts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"port",
"=",
"(",
"int",
")",
"(",
"neededResources",
".",
"getPortsHold",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"rangeStart",
")",
";",
"port",
"<=",
"(",
"int",
")",
"(",
"neededResources",
".",
"getPortsHold",
"(",
")",
".",
"get",
"(",
"0",
")",
".",
"rangeEnd",
")",
";",
"port",
"++",
")",
"{",
"freePorts",
".",
"add",
"(",
"port",
")",
";",
"}",
"// Add the tasks",
"tasks",
".",
"add",
"(",
"new",
"LaunchableTask",
"(",
"taskId",
",",
"baseContainer",
",",
"offer",
",",
"freePorts",
")",
")",
";",
"// Set the flag",
"isMatched",
"=",
"true",
";",
"// Matched baseContainer, break;",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"isMatched",
")",
"{",
"LOG",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Insufficient resources remaining for baseContainer: %s, \"",
"+",
"\"will append to queue. Need: [%s]\"",
",",
"taskId",
",",
"neededResources",
".",
"toString",
"(",
")",
")",
")",
";",
"toScheduleTasks",
".",
"add",
"(",
"taskId",
")",
";",
"// Offer will not be able to satisfy resources needed for any rest container,",
"// since all containers are homogeneous.",
"// Break the loop",
"break",
";",
"}",
"}",
"return",
"tasks",
";",
"}"
] | Generate launchable tasks basing on offer resources
@param offerResources Mapping from Protos.Offer to utils class TaskResources
@return list of launchable task | [
"Generate",
"launchable",
"tasks",
"basing",
"on",
"offer",
"resources"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/mesos/framework/MesosFramework.java#L444-L508 |
28,045 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java | SchedulerMain.setupLogging | private static void setupLogging(Config config) throws IOException {
String systemConfigFilename = Context.systemConfigFile(config);
SystemConfig systemConfig = SystemConfig.newBuilder(true)
.putAll(systemConfigFilename, true)
.build();
// Init the logging setting and redirect the stdout and stderr to logging
// For now we just set the logging level as INFO; later we may accept an argument to set it.
Level loggingLevel = Level.INFO;
if (Context.verbose(config).booleanValue()) {
loggingLevel = Level.FINE;
}
// TODO(mfu): The folder creation may be duplicated with heron-executor in future
// TODO(mfu): Remove the creation in future if feasible
String loggingDir = systemConfig.getHeronLoggingDirectory();
if (!FileUtils.isDirectoryExists(loggingDir)) {
FileUtils.createDirectory(loggingDir);
}
// Log to file
LoggingHelper.loggerInit(loggingLevel, true);
// TODO(mfu): Pass the scheduler id from cmd
String processId =
String.format("%s-%s-%s", "heron", Context.topologyName(config), "scheduler");
LoggingHelper.addLoggingHandler(
LoggingHelper.getFileHandler(processId, loggingDir, true,
systemConfig.getHeronLoggingMaximumSize(),
systemConfig.getHeronLoggingMaximumFiles()));
LOG.info("Logging setup done.");
} | java | private static void setupLogging(Config config) throws IOException {
String systemConfigFilename = Context.systemConfigFile(config);
SystemConfig systemConfig = SystemConfig.newBuilder(true)
.putAll(systemConfigFilename, true)
.build();
// Init the logging setting and redirect the stdout and stderr to logging
// For now we just set the logging level as INFO; later we may accept an argument to set it.
Level loggingLevel = Level.INFO;
if (Context.verbose(config).booleanValue()) {
loggingLevel = Level.FINE;
}
// TODO(mfu): The folder creation may be duplicated with heron-executor in future
// TODO(mfu): Remove the creation in future if feasible
String loggingDir = systemConfig.getHeronLoggingDirectory();
if (!FileUtils.isDirectoryExists(loggingDir)) {
FileUtils.createDirectory(loggingDir);
}
// Log to file
LoggingHelper.loggerInit(loggingLevel, true);
// TODO(mfu): Pass the scheduler id from cmd
String processId =
String.format("%s-%s-%s", "heron", Context.topologyName(config), "scheduler");
LoggingHelper.addLoggingHandler(
LoggingHelper.getFileHandler(processId, loggingDir, true,
systemConfig.getHeronLoggingMaximumSize(),
systemConfig.getHeronLoggingMaximumFiles()));
LOG.info("Logging setup done.");
} | [
"private",
"static",
"void",
"setupLogging",
"(",
"Config",
"config",
")",
"throws",
"IOException",
"{",
"String",
"systemConfigFilename",
"=",
"Context",
".",
"systemConfigFile",
"(",
"config",
")",
";",
"SystemConfig",
"systemConfig",
"=",
"SystemConfig",
".",
"newBuilder",
"(",
"true",
")",
".",
"putAll",
"(",
"systemConfigFilename",
",",
"true",
")",
".",
"build",
"(",
")",
";",
"// Init the logging setting and redirect the stdout and stderr to logging",
"// For now we just set the logging level as INFO; later we may accept an argument to set it.",
"Level",
"loggingLevel",
"=",
"Level",
".",
"INFO",
";",
"if",
"(",
"Context",
".",
"verbose",
"(",
"config",
")",
".",
"booleanValue",
"(",
")",
")",
"{",
"loggingLevel",
"=",
"Level",
".",
"FINE",
";",
"}",
"// TODO(mfu): The folder creation may be duplicated with heron-executor in future",
"// TODO(mfu): Remove the creation in future if feasible",
"String",
"loggingDir",
"=",
"systemConfig",
".",
"getHeronLoggingDirectory",
"(",
")",
";",
"if",
"(",
"!",
"FileUtils",
".",
"isDirectoryExists",
"(",
"loggingDir",
")",
")",
"{",
"FileUtils",
".",
"createDirectory",
"(",
"loggingDir",
")",
";",
"}",
"// Log to file",
"LoggingHelper",
".",
"loggerInit",
"(",
"loggingLevel",
",",
"true",
")",
";",
"// TODO(mfu): Pass the scheduler id from cmd",
"String",
"processId",
"=",
"String",
".",
"format",
"(",
"\"%s-%s-%s\"",
",",
"\"heron\"",
",",
"Context",
".",
"topologyName",
"(",
"config",
")",
",",
"\"scheduler\"",
")",
";",
"LoggingHelper",
".",
"addLoggingHandler",
"(",
"LoggingHelper",
".",
"getFileHandler",
"(",
"processId",
",",
"loggingDir",
",",
"true",
",",
"systemConfig",
".",
"getHeronLoggingMaximumSize",
"(",
")",
",",
"systemConfig",
".",
"getHeronLoggingMaximumFiles",
"(",
")",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Logging setup done.\"",
")",
";",
"}"
] | Set up logging based on the Config | [
"Set",
"up",
"logging",
"based",
"on",
"the",
"Config"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java#L282-L314 |
28,046 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java | SchedulerMain.getServer | protected SchedulerServer getServer(
Config runtime, IScheduler scheduler, int port) throws IOException {
// create an instance of the server using scheduler class and port
return new SchedulerServer(runtime, scheduler, port);
} | java | protected SchedulerServer getServer(
Config runtime, IScheduler scheduler, int port) throws IOException {
// create an instance of the server using scheduler class and port
return new SchedulerServer(runtime, scheduler, port);
} | [
"protected",
"SchedulerServer",
"getServer",
"(",
"Config",
"runtime",
",",
"IScheduler",
"scheduler",
",",
"int",
"port",
")",
"throws",
"IOException",
"{",
"// create an instance of the server using scheduler class and port",
"return",
"new",
"SchedulerServer",
"(",
"runtime",
",",
"scheduler",
",",
"port",
")",
";",
"}"
] | Get the http server for receiving scheduler requests
@param runtime the runtime configuration
@param scheduler an instance of the scheduler
@param port the port for scheduler to listen on
@return an instance of the http server | [
"Get",
"the",
"http",
"server",
"for",
"receiving",
"scheduler",
"requests"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/SchedulerMain.java#L324-L329 |
28,047 | apache/incubator-heron | heron/instance/src/java/org/apache/heron/instance/spout/SpoutInstance.java | SpoutInstance.addSpoutsTasks | private void addSpoutsTasks() {
// Register spoutTasks
Runnable spoutTasks = new Runnable() {
@Override
public void run() {
spoutMetrics.updateTaskRunCount();
// Check whether we should produce more tuples
if (isProduceTuple()) {
spoutMetrics.updateProduceTupleCount();
produceTuple();
// Though we may execute MAX_READ tuples, finally we will packet it as
// one outgoingPacket and push to out queues
// Notice: Tuples are not necessary emitted during nextTuple methods. We could emit
// tuples as long as we invoke collector.emit(...)
collector.sendOutTuples();
}
if (!collector.isOutQueuesAvailable()) {
spoutMetrics.updateOutQueueFullCount();
}
// Check if we have any message to process anyway
readTuplesAndExecute(streamInQueue);
if (ackEnabled) {
// Update the pending-to-be-acked tuples counts
spoutMetrics.updatePendingTuplesCount(collector.numInFlight());
} else {
doImmediateAcks();
}
// If we have more work to do
if (isContinueWork()) {
spoutMetrics.updateContinueWorkCount();
looper.wakeUp();
}
}
};
looper.addTasksOnWakeup(spoutTasks);
// Look for the timeout's tuples
if (enableMessageTimeouts) {
lookForTimeouts();
}
InstanceUtils.prepareTimerEvents(looper, helper);
} | java | private void addSpoutsTasks() {
// Register spoutTasks
Runnable spoutTasks = new Runnable() {
@Override
public void run() {
spoutMetrics.updateTaskRunCount();
// Check whether we should produce more tuples
if (isProduceTuple()) {
spoutMetrics.updateProduceTupleCount();
produceTuple();
// Though we may execute MAX_READ tuples, finally we will packet it as
// one outgoingPacket and push to out queues
// Notice: Tuples are not necessary emitted during nextTuple methods. We could emit
// tuples as long as we invoke collector.emit(...)
collector.sendOutTuples();
}
if (!collector.isOutQueuesAvailable()) {
spoutMetrics.updateOutQueueFullCount();
}
// Check if we have any message to process anyway
readTuplesAndExecute(streamInQueue);
if (ackEnabled) {
// Update the pending-to-be-acked tuples counts
spoutMetrics.updatePendingTuplesCount(collector.numInFlight());
} else {
doImmediateAcks();
}
// If we have more work to do
if (isContinueWork()) {
spoutMetrics.updateContinueWorkCount();
looper.wakeUp();
}
}
};
looper.addTasksOnWakeup(spoutTasks);
// Look for the timeout's tuples
if (enableMessageTimeouts) {
lookForTimeouts();
}
InstanceUtils.prepareTimerEvents(looper, helper);
} | [
"private",
"void",
"addSpoutsTasks",
"(",
")",
"{",
"// Register spoutTasks",
"Runnable",
"spoutTasks",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"spoutMetrics",
".",
"updateTaskRunCount",
"(",
")",
";",
"// Check whether we should produce more tuples",
"if",
"(",
"isProduceTuple",
"(",
")",
")",
"{",
"spoutMetrics",
".",
"updateProduceTupleCount",
"(",
")",
";",
"produceTuple",
"(",
")",
";",
"// Though we may execute MAX_READ tuples, finally we will packet it as",
"// one outgoingPacket and push to out queues",
"// Notice: Tuples are not necessary emitted during nextTuple methods. We could emit",
"// tuples as long as we invoke collector.emit(...)",
"collector",
".",
"sendOutTuples",
"(",
")",
";",
"}",
"if",
"(",
"!",
"collector",
".",
"isOutQueuesAvailable",
"(",
")",
")",
"{",
"spoutMetrics",
".",
"updateOutQueueFullCount",
"(",
")",
";",
"}",
"// Check if we have any message to process anyway",
"readTuplesAndExecute",
"(",
"streamInQueue",
")",
";",
"if",
"(",
"ackEnabled",
")",
"{",
"// Update the pending-to-be-acked tuples counts",
"spoutMetrics",
".",
"updatePendingTuplesCount",
"(",
"collector",
".",
"numInFlight",
"(",
")",
")",
";",
"}",
"else",
"{",
"doImmediateAcks",
"(",
")",
";",
"}",
"// If we have more work to do",
"if",
"(",
"isContinueWork",
"(",
")",
")",
"{",
"spoutMetrics",
".",
"updateContinueWorkCount",
"(",
")",
";",
"looper",
".",
"wakeUp",
"(",
")",
";",
"}",
"}",
"}",
";",
"looper",
".",
"addTasksOnWakeup",
"(",
"spoutTasks",
")",
";",
"// Look for the timeout's tuples",
"if",
"(",
"enableMessageTimeouts",
")",
"{",
"lookForTimeouts",
"(",
")",
";",
"}",
"InstanceUtils",
".",
"prepareTimerEvents",
"(",
"looper",
",",
"helper",
")",
";",
"}"
] | Tasks happen in every time looper is waken up | [
"Tasks",
"happen",
"in",
"every",
"time",
"looper",
"is",
"waken",
"up"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/instance/src/java/org/apache/heron/instance/spout/SpoutInstance.java#L253-L300 |
28,048 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/common/Config.java | Config.lazyCreateConfig | private Config lazyCreateConfig(Mode newMode) {
if (newMode == this.mode) {
return this;
}
// this is here so that we don't keep cascading deeper into object creation so:
// localConfig == toLocalMode(toClusterMode(localConfig))
Config newRawConfig = this.rawConfig;
Config newLocalConfig = this.localConfig;
Config newClusterConfig = this.clusterConfig;
switch (this.mode) {
case RAW:
newRawConfig = this;
break;
case LOCAL:
newLocalConfig = this;
break;
case CLUSTER:
newClusterConfig = this;
break;
default:
throw new IllegalArgumentException(
"Unrecognized mode found in config: " + this.mode);
}
switch (newMode) {
case LOCAL:
if (this.localConfig == null) {
Config tempConfig = Config.expand(Config.newBuilder().putAll(rawConfig.cfgMap).build());
this.localConfig = new Config(Mode.LOCAL, newRawConfig, tempConfig, newClusterConfig);
}
return this.localConfig;
case CLUSTER:
if (this.clusterConfig == null) {
Config.Builder bc = Config.newBuilder()
.putAll(rawConfig.cfgMap)
.put(Key.HERON_HOME, get(Key.HERON_CLUSTER_HOME))
.put(Key.HERON_CONF, get(Key.HERON_CLUSTER_CONF));
Config tempConfig = Config.expand(bc.build());
this.clusterConfig = new Config(Mode.CLUSTER, newRawConfig, newLocalConfig, tempConfig);
}
return this.clusterConfig;
case RAW:
default:
throw new IllegalArgumentException(
"Unrecognized mode passed to lazyCreateConfig: " + newMode);
}
} | java | private Config lazyCreateConfig(Mode newMode) {
if (newMode == this.mode) {
return this;
}
// this is here so that we don't keep cascading deeper into object creation so:
// localConfig == toLocalMode(toClusterMode(localConfig))
Config newRawConfig = this.rawConfig;
Config newLocalConfig = this.localConfig;
Config newClusterConfig = this.clusterConfig;
switch (this.mode) {
case RAW:
newRawConfig = this;
break;
case LOCAL:
newLocalConfig = this;
break;
case CLUSTER:
newClusterConfig = this;
break;
default:
throw new IllegalArgumentException(
"Unrecognized mode found in config: " + this.mode);
}
switch (newMode) {
case LOCAL:
if (this.localConfig == null) {
Config tempConfig = Config.expand(Config.newBuilder().putAll(rawConfig.cfgMap).build());
this.localConfig = new Config(Mode.LOCAL, newRawConfig, tempConfig, newClusterConfig);
}
return this.localConfig;
case CLUSTER:
if (this.clusterConfig == null) {
Config.Builder bc = Config.newBuilder()
.putAll(rawConfig.cfgMap)
.put(Key.HERON_HOME, get(Key.HERON_CLUSTER_HOME))
.put(Key.HERON_CONF, get(Key.HERON_CLUSTER_CONF));
Config tempConfig = Config.expand(bc.build());
this.clusterConfig = new Config(Mode.CLUSTER, newRawConfig, newLocalConfig, tempConfig);
}
return this.clusterConfig;
case RAW:
default:
throw new IllegalArgumentException(
"Unrecognized mode passed to lazyCreateConfig: " + newMode);
}
} | [
"private",
"Config",
"lazyCreateConfig",
"(",
"Mode",
"newMode",
")",
"{",
"if",
"(",
"newMode",
"==",
"this",
".",
"mode",
")",
"{",
"return",
"this",
";",
"}",
"// this is here so that we don't keep cascading deeper into object creation so:",
"// localConfig == toLocalMode(toClusterMode(localConfig))",
"Config",
"newRawConfig",
"=",
"this",
".",
"rawConfig",
";",
"Config",
"newLocalConfig",
"=",
"this",
".",
"localConfig",
";",
"Config",
"newClusterConfig",
"=",
"this",
".",
"clusterConfig",
";",
"switch",
"(",
"this",
".",
"mode",
")",
"{",
"case",
"RAW",
":",
"newRawConfig",
"=",
"this",
";",
"break",
";",
"case",
"LOCAL",
":",
"newLocalConfig",
"=",
"this",
";",
"break",
";",
"case",
"CLUSTER",
":",
"newClusterConfig",
"=",
"this",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unrecognized mode found in config: \"",
"+",
"this",
".",
"mode",
")",
";",
"}",
"switch",
"(",
"newMode",
")",
"{",
"case",
"LOCAL",
":",
"if",
"(",
"this",
".",
"localConfig",
"==",
"null",
")",
"{",
"Config",
"tempConfig",
"=",
"Config",
".",
"expand",
"(",
"Config",
".",
"newBuilder",
"(",
")",
".",
"putAll",
"(",
"rawConfig",
".",
"cfgMap",
")",
".",
"build",
"(",
")",
")",
";",
"this",
".",
"localConfig",
"=",
"new",
"Config",
"(",
"Mode",
".",
"LOCAL",
",",
"newRawConfig",
",",
"tempConfig",
",",
"newClusterConfig",
")",
";",
"}",
"return",
"this",
".",
"localConfig",
";",
"case",
"CLUSTER",
":",
"if",
"(",
"this",
".",
"clusterConfig",
"==",
"null",
")",
"{",
"Config",
".",
"Builder",
"bc",
"=",
"Config",
".",
"newBuilder",
"(",
")",
".",
"putAll",
"(",
"rawConfig",
".",
"cfgMap",
")",
".",
"put",
"(",
"Key",
".",
"HERON_HOME",
",",
"get",
"(",
"Key",
".",
"HERON_CLUSTER_HOME",
")",
")",
".",
"put",
"(",
"Key",
".",
"HERON_CONF",
",",
"get",
"(",
"Key",
".",
"HERON_CLUSTER_CONF",
")",
")",
";",
"Config",
"tempConfig",
"=",
"Config",
".",
"expand",
"(",
"bc",
".",
"build",
"(",
")",
")",
";",
"this",
".",
"clusterConfig",
"=",
"new",
"Config",
"(",
"Mode",
".",
"CLUSTER",
",",
"newRawConfig",
",",
"newLocalConfig",
",",
"tempConfig",
")",
";",
"}",
"return",
"this",
".",
"clusterConfig",
";",
"case",
"RAW",
":",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unrecognized mode passed to lazyCreateConfig: \"",
"+",
"newMode",
")",
";",
"}",
"}"
] | what gets generated during toClusterMode | [
"what",
"gets",
"generated",
"during",
"toClusterMode"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/common/Config.java#L148-L195 |
28,049 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/logging/LoggingHelper.java | LoggingHelper.loggerInit | public static void loggerInit(Level level, boolean isRedirectStdOutErr, String format)
throws IOException {
// Set the java util logging format
setLoggingFormat(format);
// Configure the root logger and its handlers so that all the
// derived loggers will inherit the properties
Logger rootLogger = Logger.getLogger("");
for (Handler handler : rootLogger.getHandlers()) {
handler.setLevel(level);
}
rootLogger.setLevel(level);
if (rootLogger.getLevel().intValue() < Level.WARNING.intValue()) {
// zookeeper logging scares me. if people want this, we can patch to config-drive this
Logger.getLogger("org.apache.zookeeper").setLevel(Level.WARNING);
}
// setting logging for http client to be error level
System.setProperty(
"org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty(
"org.apache.commons.logging.simplelog.log.httpclient.wire", "ERROR");
System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.http", "ERROR");
System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.http.headers", "ERROR");
if (isRedirectStdOutErr) {
// Remove ConsoleHandler if present, to avoid StackOverflowError.
// ConsoleHandler writes to System.err and since we are redirecting
// System.err to Logger, it results in an infinite loop.
for (Handler handler : rootLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
rootLogger.removeHandler(handler);
}
}
// now rebind stdout/stderr to logger
Logger logger;
LoggingOutputStream los;
logger = Logger.getLogger("stdout");
los = new LoggingOutputStream(logger, StdOutErrLevel.STDOUT);
System.setOut(new PrintStream(los, true));
logger = Logger.getLogger("stderr");
los = new LoggingOutputStream(logger, StdOutErrLevel.STDERR);
System.setErr(new PrintStream(los, true));
}
} | java | public static void loggerInit(Level level, boolean isRedirectStdOutErr, String format)
throws IOException {
// Set the java util logging format
setLoggingFormat(format);
// Configure the root logger and its handlers so that all the
// derived loggers will inherit the properties
Logger rootLogger = Logger.getLogger("");
for (Handler handler : rootLogger.getHandlers()) {
handler.setLevel(level);
}
rootLogger.setLevel(level);
if (rootLogger.getLevel().intValue() < Level.WARNING.intValue()) {
// zookeeper logging scares me. if people want this, we can patch to config-drive this
Logger.getLogger("org.apache.zookeeper").setLevel(Level.WARNING);
}
// setting logging for http client to be error level
System.setProperty(
"org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty(
"org.apache.commons.logging.simplelog.log.httpclient.wire", "ERROR");
System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.http", "ERROR");
System.setProperty(
"org.apache.commons.logging.simplelog.log.org.apache.http.headers", "ERROR");
if (isRedirectStdOutErr) {
// Remove ConsoleHandler if present, to avoid StackOverflowError.
// ConsoleHandler writes to System.err and since we are redirecting
// System.err to Logger, it results in an infinite loop.
for (Handler handler : rootLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
rootLogger.removeHandler(handler);
}
}
// now rebind stdout/stderr to logger
Logger logger;
LoggingOutputStream los;
logger = Logger.getLogger("stdout");
los = new LoggingOutputStream(logger, StdOutErrLevel.STDOUT);
System.setOut(new PrintStream(los, true));
logger = Logger.getLogger("stderr");
los = new LoggingOutputStream(logger, StdOutErrLevel.STDERR);
System.setErr(new PrintStream(los, true));
}
} | [
"public",
"static",
"void",
"loggerInit",
"(",
"Level",
"level",
",",
"boolean",
"isRedirectStdOutErr",
",",
"String",
"format",
")",
"throws",
"IOException",
"{",
"// Set the java util logging format",
"setLoggingFormat",
"(",
"format",
")",
";",
"// Configure the root logger and its handlers so that all the",
"// derived loggers will inherit the properties",
"Logger",
"rootLogger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"\"",
")",
";",
"for",
"(",
"Handler",
"handler",
":",
"rootLogger",
".",
"getHandlers",
"(",
")",
")",
"{",
"handler",
".",
"setLevel",
"(",
"level",
")",
";",
"}",
"rootLogger",
".",
"setLevel",
"(",
"level",
")",
";",
"if",
"(",
"rootLogger",
".",
"getLevel",
"(",
")",
".",
"intValue",
"(",
")",
"<",
"Level",
".",
"WARNING",
".",
"intValue",
"(",
")",
")",
"{",
"// zookeeper logging scares me. if people want this, we can patch to config-drive this",
"Logger",
".",
"getLogger",
"(",
"\"org.apache.zookeeper\"",
")",
".",
"setLevel",
"(",
"Level",
".",
"WARNING",
")",
";",
"}",
"// setting logging for http client to be error level",
"System",
".",
"setProperty",
"(",
"\"org.apache.commons.logging.Log\"",
",",
"\"org.apache.commons.logging.impl.SimpleLog\"",
")",
";",
"System",
".",
"setProperty",
"(",
"\"org.apache.commons.logging.simplelog.log.httpclient.wire\"",
",",
"\"ERROR\"",
")",
";",
"System",
".",
"setProperty",
"(",
"\"org.apache.commons.logging.simplelog.log.org.apache.http\"",
",",
"\"ERROR\"",
")",
";",
"System",
".",
"setProperty",
"(",
"\"org.apache.commons.logging.simplelog.log.org.apache.http.headers\"",
",",
"\"ERROR\"",
")",
";",
"if",
"(",
"isRedirectStdOutErr",
")",
"{",
"// Remove ConsoleHandler if present, to avoid StackOverflowError.",
"// ConsoleHandler writes to System.err and since we are redirecting",
"// System.err to Logger, it results in an infinite loop.",
"for",
"(",
"Handler",
"handler",
":",
"rootLogger",
".",
"getHandlers",
"(",
")",
")",
"{",
"if",
"(",
"handler",
"instanceof",
"ConsoleHandler",
")",
"{",
"rootLogger",
".",
"removeHandler",
"(",
"handler",
")",
";",
"}",
"}",
"// now rebind stdout/stderr to logger",
"Logger",
"logger",
";",
"LoggingOutputStream",
"los",
";",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"stdout\"",
")",
";",
"los",
"=",
"new",
"LoggingOutputStream",
"(",
"logger",
",",
"StdOutErrLevel",
".",
"STDOUT",
")",
";",
"System",
".",
"setOut",
"(",
"new",
"PrintStream",
"(",
"los",
",",
"true",
")",
")",
";",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"\"stderr\"",
")",
";",
"los",
"=",
"new",
"LoggingOutputStream",
"(",
"logger",
",",
"StdOutErrLevel",
".",
"STDERR",
")",
";",
"System",
".",
"setErr",
"(",
"new",
"PrintStream",
"(",
"los",
",",
"true",
")",
")",
";",
"}",
"}"
] | Init java util logging
@param level the Level of message to log
@param isRedirectStdOutErr whether we redirect std out&err
@param format the format to log | [
"Init",
"java",
"util",
"logging"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/logging/LoggingHelper.java#L67-L119 |
28,050 | apache/incubator-heron | heron/metricsmgr/src/java/org/apache/heron/metricsmgr/executor/SinkExecutor.java | SinkExecutor.addSinkTasks | private void addSinkTasks() {
Runnable sinkTasks = new Runnable() {
@Override
public void run() {
while (!metricsInSinkQueue.isEmpty()) {
metricsSink.processRecord(metricsInSinkQueue.poll());
}
}
};
slaveLooper.addTasksOnWakeup(sinkTasks);
} | java | private void addSinkTasks() {
Runnable sinkTasks = new Runnable() {
@Override
public void run() {
while (!metricsInSinkQueue.isEmpty()) {
metricsSink.processRecord(metricsInSinkQueue.poll());
}
}
};
slaveLooper.addTasksOnWakeup(sinkTasks);
} | [
"private",
"void",
"addSinkTasks",
"(",
")",
"{",
"Runnable",
"sinkTasks",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"!",
"metricsInSinkQueue",
".",
"isEmpty",
"(",
")",
")",
"{",
"metricsSink",
".",
"processRecord",
"(",
"metricsInSinkQueue",
".",
"poll",
"(",
")",
")",
";",
"}",
"}",
"}",
";",
"slaveLooper",
".",
"addTasksOnWakeup",
"(",
"sinkTasks",
")",
";",
"}"
] | Add task to invoke processRecord method when the WakeableLooper is waken up | [
"Add",
"task",
"to",
"invoke",
"processRecord",
"method",
"when",
"the",
"WakeableLooper",
"is",
"waken",
"up"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/metricsmgr/src/java/org/apache/heron/metricsmgr/executor/SinkExecutor.java#L115-L126 |
28,051 | apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java | ResourceCompliantRRPacking.getResourceCompliantRRAllocation | private PackingPlanBuilder getResourceCompliantRRAllocation(
PackingPlanBuilder planBuilder, Map<String, Integer> componentChanges)
throws ConstraintViolationException {
Map<String, Integer> componentsToScaleDown =
PackingUtils.getComponentsToScale(componentChanges, PackingUtils.ScalingDirection.DOWN);
Map<String, Integer> componentsToScaleUp =
PackingUtils.getComponentsToScale(componentChanges, PackingUtils.ScalingDirection.UP);
if (!componentsToScaleDown.isEmpty()) {
resetToFirstContainer();
removeInstancesFromContainers(planBuilder, componentsToScaleDown);
}
if (!componentsToScaleUp.isEmpty()) {
resetToFirstContainer();
assignInstancesToContainers(planBuilder, componentsToScaleUp, PolicyType.FLEXIBLE);
}
return planBuilder;
} | java | private PackingPlanBuilder getResourceCompliantRRAllocation(
PackingPlanBuilder planBuilder, Map<String, Integer> componentChanges)
throws ConstraintViolationException {
Map<String, Integer> componentsToScaleDown =
PackingUtils.getComponentsToScale(componentChanges, PackingUtils.ScalingDirection.DOWN);
Map<String, Integer> componentsToScaleUp =
PackingUtils.getComponentsToScale(componentChanges, PackingUtils.ScalingDirection.UP);
if (!componentsToScaleDown.isEmpty()) {
resetToFirstContainer();
removeInstancesFromContainers(planBuilder, componentsToScaleDown);
}
if (!componentsToScaleUp.isEmpty()) {
resetToFirstContainer();
assignInstancesToContainers(planBuilder, componentsToScaleUp, PolicyType.FLEXIBLE);
}
return planBuilder;
} | [
"private",
"PackingPlanBuilder",
"getResourceCompliantRRAllocation",
"(",
"PackingPlanBuilder",
"planBuilder",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"componentChanges",
")",
"throws",
"ConstraintViolationException",
"{",
"Map",
"<",
"String",
",",
"Integer",
">",
"componentsToScaleDown",
"=",
"PackingUtils",
".",
"getComponentsToScale",
"(",
"componentChanges",
",",
"PackingUtils",
".",
"ScalingDirection",
".",
"DOWN",
")",
";",
"Map",
"<",
"String",
",",
"Integer",
">",
"componentsToScaleUp",
"=",
"PackingUtils",
".",
"getComponentsToScale",
"(",
"componentChanges",
",",
"PackingUtils",
".",
"ScalingDirection",
".",
"UP",
")",
";",
"if",
"(",
"!",
"componentsToScaleDown",
".",
"isEmpty",
"(",
")",
")",
"{",
"resetToFirstContainer",
"(",
")",
";",
"removeInstancesFromContainers",
"(",
"planBuilder",
",",
"componentsToScaleDown",
")",
";",
"}",
"if",
"(",
"!",
"componentsToScaleUp",
".",
"isEmpty",
"(",
")",
")",
"{",
"resetToFirstContainer",
"(",
")",
";",
"assignInstancesToContainers",
"(",
"planBuilder",
",",
"componentsToScaleUp",
",",
"PolicyType",
".",
"FLEXIBLE",
")",
";",
"}",
"return",
"planBuilder",
";",
"}"
] | Get the instances' allocation based on the ResourceCompliantRR packing algorithm
@return Map < containerId, list of InstanceId belonging to this container > | [
"Get",
"the",
"instances",
"allocation",
"based",
"on",
"the",
"ResourceCompliantRR",
"packing",
"algorithm"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java#L243-L262 |
28,052 | apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java | ResourceCompliantRRPacking.assignInstancesToContainers | private void assignInstancesToContainers(PackingPlanBuilder planBuilder,
Map<String, Integer> parallelismMap,
PolicyType policyType)
throws ConstraintViolationException {
for (String componentName : parallelismMap.keySet()) {
int numInstance = parallelismMap.get(componentName);
for (int i = 0; i < numInstance; ++i) {
policyType.assignInstance(planBuilder, componentName, this);
}
}
} | java | private void assignInstancesToContainers(PackingPlanBuilder planBuilder,
Map<String, Integer> parallelismMap,
PolicyType policyType)
throws ConstraintViolationException {
for (String componentName : parallelismMap.keySet()) {
int numInstance = parallelismMap.get(componentName);
for (int i = 0; i < numInstance; ++i) {
policyType.assignInstance(planBuilder, componentName, this);
}
}
} | [
"private",
"void",
"assignInstancesToContainers",
"(",
"PackingPlanBuilder",
"planBuilder",
",",
"Map",
"<",
"String",
",",
"Integer",
">",
"parallelismMap",
",",
"PolicyType",
"policyType",
")",
"throws",
"ConstraintViolationException",
"{",
"for",
"(",
"String",
"componentName",
":",
"parallelismMap",
".",
"keySet",
"(",
")",
")",
"{",
"int",
"numInstance",
"=",
"parallelismMap",
".",
"get",
"(",
"componentName",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numInstance",
";",
"++",
"i",
")",
"{",
"policyType",
".",
"assignInstance",
"(",
"planBuilder",
",",
"componentName",
",",
"this",
")",
";",
"}",
"}",
"}"
] | Assigns instances to containers.
@param planBuilder packing plan builder
@param parallelismMap component parallelism | [
"Assigns",
"instances",
"to",
"containers",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java#L270-L280 |
28,053 | apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java | ResourceCompliantRRPacking.strictRRpolicy | private void strictRRpolicy(PackingPlanBuilder planBuilder,
String componentName) throws ConstraintViolationException {
planBuilder.addInstance(this.containerId, componentName);
this.containerId = nextContainerId(this.containerId);
} | java | private void strictRRpolicy(PackingPlanBuilder planBuilder,
String componentName) throws ConstraintViolationException {
planBuilder.addInstance(this.containerId, componentName);
this.containerId = nextContainerId(this.containerId);
} | [
"private",
"void",
"strictRRpolicy",
"(",
"PackingPlanBuilder",
"planBuilder",
",",
"String",
"componentName",
")",
"throws",
"ConstraintViolationException",
"{",
"planBuilder",
".",
"addInstance",
"(",
"this",
".",
"containerId",
",",
"componentName",
")",
";",
"this",
".",
"containerId",
"=",
"nextContainerId",
"(",
"this",
".",
"containerId",
")",
";",
"}"
] | Attempts to place the instance the current containerId.
@param planBuilder packing plan builder
@param componentName the component name of the instance that needs to be placed in the container
@throws ResourceExceededException if there is no room on the current container for the instance | [
"Attempts",
"to",
"place",
"the",
"instance",
"the",
"current",
"containerId",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java#L289-L293 |
28,054 | apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java | ResourceCompliantRRPacking.flexibleRRpolicy | private void flexibleRRpolicy(PackingPlanBuilder planBuilder,
String componentName) throws ResourceExceededException {
// If there is not enough space on containerId look at other containers in a RR fashion
// starting from containerId.
ContainerIdScorer scorer = new ContainerIdScorer(this.containerId, this.numContainers);
this.containerId = nextContainerId(planBuilder.addInstance(scorer, componentName));
} | java | private void flexibleRRpolicy(PackingPlanBuilder planBuilder,
String componentName) throws ResourceExceededException {
// If there is not enough space on containerId look at other containers in a RR fashion
// starting from containerId.
ContainerIdScorer scorer = new ContainerIdScorer(this.containerId, this.numContainers);
this.containerId = nextContainerId(planBuilder.addInstance(scorer, componentName));
} | [
"private",
"void",
"flexibleRRpolicy",
"(",
"PackingPlanBuilder",
"planBuilder",
",",
"String",
"componentName",
")",
"throws",
"ResourceExceededException",
"{",
"// If there is not enough space on containerId look at other containers in a RR fashion",
"// starting from containerId.",
"ContainerIdScorer",
"scorer",
"=",
"new",
"ContainerIdScorer",
"(",
"this",
".",
"containerId",
",",
"this",
".",
"numContainers",
")",
";",
"this",
".",
"containerId",
"=",
"nextContainerId",
"(",
"planBuilder",
".",
"addInstance",
"(",
"scorer",
",",
"componentName",
")",
")",
";",
"}"
] | Performs a RR placement. Tries to place the instance on any container with space, starting at
containerId and cycling through the container set until it can be placed.
@param planBuilder packing plan builder
@param componentName the component name of the instance that needs to be placed in the container
@throws ResourceExceededException if there is no room on any container to place the instance | [
"Performs",
"a",
"RR",
"placement",
".",
"Tries",
"to",
"place",
"the",
"instance",
"on",
"any",
"container",
"with",
"space",
"starting",
"at",
"containerId",
"and",
"cycling",
"through",
"the",
"container",
"set",
"until",
"it",
"can",
"be",
"placed",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java#L303-L309 |
28,055 | apache/incubator-heron | heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java | ResourceCompliantRRPacking.removeRRInstance | private void removeRRInstance(PackingPlanBuilder packingPlanBuilder,
String componentName) throws RuntimeException {
List<Scorer<Container>> scorers = new ArrayList<>();
scorers.add(new HomogeneityScorer(componentName, true)); // all-same-component containers first
scorers.add(new InstanceCountScorer()); // then fewest instances
scorers.add(new HomogeneityScorer(componentName, false)); // then most homogeneous
scorers.add(new ContainerIdScorer(false)); // then highest container id
this.containerId = nextContainerId(packingPlanBuilder.removeInstance(scorers, componentName));
} | java | private void removeRRInstance(PackingPlanBuilder packingPlanBuilder,
String componentName) throws RuntimeException {
List<Scorer<Container>> scorers = new ArrayList<>();
scorers.add(new HomogeneityScorer(componentName, true)); // all-same-component containers first
scorers.add(new InstanceCountScorer()); // then fewest instances
scorers.add(new HomogeneityScorer(componentName, false)); // then most homogeneous
scorers.add(new ContainerIdScorer(false)); // then highest container id
this.containerId = nextContainerId(packingPlanBuilder.removeInstance(scorers, componentName));
} | [
"private",
"void",
"removeRRInstance",
"(",
"PackingPlanBuilder",
"packingPlanBuilder",
",",
"String",
"componentName",
")",
"throws",
"RuntimeException",
"{",
"List",
"<",
"Scorer",
"<",
"Container",
">>",
"scorers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"scorers",
".",
"add",
"(",
"new",
"HomogeneityScorer",
"(",
"componentName",
",",
"true",
")",
")",
";",
"// all-same-component containers first",
"scorers",
".",
"add",
"(",
"new",
"InstanceCountScorer",
"(",
")",
")",
";",
"// then fewest instances",
"scorers",
".",
"add",
"(",
"new",
"HomogeneityScorer",
"(",
"componentName",
",",
"false",
")",
")",
";",
"// then most homogeneous",
"scorers",
".",
"add",
"(",
"new",
"ContainerIdScorer",
"(",
"false",
")",
")",
";",
"// then highest container id",
"this",
".",
"containerId",
"=",
"nextContainerId",
"(",
"packingPlanBuilder",
".",
"removeInstance",
"(",
"scorers",
",",
"componentName",
")",
")",
";",
"}"
] | Remove an instance of a particular component from the containers | [
"Remove",
"an",
"instance",
"of",
"a",
"particular",
"component",
"from",
"the",
"containers"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/packing/src/java/org/apache/heron/packing/roundrobin/ResourceCompliantRRPacking.java#L330-L339 |
28,056 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java | TopologyContextImpl.invokeHookSpoutAck | public void invokeHookSpoutAck(Object messageId, Duration completeLatency) {
if (taskHooks.size() != 0) {
SpoutAckInfo ackInfo = new SpoutAckInfo(messageId, getThisTaskId(), completeLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.spoutAck(ackInfo);
}
}
} | java | public void invokeHookSpoutAck(Object messageId, Duration completeLatency) {
if (taskHooks.size() != 0) {
SpoutAckInfo ackInfo = new SpoutAckInfo(messageId, getThisTaskId(), completeLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.spoutAck(ackInfo);
}
}
} | [
"public",
"void",
"invokeHookSpoutAck",
"(",
"Object",
"messageId",
",",
"Duration",
"completeLatency",
")",
"{",
"if",
"(",
"taskHooks",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"SpoutAckInfo",
"ackInfo",
"=",
"new",
"SpoutAckInfo",
"(",
"messageId",
",",
"getThisTaskId",
"(",
")",
",",
"completeLatency",
")",
";",
"for",
"(",
"ITaskHook",
"taskHook",
":",
"taskHooks",
")",
"{",
"taskHook",
".",
"spoutAck",
"(",
"ackInfo",
")",
";",
"}",
"}",
"}"
] | Task hook called in spout every time a tuple gets acked | [
"Task",
"hook",
"called",
"in",
"spout",
"every",
"time",
"a",
"tuple",
"gets",
"acked"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java#L129-L137 |
28,057 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java | TopologyContextImpl.invokeHookSpoutFail | public void invokeHookSpoutFail(Object messageId, Duration failLatency) {
if (taskHooks.size() != 0) {
SpoutFailInfo failInfo = new SpoutFailInfo(messageId, getThisTaskId(), failLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.spoutFail(failInfo);
}
}
} | java | public void invokeHookSpoutFail(Object messageId, Duration failLatency) {
if (taskHooks.size() != 0) {
SpoutFailInfo failInfo = new SpoutFailInfo(messageId, getThisTaskId(), failLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.spoutFail(failInfo);
}
}
} | [
"public",
"void",
"invokeHookSpoutFail",
"(",
"Object",
"messageId",
",",
"Duration",
"failLatency",
")",
"{",
"if",
"(",
"taskHooks",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"SpoutFailInfo",
"failInfo",
"=",
"new",
"SpoutFailInfo",
"(",
"messageId",
",",
"getThisTaskId",
"(",
")",
",",
"failLatency",
")",
";",
"for",
"(",
"ITaskHook",
"taskHook",
":",
"taskHooks",
")",
"{",
"taskHook",
".",
"spoutFail",
"(",
"failInfo",
")",
";",
"}",
"}",
"}"
] | Task hook called in spout every time a tuple gets failed | [
"Task",
"hook",
"called",
"in",
"spout",
"every",
"time",
"a",
"tuple",
"gets",
"failed"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java#L142-L150 |
28,058 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java | TopologyContextImpl.invokeHookBoltExecute | public void invokeHookBoltExecute(Tuple tuple, Duration executeLatency) {
if (taskHooks.size() != 0) {
BoltExecuteInfo executeInfo = new BoltExecuteInfo(tuple, getThisTaskId(), executeLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.boltExecute(executeInfo);
}
}
} | java | public void invokeHookBoltExecute(Tuple tuple, Duration executeLatency) {
if (taskHooks.size() != 0) {
BoltExecuteInfo executeInfo = new BoltExecuteInfo(tuple, getThisTaskId(), executeLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.boltExecute(executeInfo);
}
}
} | [
"public",
"void",
"invokeHookBoltExecute",
"(",
"Tuple",
"tuple",
",",
"Duration",
"executeLatency",
")",
"{",
"if",
"(",
"taskHooks",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"BoltExecuteInfo",
"executeInfo",
"=",
"new",
"BoltExecuteInfo",
"(",
"tuple",
",",
"getThisTaskId",
"(",
")",
",",
"executeLatency",
")",
";",
"for",
"(",
"ITaskHook",
"taskHook",
":",
"taskHooks",
")",
"{",
"taskHook",
".",
"boltExecute",
"(",
"executeInfo",
")",
";",
"}",
"}",
"}"
] | Task hook called in bolt every time a tuple gets executed | [
"Task",
"hook",
"called",
"in",
"bolt",
"every",
"time",
"a",
"tuple",
"gets",
"executed"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java#L155-L163 |
28,059 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java | TopologyContextImpl.invokeHookBoltAck | public void invokeHookBoltAck(Tuple tuple, Duration processLatency) {
if (taskHooks.size() != 0) {
BoltAckInfo ackInfo = new BoltAckInfo(tuple, getThisTaskId(), processLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.boltAck(ackInfo);
}
}
} | java | public void invokeHookBoltAck(Tuple tuple, Duration processLatency) {
if (taskHooks.size() != 0) {
BoltAckInfo ackInfo = new BoltAckInfo(tuple, getThisTaskId(), processLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.boltAck(ackInfo);
}
}
} | [
"public",
"void",
"invokeHookBoltAck",
"(",
"Tuple",
"tuple",
",",
"Duration",
"processLatency",
")",
"{",
"if",
"(",
"taskHooks",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"BoltAckInfo",
"ackInfo",
"=",
"new",
"BoltAckInfo",
"(",
"tuple",
",",
"getThisTaskId",
"(",
")",
",",
"processLatency",
")",
";",
"for",
"(",
"ITaskHook",
"taskHook",
":",
"taskHooks",
")",
"{",
"taskHook",
".",
"boltAck",
"(",
"ackInfo",
")",
";",
"}",
"}",
"}"
] | Task hook called in bolt every time a tuple gets acked | [
"Task",
"hook",
"called",
"in",
"bolt",
"every",
"time",
"a",
"tuple",
"gets",
"acked"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java#L168-L176 |
28,060 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java | TopologyContextImpl.invokeHookBoltFail | public void invokeHookBoltFail(Tuple tuple, Duration failLatency) {
if (taskHooks.size() != 0) {
BoltFailInfo failInfo = new BoltFailInfo(tuple, getThisTaskId(), failLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.boltFail(failInfo);
}
}
} | java | public void invokeHookBoltFail(Tuple tuple, Duration failLatency) {
if (taskHooks.size() != 0) {
BoltFailInfo failInfo = new BoltFailInfo(tuple, getThisTaskId(), failLatency);
for (ITaskHook taskHook : taskHooks) {
taskHook.boltFail(failInfo);
}
}
} | [
"public",
"void",
"invokeHookBoltFail",
"(",
"Tuple",
"tuple",
",",
"Duration",
"failLatency",
")",
"{",
"if",
"(",
"taskHooks",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"BoltFailInfo",
"failInfo",
"=",
"new",
"BoltFailInfo",
"(",
"tuple",
",",
"getThisTaskId",
"(",
")",
",",
"failLatency",
")",
";",
"for",
"(",
"ITaskHook",
"taskHook",
":",
"taskHooks",
")",
"{",
"taskHook",
".",
"boltFail",
"(",
"failInfo",
")",
";",
"}",
"}",
"}"
] | Task hook called in bolt every time a tuple gets failed | [
"Task",
"hook",
"called",
"in",
"bolt",
"every",
"time",
"a",
"tuple",
"gets",
"failed"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/topology/TopologyContextImpl.java#L181-L189 |
28,061 | apache/incubator-heron | heron/tools/apiserver/src/java/org/apache/heron/apiserver/utils/FileHelper.java | FileHelper.writeToFile | public static void writeToFile(InputStream uploadedInputStream,
String uploadedFileLocation) throws IOException {
File file = new File(uploadedFileLocation);
file.getParentFile().mkdirs();
int read = 0;
byte[] bytes = new byte[1024];
try (OutputStream out = new FileOutputStream(file)) {
while ((read = uploadedInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
}
} | java | public static void writeToFile(InputStream uploadedInputStream,
String uploadedFileLocation) throws IOException {
File file = new File(uploadedFileLocation);
file.getParentFile().mkdirs();
int read = 0;
byte[] bytes = new byte[1024];
try (OutputStream out = new FileOutputStream(file)) {
while ((read = uploadedInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
}
} | [
"public",
"static",
"void",
"writeToFile",
"(",
"InputStream",
"uploadedInputStream",
",",
"String",
"uploadedFileLocation",
")",
"throws",
"IOException",
"{",
"File",
"file",
"=",
"new",
"File",
"(",
"uploadedFileLocation",
")",
";",
"file",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"int",
"read",
"=",
"0",
";",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"try",
"(",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
")",
"{",
"while",
"(",
"(",
"read",
"=",
"uploadedInputStream",
".",
"read",
"(",
"bytes",
")",
")",
"!=",
"-",
"1",
")",
"{",
"out",
".",
"write",
"(",
"bytes",
",",
"0",
",",
"read",
")",
";",
"}",
"out",
".",
"flush",
"(",
")",
";",
"}",
"}"
] | save uploaded file to new location | [
"save",
"uploaded",
"file",
"to",
"new",
"location"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/utils/FileHelper.java#L121-L135 |
28,062 | apache/incubator-heron | heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/FileResource.java | FileResource.uploadFile | @POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
Config config = createConfig();
if (uploadedInputStream == null) {
String msg = "input stream is null";
LOG.error(msg);
return Response.status(Response.Status.BAD_REQUEST)
.type(MediaType.APPLICATION_JSON)
.entity(Utils.createMessage(msg)).build();
}
if (fileDetail == null) {
String msg = "form data content disposition is null";
LOG.error(msg);
return Response.status(Response.Status.BAD_REQUEST)
.type(MediaType.APPLICATION_JSON)
.entity(Utils.createMessage(msg)).build();
}
String uploadDir = config.getStringValue(FILE_SYSTEM_DIRECTORY);
final String fileName = UUID.randomUUID() + "-" + fileDetail.getFileName();
final String uploadedFileLocation
= uploadDir + "/" + fileName;
// save it
try {
FileHelper.writeToFile(uploadedInputStream, uploadedFileLocation);
} catch (IOException e) {
LOG.error("error uploading file {}", fileDetail.getFileName(), e);
return Response.serverError()
.type(MediaType.APPLICATION_JSON)
.entity(Utils.createMessage(e.getMessage()))
.build();
}
String uri = String.format("http://%s:%s/api/v1/file/download/%s",
getHostNameOrIP(), getPort(), fileName);
return Response.status(Response.Status.OK).entity(uri).build();
} | java | @POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
Config config = createConfig();
if (uploadedInputStream == null) {
String msg = "input stream is null";
LOG.error(msg);
return Response.status(Response.Status.BAD_REQUEST)
.type(MediaType.APPLICATION_JSON)
.entity(Utils.createMessage(msg)).build();
}
if (fileDetail == null) {
String msg = "form data content disposition is null";
LOG.error(msg);
return Response.status(Response.Status.BAD_REQUEST)
.type(MediaType.APPLICATION_JSON)
.entity(Utils.createMessage(msg)).build();
}
String uploadDir = config.getStringValue(FILE_SYSTEM_DIRECTORY);
final String fileName = UUID.randomUUID() + "-" + fileDetail.getFileName();
final String uploadedFileLocation
= uploadDir + "/" + fileName;
// save it
try {
FileHelper.writeToFile(uploadedInputStream, uploadedFileLocation);
} catch (IOException e) {
LOG.error("error uploading file {}", fileDetail.getFileName(), e);
return Response.serverError()
.type(MediaType.APPLICATION_JSON)
.entity(Utils.createMessage(e.getMessage()))
.build();
}
String uri = String.format("http://%s:%s/api/v1/file/download/%s",
getHostNameOrIP(), getPort(), fileName);
return Response.status(Response.Status.OK).entity(uri).build();
} | [
"@",
"POST",
"@",
"Path",
"(",
"\"/upload\"",
")",
"@",
"Consumes",
"(",
"MediaType",
".",
"MULTIPART_FORM_DATA",
")",
"public",
"Response",
"uploadFile",
"(",
"@",
"FormDataParam",
"(",
"\"file\"",
")",
"InputStream",
"uploadedInputStream",
",",
"@",
"FormDataParam",
"(",
"\"file\"",
")",
"FormDataContentDisposition",
"fileDetail",
")",
"{",
"Config",
"config",
"=",
"createConfig",
"(",
")",
";",
"if",
"(",
"uploadedInputStream",
"==",
"null",
")",
"{",
"String",
"msg",
"=",
"\"input stream is null\"",
";",
"LOG",
".",
"error",
"(",
"msg",
")",
";",
"return",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"BAD_REQUEST",
")",
".",
"type",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"entity",
"(",
"Utils",
".",
"createMessage",
"(",
"msg",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"if",
"(",
"fileDetail",
"==",
"null",
")",
"{",
"String",
"msg",
"=",
"\"form data content disposition is null\"",
";",
"LOG",
".",
"error",
"(",
"msg",
")",
";",
"return",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"BAD_REQUEST",
")",
".",
"type",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"entity",
"(",
"Utils",
".",
"createMessage",
"(",
"msg",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"String",
"uploadDir",
"=",
"config",
".",
"getStringValue",
"(",
"FILE_SYSTEM_DIRECTORY",
")",
";",
"final",
"String",
"fileName",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
"+",
"\"-\"",
"+",
"fileDetail",
".",
"getFileName",
"(",
")",
";",
"final",
"String",
"uploadedFileLocation",
"=",
"uploadDir",
"+",
"\"/\"",
"+",
"fileName",
";",
"// save it",
"try",
"{",
"FileHelper",
".",
"writeToFile",
"(",
"uploadedInputStream",
",",
"uploadedFileLocation",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"error uploading file {}\"",
",",
"fileDetail",
".",
"getFileName",
"(",
")",
",",
"e",
")",
";",
"return",
"Response",
".",
"serverError",
"(",
")",
".",
"type",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
".",
"entity",
"(",
"Utils",
".",
"createMessage",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
")",
".",
"build",
"(",
")",
";",
"}",
"String",
"uri",
"=",
"String",
".",
"format",
"(",
"\"http://%s:%s/api/v1/file/download/%s\"",
",",
"getHostNameOrIP",
"(",
")",
",",
"getPort",
"(",
")",
",",
"fileName",
")",
";",
"return",
"Response",
".",
"status",
"(",
"Response",
".",
"Status",
".",
"OK",
")",
".",
"entity",
"(",
"uri",
")",
".",
"build",
"(",
")",
";",
"}"
] | Endpoints for artifacts upload | [
"Endpoints",
"for",
"artifacts",
"upload"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/FileResource.java#L77-L123 |
28,063 | apache/incubator-heron | heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/FileResource.java | FileResource.downloadFile | @GET
@Path("/download/{file}")
public Response downloadFile(final @PathParam("file") String file) {
Config config = createConfig();
String uploadDir = config.getStringValue(FILE_SYSTEM_DIRECTORY);
String filePath = uploadDir + "/" + file;
return getResponseByFile(filePath);
} | java | @GET
@Path("/download/{file}")
public Response downloadFile(final @PathParam("file") String file) {
Config config = createConfig();
String uploadDir = config.getStringValue(FILE_SYSTEM_DIRECTORY);
String filePath = uploadDir + "/" + file;
return getResponseByFile(filePath);
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"/download/{file}\"",
")",
"public",
"Response",
"downloadFile",
"(",
"final",
"@",
"PathParam",
"(",
"\"file\"",
")",
"String",
"file",
")",
"{",
"Config",
"config",
"=",
"createConfig",
"(",
")",
";",
"String",
"uploadDir",
"=",
"config",
".",
"getStringValue",
"(",
"FILE_SYSTEM_DIRECTORY",
")",
";",
"String",
"filePath",
"=",
"uploadDir",
"+",
"\"/\"",
"+",
"file",
";",
"return",
"getResponseByFile",
"(",
"filePath",
")",
";",
"}"
] | Endpoints for artifacts download | [
"Endpoints",
"for",
"artifacts",
"download"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/tools/apiserver/src/java/org/apache/heron/apiserver/resources/FileResource.java#L128-L135 |
28,064 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/marathon/MarathonController.java | MarathonController.submitTopology | public boolean submitTopology(String appConf) {
if (this.isVerbose) {
LOG.log(Level.INFO, "Topology conf is: " + appConf);
}
// Marathon atleast till 1.4.x does not allow upper case jobids
if (!this.topologyName.equals(this.topologyName.toLowerCase())) {
LOG.log(Level.SEVERE, "Marathon scheduler does not allow upper case topologies");
return false;
}
// Setup Connection
String schedulerURI = String.format("%s/v2/groups", this.marathonURI);
HttpURLConnection conn = NetworkUtils.getHttpConnection(schedulerURI);
// Attach a token if there is one specified
if (this.marathonAuthToken != null) {
conn.setRequestProperty("Authorization", String.format("token=%s", this.marathonAuthToken));
}
if (conn == null) {
LOG.log(Level.SEVERE, "Failed to find marathon scheduler");
return false;
}
try {
// Send post request with marathon conf for topology
if (!NetworkUtils.sendHttpPostRequest(conn, NetworkUtils.JSON_TYPE, appConf.getBytes())) {
LOG.log(Level.SEVERE, "Failed to send post request");
return false;
}
// Check response
boolean success = NetworkUtils.checkHttpResponseCode(conn, HttpURLConnection.HTTP_CREATED);
if (success) {
LOG.log(Level.INFO, "Topology submitted successfully");
return true;
} else if (NetworkUtils.checkHttpResponseCode(conn, HttpURLConnection.HTTP_UNAUTHORIZED)) {
LOG.log(Level.SEVERE, "Marathon requires authentication");
return false;
} else {
LOG.log(Level.SEVERE, "Failed to submit topology");
return false;
}
} finally {
// Disconnect to release resources
conn.disconnect();
}
} | java | public boolean submitTopology(String appConf) {
if (this.isVerbose) {
LOG.log(Level.INFO, "Topology conf is: " + appConf);
}
// Marathon atleast till 1.4.x does not allow upper case jobids
if (!this.topologyName.equals(this.topologyName.toLowerCase())) {
LOG.log(Level.SEVERE, "Marathon scheduler does not allow upper case topologies");
return false;
}
// Setup Connection
String schedulerURI = String.format("%s/v2/groups", this.marathonURI);
HttpURLConnection conn = NetworkUtils.getHttpConnection(schedulerURI);
// Attach a token if there is one specified
if (this.marathonAuthToken != null) {
conn.setRequestProperty("Authorization", String.format("token=%s", this.marathonAuthToken));
}
if (conn == null) {
LOG.log(Level.SEVERE, "Failed to find marathon scheduler");
return false;
}
try {
// Send post request with marathon conf for topology
if (!NetworkUtils.sendHttpPostRequest(conn, NetworkUtils.JSON_TYPE, appConf.getBytes())) {
LOG.log(Level.SEVERE, "Failed to send post request");
return false;
}
// Check response
boolean success = NetworkUtils.checkHttpResponseCode(conn, HttpURLConnection.HTTP_CREATED);
if (success) {
LOG.log(Level.INFO, "Topology submitted successfully");
return true;
} else if (NetworkUtils.checkHttpResponseCode(conn, HttpURLConnection.HTTP_UNAUTHORIZED)) {
LOG.log(Level.SEVERE, "Marathon requires authentication");
return false;
} else {
LOG.log(Level.SEVERE, "Failed to submit topology");
return false;
}
} finally {
// Disconnect to release resources
conn.disconnect();
}
} | [
"public",
"boolean",
"submitTopology",
"(",
"String",
"appConf",
")",
"{",
"if",
"(",
"this",
".",
"isVerbose",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Topology conf is: \"",
"+",
"appConf",
")",
";",
"}",
"// Marathon atleast till 1.4.x does not allow upper case jobids",
"if",
"(",
"!",
"this",
".",
"topologyName",
".",
"equals",
"(",
"this",
".",
"topologyName",
".",
"toLowerCase",
"(",
")",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Marathon scheduler does not allow upper case topologies\"",
")",
";",
"return",
"false",
";",
"}",
"// Setup Connection",
"String",
"schedulerURI",
"=",
"String",
".",
"format",
"(",
"\"%s/v2/groups\"",
",",
"this",
".",
"marathonURI",
")",
";",
"HttpURLConnection",
"conn",
"=",
"NetworkUtils",
".",
"getHttpConnection",
"(",
"schedulerURI",
")",
";",
"// Attach a token if there is one specified",
"if",
"(",
"this",
".",
"marathonAuthToken",
"!=",
"null",
")",
"{",
"conn",
".",
"setRequestProperty",
"(",
"\"Authorization\"",
",",
"String",
".",
"format",
"(",
"\"token=%s\"",
",",
"this",
".",
"marathonAuthToken",
")",
")",
";",
"}",
"if",
"(",
"conn",
"==",
"null",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to find marathon scheduler\"",
")",
";",
"return",
"false",
";",
"}",
"try",
"{",
"// Send post request with marathon conf for topology",
"if",
"(",
"!",
"NetworkUtils",
".",
"sendHttpPostRequest",
"(",
"conn",
",",
"NetworkUtils",
".",
"JSON_TYPE",
",",
"appConf",
".",
"getBytes",
"(",
")",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to send post request\"",
")",
";",
"return",
"false",
";",
"}",
"// Check response",
"boolean",
"success",
"=",
"NetworkUtils",
".",
"checkHttpResponseCode",
"(",
"conn",
",",
"HttpURLConnection",
".",
"HTTP_CREATED",
")",
";",
"if",
"(",
"success",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"Topology submitted successfully\"",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"NetworkUtils",
".",
"checkHttpResponseCode",
"(",
"conn",
",",
"HttpURLConnection",
".",
"HTTP_UNAUTHORIZED",
")",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Marathon requires authentication\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to submit topology\"",
")",
";",
"return",
"false",
";",
"}",
"}",
"finally",
"{",
"// Disconnect to release resources",
"conn",
".",
"disconnect",
"(",
")",
";",
"}",
"}"
] | submit a topology as a group, containers as apps in the group | [
"submit",
"a",
"topology",
"as",
"a",
"group",
"containers",
"as",
"apps",
"in",
"the",
"group"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/marathon/MarathonController.java#L152-L201 |
28,065 | apache/incubator-heron | heron/metricsmgr/src/java/org/apache/heron/metricsmgr/sink/metricscache/MetricsCacheSink.java | MetricsCacheSink.startMetricsCacheChecker | private void startMetricsCacheChecker() {
final int checkIntervalSec =
TypeUtils.getInteger(sinkConfig.get(KEY_TMASTER_LOCATION_CHECK_INTERVAL_SEC));
Runnable runnable = new Runnable() {
@Override
public void run() {
TopologyMaster.MetricsCacheLocation location =
(TopologyMaster.MetricsCacheLocation) SingletonRegistry.INSTANCE.getSingleton(
MetricsManagerServer.METRICSCACHE_LOCATION_BEAN_NAME);
if (location != null) {
if (currentMetricsCacheLocation == null
|| !location.equals(currentMetricsCacheLocation)) {
LOG.info("Update current MetricsCacheLocation to: " + location);
currentMetricsCacheLocation = location;
metricsCacheClientService.updateMetricsCacheLocation(currentMetricsCacheLocation);
metricsCacheClientService.startNewMasterClient();
// Update Metrics
sinkContext.exportCountMetric(METRICSMGR_LOCATION_UPDATE_COUNT, 1);
}
}
// Schedule itself in future
tMasterLocationStarter.schedule(this, checkIntervalSec, TimeUnit.SECONDS);
}
};
// First Entry
tMasterLocationStarter.schedule(runnable, checkIntervalSec, TimeUnit.SECONDS);
LOG.info("MetricsCacheChecker started with interval: " + checkIntervalSec);
} | java | private void startMetricsCacheChecker() {
final int checkIntervalSec =
TypeUtils.getInteger(sinkConfig.get(KEY_TMASTER_LOCATION_CHECK_INTERVAL_SEC));
Runnable runnable = new Runnable() {
@Override
public void run() {
TopologyMaster.MetricsCacheLocation location =
(TopologyMaster.MetricsCacheLocation) SingletonRegistry.INSTANCE.getSingleton(
MetricsManagerServer.METRICSCACHE_LOCATION_BEAN_NAME);
if (location != null) {
if (currentMetricsCacheLocation == null
|| !location.equals(currentMetricsCacheLocation)) {
LOG.info("Update current MetricsCacheLocation to: " + location);
currentMetricsCacheLocation = location;
metricsCacheClientService.updateMetricsCacheLocation(currentMetricsCacheLocation);
metricsCacheClientService.startNewMasterClient();
// Update Metrics
sinkContext.exportCountMetric(METRICSMGR_LOCATION_UPDATE_COUNT, 1);
}
}
// Schedule itself in future
tMasterLocationStarter.schedule(this, checkIntervalSec, TimeUnit.SECONDS);
}
};
// First Entry
tMasterLocationStarter.schedule(runnable, checkIntervalSec, TimeUnit.SECONDS);
LOG.info("MetricsCacheChecker started with interval: " + checkIntervalSec);
} | [
"private",
"void",
"startMetricsCacheChecker",
"(",
")",
"{",
"final",
"int",
"checkIntervalSec",
"=",
"TypeUtils",
".",
"getInteger",
"(",
"sinkConfig",
".",
"get",
"(",
"KEY_TMASTER_LOCATION_CHECK_INTERVAL_SEC",
")",
")",
";",
"Runnable",
"runnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"TopologyMaster",
".",
"MetricsCacheLocation",
"location",
"=",
"(",
"TopologyMaster",
".",
"MetricsCacheLocation",
")",
"SingletonRegistry",
".",
"INSTANCE",
".",
"getSingleton",
"(",
"MetricsManagerServer",
".",
"METRICSCACHE_LOCATION_BEAN_NAME",
")",
";",
"if",
"(",
"location",
"!=",
"null",
")",
"{",
"if",
"(",
"currentMetricsCacheLocation",
"==",
"null",
"||",
"!",
"location",
".",
"equals",
"(",
"currentMetricsCacheLocation",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Update current MetricsCacheLocation to: \"",
"+",
"location",
")",
";",
"currentMetricsCacheLocation",
"=",
"location",
";",
"metricsCacheClientService",
".",
"updateMetricsCacheLocation",
"(",
"currentMetricsCacheLocation",
")",
";",
"metricsCacheClientService",
".",
"startNewMasterClient",
"(",
")",
";",
"// Update Metrics",
"sinkContext",
".",
"exportCountMetric",
"(",
"METRICSMGR_LOCATION_UPDATE_COUNT",
",",
"1",
")",
";",
"}",
"}",
"// Schedule itself in future",
"tMasterLocationStarter",
".",
"schedule",
"(",
"this",
",",
"checkIntervalSec",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"}",
";",
"// First Entry",
"tMasterLocationStarter",
".",
"schedule",
"(",
"runnable",
",",
"checkIntervalSec",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"LOG",
".",
"info",
"(",
"\"MetricsCacheChecker started with interval: \"",
"+",
"checkIntervalSec",
")",
";",
"}"
] | If so, restart the metricsCacheClientService with the new MetricsCacheLocation | [
"If",
"so",
"restart",
"the",
"metricsCacheClientService",
"with",
"the",
"new",
"MetricsCacheLocation"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/metricsmgr/src/java/org/apache/heron/metricsmgr/sink/metricscache/MetricsCacheSink.java#L157-L189 |
28,066 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/config/ConfigReader.java | ConfigReader.loadFile | @SuppressWarnings("unchecked") // when we cast yaml.load(fin)
public static Map<String, Object> loadFile(String fileName) {
Map<String, Object> props = new HashMap<>();
if (fileName == null) {
LOG.warning("Config file name cannot be null");
return props;
} else if (fileName.isEmpty()) {
LOG.warning("Config file name is empty");
return props;
} else {
// check if the file exists and also it is a regular file
Path path = Paths.get(fileName);
if (!Files.exists(path)) {
LOG.fine("Config file " + fileName + " does not exist");
return props;
}
if (!Files.isRegularFile(path)) {
LOG.warning("Config file " + fileName + " might be a directory.");
return props;
}
LOG.log(Level.FINE, "Reading config file {0}", fileName);
Map<String, Object> propsYaml = null;
try {
FileInputStream fin = new FileInputStream(new File(fileName));
try {
Yaml yaml = new Yaml();
propsYaml = (Map<String, Object>) yaml.load(fin);
LOG.log(Level.FINE, "Successfully read config file {0}", fileName);
} finally {
fin.close();
}
} catch (IOException e) {
LOG.log(Level.SEVERE, "Failed to load config file: " + fileName, e);
}
return propsYaml != null ? propsYaml : props;
}
} | java | @SuppressWarnings("unchecked") // when we cast yaml.load(fin)
public static Map<String, Object> loadFile(String fileName) {
Map<String, Object> props = new HashMap<>();
if (fileName == null) {
LOG.warning("Config file name cannot be null");
return props;
} else if (fileName.isEmpty()) {
LOG.warning("Config file name is empty");
return props;
} else {
// check if the file exists and also it is a regular file
Path path = Paths.get(fileName);
if (!Files.exists(path)) {
LOG.fine("Config file " + fileName + " does not exist");
return props;
}
if (!Files.isRegularFile(path)) {
LOG.warning("Config file " + fileName + " might be a directory.");
return props;
}
LOG.log(Level.FINE, "Reading config file {0}", fileName);
Map<String, Object> propsYaml = null;
try {
FileInputStream fin = new FileInputStream(new File(fileName));
try {
Yaml yaml = new Yaml();
propsYaml = (Map<String, Object>) yaml.load(fin);
LOG.log(Level.FINE, "Successfully read config file {0}", fileName);
} finally {
fin.close();
}
} catch (IOException e) {
LOG.log(Level.SEVERE, "Failed to load config file: " + fileName, e);
}
return propsYaml != null ? propsYaml : props;
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// when we cast yaml.load(fin)",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"loadFile",
"(",
"String",
"fileName",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"props",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"fileName",
"==",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Config file name cannot be null\"",
")",
";",
"return",
"props",
";",
"}",
"else",
"if",
"(",
"fileName",
".",
"isEmpty",
"(",
")",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Config file name is empty\"",
")",
";",
"return",
"props",
";",
"}",
"else",
"{",
"// check if the file exists and also it is a regular file",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"fileName",
")",
";",
"if",
"(",
"!",
"Files",
".",
"exists",
"(",
"path",
")",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Config file \"",
"+",
"fileName",
"+",
"\" does not exist\"",
")",
";",
"return",
"props",
";",
"}",
"if",
"(",
"!",
"Files",
".",
"isRegularFile",
"(",
"path",
")",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Config file \"",
"+",
"fileName",
"+",
"\" might be a directory.\"",
")",
";",
"return",
"props",
";",
"}",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Reading config file {0}\"",
",",
"fileName",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"propsYaml",
"=",
"null",
";",
"try",
"{",
"FileInputStream",
"fin",
"=",
"new",
"FileInputStream",
"(",
"new",
"File",
"(",
"fileName",
")",
")",
";",
"try",
"{",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"propsYaml",
"=",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"yaml",
".",
"load",
"(",
"fin",
")",
";",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Successfully read config file {0}\"",
",",
"fileName",
")",
";",
"}",
"finally",
"{",
"fin",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to load config file: \"",
"+",
"fileName",
",",
"e",
")",
";",
"}",
"return",
"propsYaml",
"!=",
"null",
"?",
"propsYaml",
":",
"props",
";",
"}",
"}"
] | Load properties from the given YAML file
@param fileName the name of YAML file to read
@return Map, contains the key value pairs of config | [
"Load",
"properties",
"from",
"the",
"given",
"YAML",
"file"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/config/ConfigReader.java#L52-L94 |
28,067 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/config/ConfigReader.java | ConfigReader.loadStream | @SuppressWarnings("unchecked") // yaml.load API returns raw Map
public static Map<String, Object> loadStream(InputStream inputStream) {
LOG.fine("Reading config stream");
Yaml yaml = new Yaml();
Map<Object, Object> propsYaml = (Map<Object, Object>) yaml.load(inputStream);
LOG.fine("Successfully read config");
Map<String, Object> typedMap = new HashMap<>();
for (Object key: propsYaml.keySet()) {
typedMap.put(key.toString(), propsYaml.get(key));
}
return typedMap;
} | java | @SuppressWarnings("unchecked") // yaml.load API returns raw Map
public static Map<String, Object> loadStream(InputStream inputStream) {
LOG.fine("Reading config stream");
Yaml yaml = new Yaml();
Map<Object, Object> propsYaml = (Map<Object, Object>) yaml.load(inputStream);
LOG.fine("Successfully read config");
Map<String, Object> typedMap = new HashMap<>();
for (Object key: propsYaml.keySet()) {
typedMap.put(key.toString(), propsYaml.get(key));
}
return typedMap;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"// yaml.load API returns raw Map",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"loadStream",
"(",
"InputStream",
"inputStream",
")",
"{",
"LOG",
".",
"fine",
"(",
"\"Reading config stream\"",
")",
";",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"Map",
"<",
"Object",
",",
"Object",
">",
"propsYaml",
"=",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
")",
"yaml",
".",
"load",
"(",
"inputStream",
")",
";",
"LOG",
".",
"fine",
"(",
"\"Successfully read config\"",
")",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"typedMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"key",
":",
"propsYaml",
".",
"keySet",
"(",
")",
")",
"{",
"typedMap",
".",
"put",
"(",
"key",
".",
"toString",
"(",
")",
",",
"propsYaml",
".",
"get",
"(",
"key",
")",
")",
";",
"}",
"return",
"typedMap",
";",
"}"
] | Load config from the given YAML stream
@param inputStream the name of YAML stream to read
@return Map, contains the key value pairs of config | [
"Load",
"config",
"from",
"the",
"given",
"YAML",
"stream"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/config/ConfigReader.java#L103-L117 |
28,068 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/basics/Communicator.java | Communicator.poll | public E poll() {
E result = buffer.poll();
if (producer != null) {
producer.wakeUp();
}
return result;
} | java | public E poll() {
E result = buffer.poll();
if (producer != null) {
producer.wakeUp();
}
return result;
} | [
"public",
"E",
"poll",
"(",
")",
"{",
"E",
"result",
"=",
"buffer",
".",
"poll",
"(",
")",
";",
"if",
"(",
"producer",
"!=",
"null",
")",
"{",
"producer",
".",
"wakeUp",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Check if there is any item in the queue
@return null if there is no item inside the queue | [
"Check",
"if",
"there",
"is",
"any",
"item",
"in",
"the",
"queue"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/basics/Communicator.java#L157-L164 |
28,069 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/basics/Communicator.java | Communicator.offer | public boolean offer(E e) {
buffer.offer(e);
if (consumer != null) {
consumer.wakeUp();
}
return true;
} | java | public boolean offer(E e) {
buffer.offer(e);
if (consumer != null) {
consumer.wakeUp();
}
return true;
} | [
"public",
"boolean",
"offer",
"(",
"E",
"e",
")",
"{",
"buffer",
".",
"offer",
"(",
"e",
")",
";",
"if",
"(",
"consumer",
"!=",
"null",
")",
"{",
"consumer",
".",
"wakeUp",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Since it is an unbounded queue, the offer will always return true.
@param e Item to be inserted
@return true : inserted successfully | [
"Since",
"it",
"is",
"an",
"unbounded",
"queue",
"the",
"offer",
"will",
"always",
"return",
"true",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/basics/Communicator.java#L172-L179 |
28,070 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/basics/Communicator.java | Communicator.drainTo | public int drainTo(Collection<? super E> c) {
int result = buffer.drainTo(c);
if (producer != null) {
producer.wakeUp();
}
return result;
} | java | public int drainTo(Collection<? super E> c) {
int result = buffer.drainTo(c);
if (producer != null) {
producer.wakeUp();
}
return result;
} | [
"public",
"int",
"drainTo",
"(",
"Collection",
"<",
"?",
"super",
"E",
">",
"c",
")",
"{",
"int",
"result",
"=",
"buffer",
".",
"drainTo",
"(",
"c",
")",
";",
"if",
"(",
"producer",
"!=",
"null",
")",
"{",
"producer",
".",
"wakeUp",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Removes all available elements from this queue and adds them to the given collection.
This operation may be more efficient than repeatedly polling this queue.
A failure encountered while attempting to add elements to collection c may result in elements being in neither,
either or both collections when the associated exception is thrown. Attempts to drain a queue to itself result in IllegalArgumentException.
Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.
@return the number of elements transferred | [
"Removes",
"all",
"available",
"elements",
"from",
"this",
"queue",
"and",
"adds",
"them",
"to",
"the",
"given",
"collection",
".",
"This",
"operation",
"may",
"be",
"more",
"efficient",
"than",
"repeatedly",
"polling",
"this",
"queue",
".",
"A",
"failure",
"encountered",
"while",
"attempting",
"to",
"add",
"elements",
"to",
"collection",
"c",
"may",
"result",
"in",
"elements",
"being",
"in",
"neither",
"either",
"or",
"both",
"collections",
"when",
"the",
"associated",
"exception",
"is",
"thrown",
".",
"Attempts",
"to",
"drain",
"a",
"queue",
"to",
"itself",
"result",
"in",
"IllegalArgumentException",
".",
"Further",
"the",
"behavior",
"of",
"this",
"operation",
"is",
"undefined",
"if",
"the",
"specified",
"collection",
"is",
"modified",
"while",
"the",
"operation",
"is",
"in",
"progress",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/basics/Communicator.java#L206-L213 |
28,071 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/nomad/NomadScheduler.java | NomadScheduler.getTaskSpecDockerDriver | Task getTaskSpecDockerDriver(Task task, String taskName, int containerIndex) {
String executorBinary = Context.executorBinary(this.clusterConfig);
// get arguments for heron executor command
String[] executorArgs = SchedulerUtils.executorCommandArgs(
this.clusterConfig, this.runtimeConfig, NomadConstants.EXECUTOR_PORTS,
String.valueOf(containerIndex));
// get complete heron executor command
String executorCmd = executorBinary + " " + String.join(" ", executorArgs);
// get heron_downloader command for downloading topology package
String topologyDownloadCmd = getFetchCommand(this.clusterConfig,
this.clusterConfig, this.runtimeConfig);
task.setName(taskName);
// use nomad driver
task.setDriver(NomadConstants.NomadDriver.DOCKER.getName());
// set docker image to use
task.addConfig(NomadConstants.NOMAD_IMAGE,
NomadContext.getHeronExecutorDockerImage(this.localConfig));
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND, NomadConstants.SHELL_CMD);
task.addConfig(NomadConstants.NETWORK_MODE,
NomadContext.getHeronNomadNetworkMode(this.localConfig));
String setMetricsPortFileCmd = getSetMetricsPortFileCmd();
String[] args = {"-c", String.format("%s && %s && %s",
topologyDownloadCmd, setMetricsPortFileCmd, executorCmd)};
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND_ARGS, args);
Map<String, String> envVars = new HashMap<>();
envVars.put(NomadConstants.HOST, "${attr.unique.network.ip-address}");
task.setEnv(envVars);
return task;
} | java | Task getTaskSpecDockerDriver(Task task, String taskName, int containerIndex) {
String executorBinary = Context.executorBinary(this.clusterConfig);
// get arguments for heron executor command
String[] executorArgs = SchedulerUtils.executorCommandArgs(
this.clusterConfig, this.runtimeConfig, NomadConstants.EXECUTOR_PORTS,
String.valueOf(containerIndex));
// get complete heron executor command
String executorCmd = executorBinary + " " + String.join(" ", executorArgs);
// get heron_downloader command for downloading topology package
String topologyDownloadCmd = getFetchCommand(this.clusterConfig,
this.clusterConfig, this.runtimeConfig);
task.setName(taskName);
// use nomad driver
task.setDriver(NomadConstants.NomadDriver.DOCKER.getName());
// set docker image to use
task.addConfig(NomadConstants.NOMAD_IMAGE,
NomadContext.getHeronExecutorDockerImage(this.localConfig));
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND, NomadConstants.SHELL_CMD);
task.addConfig(NomadConstants.NETWORK_MODE,
NomadContext.getHeronNomadNetworkMode(this.localConfig));
String setMetricsPortFileCmd = getSetMetricsPortFileCmd();
String[] args = {"-c", String.format("%s && %s && %s",
topologyDownloadCmd, setMetricsPortFileCmd, executorCmd)};
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND_ARGS, args);
Map<String, String> envVars = new HashMap<>();
envVars.put(NomadConstants.HOST, "${attr.unique.network.ip-address}");
task.setEnv(envVars);
return task;
} | [
"Task",
"getTaskSpecDockerDriver",
"(",
"Task",
"task",
",",
"String",
"taskName",
",",
"int",
"containerIndex",
")",
"{",
"String",
"executorBinary",
"=",
"Context",
".",
"executorBinary",
"(",
"this",
".",
"clusterConfig",
")",
";",
"// get arguments for heron executor command",
"String",
"[",
"]",
"executorArgs",
"=",
"SchedulerUtils",
".",
"executorCommandArgs",
"(",
"this",
".",
"clusterConfig",
",",
"this",
".",
"runtimeConfig",
",",
"NomadConstants",
".",
"EXECUTOR_PORTS",
",",
"String",
".",
"valueOf",
"(",
"containerIndex",
")",
")",
";",
"// get complete heron executor command",
"String",
"executorCmd",
"=",
"executorBinary",
"+",
"\" \"",
"+",
"String",
".",
"join",
"(",
"\" \"",
",",
"executorArgs",
")",
";",
"// get heron_downloader command for downloading topology package",
"String",
"topologyDownloadCmd",
"=",
"getFetchCommand",
"(",
"this",
".",
"clusterConfig",
",",
"this",
".",
"clusterConfig",
",",
"this",
".",
"runtimeConfig",
")",
";",
"task",
".",
"setName",
"(",
"taskName",
")",
";",
"// use nomad driver",
"task",
".",
"setDriver",
"(",
"NomadConstants",
".",
"NomadDriver",
".",
"DOCKER",
".",
"getName",
"(",
")",
")",
";",
"// set docker image to use",
"task",
".",
"addConfig",
"(",
"NomadConstants",
".",
"NOMAD_IMAGE",
",",
"NomadContext",
".",
"getHeronExecutorDockerImage",
"(",
"this",
".",
"localConfig",
")",
")",
";",
"task",
".",
"addConfig",
"(",
"NomadConstants",
".",
"NOMAD_TASK_COMMAND",
",",
"NomadConstants",
".",
"SHELL_CMD",
")",
";",
"task",
".",
"addConfig",
"(",
"NomadConstants",
".",
"NETWORK_MODE",
",",
"NomadContext",
".",
"getHeronNomadNetworkMode",
"(",
"this",
".",
"localConfig",
")",
")",
";",
"String",
"setMetricsPortFileCmd",
"=",
"getSetMetricsPortFileCmd",
"(",
")",
";",
"String",
"[",
"]",
"args",
"=",
"{",
"\"-c\"",
",",
"String",
".",
"format",
"(",
"\"%s && %s && %s\"",
",",
"topologyDownloadCmd",
",",
"setMetricsPortFileCmd",
",",
"executorCmd",
")",
"}",
";",
"task",
".",
"addConfig",
"(",
"NomadConstants",
".",
"NOMAD_TASK_COMMAND_ARGS",
",",
"args",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"envVars",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HOST",
",",
"\"${attr.unique.network.ip-address}\"",
")",
";",
"task",
".",
"setEnv",
"(",
"envVars",
")",
";",
"return",
"task",
";",
"}"
] | Get the task spec for using the docker driver in Nomad
In docker mode, Heron will be use in docker containers | [
"Get",
"the",
"task",
"spec",
"for",
"using",
"the",
"docker",
"driver",
"in",
"Nomad",
"In",
"docker",
"mode",
"Heron",
"will",
"be",
"use",
"in",
"docker",
"containers"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/nomad/NomadScheduler.java#L333-L371 |
28,072 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/nomad/NomadScheduler.java | NomadScheduler.getTaskSpecRawDriver | Task getTaskSpecRawDriver(Task task, String taskName, int containerIndex) {
String executorBinary = Context.executorBinary(this.clusterConfig);
// get arguments for heron executor command
String[] executorArgs = SchedulerUtils.executorCommandArgs(
this.clusterConfig, this.runtimeConfig, NomadConstants.EXECUTOR_PORTS,
String.valueOf(containerIndex));
// get complete heron executor command
String executorCmd = executorBinary + " " + String.join(" ", executorArgs);
// get heron_downloader command for downloading topology package
String topologyDownloadCmd = getFetchCommand(this.localConfig,
this.clusterConfig, this.runtimeConfig);
// read nomad heron executor start up script from file
String heronNomadScript = getHeronNomadScript(this.localConfig);
task.setName(taskName);
// use raw_exec driver
task.setDriver(NomadConstants.NomadDriver.RAW_EXEC.getName());
// call nomad heron start up script
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND, NomadConstants.SHELL_CMD);
String[] args = {NomadConstants.NOMAD_HERON_SCRIPT_NAME};
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND_ARGS, args);
Template template = new Template();
template.setEmbeddedTmpl(heronNomadScript);
template.setDestPath(NomadConstants.NOMAD_HERON_SCRIPT_NAME);
task.addTemplates(template);
// configure nomad to allocate dynamic ports
Port[] ports = new Port[NomadConstants.EXECUTOR_PORTS.size()];
int i = 0;
for (SchedulerUtils.ExecutorPort port : NomadConstants.EXECUTOR_PORTS.keySet()) {
ports[i] = new Port().setLabel(port.getName().replace("-", "_"));
i++;
}
// set enviroment variables used int the heron nomad start up script
Map<String, String> envVars = new HashMap<>();
envVars.put(NomadConstants.HERON_NOMAD_WORKING_DIR,
NomadContext.workingDirectory(this.localConfig) + "/container-"
+ String.valueOf(containerIndex));
if (NomadContext.useCorePackageUri(this.localConfig)) {
envVars.put(NomadConstants.HERON_USE_CORE_PACKAGE_URI, "true");
envVars.put(NomadConstants.HERON_CORE_PACKAGE_URI,
NomadContext.corePackageUri(this.localConfig));
} else {
envVars.put(NomadConstants.HERON_USE_CORE_PACKAGE_URI, "false");
envVars.put(NomadConstants.HERON_CORE_PACKAGE_DIR,
NomadContext.corePackageDirectory(this.localConfig));
}
envVars.put(NomadConstants.HERON_TOPOLOGY_DOWNLOAD_CMD, topologyDownloadCmd);
envVars.put(NomadConstants.HERON_EXECUTOR_CMD, executorCmd);
task.setEnv(envVars);
return task;
} | java | Task getTaskSpecRawDriver(Task task, String taskName, int containerIndex) {
String executorBinary = Context.executorBinary(this.clusterConfig);
// get arguments for heron executor command
String[] executorArgs = SchedulerUtils.executorCommandArgs(
this.clusterConfig, this.runtimeConfig, NomadConstants.EXECUTOR_PORTS,
String.valueOf(containerIndex));
// get complete heron executor command
String executorCmd = executorBinary + " " + String.join(" ", executorArgs);
// get heron_downloader command for downloading topology package
String topologyDownloadCmd = getFetchCommand(this.localConfig,
this.clusterConfig, this.runtimeConfig);
// read nomad heron executor start up script from file
String heronNomadScript = getHeronNomadScript(this.localConfig);
task.setName(taskName);
// use raw_exec driver
task.setDriver(NomadConstants.NomadDriver.RAW_EXEC.getName());
// call nomad heron start up script
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND, NomadConstants.SHELL_CMD);
String[] args = {NomadConstants.NOMAD_HERON_SCRIPT_NAME};
task.addConfig(NomadConstants.NOMAD_TASK_COMMAND_ARGS, args);
Template template = new Template();
template.setEmbeddedTmpl(heronNomadScript);
template.setDestPath(NomadConstants.NOMAD_HERON_SCRIPT_NAME);
task.addTemplates(template);
// configure nomad to allocate dynamic ports
Port[] ports = new Port[NomadConstants.EXECUTOR_PORTS.size()];
int i = 0;
for (SchedulerUtils.ExecutorPort port : NomadConstants.EXECUTOR_PORTS.keySet()) {
ports[i] = new Port().setLabel(port.getName().replace("-", "_"));
i++;
}
// set enviroment variables used int the heron nomad start up script
Map<String, String> envVars = new HashMap<>();
envVars.put(NomadConstants.HERON_NOMAD_WORKING_DIR,
NomadContext.workingDirectory(this.localConfig) + "/container-"
+ String.valueOf(containerIndex));
if (NomadContext.useCorePackageUri(this.localConfig)) {
envVars.put(NomadConstants.HERON_USE_CORE_PACKAGE_URI, "true");
envVars.put(NomadConstants.HERON_CORE_PACKAGE_URI,
NomadContext.corePackageUri(this.localConfig));
} else {
envVars.put(NomadConstants.HERON_USE_CORE_PACKAGE_URI, "false");
envVars.put(NomadConstants.HERON_CORE_PACKAGE_DIR,
NomadContext.corePackageDirectory(this.localConfig));
}
envVars.put(NomadConstants.HERON_TOPOLOGY_DOWNLOAD_CMD, topologyDownloadCmd);
envVars.put(NomadConstants.HERON_EXECUTOR_CMD, executorCmd);
task.setEnv(envVars);
return task;
} | [
"Task",
"getTaskSpecRawDriver",
"(",
"Task",
"task",
",",
"String",
"taskName",
",",
"int",
"containerIndex",
")",
"{",
"String",
"executorBinary",
"=",
"Context",
".",
"executorBinary",
"(",
"this",
".",
"clusterConfig",
")",
";",
"// get arguments for heron executor command",
"String",
"[",
"]",
"executorArgs",
"=",
"SchedulerUtils",
".",
"executorCommandArgs",
"(",
"this",
".",
"clusterConfig",
",",
"this",
".",
"runtimeConfig",
",",
"NomadConstants",
".",
"EXECUTOR_PORTS",
",",
"String",
".",
"valueOf",
"(",
"containerIndex",
")",
")",
";",
"// get complete heron executor command",
"String",
"executorCmd",
"=",
"executorBinary",
"+",
"\" \"",
"+",
"String",
".",
"join",
"(",
"\" \"",
",",
"executorArgs",
")",
";",
"// get heron_downloader command for downloading topology package",
"String",
"topologyDownloadCmd",
"=",
"getFetchCommand",
"(",
"this",
".",
"localConfig",
",",
"this",
".",
"clusterConfig",
",",
"this",
".",
"runtimeConfig",
")",
";",
"// read nomad heron executor start up script from file",
"String",
"heronNomadScript",
"=",
"getHeronNomadScript",
"(",
"this",
".",
"localConfig",
")",
";",
"task",
".",
"setName",
"(",
"taskName",
")",
";",
"// use raw_exec driver",
"task",
".",
"setDriver",
"(",
"NomadConstants",
".",
"NomadDriver",
".",
"RAW_EXEC",
".",
"getName",
"(",
")",
")",
";",
"// call nomad heron start up script",
"task",
".",
"addConfig",
"(",
"NomadConstants",
".",
"NOMAD_TASK_COMMAND",
",",
"NomadConstants",
".",
"SHELL_CMD",
")",
";",
"String",
"[",
"]",
"args",
"=",
"{",
"NomadConstants",
".",
"NOMAD_HERON_SCRIPT_NAME",
"}",
";",
"task",
".",
"addConfig",
"(",
"NomadConstants",
".",
"NOMAD_TASK_COMMAND_ARGS",
",",
"args",
")",
";",
"Template",
"template",
"=",
"new",
"Template",
"(",
")",
";",
"template",
".",
"setEmbeddedTmpl",
"(",
"heronNomadScript",
")",
";",
"template",
".",
"setDestPath",
"(",
"NomadConstants",
".",
"NOMAD_HERON_SCRIPT_NAME",
")",
";",
"task",
".",
"addTemplates",
"(",
"template",
")",
";",
"// configure nomad to allocate dynamic ports",
"Port",
"[",
"]",
"ports",
"=",
"new",
"Port",
"[",
"NomadConstants",
".",
"EXECUTOR_PORTS",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"SchedulerUtils",
".",
"ExecutorPort",
"port",
":",
"NomadConstants",
".",
"EXECUTOR_PORTS",
".",
"keySet",
"(",
")",
")",
"{",
"ports",
"[",
"i",
"]",
"=",
"new",
"Port",
"(",
")",
".",
"setLabel",
"(",
"port",
".",
"getName",
"(",
")",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
")",
";",
"i",
"++",
";",
"}",
"// set enviroment variables used int the heron nomad start up script",
"Map",
"<",
"String",
",",
"String",
">",
"envVars",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_NOMAD_WORKING_DIR",
",",
"NomadContext",
".",
"workingDirectory",
"(",
"this",
".",
"localConfig",
")",
"+",
"\"/container-\"",
"+",
"String",
".",
"valueOf",
"(",
"containerIndex",
")",
")",
";",
"if",
"(",
"NomadContext",
".",
"useCorePackageUri",
"(",
"this",
".",
"localConfig",
")",
")",
"{",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_USE_CORE_PACKAGE_URI",
",",
"\"true\"",
")",
";",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_CORE_PACKAGE_URI",
",",
"NomadContext",
".",
"corePackageUri",
"(",
"this",
".",
"localConfig",
")",
")",
";",
"}",
"else",
"{",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_USE_CORE_PACKAGE_URI",
",",
"\"false\"",
")",
";",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_CORE_PACKAGE_DIR",
",",
"NomadContext",
".",
"corePackageDirectory",
"(",
"this",
".",
"localConfig",
")",
")",
";",
"}",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_TOPOLOGY_DOWNLOAD_CMD",
",",
"topologyDownloadCmd",
")",
";",
"envVars",
".",
"put",
"(",
"NomadConstants",
".",
"HERON_EXECUTOR_CMD",
",",
"executorCmd",
")",
";",
"task",
".",
"setEnv",
"(",
"envVars",
")",
";",
"return",
"task",
";",
"}"
] | Get the task spec for using raw_exec driver in Nomad
In raw exec mode, Heron will be run directly on the machine | [
"Get",
"the",
"task",
"spec",
"for",
"using",
"raw_exec",
"driver",
"in",
"Nomad",
"In",
"raw",
"exec",
"mode",
"Heron",
"will",
"be",
"run",
"directly",
"on",
"the",
"machine"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/nomad/NomadScheduler.java#L377-L431 |
28,073 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/nomad/NomadScheduler.java | NomadScheduler.getFetchCommand | static String getFetchCommand(Config localConfig, Config clusterConfig, Config runtime) {
return String.format("%s -u %s -f . -m local -p %s -d %s",
Context.downloaderBinary(clusterConfig),
Runtime.topologyPackageUri(runtime).toString(), Context.heronConf(localConfig),
Context.heronHome(clusterConfig));
} | java | static String getFetchCommand(Config localConfig, Config clusterConfig, Config runtime) {
return String.format("%s -u %s -f . -m local -p %s -d %s",
Context.downloaderBinary(clusterConfig),
Runtime.topologyPackageUri(runtime).toString(), Context.heronConf(localConfig),
Context.heronHome(clusterConfig));
} | [
"static",
"String",
"getFetchCommand",
"(",
"Config",
"localConfig",
",",
"Config",
"clusterConfig",
",",
"Config",
"runtime",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s -u %s -f . -m local -p %s -d %s\"",
",",
"Context",
".",
"downloaderBinary",
"(",
"clusterConfig",
")",
",",
"Runtime",
".",
"topologyPackageUri",
"(",
"runtime",
")",
".",
"toString",
"(",
")",
",",
"Context",
".",
"heronConf",
"(",
"localConfig",
")",
",",
"Context",
".",
"heronHome",
"(",
"clusterConfig",
")",
")",
";",
"}"
] | Get the command that will be used to retrieve the topology JAR | [
"Get",
"the",
"command",
"that",
"will",
"be",
"used",
"to",
"retrieve",
"the",
"topology",
"JAR"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/nomad/NomadScheduler.java#L554-L559 |
28,074 | apache/incubator-heron | heron/uploaders/src/java/org/apache/heron/uploader/gcs/GcsUploader.java | GcsUploader.generateStorageObjectName | private static String generateStorageObjectName(String topologyName, String filename) {
return String.format("%s/%s", topologyName, filename);
} | java | private static String generateStorageObjectName(String topologyName, String filename) {
return String.format("%s/%s", topologyName, filename);
} | [
"private",
"static",
"String",
"generateStorageObjectName",
"(",
"String",
"topologyName",
",",
"String",
"filename",
")",
"{",
"return",
"String",
".",
"format",
"(",
"\"%s/%s\"",
",",
"topologyName",
",",
"filename",
")",
";",
"}"
] | Generate the storage object name in gcs given the topologyName and filename.
@param topologyName the name of the topology
@param filename the name of the file to upload to gcs
@return the name of the object. | [
"Generate",
"the",
"storage",
"object",
"name",
"in",
"gcs",
"given",
"the",
"topologyName",
"and",
"filename",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/uploaders/src/java/org/apache/heron/uploader/gcs/GcsUploader.java#L214-L216 |
28,075 | apache/incubator-heron | heron/uploaders/src/java/org/apache/heron/uploader/gcs/GcsUploader.java | GcsUploader.getDownloadUrl | private static String getDownloadUrl(String bucket, String objectName) {
return String.format(GCS_URL_FORMAT, bucket, objectName);
} | java | private static String getDownloadUrl(String bucket, String objectName) {
return String.format(GCS_URL_FORMAT, bucket, objectName);
} | [
"private",
"static",
"String",
"getDownloadUrl",
"(",
"String",
"bucket",
",",
"String",
"objectName",
")",
"{",
"return",
"String",
".",
"format",
"(",
"GCS_URL_FORMAT",
",",
"bucket",
",",
"objectName",
")",
";",
"}"
] | Returns a url to download an gcs object the given bucket and object name
@param bucket the name of the bucket
@param objectName the name of the object
@return a url to download the object | [
"Returns",
"a",
"url",
"to",
"download",
"an",
"gcs",
"object",
"the",
"given",
"bucket",
"and",
"object",
"name"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/uploaders/src/java/org/apache/heron/uploader/gcs/GcsUploader.java#L225-L227 |
28,076 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/slurm/SlurmLauncher.java | SlurmLauncher.setupWorkingDirectory | protected boolean setupWorkingDirectory() {
// get the path of core release URI
String coreReleasePackageURI = SlurmContext.corePackageUri(config);
// form the target dest core release file name
String coreReleaseFileDestination = Paths.get(
topologyWorkingDirectory, "heron-core.tar.gz").toString();
// Form the topology package's URI
String topologyPackageURI = Runtime.topologyPackageUri(runtime).toString();
// form the target topology package file name
String topologyPackageDestination = Paths.get(
topologyWorkingDirectory, "topology.tar.gz").toString();
if (!SchedulerUtils.createOrCleanDirectory(topologyWorkingDirectory)) {
return false;
}
final boolean isVerbose = Context.verbose(config);
if (!SchedulerUtils.extractPackage(topologyWorkingDirectory, coreReleasePackageURI,
coreReleaseFileDestination, true, isVerbose)) {
return false;
}
return SchedulerUtils.extractPackage(topologyWorkingDirectory, topologyPackageURI,
topologyPackageDestination, true, isVerbose);
} | java | protected boolean setupWorkingDirectory() {
// get the path of core release URI
String coreReleasePackageURI = SlurmContext.corePackageUri(config);
// form the target dest core release file name
String coreReleaseFileDestination = Paths.get(
topologyWorkingDirectory, "heron-core.tar.gz").toString();
// Form the topology package's URI
String topologyPackageURI = Runtime.topologyPackageUri(runtime).toString();
// form the target topology package file name
String topologyPackageDestination = Paths.get(
topologyWorkingDirectory, "topology.tar.gz").toString();
if (!SchedulerUtils.createOrCleanDirectory(topologyWorkingDirectory)) {
return false;
}
final boolean isVerbose = Context.verbose(config);
if (!SchedulerUtils.extractPackage(topologyWorkingDirectory, coreReleasePackageURI,
coreReleaseFileDestination, true, isVerbose)) {
return false;
}
return SchedulerUtils.extractPackage(topologyWorkingDirectory, topologyPackageURI,
topologyPackageDestination, true, isVerbose);
} | [
"protected",
"boolean",
"setupWorkingDirectory",
"(",
")",
"{",
"// get the path of core release URI",
"String",
"coreReleasePackageURI",
"=",
"SlurmContext",
".",
"corePackageUri",
"(",
"config",
")",
";",
"// form the target dest core release file name",
"String",
"coreReleaseFileDestination",
"=",
"Paths",
".",
"get",
"(",
"topologyWorkingDirectory",
",",
"\"heron-core.tar.gz\"",
")",
".",
"toString",
"(",
")",
";",
"// Form the topology package's URI",
"String",
"topologyPackageURI",
"=",
"Runtime",
".",
"topologyPackageUri",
"(",
"runtime",
")",
".",
"toString",
"(",
")",
";",
"// form the target topology package file name",
"String",
"topologyPackageDestination",
"=",
"Paths",
".",
"get",
"(",
"topologyWorkingDirectory",
",",
"\"topology.tar.gz\"",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"SchedulerUtils",
".",
"createOrCleanDirectory",
"(",
"topologyWorkingDirectory",
")",
")",
"{",
"return",
"false",
";",
"}",
"final",
"boolean",
"isVerbose",
"=",
"Context",
".",
"verbose",
"(",
"config",
")",
";",
"if",
"(",
"!",
"SchedulerUtils",
".",
"extractPackage",
"(",
"topologyWorkingDirectory",
",",
"coreReleasePackageURI",
",",
"coreReleaseFileDestination",
",",
"true",
",",
"isVerbose",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"SchedulerUtils",
".",
"extractPackage",
"(",
"topologyWorkingDirectory",
",",
"topologyPackageURI",
",",
"topologyPackageDestination",
",",
"true",
",",
"isVerbose",
")",
";",
"}"
] | setup the working directory mainly it downloads and extracts the heron-core-release
and topology package to the working directory
@return false if setup fails | [
"setup",
"the",
"working",
"directory",
"mainly",
"it",
"downloads",
"and",
"extracts",
"the",
"heron",
"-",
"core",
"-",
"release",
"and",
"topology",
"package",
"to",
"the",
"working",
"directory"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/slurm/SlurmLauncher.java#L85-L112 |
28,077 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java | JVMMetrics.registerMetrics | public void registerMetrics(MetricsCollector metricsCollector) {
SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(
SystemConfig.HERON_SYSTEM_CONFIG);
int interval = (int) systemConfig.getHeronMetricsExportInterval().getSeconds();
metricsCollector.registerMetric("__jvm-gc-collection-time-ms", jvmGCTimeMs, interval);
metricsCollector.registerMetric("__jvm-gc-collection-count", jvmGCCount, interval);
metricsCollector.registerMetric("__jvm-gc-time-ms", jvmGCTimeMsPerGCType, interval);
metricsCollector.registerMetric("__jvm-gc-count", jvmGCCountPerGCType, interval);
metricsCollector.registerMetric("__jvm-uptime-secs", jvmUpTimeSecs, interval);
metricsCollector.registerMetric("__jvm-thread-count", jvmThreadCount, interval);
metricsCollector.registerMetric("__jvm-daemon-thread-count", jvmDaemonThreadCount, interval);
metricsCollector.registerMetric("__jvm-process-cpu-time-nanos", processCPUTimeNs, interval);
metricsCollector.registerMetric("__jvm-threads-cpu-time-nanos", threadsCPUTimeNs, interval);
metricsCollector.registerMetric(
"__jvm-other-threads-cpu-time-nanos", otherThreadsCPUTimeNs, interval);
metricsCollector.registerMetric(
"__jvm-threads-user-cpu-time-nanos", threadsUserCPUTimeNs, interval);
metricsCollector.registerMetric(
"__jvm-other-threads-user-cpu-time-nanos", otherThreadsUserCPUTimeNs, interval);
metricsCollector.registerMetric("__jvm-process-cpu-load", processCPULoad, interval);
metricsCollector.registerMetric("__jvm-fd-count", fdCount, interval);
metricsCollector.registerMetric("__jvm-fd-limit", fdLimit, interval);
metricsCollector.registerMetric("__jvm-memory-free-mb", jvmMemoryFreeMB, interval);
metricsCollector.registerMetric("__jvm-memory-used-mb", jvmMemoryUsedMB, interval);
metricsCollector.registerMetric("__jvm-memory-mb-total", jvmMemoryTotalMB, interval);
metricsCollector.registerMetric("__jvm-memory-heap-mb-used", jvmMemoryHeapUsedMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-heap-mb-committed", jvmMemoryHeapCommittedMB, interval);
metricsCollector.registerMetric("__jvm-memory-heap-mb-max", jvmMemoryHeapMaxMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-non-heap-mb-used", jvmMemoryNonHeapUsedMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-non-heap-mb-committed", jvmMemoryNonHeapCommittedMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-non-heap-mb-max", jvmMemoryNonHeapMaxMB, interval);
metricsCollector.registerMetric(
"__jvm-peak-usage", jvmPeakUsagePerMemoryPool, interval);
metricsCollector.registerMetric(
"__jvm-collection-usage", jvmCollectionUsagePerMemoryPool, interval);
metricsCollector.registerMetric(
"__jvm-estimated-usage", jvmEstimatedUsagePerMemoryPool, interval);
metricsCollector.registerMetric("__jvm-buffer-pool", jvmBufferPoolMemoryUsage, interval);
} | java | public void registerMetrics(MetricsCollector metricsCollector) {
SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(
SystemConfig.HERON_SYSTEM_CONFIG);
int interval = (int) systemConfig.getHeronMetricsExportInterval().getSeconds();
metricsCollector.registerMetric("__jvm-gc-collection-time-ms", jvmGCTimeMs, interval);
metricsCollector.registerMetric("__jvm-gc-collection-count", jvmGCCount, interval);
metricsCollector.registerMetric("__jvm-gc-time-ms", jvmGCTimeMsPerGCType, interval);
metricsCollector.registerMetric("__jvm-gc-count", jvmGCCountPerGCType, interval);
metricsCollector.registerMetric("__jvm-uptime-secs", jvmUpTimeSecs, interval);
metricsCollector.registerMetric("__jvm-thread-count", jvmThreadCount, interval);
metricsCollector.registerMetric("__jvm-daemon-thread-count", jvmDaemonThreadCount, interval);
metricsCollector.registerMetric("__jvm-process-cpu-time-nanos", processCPUTimeNs, interval);
metricsCollector.registerMetric("__jvm-threads-cpu-time-nanos", threadsCPUTimeNs, interval);
metricsCollector.registerMetric(
"__jvm-other-threads-cpu-time-nanos", otherThreadsCPUTimeNs, interval);
metricsCollector.registerMetric(
"__jvm-threads-user-cpu-time-nanos", threadsUserCPUTimeNs, interval);
metricsCollector.registerMetric(
"__jvm-other-threads-user-cpu-time-nanos", otherThreadsUserCPUTimeNs, interval);
metricsCollector.registerMetric("__jvm-process-cpu-load", processCPULoad, interval);
metricsCollector.registerMetric("__jvm-fd-count", fdCount, interval);
metricsCollector.registerMetric("__jvm-fd-limit", fdLimit, interval);
metricsCollector.registerMetric("__jvm-memory-free-mb", jvmMemoryFreeMB, interval);
metricsCollector.registerMetric("__jvm-memory-used-mb", jvmMemoryUsedMB, interval);
metricsCollector.registerMetric("__jvm-memory-mb-total", jvmMemoryTotalMB, interval);
metricsCollector.registerMetric("__jvm-memory-heap-mb-used", jvmMemoryHeapUsedMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-heap-mb-committed", jvmMemoryHeapCommittedMB, interval);
metricsCollector.registerMetric("__jvm-memory-heap-mb-max", jvmMemoryHeapMaxMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-non-heap-mb-used", jvmMemoryNonHeapUsedMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-non-heap-mb-committed", jvmMemoryNonHeapCommittedMB, interval);
metricsCollector.registerMetric(
"__jvm-memory-non-heap-mb-max", jvmMemoryNonHeapMaxMB, interval);
metricsCollector.registerMetric(
"__jvm-peak-usage", jvmPeakUsagePerMemoryPool, interval);
metricsCollector.registerMetric(
"__jvm-collection-usage", jvmCollectionUsagePerMemoryPool, interval);
metricsCollector.registerMetric(
"__jvm-estimated-usage", jvmEstimatedUsagePerMemoryPool, interval);
metricsCollector.registerMetric("__jvm-buffer-pool", jvmBufferPoolMemoryUsage, interval);
} | [
"public",
"void",
"registerMetrics",
"(",
"MetricsCollector",
"metricsCollector",
")",
"{",
"SystemConfig",
"systemConfig",
"=",
"(",
"SystemConfig",
")",
"SingletonRegistry",
".",
"INSTANCE",
".",
"getSingleton",
"(",
"SystemConfig",
".",
"HERON_SYSTEM_CONFIG",
")",
";",
"int",
"interval",
"=",
"(",
"int",
")",
"systemConfig",
".",
"getHeronMetricsExportInterval",
"(",
")",
".",
"getSeconds",
"(",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-gc-collection-time-ms\"",
",",
"jvmGCTimeMs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-gc-collection-count\"",
",",
"jvmGCCount",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-gc-time-ms\"",
",",
"jvmGCTimeMsPerGCType",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-gc-count\"",
",",
"jvmGCCountPerGCType",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-uptime-secs\"",
",",
"jvmUpTimeSecs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-thread-count\"",
",",
"jvmThreadCount",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-daemon-thread-count\"",
",",
"jvmDaemonThreadCount",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-process-cpu-time-nanos\"",
",",
"processCPUTimeNs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-threads-cpu-time-nanos\"",
",",
"threadsCPUTimeNs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-other-threads-cpu-time-nanos\"",
",",
"otherThreadsCPUTimeNs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-threads-user-cpu-time-nanos\"",
",",
"threadsUserCPUTimeNs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-other-threads-user-cpu-time-nanos\"",
",",
"otherThreadsUserCPUTimeNs",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-process-cpu-load\"",
",",
"processCPULoad",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-fd-count\"",
",",
"fdCount",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-fd-limit\"",
",",
"fdLimit",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-free-mb\"",
",",
"jvmMemoryFreeMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-used-mb\"",
",",
"jvmMemoryUsedMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-mb-total\"",
",",
"jvmMemoryTotalMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-heap-mb-used\"",
",",
"jvmMemoryHeapUsedMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-heap-mb-committed\"",
",",
"jvmMemoryHeapCommittedMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-heap-mb-max\"",
",",
"jvmMemoryHeapMaxMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-non-heap-mb-used\"",
",",
"jvmMemoryNonHeapUsedMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-non-heap-mb-committed\"",
",",
"jvmMemoryNonHeapCommittedMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-memory-non-heap-mb-max\"",
",",
"jvmMemoryNonHeapMaxMB",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-peak-usage\"",
",",
"jvmPeakUsagePerMemoryPool",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-collection-usage\"",
",",
"jvmCollectionUsagePerMemoryPool",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-estimated-usage\"",
",",
"jvmEstimatedUsagePerMemoryPool",
",",
"interval",
")",
";",
"metricsCollector",
".",
"registerMetric",
"(",
"\"__jvm-buffer-pool\"",
",",
"jvmBufferPoolMemoryUsage",
",",
"interval",
")",
";",
"}"
] | Register metrics with the metrics collector | [
"Register",
"metrics",
"with",
"the",
"metrics",
"collector"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java#L213-L264 |
28,078 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java | JVMMetrics.updateBufferPoolMetrics | private void updateBufferPoolMetrics() {
for (BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeanList) {
String normalizedKeyName = bufferPoolMXBean.getName().replaceAll("[^\\w]", "-");
final ByteAmount memoryUsed = ByteAmount.fromBytes(bufferPoolMXBean.getMemoryUsed());
final ByteAmount totalCapacity = ByteAmount.fromBytes(bufferPoolMXBean.getTotalCapacity());
final ByteAmount count = ByteAmount.fromBytes(bufferPoolMXBean.getCount());
// The estimated memory the JVM is using for this buffer pool
jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-memory-used")
.setValue(memoryUsed.asMegabytes());
// The estimated total capacity of the buffers in this pool
jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-total-capacity")
.setValue(totalCapacity.asMegabytes());
// THe estimated number of buffers in this pool
jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-count")
.setValue(count.asMegabytes());
}
} | java | private void updateBufferPoolMetrics() {
for (BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeanList) {
String normalizedKeyName = bufferPoolMXBean.getName().replaceAll("[^\\w]", "-");
final ByteAmount memoryUsed = ByteAmount.fromBytes(bufferPoolMXBean.getMemoryUsed());
final ByteAmount totalCapacity = ByteAmount.fromBytes(bufferPoolMXBean.getTotalCapacity());
final ByteAmount count = ByteAmount.fromBytes(bufferPoolMXBean.getCount());
// The estimated memory the JVM is using for this buffer pool
jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-memory-used")
.setValue(memoryUsed.asMegabytes());
// The estimated total capacity of the buffers in this pool
jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-total-capacity")
.setValue(totalCapacity.asMegabytes());
// THe estimated number of buffers in this pool
jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-count")
.setValue(count.asMegabytes());
}
} | [
"private",
"void",
"updateBufferPoolMetrics",
"(",
")",
"{",
"for",
"(",
"BufferPoolMXBean",
"bufferPoolMXBean",
":",
"bufferPoolMXBeanList",
")",
"{",
"String",
"normalizedKeyName",
"=",
"bufferPoolMXBean",
".",
"getName",
"(",
")",
".",
"replaceAll",
"(",
"\"[^\\\\w]\"",
",",
"\"-\"",
")",
";",
"final",
"ByteAmount",
"memoryUsed",
"=",
"ByteAmount",
".",
"fromBytes",
"(",
"bufferPoolMXBean",
".",
"getMemoryUsed",
"(",
")",
")",
";",
"final",
"ByteAmount",
"totalCapacity",
"=",
"ByteAmount",
".",
"fromBytes",
"(",
"bufferPoolMXBean",
".",
"getTotalCapacity",
"(",
")",
")",
";",
"final",
"ByteAmount",
"count",
"=",
"ByteAmount",
".",
"fromBytes",
"(",
"bufferPoolMXBean",
".",
"getCount",
"(",
")",
")",
";",
"// The estimated memory the JVM is using for this buffer pool",
"jvmBufferPoolMemoryUsage",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-memory-used\"",
")",
".",
"setValue",
"(",
"memoryUsed",
".",
"asMegabytes",
"(",
")",
")",
";",
"// The estimated total capacity of the buffers in this pool",
"jvmBufferPoolMemoryUsage",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-total-capacity\"",
")",
".",
"setValue",
"(",
"totalCapacity",
".",
"asMegabytes",
"(",
")",
")",
";",
"// THe estimated number of buffers in this pool",
"jvmBufferPoolMemoryUsage",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-count\"",
")",
".",
"setValue",
"(",
"count",
".",
"asMegabytes",
"(",
")",
")",
";",
"}",
"}"
] | These metrics can be useful for diagnosing native memory usage. | [
"These",
"metrics",
"can",
"be",
"useful",
"for",
"diagnosing",
"native",
"memory",
"usage",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java#L310-L330 |
28,079 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java | JVMMetrics.updateMemoryPoolMetrics | private void updateMemoryPoolMetrics() {
for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeanList) {
String normalizedKeyName = memoryPoolMXBean.getName().replaceAll("[^\\w]", "-");
MemoryUsage peakUsage = memoryPoolMXBean.getPeakUsage();
if (peakUsage != null) {
jvmPeakUsagePerMemoryPool.safeScope(normalizedKeyName + "-used")
.setValue(ByteAmount.fromBytes(peakUsage.getUsed()).asMegabytes());
jvmPeakUsagePerMemoryPool.safeScope(normalizedKeyName + "-committed")
.setValue(ByteAmount.fromBytes(peakUsage.getCommitted()).asMegabytes());
jvmPeakUsagePerMemoryPool.safeScope(normalizedKeyName + "-max")
.setValue(ByteAmount.fromBytes(peakUsage.getMax()).asMegabytes());
}
MemoryUsage collectionUsage = memoryPoolMXBean.getCollectionUsage();
if (collectionUsage != null) {
jvmCollectionUsagePerMemoryPool.safeScope(normalizedKeyName + "-used")
.setValue(ByteAmount.fromBytes(collectionUsage.getUsed()).asMegabytes());
jvmCollectionUsagePerMemoryPool.safeScope(normalizedKeyName + "-committed")
.setValue(ByteAmount.fromBytes(collectionUsage.getCommitted()).asMegabytes());
jvmCollectionUsagePerMemoryPool.safeScope(normalizedKeyName + "-max")
.setValue(ByteAmount.fromBytes(collectionUsage.getMax()).asMegabytes());
}
MemoryUsage estimatedUsage = memoryPoolMXBean.getUsage();
if (estimatedUsage != null) {
jvmEstimatedUsagePerMemoryPool.safeScope(normalizedKeyName + "-used")
.setValue(ByteAmount.fromBytes(estimatedUsage.getUsed()).asMegabytes());
jvmEstimatedUsagePerMemoryPool.safeScope(normalizedKeyName + "-committed")
.setValue(ByteAmount.fromBytes(estimatedUsage.getCommitted()).asMegabytes());
jvmEstimatedUsagePerMemoryPool.safeScope(normalizedKeyName + "-max")
.setValue(ByteAmount.fromBytes(estimatedUsage.getMax()).asMegabytes());
}
}
} | java | private void updateMemoryPoolMetrics() {
for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeanList) {
String normalizedKeyName = memoryPoolMXBean.getName().replaceAll("[^\\w]", "-");
MemoryUsage peakUsage = memoryPoolMXBean.getPeakUsage();
if (peakUsage != null) {
jvmPeakUsagePerMemoryPool.safeScope(normalizedKeyName + "-used")
.setValue(ByteAmount.fromBytes(peakUsage.getUsed()).asMegabytes());
jvmPeakUsagePerMemoryPool.safeScope(normalizedKeyName + "-committed")
.setValue(ByteAmount.fromBytes(peakUsage.getCommitted()).asMegabytes());
jvmPeakUsagePerMemoryPool.safeScope(normalizedKeyName + "-max")
.setValue(ByteAmount.fromBytes(peakUsage.getMax()).asMegabytes());
}
MemoryUsage collectionUsage = memoryPoolMXBean.getCollectionUsage();
if (collectionUsage != null) {
jvmCollectionUsagePerMemoryPool.safeScope(normalizedKeyName + "-used")
.setValue(ByteAmount.fromBytes(collectionUsage.getUsed()).asMegabytes());
jvmCollectionUsagePerMemoryPool.safeScope(normalizedKeyName + "-committed")
.setValue(ByteAmount.fromBytes(collectionUsage.getCommitted()).asMegabytes());
jvmCollectionUsagePerMemoryPool.safeScope(normalizedKeyName + "-max")
.setValue(ByteAmount.fromBytes(collectionUsage.getMax()).asMegabytes());
}
MemoryUsage estimatedUsage = memoryPoolMXBean.getUsage();
if (estimatedUsage != null) {
jvmEstimatedUsagePerMemoryPool.safeScope(normalizedKeyName + "-used")
.setValue(ByteAmount.fromBytes(estimatedUsage.getUsed()).asMegabytes());
jvmEstimatedUsagePerMemoryPool.safeScope(normalizedKeyName + "-committed")
.setValue(ByteAmount.fromBytes(estimatedUsage.getCommitted()).asMegabytes());
jvmEstimatedUsagePerMemoryPool.safeScope(normalizedKeyName + "-max")
.setValue(ByteAmount.fromBytes(estimatedUsage.getMax()).asMegabytes());
}
}
} | [
"private",
"void",
"updateMemoryPoolMetrics",
"(",
")",
"{",
"for",
"(",
"MemoryPoolMXBean",
"memoryPoolMXBean",
":",
"memoryPoolMXBeanList",
")",
"{",
"String",
"normalizedKeyName",
"=",
"memoryPoolMXBean",
".",
"getName",
"(",
")",
".",
"replaceAll",
"(",
"\"[^\\\\w]\"",
",",
"\"-\"",
")",
";",
"MemoryUsage",
"peakUsage",
"=",
"memoryPoolMXBean",
".",
"getPeakUsage",
"(",
")",
";",
"if",
"(",
"peakUsage",
"!=",
"null",
")",
"{",
"jvmPeakUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-used\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"peakUsage",
".",
"getUsed",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"jvmPeakUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-committed\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"peakUsage",
".",
"getCommitted",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"jvmPeakUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-max\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"peakUsage",
".",
"getMax",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"}",
"MemoryUsage",
"collectionUsage",
"=",
"memoryPoolMXBean",
".",
"getCollectionUsage",
"(",
")",
";",
"if",
"(",
"collectionUsage",
"!=",
"null",
")",
"{",
"jvmCollectionUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-used\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"collectionUsage",
".",
"getUsed",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"jvmCollectionUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-committed\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"collectionUsage",
".",
"getCommitted",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"jvmCollectionUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-max\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"collectionUsage",
".",
"getMax",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"}",
"MemoryUsage",
"estimatedUsage",
"=",
"memoryPoolMXBean",
".",
"getUsage",
"(",
")",
";",
"if",
"(",
"estimatedUsage",
"!=",
"null",
")",
"{",
"jvmEstimatedUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-used\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"estimatedUsage",
".",
"getUsed",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"jvmEstimatedUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-committed\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"estimatedUsage",
".",
"getCommitted",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"jvmEstimatedUsagePerMemoryPool",
".",
"safeScope",
"(",
"normalizedKeyName",
"+",
"\"-max\"",
")",
".",
"setValue",
"(",
"ByteAmount",
".",
"fromBytes",
"(",
"estimatedUsage",
".",
"getMax",
"(",
")",
")",
".",
"asMegabytes",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Par Eden Space, Par Survivor Space, CMS Old Gen, CMS Perm Gen | [
"Par",
"Eden",
"Space",
"Par",
"Survivor",
"Space",
"CMS",
"Old",
"Gen",
"CMS",
"Perm",
"Gen"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java#L334-L367 |
28,080 | apache/incubator-heron | heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java | JVMMetrics.updateFdMetrics | private void updateFdMetrics() {
if (osMbean instanceof com.sun.management.UnixOperatingSystemMXBean) {
final com.sun.management.UnixOperatingSystemMXBean unix =
(com.sun.management.UnixOperatingSystemMXBean) osMbean;
fdCount.setValue(unix.getOpenFileDescriptorCount());
fdLimit.setValue(unix.getMaxFileDescriptorCount());
}
} | java | private void updateFdMetrics() {
if (osMbean instanceof com.sun.management.UnixOperatingSystemMXBean) {
final com.sun.management.UnixOperatingSystemMXBean unix =
(com.sun.management.UnixOperatingSystemMXBean) osMbean;
fdCount.setValue(unix.getOpenFileDescriptorCount());
fdLimit.setValue(unix.getMaxFileDescriptorCount());
}
} | [
"private",
"void",
"updateFdMetrics",
"(",
")",
"{",
"if",
"(",
"osMbean",
"instanceof",
"com",
".",
"sun",
".",
"management",
".",
"UnixOperatingSystemMXBean",
")",
"{",
"final",
"com",
".",
"sun",
".",
"management",
".",
"UnixOperatingSystemMXBean",
"unix",
"=",
"(",
"com",
".",
"sun",
".",
"management",
".",
"UnixOperatingSystemMXBean",
")",
"osMbean",
";",
"fdCount",
".",
"setValue",
"(",
"unix",
".",
"getOpenFileDescriptorCount",
"(",
")",
")",
";",
"fdLimit",
".",
"setValue",
"(",
"unix",
".",
"getMaxFileDescriptorCount",
"(",
")",
")",
";",
"}",
"}"
] | Update file descriptor metrics | [
"Update",
"file",
"descriptor",
"metrics"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/common/src/java/org/apache/heron/common/utils/metrics/JVMMetrics.java#L454-L462 |
28,081 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraCLIController.java | AuroraCLIController.killJob | @Override
public boolean killJob() {
List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "killall"));
auroraCmd.add(jobSpec);
appendAuroraCommandOptions(auroraCmd, isVerbose);
return runProcess(auroraCmd);
} | java | @Override
public boolean killJob() {
List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "killall"));
auroraCmd.add(jobSpec);
appendAuroraCommandOptions(auroraCmd, isVerbose);
return runProcess(auroraCmd);
} | [
"@",
"Override",
"public",
"boolean",
"killJob",
"(",
")",
"{",
"List",
"<",
"String",
">",
"auroraCmd",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"\"aurora\"",
",",
"\"job\"",
",",
"\"killall\"",
")",
")",
";",
"auroraCmd",
".",
"add",
"(",
"jobSpec",
")",
";",
"appendAuroraCommandOptions",
"(",
"auroraCmd",
",",
"isVerbose",
")",
";",
"return",
"runProcess",
"(",
"auroraCmd",
")",
";",
"}"
] | Kill an aurora job | [
"Kill",
"an",
"aurora",
"job"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraCLIController.java#L91-L99 |
28,082 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraCLIController.java | AuroraCLIController.restart | @Override
public boolean restart(Integer containerId) {
List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "restart"));
if (containerId != null) {
auroraCmd.add(String.format("%s/%d", jobSpec, containerId));
} else {
auroraCmd.add(jobSpec);
}
appendAuroraCommandOptions(auroraCmd, isVerbose);
return runProcess(auroraCmd);
} | java | @Override
public boolean restart(Integer containerId) {
List<String> auroraCmd = new ArrayList<>(Arrays.asList("aurora", "job", "restart"));
if (containerId != null) {
auroraCmd.add(String.format("%s/%d", jobSpec, containerId));
} else {
auroraCmd.add(jobSpec);
}
appendAuroraCommandOptions(auroraCmd, isVerbose);
return runProcess(auroraCmd);
} | [
"@",
"Override",
"public",
"boolean",
"restart",
"(",
"Integer",
"containerId",
")",
"{",
"List",
"<",
"String",
">",
"auroraCmd",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"\"aurora\"",
",",
"\"job\"",
",",
"\"restart\"",
")",
")",
";",
"if",
"(",
"containerId",
"!=",
"null",
")",
"{",
"auroraCmd",
".",
"add",
"(",
"String",
".",
"format",
"(",
"\"%s/%d\"",
",",
"jobSpec",
",",
"containerId",
")",
")",
";",
"}",
"else",
"{",
"auroraCmd",
".",
"add",
"(",
"jobSpec",
")",
";",
"}",
"appendAuroraCommandOptions",
"(",
"auroraCmd",
",",
"isVerbose",
")",
";",
"return",
"runProcess",
"(",
"auroraCmd",
")",
";",
"}"
] | Restart an aurora job | [
"Restart",
"an",
"aurora",
"job"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraCLIController.java#L102-L114 |
28,083 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraCLIController.java | AuroraCLIController.appendAuroraCommandOptions | private static void appendAuroraCommandOptions(List<String> auroraCmd, boolean isVerbose) {
// Append verbose if needed
if (isVerbose) {
auroraCmd.add("--verbose");
}
// Append batch size.
// Note that we can not use "--no-batching" since "restart" command does not accept it.
// So we play a small trick here by setting batch size Integer.MAX_VALUE.
auroraCmd.add("--batch-size");
auroraCmd.add(Integer.toString(Integer.MAX_VALUE));
} | java | private static void appendAuroraCommandOptions(List<String> auroraCmd, boolean isVerbose) {
// Append verbose if needed
if (isVerbose) {
auroraCmd.add("--verbose");
}
// Append batch size.
// Note that we can not use "--no-batching" since "restart" command does not accept it.
// So we play a small trick here by setting batch size Integer.MAX_VALUE.
auroraCmd.add("--batch-size");
auroraCmd.add(Integer.toString(Integer.MAX_VALUE));
} | [
"private",
"static",
"void",
"appendAuroraCommandOptions",
"(",
"List",
"<",
"String",
">",
"auroraCmd",
",",
"boolean",
"isVerbose",
")",
"{",
"// Append verbose if needed",
"if",
"(",
"isVerbose",
")",
"{",
"auroraCmd",
".",
"add",
"(",
"\"--verbose\"",
")",
";",
"}",
"// Append batch size.",
"// Note that we can not use \"--no-batching\" since \"restart\" command does not accept it.",
"// So we play a small trick here by setting batch size Integer.MAX_VALUE.",
"auroraCmd",
".",
"add",
"(",
"\"--batch-size\"",
")",
";",
"auroraCmd",
".",
"add",
"(",
"Integer",
".",
"toString",
"(",
"Integer",
".",
"MAX_VALUE",
")",
")",
";",
"}"
] | Static method to append verbose and batching options if needed | [
"Static",
"method",
"to",
"append",
"verbose",
"and",
"batching",
"options",
"if",
"needed"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/aurora/AuroraCLIController.java#L202-L213 |
28,084 | apache/incubator-heron | heron/healthmgr/src/java/org/apache/heron/healthmgr/common/PhysicalPlanProvider.java | PhysicalPlanProvider.getBoltNames | public List<String> getBoltNames(PhysicalPlan pp) {
TopologyAPI.Topology localTopology = pp.getTopology();
ArrayList<String> boltNames = new ArrayList<>();
for (TopologyAPI.Bolt bolt : localTopology.getBoltsList()) {
boltNames.add(bolt.getComp().getName());
}
return boltNames;
} | java | public List<String> getBoltNames(PhysicalPlan pp) {
TopologyAPI.Topology localTopology = pp.getTopology();
ArrayList<String> boltNames = new ArrayList<>();
for (TopologyAPI.Bolt bolt : localTopology.getBoltsList()) {
boltNames.add(bolt.getComp().getName());
}
return boltNames;
} | [
"public",
"List",
"<",
"String",
">",
"getBoltNames",
"(",
"PhysicalPlan",
"pp",
")",
"{",
"TopologyAPI",
".",
"Topology",
"localTopology",
"=",
"pp",
".",
"getTopology",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"boltNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"TopologyAPI",
".",
"Bolt",
"bolt",
":",
"localTopology",
".",
"getBoltsList",
"(",
")",
")",
"{",
"boltNames",
".",
"add",
"(",
"bolt",
".",
"getComp",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"boltNames",
";",
"}"
] | A utility method to extract bolt component names from the topology.
@return list of all bolt names | [
"A",
"utility",
"method",
"to",
"extract",
"bolt",
"component",
"names",
"from",
"the",
"topology",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/healthmgr/src/java/org/apache/heron/healthmgr/common/PhysicalPlanProvider.java#L120-L128 |
28,085 | apache/incubator-heron | heron/healthmgr/src/java/org/apache/heron/healthmgr/common/PhysicalPlanProvider.java | PhysicalPlanProvider.getSpoutNames | public List<String> getSpoutNames(PhysicalPlan pp) {
TopologyAPI.Topology localTopology = pp.getTopology();
ArrayList<String> spoutNames = new ArrayList<>();
for (TopologyAPI.Spout spout : localTopology.getSpoutsList()) {
spoutNames.add(spout.getComp().getName());
}
return spoutNames;
} | java | public List<String> getSpoutNames(PhysicalPlan pp) {
TopologyAPI.Topology localTopology = pp.getTopology();
ArrayList<String> spoutNames = new ArrayList<>();
for (TopologyAPI.Spout spout : localTopology.getSpoutsList()) {
spoutNames.add(spout.getComp().getName());
}
return spoutNames;
} | [
"public",
"List",
"<",
"String",
">",
"getSpoutNames",
"(",
"PhysicalPlan",
"pp",
")",
"{",
"TopologyAPI",
".",
"Topology",
"localTopology",
"=",
"pp",
".",
"getTopology",
"(",
")",
";",
"ArrayList",
"<",
"String",
">",
"spoutNames",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"TopologyAPI",
".",
"Spout",
"spout",
":",
"localTopology",
".",
"getSpoutsList",
"(",
")",
")",
"{",
"spoutNames",
".",
"add",
"(",
"spout",
".",
"getComp",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"spoutNames",
";",
"}"
] | A utility method to extract spout component names from the topology.
@return list of all spout names | [
"A",
"utility",
"method",
"to",
"extract",
"spout",
"component",
"names",
"from",
"the",
"topology",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/healthmgr/src/java/org/apache/heron/healthmgr/common/PhysicalPlanProvider.java#L140-L148 |
28,086 | apache/incubator-heron | eco/src/java/org/apache/heron/eco/builder/ConfigBuilder.java | ConfigBuilder.buildConfig | public Config buildConfig(EcoTopologyDefinition topologyDefinition)
throws IllegalArgumentException {
Map<String, Object> configMap = topologyDefinition.getConfig();
Config config = new Config();
for (Map.Entry<String, Object> entry: configMap.entrySet()) {
if (entry.getKey().equals(COMPONENT_RESOURCE_MAP)) {
setComponentLevelResource(config, entry);
} else if (entry.getKey().equals(COMPONENT_JVM_OPTIONS)) {
List<Object> objects = (List<Object>) entry.getValue();
for (Object obj : objects) {
String objString = obj.toString();
objString = objString.replace(LEFT_BRACE, WHITESPACE);
objString = objString.replace(RIGHT_BRACE, WHITESPACE);
int idIndex = objString.indexOf(ID);
int optionsIndex = objString.indexOf(OPTIONS);
String id = getIdValue(objString, idIndex);
String jvmOptions;
if (optionsIndex != -1) {
int equalsIndex = objString.indexOf(EQUALS, optionsIndex);
jvmOptions = objString.substring(equalsIndex + 1, objString.length());
jvmOptions = jvmOptions.replace(LEFT_BRACKET, "")
.replace(RIGHT_BRACKET, "");
} else {
throw new IllegalArgumentException(
"You must specify the JVM options for your component");
}
config.setComponentJvmOptions(id, jvmOptions);
}
} else {
config.put(entry.getKey(), entry.getValue());
}
}
return config;
} | java | public Config buildConfig(EcoTopologyDefinition topologyDefinition)
throws IllegalArgumentException {
Map<String, Object> configMap = topologyDefinition.getConfig();
Config config = new Config();
for (Map.Entry<String, Object> entry: configMap.entrySet()) {
if (entry.getKey().equals(COMPONENT_RESOURCE_MAP)) {
setComponentLevelResource(config, entry);
} else if (entry.getKey().equals(COMPONENT_JVM_OPTIONS)) {
List<Object> objects = (List<Object>) entry.getValue();
for (Object obj : objects) {
String objString = obj.toString();
objString = objString.replace(LEFT_BRACE, WHITESPACE);
objString = objString.replace(RIGHT_BRACE, WHITESPACE);
int idIndex = objString.indexOf(ID);
int optionsIndex = objString.indexOf(OPTIONS);
String id = getIdValue(objString, idIndex);
String jvmOptions;
if (optionsIndex != -1) {
int equalsIndex = objString.indexOf(EQUALS, optionsIndex);
jvmOptions = objString.substring(equalsIndex + 1, objString.length());
jvmOptions = jvmOptions.replace(LEFT_BRACKET, "")
.replace(RIGHT_BRACKET, "");
} else {
throw new IllegalArgumentException(
"You must specify the JVM options for your component");
}
config.setComponentJvmOptions(id, jvmOptions);
}
} else {
config.put(entry.getKey(), entry.getValue());
}
}
return config;
} | [
"public",
"Config",
"buildConfig",
"(",
"EcoTopologyDefinition",
"topologyDefinition",
")",
"throws",
"IllegalArgumentException",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"configMap",
"=",
"topologyDefinition",
".",
"getConfig",
"(",
")",
";",
"Config",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"configMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"COMPONENT_RESOURCE_MAP",
")",
")",
"{",
"setComponentLevelResource",
"(",
"config",
",",
"entry",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"equals",
"(",
"COMPONENT_JVM_OPTIONS",
")",
")",
"{",
"List",
"<",
"Object",
">",
"objects",
"=",
"(",
"List",
"<",
"Object",
">",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"for",
"(",
"Object",
"obj",
":",
"objects",
")",
"{",
"String",
"objString",
"=",
"obj",
".",
"toString",
"(",
")",
";",
"objString",
"=",
"objString",
".",
"replace",
"(",
"LEFT_BRACE",
",",
"WHITESPACE",
")",
";",
"objString",
"=",
"objString",
".",
"replace",
"(",
"RIGHT_BRACE",
",",
"WHITESPACE",
")",
";",
"int",
"idIndex",
"=",
"objString",
".",
"indexOf",
"(",
"ID",
")",
";",
"int",
"optionsIndex",
"=",
"objString",
".",
"indexOf",
"(",
"OPTIONS",
")",
";",
"String",
"id",
"=",
"getIdValue",
"(",
"objString",
",",
"idIndex",
")",
";",
"String",
"jvmOptions",
";",
"if",
"(",
"optionsIndex",
"!=",
"-",
"1",
")",
"{",
"int",
"equalsIndex",
"=",
"objString",
".",
"indexOf",
"(",
"EQUALS",
",",
"optionsIndex",
")",
";",
"jvmOptions",
"=",
"objString",
".",
"substring",
"(",
"equalsIndex",
"+",
"1",
",",
"objString",
".",
"length",
"(",
")",
")",
";",
"jvmOptions",
"=",
"jvmOptions",
".",
"replace",
"(",
"LEFT_BRACKET",
",",
"\"\"",
")",
".",
"replace",
"(",
"RIGHT_BRACKET",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"You must specify the JVM options for your component\"",
")",
";",
"}",
"config",
".",
"setComponentJvmOptions",
"(",
"id",
",",
"jvmOptions",
")",
";",
"}",
"}",
"else",
"{",
"config",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"config",
";",
"}"
] | Build the config for a ECO topology definition
@param topologyDefinition - ECO topology definition | [
"Build",
"the",
"config",
"for",
"a",
"ECO",
"topology",
"definition"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/eco/src/java/org/apache/heron/eco/builder/ConfigBuilder.java#L57-L104 |
28,087 | apache/incubator-heron | heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java | TopologyUtils.verifyTopology | public static boolean verifyTopology(TopologyAPI.Topology topology) {
if (!topology.hasName() || topology.getName().isEmpty()) {
LOG.severe("Missing topology name");
return false;
}
if (topology.getName().contains(".") || topology.getName().contains("/")) {
LOG.severe("Invalid topology name. Topology name shouldn't have . or /");
return false;
}
// Only verify RAM map string well-formed.
getComponentRamMapConfig(topology);
// Verify all bolts input streams exist. First get all output streams.
Set<String> outputStreams = new HashSet<>();
for (TopologyAPI.Spout spout : topology.getSpoutsList()) {
for (TopologyAPI.OutputStream stream : spout.getOutputsList()) {
outputStreams.add(
stream.getStream().getComponentName() + "/" + stream.getStream().getId());
}
}
for (TopologyAPI.Bolt bolt : topology.getBoltsList()) {
for (TopologyAPI.OutputStream stream : bolt.getOutputsList()) {
outputStreams.add(
stream.getStream().getComponentName() + "/" + stream.getStream().getId());
}
}
// Match output streams with input streams.
for (TopologyAPI.Bolt bolt : topology.getBoltsList()) {
for (TopologyAPI.InputStream stream : bolt.getInputsList()) {
String key = stream.getStream().getComponentName() + "/" + stream.getStream().getId();
if (!outputStreams.contains(key)) {
LOG.severe("Invalid input stream " + key + " existing streams are " + outputStreams);
return false;
}
}
}
// TODO(nbhagat): Should we enforce all output stream must be consumed?
return true;
} | java | public static boolean verifyTopology(TopologyAPI.Topology topology) {
if (!topology.hasName() || topology.getName().isEmpty()) {
LOG.severe("Missing topology name");
return false;
}
if (topology.getName().contains(".") || topology.getName().contains("/")) {
LOG.severe("Invalid topology name. Topology name shouldn't have . or /");
return false;
}
// Only verify RAM map string well-formed.
getComponentRamMapConfig(topology);
// Verify all bolts input streams exist. First get all output streams.
Set<String> outputStreams = new HashSet<>();
for (TopologyAPI.Spout spout : topology.getSpoutsList()) {
for (TopologyAPI.OutputStream stream : spout.getOutputsList()) {
outputStreams.add(
stream.getStream().getComponentName() + "/" + stream.getStream().getId());
}
}
for (TopologyAPI.Bolt bolt : topology.getBoltsList()) {
for (TopologyAPI.OutputStream stream : bolt.getOutputsList()) {
outputStreams.add(
stream.getStream().getComponentName() + "/" + stream.getStream().getId());
}
}
// Match output streams with input streams.
for (TopologyAPI.Bolt bolt : topology.getBoltsList()) {
for (TopologyAPI.InputStream stream : bolt.getInputsList()) {
String key = stream.getStream().getComponentName() + "/" + stream.getStream().getId();
if (!outputStreams.contains(key)) {
LOG.severe("Invalid input stream " + key + " existing streams are " + outputStreams);
return false;
}
}
}
// TODO(nbhagat): Should we enforce all output stream must be consumed?
return true;
} | [
"public",
"static",
"boolean",
"verifyTopology",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
")",
"{",
"if",
"(",
"!",
"topology",
".",
"hasName",
"(",
")",
"||",
"topology",
".",
"getName",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Missing topology name\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"topology",
".",
"getName",
"(",
")",
".",
"contains",
"(",
"\".\"",
")",
"||",
"topology",
".",
"getName",
"(",
")",
".",
"contains",
"(",
"\"/\"",
")",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Invalid topology name. Topology name shouldn't have . or /\"",
")",
";",
"return",
"false",
";",
"}",
"// Only verify RAM map string well-formed.",
"getComponentRamMapConfig",
"(",
"topology",
")",
";",
"// Verify all bolts input streams exist. First get all output streams.",
"Set",
"<",
"String",
">",
"outputStreams",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"TopologyAPI",
".",
"Spout",
"spout",
":",
"topology",
".",
"getSpoutsList",
"(",
")",
")",
"{",
"for",
"(",
"TopologyAPI",
".",
"OutputStream",
"stream",
":",
"spout",
".",
"getOutputsList",
"(",
")",
")",
"{",
"outputStreams",
".",
"add",
"(",
"stream",
".",
"getStream",
"(",
")",
".",
"getComponentName",
"(",
")",
"+",
"\"/\"",
"+",
"stream",
".",
"getStream",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"TopologyAPI",
".",
"Bolt",
"bolt",
":",
"topology",
".",
"getBoltsList",
"(",
")",
")",
"{",
"for",
"(",
"TopologyAPI",
".",
"OutputStream",
"stream",
":",
"bolt",
".",
"getOutputsList",
"(",
")",
")",
"{",
"outputStreams",
".",
"add",
"(",
"stream",
".",
"getStream",
"(",
")",
".",
"getComponentName",
"(",
")",
"+",
"\"/\"",
"+",
"stream",
".",
"getStream",
"(",
")",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"// Match output streams with input streams.",
"for",
"(",
"TopologyAPI",
".",
"Bolt",
"bolt",
":",
"topology",
".",
"getBoltsList",
"(",
")",
")",
"{",
"for",
"(",
"TopologyAPI",
".",
"InputStream",
"stream",
":",
"bolt",
".",
"getInputsList",
"(",
")",
")",
"{",
"String",
"key",
"=",
"stream",
".",
"getStream",
"(",
")",
".",
"getComponentName",
"(",
")",
"+",
"\"/\"",
"+",
"stream",
".",
"getStream",
"(",
")",
".",
"getId",
"(",
")",
";",
"if",
"(",
"!",
"outputStreams",
".",
"contains",
"(",
"key",
")",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Invalid input stream \"",
"+",
"key",
"+",
"\" existing streams are \"",
"+",
"outputStreams",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"// TODO(nbhagat): Should we enforce all output stream must be consumed?",
"return",
"true",
";",
"}"
] | Verify if the given topology has all the necessary information | [
"Verify",
"if",
"the",
"given",
"topology",
"has",
"all",
"the",
"necessary",
"information"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java#L181-L220 |
28,088 | apache/incubator-heron | heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java | TopologyUtils.getComponentCpuMapConfig | public static Map<String, Double> getComponentCpuMapConfig(TopologyAPI.Topology topology)
throws RuntimeException {
Map<String, String> configMap =
getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_CPUMAP);
Map<String, Double> cpuMap = new HashMap<>();
for (Map.Entry<String, String> entry : configMap.entrySet()) {
Double requiredCpu = Double.parseDouble(entry.getValue());
cpuMap.put(entry.getKey(), requiredCpu);
}
return cpuMap;
} | java | public static Map<String, Double> getComponentCpuMapConfig(TopologyAPI.Topology topology)
throws RuntimeException {
Map<String, String> configMap =
getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_CPUMAP);
Map<String, Double> cpuMap = new HashMap<>();
for (Map.Entry<String, String> entry : configMap.entrySet()) {
Double requiredCpu = Double.parseDouble(entry.getValue());
cpuMap.put(entry.getKey(), requiredCpu);
}
return cpuMap;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Double",
">",
"getComponentCpuMapConfig",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
")",
"throws",
"RuntimeException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"configMap",
"=",
"getComponentConfigMap",
"(",
"topology",
",",
"Config",
".",
"TOPOLOGY_COMPONENT_CPUMAP",
")",
";",
"Map",
"<",
"String",
",",
"Double",
">",
"cpuMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"configMap",
".",
"entrySet",
"(",
")",
")",
"{",
"Double",
"requiredCpu",
"=",
"Double",
".",
"parseDouble",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"cpuMap",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"requiredCpu",
")",
";",
"}",
"return",
"cpuMap",
";",
"}"
] | Parses the value in Config.TOPOLOGY_COMPONENT_CPUMAP,
and returns a map containing only component specified.
Returns a empty map if the Config is not set
@param topology the topology def
@return a map (componentName -> cpu required) | [
"Parses",
"the",
"value",
"in",
"Config",
".",
"TOPOLOGY_COMPONENT_CPUMAP",
"and",
"returns",
"a",
"map",
"containing",
"only",
"component",
"specified",
".",
"Returns",
"a",
"empty",
"map",
"if",
"the",
"Config",
"is",
"not",
"set"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java#L235-L246 |
28,089 | apache/incubator-heron | heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java | TopologyUtils.getComponentRamMapConfig | public static Map<String, ByteAmount> getComponentRamMapConfig(TopologyAPI.Topology topology)
throws RuntimeException {
Map<String, String> configMap =
getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_RAMMAP);
Map<String, ByteAmount> ramMap = new HashMap<>();
for (Map.Entry<String, String> entry : configMap.entrySet()) {
long requiredRam = Long.parseLong(entry.getValue());
ramMap.put(entry.getKey(), ByteAmount.fromBytes(requiredRam));
}
return ramMap;
} | java | public static Map<String, ByteAmount> getComponentRamMapConfig(TopologyAPI.Topology topology)
throws RuntimeException {
Map<String, String> configMap =
getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_RAMMAP);
Map<String, ByteAmount> ramMap = new HashMap<>();
for (Map.Entry<String, String> entry : configMap.entrySet()) {
long requiredRam = Long.parseLong(entry.getValue());
ramMap.put(entry.getKey(), ByteAmount.fromBytes(requiredRam));
}
return ramMap;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"ByteAmount",
">",
"getComponentRamMapConfig",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
")",
"throws",
"RuntimeException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"configMap",
"=",
"getComponentConfigMap",
"(",
"topology",
",",
"Config",
".",
"TOPOLOGY_COMPONENT_RAMMAP",
")",
";",
"Map",
"<",
"String",
",",
"ByteAmount",
">",
"ramMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"configMap",
".",
"entrySet",
"(",
")",
")",
"{",
"long",
"requiredRam",
"=",
"Long",
".",
"parseLong",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"ramMap",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"ByteAmount",
".",
"fromBytes",
"(",
"requiredRam",
")",
")",
";",
"}",
"return",
"ramMap",
";",
"}"
] | Parses the value in Config.TOPOLOGY_COMPONENT_RAMMAP,
and returns a map containing only component specified.
Returns a empty map if the Config is not set
@param topology the topology def
@return a map (componentName -> RAM required) | [
"Parses",
"the",
"value",
"in",
"Config",
".",
"TOPOLOGY_COMPONENT_RAMMAP",
"and",
"returns",
"a",
"map",
"containing",
"only",
"component",
"specified",
".",
"Returns",
"a",
"empty",
"map",
"if",
"the",
"Config",
"is",
"not",
"set"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java#L256-L267 |
28,090 | apache/incubator-heron | heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java | TopologyUtils.getComponentDiskMapConfig | public static Map<String, ByteAmount> getComponentDiskMapConfig(TopologyAPI.Topology topology)
throws RuntimeException {
Map<String, String> configMap =
getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_DISKMAP);
Map<String, ByteAmount> diskMap = new HashMap<>();
for (Map.Entry<String, String> entry : configMap.entrySet()) {
long requiredDisk = Long.parseLong(entry.getValue());
diskMap.put(entry.getKey(), ByteAmount.fromBytes(requiredDisk));
}
return diskMap;
} | java | public static Map<String, ByteAmount> getComponentDiskMapConfig(TopologyAPI.Topology topology)
throws RuntimeException {
Map<String, String> configMap =
getComponentConfigMap(topology, Config.TOPOLOGY_COMPONENT_DISKMAP);
Map<String, ByteAmount> diskMap = new HashMap<>();
for (Map.Entry<String, String> entry : configMap.entrySet()) {
long requiredDisk = Long.parseLong(entry.getValue());
diskMap.put(entry.getKey(), ByteAmount.fromBytes(requiredDisk));
}
return diskMap;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"ByteAmount",
">",
"getComponentDiskMapConfig",
"(",
"TopologyAPI",
".",
"Topology",
"topology",
")",
"throws",
"RuntimeException",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"configMap",
"=",
"getComponentConfigMap",
"(",
"topology",
",",
"Config",
".",
"TOPOLOGY_COMPONENT_DISKMAP",
")",
";",
"Map",
"<",
"String",
",",
"ByteAmount",
">",
"diskMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"configMap",
".",
"entrySet",
"(",
")",
")",
"{",
"long",
"requiredDisk",
"=",
"Long",
".",
"parseLong",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"diskMap",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"ByteAmount",
".",
"fromBytes",
"(",
"requiredDisk",
")",
")",
";",
"}",
"return",
"diskMap",
";",
"}"
] | Parses the value in Config.TOPOLOGY_COMPONENT_DISKMAP,
and returns a map containing only component specified.
Returns a empty map if the Config is not set
@param topology the topology def
@return a map (componentName -> disk required) | [
"Parses",
"the",
"value",
"in",
"Config",
".",
"TOPOLOGY_COMPONENT_DISKMAP",
"and",
"returns",
"a",
"map",
"containing",
"only",
"component",
"specified",
".",
"Returns",
"a",
"empty",
"map",
"if",
"the",
"Config",
"is",
"not",
"set"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/api/src/java/org/apache/heron/api/utils/TopologyUtils.java#L277-L288 |
28,091 | apache/incubator-heron | heron/scheduler-core/src/java/org/apache/heron/scheduler/UpdateTopologyManager.java | UpdateTopologyManager.updateTopology | public void updateTopology(final PackingPlans.PackingPlan existingProtoPackingPlan,
final PackingPlans.PackingPlan proposedProtoPackingPlan)
throws ExecutionException, InterruptedException, ConcurrentModificationException {
String topologyName = Runtime.topologyName(runtime);
SchedulerStateManagerAdaptor stateManager = Runtime.schedulerStateManagerAdaptor(runtime);
Lock lock = stateManager.getLock(topologyName, IStateManager.LockName.UPDATE_TOPOLOGY);
if (lock.tryLock(5, TimeUnit.SECONDS)) {
try {
PackingPlans.PackingPlan foundPackingPlan = getPackingPlan(stateManager, topologyName);
if (!deserializer.fromProto(existingProtoPackingPlan)
.equals(deserializer.fromProto(foundPackingPlan))) {
throw new ConcurrentModificationException(String.format(
"The packing plan in state manager is not the same as the submitted existing "
+ "packing plan for topology %s. Another actor has changed it and has likely"
+ "performed an update on it. Failing this request, try again once other "
+ "update is complete", topologyName));
}
updateTopology(existingProtoPackingPlan, proposedProtoPackingPlan, stateManager);
} finally {
lock.unlock();
}
} else {
throw new ConcurrentModificationException(String.format(
"The update lock can not be obtained for topology %s. Another actor is performing an "
+ "update on it. Failing this request, try again once current update is complete",
topologyName));
}
} | java | public void updateTopology(final PackingPlans.PackingPlan existingProtoPackingPlan,
final PackingPlans.PackingPlan proposedProtoPackingPlan)
throws ExecutionException, InterruptedException, ConcurrentModificationException {
String topologyName = Runtime.topologyName(runtime);
SchedulerStateManagerAdaptor stateManager = Runtime.schedulerStateManagerAdaptor(runtime);
Lock lock = stateManager.getLock(topologyName, IStateManager.LockName.UPDATE_TOPOLOGY);
if (lock.tryLock(5, TimeUnit.SECONDS)) {
try {
PackingPlans.PackingPlan foundPackingPlan = getPackingPlan(stateManager, topologyName);
if (!deserializer.fromProto(existingProtoPackingPlan)
.equals(deserializer.fromProto(foundPackingPlan))) {
throw new ConcurrentModificationException(String.format(
"The packing plan in state manager is not the same as the submitted existing "
+ "packing plan for topology %s. Another actor has changed it and has likely"
+ "performed an update on it. Failing this request, try again once other "
+ "update is complete", topologyName));
}
updateTopology(existingProtoPackingPlan, proposedProtoPackingPlan, stateManager);
} finally {
lock.unlock();
}
} else {
throw new ConcurrentModificationException(String.format(
"The update lock can not be obtained for topology %s. Another actor is performing an "
+ "update on it. Failing this request, try again once current update is complete",
topologyName));
}
} | [
"public",
"void",
"updateTopology",
"(",
"final",
"PackingPlans",
".",
"PackingPlan",
"existingProtoPackingPlan",
",",
"final",
"PackingPlans",
".",
"PackingPlan",
"proposedProtoPackingPlan",
")",
"throws",
"ExecutionException",
",",
"InterruptedException",
",",
"ConcurrentModificationException",
"{",
"String",
"topologyName",
"=",
"Runtime",
".",
"topologyName",
"(",
"runtime",
")",
";",
"SchedulerStateManagerAdaptor",
"stateManager",
"=",
"Runtime",
".",
"schedulerStateManagerAdaptor",
"(",
"runtime",
")",
";",
"Lock",
"lock",
"=",
"stateManager",
".",
"getLock",
"(",
"topologyName",
",",
"IStateManager",
".",
"LockName",
".",
"UPDATE_TOPOLOGY",
")",
";",
"if",
"(",
"lock",
".",
"tryLock",
"(",
"5",
",",
"TimeUnit",
".",
"SECONDS",
")",
")",
"{",
"try",
"{",
"PackingPlans",
".",
"PackingPlan",
"foundPackingPlan",
"=",
"getPackingPlan",
"(",
"stateManager",
",",
"topologyName",
")",
";",
"if",
"(",
"!",
"deserializer",
".",
"fromProto",
"(",
"existingProtoPackingPlan",
")",
".",
"equals",
"(",
"deserializer",
".",
"fromProto",
"(",
"foundPackingPlan",
")",
")",
")",
"{",
"throw",
"new",
"ConcurrentModificationException",
"(",
"String",
".",
"format",
"(",
"\"The packing plan in state manager is not the same as the submitted existing \"",
"+",
"\"packing plan for topology %s. Another actor has changed it and has likely\"",
"+",
"\"performed an update on it. Failing this request, try again once other \"",
"+",
"\"update is complete\"",
",",
"topologyName",
")",
")",
";",
"}",
"updateTopology",
"(",
"existingProtoPackingPlan",
",",
"proposedProtoPackingPlan",
",",
"stateManager",
")",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"ConcurrentModificationException",
"(",
"String",
".",
"format",
"(",
"\"The update lock can not be obtained for topology %s. Another actor is performing an \"",
"+",
"\"update on it. Failing this request, try again once current update is complete\"",
",",
"topologyName",
")",
")",
";",
"}",
"}"
] | Scales the topology out or in based on the proposedPackingPlan
@param existingProtoPackingPlan the current plan. If this isn't what's found in the state
manager, the update will fail
@param proposedProtoPackingPlan packing plan to change the topology to | [
"Scales",
"the",
"topology",
"out",
"or",
"in",
"based",
"on",
"the",
"proposedPackingPlan"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/scheduler-core/src/java/org/apache/heron/scheduler/UpdateTopologyManager.java#L97-L127 |
28,092 | apache/incubator-heron | heron/api/src/java/org/apache/heron/api/topology/TopologyBuilder.java | TopologyBuilder.setSpout | public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelismHint) {
validateComponentName(id);
SpoutDeclarer s = new SpoutDeclarer(id, spout, parallelismHint);
spouts.put(id, s);
return s;
} | java | public SpoutDeclarer setSpout(String id, IRichSpout spout, Number parallelismHint) {
validateComponentName(id);
SpoutDeclarer s = new SpoutDeclarer(id, spout, parallelismHint);
spouts.put(id, s);
return s;
} | [
"public",
"SpoutDeclarer",
"setSpout",
"(",
"String",
"id",
",",
"IRichSpout",
"spout",
",",
"Number",
"parallelismHint",
")",
"{",
"validateComponentName",
"(",
"id",
")",
";",
"SpoutDeclarer",
"s",
"=",
"new",
"SpoutDeclarer",
"(",
"id",
",",
"spout",
",",
"parallelismHint",
")",
";",
"spouts",
".",
"put",
"(",
"id",
",",
"s",
")",
";",
"return",
"s",
";",
"}"
] | Define a new spout in this topology with the specified parallelism. If the spout declares
itself as non-distributed, the parallelismHint 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 parallelismHint the number of tasks that should be assigned to execute this spout. Each task will run on a thread in a process somwehere around the cluster.
@param spout the spout | [
"Define",
"a",
"new",
"spout",
"in",
"this",
"topology",
"with",
"the",
"specified",
"parallelism",
".",
"If",
"the",
"spout",
"declares",
"itself",
"as",
"non",
"-",
"distributed",
"the",
"parallelismHint",
"will",
"be",
"ignored",
"and",
"only",
"one",
"task",
"will",
"be",
"allocated",
"to",
"this",
"component",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/api/src/java/org/apache/heron/api/topology/TopologyBuilder.java#L259-L264 |
28,093 | apache/incubator-heron | heron/healthmgr/src/java/org/apache/heron/healthmgr/detectors/SkewDetector.java | SkewDetector.detect | @Override
public Collection<Symptom> detect(Collection<Measurement> measurements) {
Collection<Symptom> result = new ArrayList<>();
MeasurementsTable metrics = MeasurementsTable.of(measurements).type(metricName);
Instant now = context.checkpoint();
for (String component : metrics.uniqueComponents()) {
Set<String> addresses = new HashSet<>();
Set<String> positiveAddresses = new HashSet<>();
Set<String> negativeAddresses = new HashSet<>();
double componentMax = getMaxOfAverage(metrics.component(component));
double componentMin = getMinOfAverage(metrics.component(component));
if (componentMax > skewRatio * componentMin) {
//there is skew
addresses.add(component);
result.add(new Symptom(symptomType.text(), now, addresses));
for (String instance : metrics.component(component).uniqueInstances()) {
if (metrics.instance(instance).mean() >= 0.90 * componentMax) {
positiveAddresses.add(instance);
}
if (metrics.instance(instance).mean() <= 1.10 * componentMin) {
negativeAddresses.add(instance);
}
}
if (!positiveAddresses.isEmpty()) {
result.add(new Symptom("POSITIVE " + symptomType.text(), now, positiveAddresses));
}
if (!negativeAddresses.isEmpty()) {
result.add(new Symptom("NEGATIVE " + symptomType.text(), now, negativeAddresses));
}
}
}
return result;
} | java | @Override
public Collection<Symptom> detect(Collection<Measurement> measurements) {
Collection<Symptom> result = new ArrayList<>();
MeasurementsTable metrics = MeasurementsTable.of(measurements).type(metricName);
Instant now = context.checkpoint();
for (String component : metrics.uniqueComponents()) {
Set<String> addresses = new HashSet<>();
Set<String> positiveAddresses = new HashSet<>();
Set<String> negativeAddresses = new HashSet<>();
double componentMax = getMaxOfAverage(metrics.component(component));
double componentMin = getMinOfAverage(metrics.component(component));
if (componentMax > skewRatio * componentMin) {
//there is skew
addresses.add(component);
result.add(new Symptom(symptomType.text(), now, addresses));
for (String instance : metrics.component(component).uniqueInstances()) {
if (metrics.instance(instance).mean() >= 0.90 * componentMax) {
positiveAddresses.add(instance);
}
if (metrics.instance(instance).mean() <= 1.10 * componentMin) {
negativeAddresses.add(instance);
}
}
if (!positiveAddresses.isEmpty()) {
result.add(new Symptom("POSITIVE " + symptomType.text(), now, positiveAddresses));
}
if (!negativeAddresses.isEmpty()) {
result.add(new Symptom("NEGATIVE " + symptomType.text(), now, negativeAddresses));
}
}
}
return result;
} | [
"@",
"Override",
"public",
"Collection",
"<",
"Symptom",
">",
"detect",
"(",
"Collection",
"<",
"Measurement",
">",
"measurements",
")",
"{",
"Collection",
"<",
"Symptom",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"MeasurementsTable",
"metrics",
"=",
"MeasurementsTable",
".",
"of",
"(",
"measurements",
")",
".",
"type",
"(",
"metricName",
")",
";",
"Instant",
"now",
"=",
"context",
".",
"checkpoint",
"(",
")",
";",
"for",
"(",
"String",
"component",
":",
"metrics",
".",
"uniqueComponents",
"(",
")",
")",
"{",
"Set",
"<",
"String",
">",
"addresses",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"positiveAddresses",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"Set",
"<",
"String",
">",
"negativeAddresses",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"double",
"componentMax",
"=",
"getMaxOfAverage",
"(",
"metrics",
".",
"component",
"(",
"component",
")",
")",
";",
"double",
"componentMin",
"=",
"getMinOfAverage",
"(",
"metrics",
".",
"component",
"(",
"component",
")",
")",
";",
"if",
"(",
"componentMax",
">",
"skewRatio",
"*",
"componentMin",
")",
"{",
"//there is skew",
"addresses",
".",
"add",
"(",
"component",
")",
";",
"result",
".",
"add",
"(",
"new",
"Symptom",
"(",
"symptomType",
".",
"text",
"(",
")",
",",
"now",
",",
"addresses",
")",
")",
";",
"for",
"(",
"String",
"instance",
":",
"metrics",
".",
"component",
"(",
"component",
")",
".",
"uniqueInstances",
"(",
")",
")",
"{",
"if",
"(",
"metrics",
".",
"instance",
"(",
"instance",
")",
".",
"mean",
"(",
")",
">=",
"0.90",
"*",
"componentMax",
")",
"{",
"positiveAddresses",
".",
"add",
"(",
"instance",
")",
";",
"}",
"if",
"(",
"metrics",
".",
"instance",
"(",
"instance",
")",
".",
"mean",
"(",
")",
"<=",
"1.10",
"*",
"componentMin",
")",
"{",
"negativeAddresses",
".",
"add",
"(",
"instance",
")",
";",
"}",
"}",
"if",
"(",
"!",
"positiveAddresses",
".",
"isEmpty",
"(",
")",
")",
"{",
"result",
".",
"add",
"(",
"new",
"Symptom",
"(",
"\"POSITIVE \"",
"+",
"symptomType",
".",
"text",
"(",
")",
",",
"now",
",",
"positiveAddresses",
")",
")",
";",
"}",
"if",
"(",
"!",
"negativeAddresses",
".",
"isEmpty",
"(",
")",
")",
"{",
"result",
".",
"add",
"(",
"new",
"Symptom",
"(",
"\"NEGATIVE \"",
"+",
"symptomType",
".",
"text",
"(",
")",
",",
"now",
",",
"negativeAddresses",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Detects components experiencing skew on a specific metric
@return At most two symptoms corresponding to each affected component -- one for positive skew
and one for negative skew | [
"Detects",
"components",
"experiencing",
"skew",
"on",
"a",
"specific",
"metric"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/healthmgr/src/java/org/apache/heron/healthmgr/detectors/SkewDetector.java#L56-L93 |
28,094 | apache/incubator-heron | heron/schedulers/src/java/org/apache/heron/scheduler/local/LocalLauncher.java | LocalLauncher.launch | @Override
public boolean launch(PackingPlan packing) {
LOG.log(Level.FINE, "Launching topology for local cluster {0}",
LocalContext.cluster(config));
// setup the working directory
// mainly it downloads and extracts the heron-core-release and topology package
if (!setupWorkingDirectoryAndExtractPackages()) {
LOG.severe("Failed to setup working directory");
return false;
}
String[] schedulerCmd = getSchedulerCommand();
Process p = startScheduler(schedulerCmd);
if (p == null) {
LOG.severe("Failed to start SchedulerMain using: " + Arrays.toString(schedulerCmd));
return false;
}
LOG.log(Level.FINE, String.format(
"To check the status and logs of the topology, use the working directory %s",
LocalContext.workingDirectory(config)));
return true;
} | java | @Override
public boolean launch(PackingPlan packing) {
LOG.log(Level.FINE, "Launching topology for local cluster {0}",
LocalContext.cluster(config));
// setup the working directory
// mainly it downloads and extracts the heron-core-release and topology package
if (!setupWorkingDirectoryAndExtractPackages()) {
LOG.severe("Failed to setup working directory");
return false;
}
String[] schedulerCmd = getSchedulerCommand();
Process p = startScheduler(schedulerCmd);
if (p == null) {
LOG.severe("Failed to start SchedulerMain using: " + Arrays.toString(schedulerCmd));
return false;
}
LOG.log(Level.FINE, String.format(
"To check the status and logs of the topology, use the working directory %s",
LocalContext.workingDirectory(config)));
return true;
} | [
"@",
"Override",
"public",
"boolean",
"launch",
"(",
"PackingPlan",
"packing",
")",
"{",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Launching topology for local cluster {0}\"",
",",
"LocalContext",
".",
"cluster",
"(",
"config",
")",
")",
";",
"// setup the working directory",
"// mainly it downloads and extracts the heron-core-release and topology package",
"if",
"(",
"!",
"setupWorkingDirectoryAndExtractPackages",
"(",
")",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Failed to setup working directory\"",
")",
";",
"return",
"false",
";",
"}",
"String",
"[",
"]",
"schedulerCmd",
"=",
"getSchedulerCommand",
"(",
")",
";",
"Process",
"p",
"=",
"startScheduler",
"(",
"schedulerCmd",
")",
";",
"if",
"(",
"p",
"==",
"null",
")",
"{",
"LOG",
".",
"severe",
"(",
"\"Failed to start SchedulerMain using: \"",
"+",
"Arrays",
".",
"toString",
"(",
"schedulerCmd",
")",
")",
";",
"return",
"false",
";",
"}",
"LOG",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"String",
".",
"format",
"(",
"\"To check the status and logs of the topology, use the working directory %s\"",
",",
"LocalContext",
".",
"workingDirectory",
"(",
"config",
")",
")",
")",
";",
"return",
"true",
";",
"}"
] | Launch the topology | [
"Launch",
"the",
"topology"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/schedulers/src/java/org/apache/heron/scheduler/local/LocalLauncher.java#L70-L96 |
28,095 | apache/incubator-heron | heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManager.java | MetricsCacheManager.start | public void start() throws Exception {
// 1. Do prepare work
// create an instance of state manager
String statemgrClass = Context.stateManagerClass(config);
LOG.info("Context.stateManagerClass " + statemgrClass);
IStateManager statemgr;
try {
statemgr = ReflectionUtils.newInstance(statemgrClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new Exception(String.format(
"Failed to instantiate state manager class '%s'",
statemgrClass), e);
}
// Put it in a try block so that we can always clean resources
try {
// initialize the statemgr
statemgr.initialize(config);
Boolean b = statemgr.setMetricsCacheLocation(metricsCacheLocation, topologyName)
.get(5000, TimeUnit.MILLISECONDS);
if (b != null && b) {
LOG.info("metricsCacheLocation " + metricsCacheLocation.toString());
LOG.info("topologyName " + topologyName.toString());
LOG.info("Starting Metrics Cache HTTP Server");
metricsCacheManagerHttpServer.start();
// 2. The MetricsCacheServer would run in the main thread
// We do it in the final step since it would await the main thread
LOG.info("Starting Metrics Cache Server");
metricsCacheManagerServer.start();
metricsCacheManagerServerLoop.loop();
} else {
throw new RuntimeException("Failed to set metricscahe location.");
}
} finally {
// 3. Do post work basing on the result
// Currently nothing to do here
// 4. Close the resources
SysUtils.closeIgnoringExceptions(statemgr);
}
} | java | public void start() throws Exception {
// 1. Do prepare work
// create an instance of state manager
String statemgrClass = Context.stateManagerClass(config);
LOG.info("Context.stateManagerClass " + statemgrClass);
IStateManager statemgr;
try {
statemgr = ReflectionUtils.newInstance(statemgrClass);
} catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
throw new Exception(String.format(
"Failed to instantiate state manager class '%s'",
statemgrClass), e);
}
// Put it in a try block so that we can always clean resources
try {
// initialize the statemgr
statemgr.initialize(config);
Boolean b = statemgr.setMetricsCacheLocation(metricsCacheLocation, topologyName)
.get(5000, TimeUnit.MILLISECONDS);
if (b != null && b) {
LOG.info("metricsCacheLocation " + metricsCacheLocation.toString());
LOG.info("topologyName " + topologyName.toString());
LOG.info("Starting Metrics Cache HTTP Server");
metricsCacheManagerHttpServer.start();
// 2. The MetricsCacheServer would run in the main thread
// We do it in the final step since it would await the main thread
LOG.info("Starting Metrics Cache Server");
metricsCacheManagerServer.start();
metricsCacheManagerServerLoop.loop();
} else {
throw new RuntimeException("Failed to set metricscahe location.");
}
} finally {
// 3. Do post work basing on the result
// Currently nothing to do here
// 4. Close the resources
SysUtils.closeIgnoringExceptions(statemgr);
}
} | [
"public",
"void",
"start",
"(",
")",
"throws",
"Exception",
"{",
"// 1. Do prepare work",
"// create an instance of state manager",
"String",
"statemgrClass",
"=",
"Context",
".",
"stateManagerClass",
"(",
"config",
")",
";",
"LOG",
".",
"info",
"(",
"\"Context.stateManagerClass \"",
"+",
"statemgrClass",
")",
";",
"IStateManager",
"statemgr",
";",
"try",
"{",
"statemgr",
"=",
"ReflectionUtils",
".",
"newInstance",
"(",
"statemgrClass",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InstantiationException",
"|",
"ClassNotFoundException",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"String",
".",
"format",
"(",
"\"Failed to instantiate state manager class '%s'\"",
",",
"statemgrClass",
")",
",",
"e",
")",
";",
"}",
"// Put it in a try block so that we can always clean resources",
"try",
"{",
"// initialize the statemgr",
"statemgr",
".",
"initialize",
"(",
"config",
")",
";",
"Boolean",
"b",
"=",
"statemgr",
".",
"setMetricsCacheLocation",
"(",
"metricsCacheLocation",
",",
"topologyName",
")",
".",
"get",
"(",
"5000",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"if",
"(",
"b",
"!=",
"null",
"&&",
"b",
")",
"{",
"LOG",
".",
"info",
"(",
"\"metricsCacheLocation \"",
"+",
"metricsCacheLocation",
".",
"toString",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"topologyName \"",
"+",
"topologyName",
".",
"toString",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Starting Metrics Cache HTTP Server\"",
")",
";",
"metricsCacheManagerHttpServer",
".",
"start",
"(",
")",
";",
"// 2. The MetricsCacheServer would run in the main thread",
"// We do it in the final step since it would await the main thread",
"LOG",
".",
"info",
"(",
"\"Starting Metrics Cache Server\"",
")",
";",
"metricsCacheManagerServer",
".",
"start",
"(",
")",
";",
"metricsCacheManagerServerLoop",
".",
"loop",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to set metricscahe location.\"",
")",
";",
"}",
"}",
"finally",
"{",
"// 3. Do post work basing on the result",
"// Currently nothing to do here",
"// 4. Close the resources",
"SysUtils",
".",
"closeIgnoringExceptions",
"(",
"statemgr",
")",
";",
"}",
"}"
] | start statemgr_client, metricscache_server, http_server
@throws Exception | [
"start",
"statemgr_client",
"metricscache_server",
"http_server"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/metricscachemgr/src/java/org/apache/heron/metricscachemgr/MetricsCacheManager.java#L383-L428 |
28,096 | apache/incubator-heron | heron/uploaders/src/java/org/apache/heron/uploader/s3/S3Uploader.java | S3Uploader.generateS3Path | private String generateS3Path(String pathPrefixParent, String topologyName, String filename) {
List<String> pathParts = new ArrayList<>(Arrays.asList(pathPrefixParent.split("/")));
pathParts.add(topologyName);
pathParts.add(filename);
return String.join("/", pathParts);
} | java | private String generateS3Path(String pathPrefixParent, String topologyName, String filename) {
List<String> pathParts = new ArrayList<>(Arrays.asList(pathPrefixParent.split("/")));
pathParts.add(topologyName);
pathParts.add(filename);
return String.join("/", pathParts);
} | [
"private",
"String",
"generateS3Path",
"(",
"String",
"pathPrefixParent",
",",
"String",
"topologyName",
",",
"String",
"filename",
")",
"{",
"List",
"<",
"String",
">",
"pathParts",
"=",
"new",
"ArrayList",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"pathPrefixParent",
".",
"split",
"(",
"\"/\"",
")",
")",
")",
";",
"pathParts",
".",
"add",
"(",
"topologyName",
")",
";",
"pathParts",
".",
"add",
"(",
"filename",
")",
";",
"return",
"String",
".",
"join",
"(",
"\"/\"",
",",
"pathParts",
")",
";",
"}"
] | Generate the path to a file in s3 given a prefix, topologyName, and filename
@param pathPrefixParent designates any parent folders that should be prefixed to the resulting path
@param topologyName the name of the topology that we are uploaded
@param filename the name of the resulting file that is going to be uploaded
@return the full path of the package under the bucket. The bucket is not included in this path as it is a separate
argument that is passed to the putObject call in the s3 sdk. | [
"Generate",
"the",
"path",
"to",
"a",
"file",
"in",
"s3",
"given",
"a",
"prefix",
"topologyName",
"and",
"filename"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/uploaders/src/java/org/apache/heron/uploader/s3/S3Uploader.java#L217-L223 |
28,097 | apache/incubator-heron | heron/simulator/src/java/org/apache/heron/simulator/Simulator.java | Simulator.submitTopology | public void submitTopology(String name, Config heronConfig, HeronTopology heronTopology) {
TopologyAPI.Topology topologyToRun =
heronTopology.
setConfig(heronConfig).
setName(name).
setState(TopologyAPI.TopologyState.RUNNING).
getTopology();
if (!TopologyUtils.verifyTopology(topologyToRun)) {
throw new RuntimeException("Topology object is Malformed");
}
// TODO (nlu): add simulator support stateful processing
if (isTopologyStateful(heronConfig)) {
throw new RuntimeException("Stateful topology is not supported");
}
TopologyManager topologyManager = new TopologyManager(topologyToRun);
LOG.info("Physical Plan: \n" + topologyManager.getPhysicalPlan());
// Create the stream executor
streamExecutor = new StreamExecutor(topologyManager);
// Create the metrics executor
metricsExecutor = new MetricsExecutor(systemConfig);
// Create instance Executor
for (PhysicalPlans.Instance instance : topologyManager.getPhysicalPlan().getInstancesList()) {
InstanceExecutor instanceExecutor = new InstanceExecutor(
topologyManager.getPhysicalPlan(),
instance.getInstanceId()
);
streamExecutor.addInstanceExecutor(instanceExecutor);
metricsExecutor.addInstanceExecutor(instanceExecutor);
instanceExecutors.add(instanceExecutor);
}
// Start - run executors
// Add exception handler for any uncaught exception here.
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
threadsPool.execute(metricsExecutor);
threadsPool.execute(streamExecutor);
for (InstanceExecutor instanceExecutor : instanceExecutors) {
threadsPool.execute(instanceExecutor);
}
} | java | public void submitTopology(String name, Config heronConfig, HeronTopology heronTopology) {
TopologyAPI.Topology topologyToRun =
heronTopology.
setConfig(heronConfig).
setName(name).
setState(TopologyAPI.TopologyState.RUNNING).
getTopology();
if (!TopologyUtils.verifyTopology(topologyToRun)) {
throw new RuntimeException("Topology object is Malformed");
}
// TODO (nlu): add simulator support stateful processing
if (isTopologyStateful(heronConfig)) {
throw new RuntimeException("Stateful topology is not supported");
}
TopologyManager topologyManager = new TopologyManager(topologyToRun);
LOG.info("Physical Plan: \n" + topologyManager.getPhysicalPlan());
// Create the stream executor
streamExecutor = new StreamExecutor(topologyManager);
// Create the metrics executor
metricsExecutor = new MetricsExecutor(systemConfig);
// Create instance Executor
for (PhysicalPlans.Instance instance : topologyManager.getPhysicalPlan().getInstancesList()) {
InstanceExecutor instanceExecutor = new InstanceExecutor(
topologyManager.getPhysicalPlan(),
instance.getInstanceId()
);
streamExecutor.addInstanceExecutor(instanceExecutor);
metricsExecutor.addInstanceExecutor(instanceExecutor);
instanceExecutors.add(instanceExecutor);
}
// Start - run executors
// Add exception handler for any uncaught exception here.
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
threadsPool.execute(metricsExecutor);
threadsPool.execute(streamExecutor);
for (InstanceExecutor instanceExecutor : instanceExecutors) {
threadsPool.execute(instanceExecutor);
}
} | [
"public",
"void",
"submitTopology",
"(",
"String",
"name",
",",
"Config",
"heronConfig",
",",
"HeronTopology",
"heronTopology",
")",
"{",
"TopologyAPI",
".",
"Topology",
"topologyToRun",
"=",
"heronTopology",
".",
"setConfig",
"(",
"heronConfig",
")",
".",
"setName",
"(",
"name",
")",
".",
"setState",
"(",
"TopologyAPI",
".",
"TopologyState",
".",
"RUNNING",
")",
".",
"getTopology",
"(",
")",
";",
"if",
"(",
"!",
"TopologyUtils",
".",
"verifyTopology",
"(",
"topologyToRun",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Topology object is Malformed\"",
")",
";",
"}",
"// TODO (nlu): add simulator support stateful processing",
"if",
"(",
"isTopologyStateful",
"(",
"heronConfig",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Stateful topology is not supported\"",
")",
";",
"}",
"TopologyManager",
"topologyManager",
"=",
"new",
"TopologyManager",
"(",
"topologyToRun",
")",
";",
"LOG",
".",
"info",
"(",
"\"Physical Plan: \\n\"",
"+",
"topologyManager",
".",
"getPhysicalPlan",
"(",
")",
")",
";",
"// Create the stream executor",
"streamExecutor",
"=",
"new",
"StreamExecutor",
"(",
"topologyManager",
")",
";",
"// Create the metrics executor",
"metricsExecutor",
"=",
"new",
"MetricsExecutor",
"(",
"systemConfig",
")",
";",
"// Create instance Executor",
"for",
"(",
"PhysicalPlans",
".",
"Instance",
"instance",
":",
"topologyManager",
".",
"getPhysicalPlan",
"(",
")",
".",
"getInstancesList",
"(",
")",
")",
"{",
"InstanceExecutor",
"instanceExecutor",
"=",
"new",
"InstanceExecutor",
"(",
"topologyManager",
".",
"getPhysicalPlan",
"(",
")",
",",
"instance",
".",
"getInstanceId",
"(",
")",
")",
";",
"streamExecutor",
".",
"addInstanceExecutor",
"(",
"instanceExecutor",
")",
";",
"metricsExecutor",
".",
"addInstanceExecutor",
"(",
"instanceExecutor",
")",
";",
"instanceExecutors",
".",
"add",
"(",
"instanceExecutor",
")",
";",
"}",
"// Start - run executors",
"// Add exception handler for any uncaught exception here.",
"Thread",
".",
"setDefaultUncaughtExceptionHandler",
"(",
"new",
"DefaultExceptionHandler",
"(",
")",
")",
";",
"threadsPool",
".",
"execute",
"(",
"metricsExecutor",
")",
";",
"threadsPool",
".",
"execute",
"(",
"streamExecutor",
")",
";",
"for",
"(",
"InstanceExecutor",
"instanceExecutor",
":",
"instanceExecutors",
")",
"{",
"threadsPool",
".",
"execute",
"(",
"instanceExecutor",
")",
";",
"}",
"}"
] | Submit and run topology in simulator
@param name topology name
@param heronConfig topology config
@param heronTopology topology built from topology builder | [
"Submit",
"and",
"run",
"topology",
"in",
"simulator"
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/simulator/src/java/org/apache/heron/simulator/Simulator.java#L110-L158 |
28,098 | apache/incubator-heron | heron/api/src/java/org/apache/heron/api/utils/Utils.java | Utils.getConfigBuilder | public static TopologyAPI.Config.Builder getConfigBuilder(Config config) {
TopologyAPI.Config.Builder cBldr = TopologyAPI.Config.newBuilder();
Set<String> apiVars = config.getApiVars();
for (String key : config.keySet()) {
if (key == null) {
LOG.warning("ignore: null config key found");
continue;
}
Object value = config.get(key);
if (value == null) {
LOG.warning("ignore: config key " + key + " has null value");
continue;
}
TopologyAPI.Config.KeyValue.Builder b = TopologyAPI.Config.KeyValue.newBuilder();
b.setKey(key);
if (apiVars.contains(key)) {
b.setType(TopologyAPI.ConfigValueType.STRING_VALUE);
b.setValue(value.toString());
} else {
b.setType(TopologyAPI.ConfigValueType.JAVA_SERIALIZED_VALUE);
b.setSerializedValue(ByteString.copyFrom(serialize(value)));
}
cBldr.addKvs(b);
}
return cBldr;
} | java | public static TopologyAPI.Config.Builder getConfigBuilder(Config config) {
TopologyAPI.Config.Builder cBldr = TopologyAPI.Config.newBuilder();
Set<String> apiVars = config.getApiVars();
for (String key : config.keySet()) {
if (key == null) {
LOG.warning("ignore: null config key found");
continue;
}
Object value = config.get(key);
if (value == null) {
LOG.warning("ignore: config key " + key + " has null value");
continue;
}
TopologyAPI.Config.KeyValue.Builder b = TopologyAPI.Config.KeyValue.newBuilder();
b.setKey(key);
if (apiVars.contains(key)) {
b.setType(TopologyAPI.ConfigValueType.STRING_VALUE);
b.setValue(value.toString());
} else {
b.setType(TopologyAPI.ConfigValueType.JAVA_SERIALIZED_VALUE);
b.setSerializedValue(ByteString.copyFrom(serialize(value)));
}
cBldr.addKvs(b);
}
return cBldr;
} | [
"public",
"static",
"TopologyAPI",
".",
"Config",
".",
"Builder",
"getConfigBuilder",
"(",
"Config",
"config",
")",
"{",
"TopologyAPI",
".",
"Config",
".",
"Builder",
"cBldr",
"=",
"TopologyAPI",
".",
"Config",
".",
"newBuilder",
"(",
")",
";",
"Set",
"<",
"String",
">",
"apiVars",
"=",
"config",
".",
"getApiVars",
"(",
")",
";",
"for",
"(",
"String",
"key",
":",
"config",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"key",
"==",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"ignore: null config key found\"",
")",
";",
"continue",
";",
"}",
"Object",
"value",
"=",
"config",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"ignore: config key \"",
"+",
"key",
"+",
"\" has null value\"",
")",
";",
"continue",
";",
"}",
"TopologyAPI",
".",
"Config",
".",
"KeyValue",
".",
"Builder",
"b",
"=",
"TopologyAPI",
".",
"Config",
".",
"KeyValue",
".",
"newBuilder",
"(",
")",
";",
"b",
".",
"setKey",
"(",
"key",
")",
";",
"if",
"(",
"apiVars",
".",
"contains",
"(",
"key",
")",
")",
"{",
"b",
".",
"setType",
"(",
"TopologyAPI",
".",
"ConfigValueType",
".",
"STRING_VALUE",
")",
";",
"b",
".",
"setValue",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"b",
".",
"setType",
"(",
"TopologyAPI",
".",
"ConfigValueType",
".",
"JAVA_SERIALIZED_VALUE",
")",
";",
"b",
".",
"setSerializedValue",
"(",
"ByteString",
".",
"copyFrom",
"(",
"serialize",
"(",
"value",
")",
")",
")",
";",
"}",
"cBldr",
".",
"addKvs",
"(",
"b",
")",
";",
"}",
"return",
"cBldr",
";",
"}"
] | Converts a Heron Config object into a TopologyAPI.Config.Builder. Config entries with null
keys or values are ignored.
@param config heron Config object
@return TopologyAPI.Config.Builder with values loaded from config | [
"Converts",
"a",
"Heron",
"Config",
"object",
"into",
"a",
"TopologyAPI",
".",
"Config",
".",
"Builder",
".",
"Config",
"entries",
"with",
"null",
"keys",
"or",
"values",
"are",
"ignored",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/api/src/java/org/apache/heron/api/utils/Utils.java#L127-L153 |
28,099 | apache/incubator-heron | heron/spi/src/java/org/apache/heron/spi/packing/PackingPlan.java | PackingPlan.getMaxContainerResources | public Resource getMaxContainerResources() {
double maxCpu = 0;
ByteAmount maxRam = ByteAmount.ZERO;
ByteAmount maxDisk = ByteAmount.ZERO;
for (ContainerPlan containerPlan : getContainers()) {
Resource containerResource =
containerPlan.getScheduledResource().or(containerPlan.getRequiredResource());
maxCpu = Math.max(maxCpu, containerResource.getCpu());
maxRam = maxRam.max(containerResource.getRam());
maxDisk = maxDisk.max(containerResource.getDisk());
}
return new Resource(maxCpu, maxRam, maxDisk);
} | java | public Resource getMaxContainerResources() {
double maxCpu = 0;
ByteAmount maxRam = ByteAmount.ZERO;
ByteAmount maxDisk = ByteAmount.ZERO;
for (ContainerPlan containerPlan : getContainers()) {
Resource containerResource =
containerPlan.getScheduledResource().or(containerPlan.getRequiredResource());
maxCpu = Math.max(maxCpu, containerResource.getCpu());
maxRam = maxRam.max(containerResource.getRam());
maxDisk = maxDisk.max(containerResource.getDisk());
}
return new Resource(maxCpu, maxRam, maxDisk);
} | [
"public",
"Resource",
"getMaxContainerResources",
"(",
")",
"{",
"double",
"maxCpu",
"=",
"0",
";",
"ByteAmount",
"maxRam",
"=",
"ByteAmount",
".",
"ZERO",
";",
"ByteAmount",
"maxDisk",
"=",
"ByteAmount",
".",
"ZERO",
";",
"for",
"(",
"ContainerPlan",
"containerPlan",
":",
"getContainers",
"(",
")",
")",
"{",
"Resource",
"containerResource",
"=",
"containerPlan",
".",
"getScheduledResource",
"(",
")",
".",
"or",
"(",
"containerPlan",
".",
"getRequiredResource",
"(",
")",
")",
";",
"maxCpu",
"=",
"Math",
".",
"max",
"(",
"maxCpu",
",",
"containerResource",
".",
"getCpu",
"(",
")",
")",
";",
"maxRam",
"=",
"maxRam",
".",
"max",
"(",
"containerResource",
".",
"getRam",
"(",
")",
")",
";",
"maxDisk",
"=",
"maxDisk",
".",
"max",
"(",
"containerResource",
".",
"getDisk",
"(",
")",
")",
";",
"}",
"return",
"new",
"Resource",
"(",
"maxCpu",
",",
"maxRam",
",",
"maxDisk",
")",
";",
"}"
] | Computes the maximum of all the resources required by the containers in the packing plan. If
the PackingPlan has already been scheduled, the scheduled resources will be used over the
required resources.
@return maximum Resources found in all containers. | [
"Computes",
"the",
"maximum",
"of",
"all",
"the",
"resources",
"required",
"by",
"the",
"containers",
"in",
"the",
"packing",
"plan",
".",
"If",
"the",
"PackingPlan",
"has",
"already",
"been",
"scheduled",
"the",
"scheduled",
"resources",
"will",
"be",
"used",
"over",
"the",
"required",
"resources",
"."
] | 776abe2b5a45b93a0eb957fd65cbc149d901a92a | https://github.com/apache/incubator-heron/blob/776abe2b5a45b93a0eb957fd65cbc149d901a92a/heron/spi/src/java/org/apache/heron/spi/packing/PackingPlan.java#L53-L66 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.