Search in sources :

Example 1 with GlobalJobParameters

use of org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters in project flink by apache.

the class BoltWrapper method open.

@Override
public void open() throws Exception {
    super.open();
    this.flinkCollector = new TimestampedCollector<>(this.output);
    GlobalJobParameters config = getExecutionConfig().getGlobalJobParameters();
    StormConfig stormConfig = new StormConfig();
    if (config != null) {
        if (config instanceof StormConfig) {
            stormConfig = (StormConfig) config;
        } else {
            stormConfig.putAll(config.toMap());
        }
    }
    this.topologyContext = WrapperSetupHelper.createTopologyContext(getRuntimeContext(), this.bolt, this.name, this.stormTopology, stormConfig);
    final OutputCollector stormCollector = new OutputCollector(new BoltCollector<OUT>(this.numberOfAttributes, this.topologyContext.getThisTaskId(), this.flinkCollector));
    if (this.stormTopology != null) {
        Map<GlobalStreamId, Grouping> inputs = this.topologyContext.getThisSources();
        for (GlobalStreamId inputStream : inputs.keySet()) {
            for (Integer tid : this.topologyContext.getComponentTasks(inputStream.get_componentId())) {
                this.inputComponentIds.put(tid, inputStream.get_componentId());
                this.inputStreamIds.put(tid, inputStream.get_streamId());
                this.inputSchemas.put(tid, this.topologyContext.getComponentOutputFields(inputStream));
            }
        }
    }
    this.bolt.prepare(stormConfig, this.topologyContext, stormCollector);
}
Also used : StormConfig(org.apache.flink.storm.util.StormConfig) OutputCollector(org.apache.storm.task.OutputCollector) GlobalStreamId(org.apache.storm.generated.GlobalStreamId) Grouping(org.apache.storm.generated.Grouping) GlobalJobParameters(org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters)

Example 2 with GlobalJobParameters

use of org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters in project flink by apache.

the class SpoutWrapper method run.

@Override
public final void run(final SourceContext<OUT> ctx) throws Exception {
    final GlobalJobParameters config = super.getRuntimeContext().getExecutionConfig().getGlobalJobParameters();
    StormConfig stormConfig = new StormConfig();
    if (config != null) {
        if (config instanceof StormConfig) {
            stormConfig = (StormConfig) config;
        } else {
            stormConfig.putAll(config.toMap());
        }
    }
    final TopologyContext stormTopologyContext = WrapperSetupHelper.createTopologyContext((StreamingRuntimeContext) super.getRuntimeContext(), this.spout, this.name, this.stormTopology, stormConfig);
    SpoutCollector<OUT> collector = new SpoutCollector<OUT>(this.numberOfAttributes, stormTopologyContext.getThisTaskId(), ctx);
    this.spout.open(stormConfig, stormTopologyContext, new SpoutOutputCollector(collector));
    this.spout.activate();
    if (numberOfInvocations == null) {
        if (this.spout instanceof FiniteSpout) {
            final FiniteSpout finiteSpout = (FiniteSpout) this.spout;
            while (this.isRunning && !finiteSpout.reachedEnd()) {
                finiteSpout.nextTuple();
            }
        } else {
            while (this.isRunning) {
                this.spout.nextTuple();
            }
        }
    } else {
        int counter = this.numberOfInvocations;
        if (counter >= 0) {
            while ((--counter >= 0) && this.isRunning) {
                this.spout.nextTuple();
            }
        } else {
            do {
                collector.tupleEmitted = false;
                this.spout.nextTuple();
            } while (collector.tupleEmitted && this.isRunning);
        }
    }
}
Also used : StormConfig(org.apache.flink.storm.util.StormConfig) SpoutOutputCollector(org.apache.storm.spout.SpoutOutputCollector) TopologyContext(org.apache.storm.task.TopologyContext) GlobalJobParameters(org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters) FiniteSpout(org.apache.flink.storm.util.FiniteSpout)

Example 3 with GlobalJobParameters

use of org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters in project pinpoint by naver.

the class ApplicationStatBoWindow method open.

@Override
public void open(Configuration parameters) throws Exception {
    GlobalJobParameters globalJobParameters = getRuntimeContext().getExecutionConfig().getGlobalJobParameters();
    applicationStatBoWindowInterceptor = Bootstrap.getInstance(globalJobParameters.toMap()).getApplicationStatBoWindowInterceptor();
}
Also used : GlobalJobParameters(org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters)

Example 4 with GlobalJobParameters

use of org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters in project pinpoint by naver.

the class TBaseFlatMapper method open.

public void open(Configuration parameters) throws Exception {
    GlobalJobParameters globalJobParameters = getRuntimeContext().getExecutionConfig().getGlobalJobParameters();
    this.joinAgentStatBoMapper = new JoinAgentStatBoMapper();
    Bootstrap bootstrap = Bootstrap.getInstance(globalJobParameters.toMap());
    applicationCache = bootstrap.getApplicationCache();
    tBaseFlatMapperInterceptor = bootstrap.getTbaseFlatMapperInterceptor();
}
Also used : JoinAgentStatBoMapper(com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper) Bootstrap(com.navercorp.pinpoint.flink.Bootstrap) GlobalJobParameters(org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters)

Aggregations

GlobalJobParameters (org.apache.flink.api.common.ExecutionConfig.GlobalJobParameters)4 StormConfig (org.apache.flink.storm.util.StormConfig)2 Bootstrap (com.navercorp.pinpoint.flink.Bootstrap)1 JoinAgentStatBoMapper (com.navercorp.pinpoint.flink.mapper.thrift.stat.JoinAgentStatBoMapper)1 FiniteSpout (org.apache.flink.storm.util.FiniteSpout)1 GlobalStreamId (org.apache.storm.generated.GlobalStreamId)1 Grouping (org.apache.storm.generated.Grouping)1 SpoutOutputCollector (org.apache.storm.spout.SpoutOutputCollector)1 OutputCollector (org.apache.storm.task.OutputCollector)1 TopologyContext (org.apache.storm.task.TopologyContext)1