use of org.apache.storm.hooks.BaseWorkerHook in project storm by apache.
the class WorkerState method runWorkerShutdownHooks.
public void runWorkerShutdownHooks() {
for (ByteBuffer hook : topology.get_worker_hooks()) {
byte[] hookBytes = Utils.toByteArray(hook);
BaseWorkerHook hookObject = Utils.javaDeserialize(hookBytes, BaseWorkerHook.class);
hookObject.shutdown();
}
}
use of org.apache.storm.hooks.BaseWorkerHook in project storm by apache.
the class ThriftTopologyUtilsTest method genereateStormTopology.
private StormTopology genereateStormTopology(boolean withWorkerHook) {
ImmutableMap<String, SpoutSpec> spouts = ImmutableMap.of("spout-1", new SpoutSpec());
ImmutableMap<String, Bolt> bolts = ImmutableMap.of("bolt-1", new Bolt());
ImmutableMap<String, StateSpoutSpec> state_spouts = ImmutableMap.of();
StormTopology stormTopology = new StormTopology(spouts, bolts, state_spouts);
if (withWorkerHook) {
BaseWorkerHook workerHook = new BaseWorkerHook();
stormTopology.add_to_worker_hooks(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));
}
return stormTopology;
}
use of org.apache.storm.hooks.BaseWorkerHook in project storm by apache.
the class WorkerState method runWorkerStartHooks.
public void runWorkerStartHooks() {
WorkerTopologyContext workerContext = getWorkerTopologyContext();
for (ByteBuffer hook : topology.get_worker_hooks()) {
byte[] hookBytes = Utils.toByteArray(hook);
BaseWorkerHook hookObject = Utils.javaDeserialize(hookBytes, BaseWorkerHook.class);
hookObject.start(topologyConf, workerContext);
}
}
Aggregations