use of com.alibaba.jstorm.cluster.StormBase in project jstorm by alibaba.
the class RemoveTransitionCallback method execute.
@Override
public <T> Object execute(T... args) {
LOG.info("Begin to remove topology: " + topologyid);
try {
StormBase stormBase = data.getStormClusterState().storm_base(topologyid, null);
if (stormBase == null) {
LOG.info("Topology " + topologyid + " has been removed ");
return null;
}
data.getStormClusterState().remove_storm(topologyid);
data.getTasksHeartbeat().remove(topologyid);
data.getTaskHeartbeatsCache().remove(topologyid);
NimbusUtils.removeTopologyTaskTimeout(data, topologyid);
// delete topology files in blobstore
List<String> deleteKeys = BlobStoreUtils.getKeyListFromId(data, topologyid);
BlobStoreUtils.cleanup_keys(deleteKeys, data.getBlobStore(), data.getStormClusterState());
LOG.info("Successfully removed ZK items topology: " + topologyid);
} catch (Exception e) {
// TODO Auto-generated catch block
LOG.warn("Failed to remove StormBase " + topologyid + " from ZK", e);
}
return null;
}
use of com.alibaba.jstorm.cluster.StormBase in project jstorm by alibaba.
the class TopologyAssign method setTopologyStatus.
/**
* start a topology: set active status of the topology
*/
public void setTopologyStatus(TopologyAssignEvent event) throws Exception {
StormClusterState stormClusterState = nimbusData.getStormClusterState();
String topologyId = event.getTopologyId();
String topologyName = event.getTopologyName();
String group = event.getGroup();
StormStatus status = new StormStatus(StatusType.active);
if (event.getOldStatus() != null) {
status = event.getOldStatus();
}
boolean isEnable = ConfigExtension.isEnablePerformanceMetrics(nimbusData.getConf());
StormBase stormBase = stormClusterState.storm_base(topologyId, null);
if (stormBase == null) {
stormBase = new StormBase(topologyName, TimeUtils.current_time_secs(), status, group);
stormBase.setEnableMonitor(isEnable);
stormClusterState.activate_storm(topologyId, stormBase);
} else {
stormClusterState.update_storm(topologyId, status);
stormClusterState.set_storm_monitor(topologyId, isEnable);
// when monitor/rebalance/startup topologyName is null
if (topologyName == null) {
event.setTopologyName(stormBase.getStormName());
}
}
LOG.info("Update " + topologyId + " " + status);
}
use of com.alibaba.jstorm.cluster.StormBase in project jstorm by alibaba.
the class TaskHeartbeatUpdater method cleanup.
@Override
public void cleanup() {
try {
StormBase stormBase = zkCluster.storm_base(topologyId, null);
boolean isKilledStatus = stormBase != null && stormBase.getStatus().getStatusType().equals(StatusType.killed);
if (stormBase == null || isKilledStatus) {
// wait for pendings to exit
final long timeoutMilliSeconds = 1000 * ConfigExtension.getTaskCleanupTimeoutSec(stormConf);
final long start = System.currentTimeMillis();
while (true) {
try {
long delta = System.currentTimeMillis() - start;
if (delta > timeoutMilliSeconds) {
LOG.warn("Timeout when waiting others' tasks shutdown");
break;
}
if (checkAllTasksShutdown()) {
break;
}
Thread.sleep(100);
} catch (InterruptedException e) {
break;
}
}
LOG.info("notify nimbus that all tasks's status is: {} {} ", spoutsExecutorStatusMap.toString(), boltsExecutorStatusMap.toString());
if (client == null) {
client = new NimbusClientWrapper();
client.init(stormConf);
}
client.getClient().notifyThisTopologyTasksIsDead(topologyId);
}
} catch (Exception e) {
if (client != null) {
client.cleanup();
client = null;
}
LOG.warn("Failed to get topology stormbase from zk", e);
}
}
use of com.alibaba.jstorm.cluster.StormBase in project jstorm by alibaba.
the class ZooKeeperDataViewTest method viewTopology.
@Test
public void viewTopology() throws Exception {
if (SKIP == true) {
return;
}
List<String> assignments = zkobj.getChildren(zk, Cluster.STORMS_SUBTREE, false);
for (String child : assignments) {
byte[] data = zkobj.getData(zk, Cluster.storm_path(child), false);
StormBase stormBase = (StormBase) Utils.maybe_deserialize(data);
System.out.println(gson.toJson(stormBase));
}
}
Aggregations