public class TopologyContext extends WorkerTopologyContext implements IMetricsContext
The `TopologyContext` is also used to declare `ISubscribedState` objects to synchronize state with StateSpouts this object is subscribed to.
SHARED_EXECUTOR
doSanityCheck, topoConf
Constructor and Description |
---|
TopologyContext(StormTopology topology,
Map<String,Object> topoConf,
Map<Integer,String> taskToComponent,
Map<String,List<Integer>> componentToSortedTasks,
Map<String,Map<String,Fields>> componentToStreamToFields,
Map<String,Long> blobToLastKnownVersionShared,
String stormId,
String codeDir,
String pidDir,
Integer taskId,
Integer workerPort,
List<Integer> workerTasks,
Map<String,Object> defaultResources,
Map<String,Object> userResources,
Map<String,Object> executorData,
Map<Integer,Map<Integer,Map<String,IMetric>>> registeredMetrics,
AtomicBoolean openOrPrepareWasCalled,
StormMetricRegistry metricRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
addTaskHook(ITaskHook hook) |
Map<String,Long> |
getBlobToLastKnownVersion() |
Object |
getExecutorData(String name) |
List<ITaskHook> |
getHooks() |
IMetric |
getRegisteredMetricByName(String name)
Deprecated.
|
Object |
getTaskData(String name) |
String |
getThisComponentId()
Get component id.
|
Map<String,Map<String,List<String>>> |
getThisInputFields()
Gets the declared input fields for this component.
|
Fields |
getThisOutputFields(String streamId)
Gets the declared output fields for the specified stream id for the component this task is a part of.
|
Map<String,List<String>> |
getThisOutputFieldsForStreams()
Gets the declared output fields for all streams for the component this task is a part of.
|
Map<GlobalStreamId,Grouping> |
getThisSources()
Gets the declared inputs to this component.
|
Set<String> |
getThisStreams()
Gets the set of streams declared for the component of this task.
|
Map<String,Map<String,Grouping>> |
getThisTargets()
Gets information about who is consuming the outputs of this component, and how.
|
int |
getThisTaskId()
Gets the task id of this task.
|
int |
getThisTaskIndex()
Gets the index of this task id in getComponentTasks(getThisComponentId()).
|
com.codahale.metrics.Counter |
registerCounter(String name) |
<T> com.codahale.metrics.Gauge<T> |
registerGauge(String name,
com.codahale.metrics.Gauge<T> gauge) |
com.codahale.metrics.Histogram |
registerHistogram(String name) |
com.codahale.metrics.Meter |
registerMeter(String name) |
CombinedMetric |
registerMetric(String name,
ICombiner combiner,
int timeBucketSizeInSecs)
Deprecated.
|
ReducedMetric |
registerMetric(String name,
IReducer reducer,
int timeBucketSizeInSecs)
Deprecated.
|
<T extends IMetric> |
registerMetric(String name,
T metric,
int timeBucketSizeInSecs)
Deprecated.
|
void |
registerMetricSet(String prefix,
com.codahale.metrics.MetricSet set) |
com.codahale.metrics.Timer |
registerTimer(String name) |
<T extends ISubscribedState> |
setAllSubscribedState(T obj)
All state from all subscribed state spouts streams will be synced with the provided object.
|
void |
setExecutorData(String name,
Object data) |
<T extends ISubscribedState> |
setSubscribedState(String componentId,
String streamId,
T obj)
Synchronizes the specified stream from the specified state spout component id with the provided ISubscribedState object.
|
<T extends ISubscribedState> |
setSubscribedState(String componentId,
T obj)
Synchronizes the default stream from the specified state spout component id with the provided ISubscribedState object.
|
void |
setTaskData(String name,
Object data) |
String |
toJSONString() |
getAssignmentId, getCodeDir, getNodeToHost, getPIDDir, getResource, getSharedExecutor, getTaskToNodePort, getThisWorkerPort, getThisWorkerTasks
doSanityCheck, getComponentCommon, getComponentId, getComponentIds, getComponentOutputFields, getComponentOutputFields, getComponentStreams, getComponentTasks, getConf, getRawTopology, getSources, getStormId, getTargets, getTaskToComponent, maxTopologyMessageTimeout
public TopologyContext(StormTopology topology, Map<String,Object> topoConf, Map<Integer,String> taskToComponent, Map<String,List<Integer>> componentToSortedTasks, Map<String,Map<String,Fields>> componentToStreamToFields, Map<String,Long> blobToLastKnownVersionShared, String stormId, String codeDir, String pidDir, Integer taskId, Integer workerPort, List<Integer> workerTasks, Map<String,Object> defaultResources, Map<String,Object> userResources, Map<String,Object> executorData, Map<Integer,Map<Integer,Map<String,IMetric>>> registeredMetrics, AtomicBoolean openOrPrepareWasCalled, StormMetricRegistry metricRegistry)
public <T extends ISubscribedState> T setAllSubscribedState(T obj)
It is recommended that your ISubscribedState object is kept as an instance variable of this object. The recommended usage of this method is as follows:
```java _myState = context.setAllSubscribedState(new MyState()); ```
obj
- Provided ISubscribedState implementationpublic <T extends ISubscribedState> T setSubscribedState(String componentId, T obj)
The recommended usage of this method is as follows:
```java _myState = context.setSubscribedState(componentId, new MyState()); ```
componentId
- the id of the StateSpout component to subscribe toobj
- Provided ISubscribedState implementationpublic <T extends ISubscribedState> T setSubscribedState(String componentId, String streamId, T obj)
The recommended usage of this method is as follows:
```java _myState = context.setSubscribedState(componentId, streamId, new MyState()); ```
componentId
- the id of the StateSpout component to subscribe tostreamId
- the stream to subscribe toobj
- Provided ISubscribedState implementationpublic int getThisTaskId()
public String getThisComponentId()
public Fields getThisOutputFields(String streamId)
public Map<String,List<String>> getThisOutputFieldsForStreams()
public Set<String> getThisStreams()
public int getThisTaskIndex()
public Map<String,Map<String,List<String>>> getThisInputFields()
public Map<GlobalStreamId,Grouping> getThisSources()
public Map<String,Map<String,Grouping>> getThisTargets()
public void addTaskHook(ITaskHook hook)
public String toJSONString()
toJSONString
in interface org.apache.storm.shade.org.json.simple.JSONAware
toJSONString
in class GeneralTopologyContext
@Deprecated public <T extends IMetric> T registerMetric(String name, T metric, int timeBucketSizeInSecs)
IMetricsContext
registerMetric
in interface IMetricsContext
@Deprecated public ReducedMetric registerMetric(String name, IReducer reducer, int timeBucketSizeInSecs)
IMetricsContext
registerMetric
in interface IMetricsContext
@Deprecated public CombinedMetric registerMetric(String name, ICombiner combiner, int timeBucketSizeInSecs)
IMetricsContext
registerMetric
in interface IMetricsContext
@Deprecated public IMetric getRegisteredMetricByName(String name)
public com.codahale.metrics.Timer registerTimer(String name)
registerTimer
in interface IMetricsContext
public com.codahale.metrics.Histogram registerHistogram(String name)
registerHistogram
in interface IMetricsContext
public com.codahale.metrics.Meter registerMeter(String name)
registerMeter
in interface IMetricsContext
public com.codahale.metrics.Counter registerCounter(String name)
registerCounter
in interface IMetricsContext
public <T> com.codahale.metrics.Gauge<T> registerGauge(String name, com.codahale.metrics.Gauge<T> gauge)
registerGauge
in interface IMetricsContext
public void registerMetricSet(String prefix, com.codahale.metrics.MetricSet set)
registerMetricSet
in interface IMetricsContext
Copyright © 2023 The Apache Software Foundation. All rights reserved.