Search in sources :

Example 6 with StormBase

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;
}
Also used : StormBase(com.alibaba.jstorm.cluster.StormBase)

Example 7 with StormBase

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);
}
Also used : StormClusterState(com.alibaba.jstorm.cluster.StormClusterState) StormStatus(com.alibaba.jstorm.cluster.StormStatus) StormBase(com.alibaba.jstorm.cluster.StormBase)

Example 8 with StormBase

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);
    }
}
Also used : NimbusClientWrapper(backtype.storm.utils.NimbusClientWrapper) StormBase(com.alibaba.jstorm.cluster.StormBase)

Example 9 with StormBase

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));
    }
}
Also used : StormBase(com.alibaba.jstorm.cluster.StormBase) Test(org.junit.Test)

Aggregations

StormBase (com.alibaba.jstorm.cluster.StormBase)9 StormClusterState (com.alibaba.jstorm.cluster.StormClusterState)3 TopologySummary (backtype.storm.generated.TopologySummary)2 StormStatus (com.alibaba.jstorm.cluster.StormStatus)2 Assignment (com.alibaba.jstorm.schedule.Assignment)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 TException (org.apache.thrift.TException)2 AlreadyAliveException (backtype.storm.generated.AlreadyAliveException)1 ComponentSummary (backtype.storm.generated.ComponentSummary)1 ErrorInfo (backtype.storm.generated.ErrorInfo)1 InvalidTopologyException (backtype.storm.generated.InvalidTopologyException)1 KeyAlreadyExistsException (backtype.storm.generated.KeyAlreadyExistsException)1 KeyNotFoundException (backtype.storm.generated.KeyNotFoundException)1 MetricInfo (backtype.storm.generated.MetricInfo)1 NotAliveException (backtype.storm.generated.NotAliveException)1 TaskHeartbeat (backtype.storm.generated.TaskHeartbeat)1 TaskSummary (backtype.storm.generated.TaskSummary)1