Java Code Examples for backtype.storm.task.TopologyContext#getZkCluster()

The following examples show how to use backtype.storm.task.TopologyContext#getZkCluster() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopologyMasterContext.java    From jstorm with Apache License 2.0 6 votes vote down vote up
public TopologyMasterContext(Map stormConf, TopologyContext context,
                             final OutputCollector collector) {
    this.conf = context.getStormConf();
    this.context = context;
    this.collector = collector;
    this.taskId = context.getThisTaskId();
    this.topologyId = context.getTopologyId();
    this.zkCluster = context.getZkCluster();

    workerSet = new AtomicReference<>();
    try {
        Assignment assignment = zkCluster.assignment_info(topologyId, null);
        this.workerSet.set(assignment.getWorkers());
    } catch (Exception e) {
        LOG.error("Failed to get assignment for " + topologyId);
        throw new RuntimeException(e);
    }

    this.topologyMetricContext = new TopologyMetricContext(topologyId, workerSet.get(), conf);
}
 
Example 2
Source File: JStormUtils.java    From jstorm with Apache License 2.0 5 votes vote down vote up
public static void reportError(TopologyContext topologyContext, String errorMessge) {
    StormClusterState zkCluster = topologyContext.getZkCluster();
    String topologyId = topologyContext.getTopologyId();
    int taskId = topologyContext.getThisTaskId();

    try {
        zkCluster.report_task_error(topologyId, taskId, errorMessge);
    } catch (Exception e) {
        LOG.warn("Failed to report Error");
    }
}