Search in sources :

Example 1 with IMetricsRegistrant

use of org.apache.storm.metric.api.IMetricsRegistrant in project storm by apache.

the class BoltExecutor method init.

public void init(ArrayList<Task> idToTask, int idToTaskBase) throws InterruptedException {
    executorTransfer.initLocalRecvQueues();
    workerReady.await();
    while (!stormActive.get()) {
        // Topology may be deployed in deactivated mode, wait for activation
        Utils.sleepNoSimulation(100);
    }
    LOG.info("Preparing bolt {}:{}", componentId, getTaskIds());
    for (Task taskData : idToTask) {
        if (taskData == null) {
            // This happens if the min id is too small
            continue;
        }
        IBolt boltObject = (IBolt) taskData.getTaskObject();
        TopologyContext userContext = taskData.getUserContext();
        if (boltObject instanceof ICredentialsListener) {
            ((ICredentialsListener) boltObject).setCredentials(credentials);
        }
        if (Constants.SYSTEM_COMPONENT_ID.equals(componentId)) {
            BuiltinMetricsUtil.registerIconnectionServerMetric(workerData.getReceiver(), topoConf, userContext);
            // add any autocredential expiry metrics from the worker
            if (workerData.getAutoCredentials() != null) {
                for (IAutoCredentials autoCredential : workerData.getAutoCredentials()) {
                    if (autoCredential instanceof IMetricsRegistrant) {
                        IMetricsRegistrant registrant = (IMetricsRegistrant) autoCredential;
                        registrant.registerMetrics(userContext, topoConf);
                    }
                }
            }
        }
        this.outputCollector = new BoltOutputCollectorImpl(this, taskData, rand, hasEventLoggers, ackingEnabled, isDebug);
        boltObject.prepare(topoConf, userContext, new OutputCollector(outputCollector));
    }
    openOrPrepareWasCalled.set(true);
    LOG.info("Prepared bolt {}:{}", componentId, taskIds);
    setupTicks(false);
    setupMetrics();
}
Also used : OutputCollector(org.apache.storm.task.OutputCollector) Task(org.apache.storm.daemon.Task) ICredentialsListener(org.apache.storm.ICredentialsListener) IAutoCredentials(org.apache.storm.security.auth.IAutoCredentials) IMetricsRegistrant(org.apache.storm.metric.api.IMetricsRegistrant) IBolt(org.apache.storm.task.IBolt) TopologyContext(org.apache.storm.task.TopologyContext)

Aggregations

ICredentialsListener (org.apache.storm.ICredentialsListener)1 Task (org.apache.storm.daemon.Task)1 IMetricsRegistrant (org.apache.storm.metric.api.IMetricsRegistrant)1 IAutoCredentials (org.apache.storm.security.auth.IAutoCredentials)1 IBolt (org.apache.storm.task.IBolt)1 OutputCollector (org.apache.storm.task.OutputCollector)1 TopologyContext (org.apache.storm.task.TopologyContext)1