Java Code Examples for backtype.storm.task.TopologyContext.getThisComponentId()

The following are Jave code examples for showing how to use getThisComponentId() of the backtype.storm.task.TopologyContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: reddit-sentiment-storm   File: SummarizerBolt.java   Source Code and License Vote up 6 votes
public void prepare(Map conf, TopologyContext ctx, OutputCollector collector) {
	
	this.collector = collector;
	this.myId = ctx.getThisComponentId() + "-" + ctx.getThisTaskId();
	
	this.summary = new Summary();
	
	this.publisher = new ZkPublisher();
	try {
		this.publisher.init(conf);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	
	this.lastPublishedTimestamp = 0;
}
 
Example 2
Project: reddit-sentiment-storm   File: SentimentCalculatorBolt.java   Source Code and License Vote up 5 votes
public void prepare(Map conf, TopologyContext ctx, OutputCollector collector) {
	this.collector = collector;
	this.myId = ctx.getThisComponentId() + "-" + ctx.getThisTaskId();
	
	this.sentimentData = (Map<String, Long>) conf.get("sentimentData");
	if (this.sentimentData != null) {
		LOG.info("SentiCalcBolt " + myId + " has received sentimentData");
	}
}
 
Example 3
Project: storm-demo   File: SimpleFileNameFormat.java   Source Code and License Vote up 5 votes
@SuppressWarnings("unchecked")
@Override
public void prepare(Map conf, TopologyContext topologyContext) {
    this.componentId = topologyContext.getThisComponentId();
    this.taskId = topologyContext.getThisTaskId();
    try {
        this.host = Utils.localHostname();
    } catch (UnknownHostException e) {
        throw new RuntimeException(e);
    }
}
 
Example 4
Project: storm-demo   File: DefaultFileNameFormat.java   Source Code and License Vote up 4 votes
@Override
public void prepare(Map conf, TopologyContext topologyContext) {
    this.componentId = topologyContext.getThisComponentId();
    this.taskId = topologyContext.getThisTaskId();
}