Search in sources :

Example 1 with BaseWorkerHook

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();
    }
}
Also used : ByteBuffer(java.nio.ByteBuffer) BaseWorkerHook(org.apache.storm.hooks.BaseWorkerHook)

Example 2 with BaseWorkerHook

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;
}
Also used : BaseWorkerHook(org.apache.storm.hooks.BaseWorkerHook)

Example 3 with BaseWorkerHook

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);
    }
}
Also used : WorkerTopologyContext(org.apache.storm.task.WorkerTopologyContext) ByteBuffer(java.nio.ByteBuffer) BaseWorkerHook(org.apache.storm.hooks.BaseWorkerHook)

Aggregations

BaseWorkerHook (org.apache.storm.hooks.BaseWorkerHook)3 ByteBuffer (java.nio.ByteBuffer)2 WorkerTopologyContext (org.apache.storm.task.WorkerTopologyContext)1