• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OperatorContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.datatorrent.api.Context.OperatorContext的典型用法代码示例。如果您正苦于以下问题:Java OperatorContext类的具体用法?Java OperatorContext怎么用?Java OperatorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OperatorContext类属于com.datatorrent.api.Context包,在下文中一共展示了OperatorContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  OutputPort<?> unifierOutputPort = getOutputPort();
  unifierOutputPort.setSink(
      new Sink<Object>()
      {
        @Override
        public void put(Object tuple)
        {
          outputPort.emit(tuple);
        }

        @Override
        public int getCount(boolean reset)
        {
          return 0;
        }
      }
  );
  unifier.setup(context);
  spinMillis = context.getValue(OperatorContext.SPIN_MILLIS);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:24,代码来源:Slider.java


示例2: uriHelper

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
public static URI uriHelper(OperatorContext context, URI uri)
{
  if (uri == null) {
    if (context.getValue(DAG.GATEWAY_CONNECT_ADDRESS) == null) {
      throw new IllegalArgumentException("The uri property is not set and the dt.attr.GATEWAY_CONNECT_ADDRESS is not defined");
    }

    try {
      uri = PubSubHelper.getURI(context);
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }

  return uri;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:PubSubWebSocketAppDataQuery.java


示例3: purgeCheckpoints

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
private void purgeCheckpoints()
{
  for (Pair<PTOperator, Long> p : purgeCheckpoints) {
    final PTOperator operator = p.getFirst();
    if (!operator.isOperatorStateLess()) {
      final long windowId = p.getSecond();
      Runnable r = new Runnable()
      {
        @Override
        public void run()
        {
          try {
            operator.getOperatorMeta().getValue(OperatorContext.STORAGE_AGENT).delete(operator.getId(), windowId);
          } catch (IOException ex) {
            LOG.error("Failed to purge checkpoint for operator {} for windowId {}", operator, windowId, ex);
          }
        }
      };
      poolExecutor.submit(r);
    }
  }
  purgeCheckpoints.clear();
}
 
开发者ID:apache,项目名称:apex-core,代码行数:24,代码来源:StreamingContainerManager.java


示例4: starting

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
protected void starting(Description description)
{
  super.starting(description);
  TestUtils.deleteTargetTestClassFolder(description);
  try {
    FileUtils.forceMkdir(new File(getDir()));
    Attribute.AttributeMap.DefaultAttributeMap attributeMap = new Attribute.AttributeMap.DefaultAttributeMap();
    attributeMap.put(Context.DAGContext.CHECKPOINT_WINDOW_COUNT, 60);
    attributeMap.put(Context.OperatorContext.SPIN_MILLIS, 500);

    testOperatorContext = mockOperatorContext(0, attributeMap);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:AbstractFileOutputOperatorTest.java


示例5: testLinearOperatorRecovery

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
public void testLinearOperatorRecovery() throws Exception
{
  RecoverableInputOperator.initGenTuples();
  CollectorOperator.collection.clear();
  CollectorOperator.duplicates.clear();

  dag.getAttributes().put(LogicalPlan.CHECKPOINT_WINDOW_COUNT, 2);
  dag.getAttributes().put(LogicalPlan.STREAMING_WINDOW_SIZE_MILLIS, 300);
  dag.getAttributes().put(LogicalPlan.CONTAINERS_MAX_COUNT, 1);
  RecoverableInputOperator rip = dag.addOperator("LongGenerator", RecoverableInputOperator.class);
  rip.setMaximumTuples(maxTuples);
  rip.setSimulateFailure(true);

  CollectorOperator cm = dag.addOperator("LongCollector", CollectorOperator.class);
  cm.setSimulateFailure(true);
  dag.getMeta(cm).getAttributes().put(OperatorContext.PROCESSING_MODE, processingMode);

  dag.addStream("connection", rip.output, cm.input);

  StramLocalCluster lc = new StramLocalCluster(dag);
  lc.run();
}
 
开发者ID:apache,项目名称:apex-core,代码行数:23,代码来源:ProcessingModeTests.java


示例6: testJdbcInputOperator

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Test
public void testJdbcInputOperator()
{
  JdbcStore store = new JdbcStore();
  store.setDatabaseDriver(DB_DRIVER);
  store.setDatabaseUrl(URL);

  com.datatorrent.api.Attribute.AttributeMap.DefaultAttributeMap attributeMap = new com.datatorrent.api.Attribute.AttributeMap.DefaultAttributeMap();
  attributeMap.put(DAG.APPLICATION_ID, APP_ID);
  OperatorContext context = mockOperatorContext(OPERATOR_ID, attributeMap);

  TestInputOperator inputOperator = new TestInputOperator();
  inputOperator.setStore(store);
  insertEventsInTable(10);

  CollectorTestSink<Object> sink = new CollectorTestSink<>();
  inputOperator.outputPort.setSink(sink);

  inputOperator.setup(context);
  inputOperator.beginWindow(0);
  inputOperator.emitTuples();
  inputOperator.endWindow();

  Assert.assertEquals("rows from db", 10, sink.collectedTuples.size());
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:26,代码来源:JdbcPojoOperatorTest.java


示例7: TestAerospikeInputOperator

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Test
public void TestAerospikeInputOperator()
{
  AerospikeStore store = getStore();
  OperatorContext context = getOperatorContext(APP_ID);
  TestInputOperator inputOperator = new TestInputOperator();

  inputOperator.setStore(store);
  inputOperator.insertEventsInTable(NUM_TUPLES);

  CollectorTestSink<Object> sink = new CollectorTestSink<Object>();
  inputOperator.outputPort.setSink(sink);

  inputOperator.setup(context);
  inputOperator.beginWindow(0);
  inputOperator.emitTuples();
  inputOperator.endWindow();

  Assert.assertEquals("rows from db", NUM_TUPLES, sink.collectedTuples.size());
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:AerospikeOperatorTest.java


示例8: activate

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void activate(OperatorContext ctx)
{
  dataGeneratorThread = new Thread("String Generator")
  {
    @Override
    public void run()
    {
      try {
        int i = 0;
        while (dataGeneratorThread != null && i < maxTuple) {
          stringBuffer.put((++i) + "###testString " + i);
        }
        stringBuffer.put((maxTuple + 1) + "###" + KafkaOperatorTestBase.END_TUPLE);
      } catch (InterruptedException ie) {
        //
      }
    }
  };
  dataGeneratorThread.start();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:22,代码来源:KafkaExactlyOnceOutputOperatorTest.java


示例9: testValidInputOperatorDeployInfoType

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Test
public void testValidInputOperatorDeployInfoType()
{
  TestGeneratorInputOperator.ValidInputOperator o1 = dag.addOperator("o1", TestGeneratorInputOperator.ValidInputOperator.class);
  GenericTestOperator o2 = dag.addOperator("o2", GenericTestOperator.class);

  dag.addStream("stream1", o1.outport, o2.inport1);

  dag.setAttribute(OperatorContext.STORAGE_AGENT, new MemoryStorageAgent());
  StreamingContainerManager scm = new StreamingContainerManager(dag);

  PhysicalPlan physicalPlan = scm.getPhysicalPlan();
  List<PTContainer> containers = physicalPlan.getContainers();
  for (int i = 0; i < containers.size(); ++i) {
    assignContainer(scm, "container" + (i + 1));
  }
  OperatorMeta o1Meta = dag.getMeta(o1);
  PTOperator o1Physical = physicalPlan.getOperators(o1Meta).get(0);

  String containerId = o1Physical.getContainer().getExternalId();

  OperatorDeployInfo o1DeployInfo = getDeployInfo(scm.getContainerAgent(containerId)).get(0);
  Assert.assertEquals("type " + o1DeployInfo, OperatorDeployInfo.OperatorType.INPUT, o1DeployInfo.type);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:25,代码来源:StreamingContainerManagerTest.java


示例10: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  try {
    fs = getHDFSInstance();
  } catch (IOException ex) {
    throw new RuntimeException(ex);
  }

  this.context = context;
  lastTimeStamp = System.currentTimeMillis();

  fileCounters.setCounter(Counters.TOTAL_BYTES_WRITTEN, new MutableLong());
  fileCounters.setCounter(Counters.TOTAL_TIME_ELAPSED, new MutableLong());
  super.setup(context);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:HiveOperator.java


示例11: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * Initialize various map and list fields
 */
@Override
public void setup(OperatorContext context)
{
  if (null == wordMapFile) {
    wordMapFile = new HashMap<>();
  }
  if (null == wordMapGlobal) {
    wordMapGlobal = new HashMap<>();
  }
  resultPerFile = new ArrayList(1);
  resultGlobal = new ArrayList(1);
  // singleton map {<fileName> => fileFinalList}; cannot populate it yet since we need fileName
  resultFileFinal = new HashMap<>(1);
  fileFinalList = new ArrayList<>();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:20,代码来源:FileWordCount.java


示例12: testNumberOfUnifiersWithEvenPartitions

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Test
public void testNumberOfUnifiersWithEvenPartitions()
{
  LogicalPlan dag = new LogicalPlan();
  dag.setAttribute(OperatorContext.STORAGE_AGENT, new StramTestSupport.MemoryStorageAgent());
  GenericTestOperator node1 = dag.addOperator("node1", GenericTestOperator.class);
  GenericTestOperator node2 = dag.addOperator("node2", GenericTestOperator.class);
  dag.addStream("node1.outport1", node1.outport1, node2.inport1);
  dag.setOperatorAttribute(node1, OperatorContext.PARTITIONER, new StatelessPartitioner<GenericTestOperator>(8));
  dag.setOutputPortAttribute(node1.outport1, PortContext.UNIFIER_LIMIT, 4);
  PhysicalPlan plan = new PhysicalPlan(dag, new TestPlanContext());
  List<PTContainer> containers = plan.getContainers();
  int unifierCount = 0;
  int totalOperators = 0;
  for (PTContainer container : containers) {
    List<PTOperator> operators = container.getOperators();
    for (PTOperator operator : operators) {
      totalOperators++;
      if (operator.isUnifier()) {
        unifierCount++;
      }
    }
  }
  Assert.assertEquals("Number of operators", 12, totalOperators);
  Assert.assertEquals("Number of unifiers", 3, unifierCount);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:27,代码来源:PhysicalPlanTest.java


示例13: populateDAG

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
  String filePath = "HDFSOutputOperatorBenchmarkingApp/"
      + System.currentTimeMillis();

  dag.setAttribute(DAG.STREAMING_WINDOW_SIZE_MILLIS, 1000);

  RandomWordGenerator wordGenerator = dag.addOperator("wordGenerator", RandomWordGenerator.class);

  dag.getOperatorMeta("wordGenerator").getMeta(wordGenerator.output)
      .getAttributes().put(PortContext.QUEUE_CAPACITY, 10000);
  dag.getOperatorMeta("wordGenerator").getAttributes()
      .put(OperatorContext.APPLICATION_WINDOW_COUNT, 1);

  FSByteOutputOperator hdfsOutputOperator = dag.addOperator("hdfsOutputOperator", new FSByteOutputOperator());
  hdfsOutputOperator.setFilePath(filePath);
  dag.getOperatorMeta("hdfsOutputOperator").getAttributes()
      .put(OperatorContext.COUNTERS_AGGREGATOR, new BasicCounters.LongAggregator<MutableLong>());

  dag.addStream("Generator2HDFSOutput", wordGenerator.output, hdfsOutputOperator.input);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:FSOutputOperatorBenchmark.java


示例14: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void setup(OperatorContext context) {
  this.traceTuples =
      ApexStreamTuple.Logging.isDebugEnabled(
          pipelineOptions.get().as(ApexPipelineOptions.class), this);
  try {
    reader = source.createReader(this.pipelineOptions.get(), null);
    available = reader.start();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:13,代码来源:ApexReadUnboundedInputOperator.java


示例15: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void setup(OperatorContext ctx)
{
  context = ZMQ.context(1);
  subscriber = context.socket(ZMQ.SUB);
  subscriber.connect(url);
  subscriber.subscribe(filter.getBytes());
  syncclient = context.socket(ZMQ.REQ);
  syncclient.connect(syncUrl);
  syncclient.send("".getBytes(), 0);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:12,代码来源:AbstractBaseZeroMQInputOperator.java


示例16: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  sc = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
  for (String s : setupScripts) {
    EvalUnit unit = sc.parse(s);
    unit.run();
  }
  if (type == Type.EVAL) {
    unit = sc.parse(script);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:13,代码来源:RubyOperator.java


示例17: setup

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  super.setup(context);
  try {
    queryStatement = store.getConnection().createStatement();
  } catch (SQLException e) {
    throw new RuntimeException("creating query", e);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:11,代码来源:AbstractJdbcInputOperator.java


示例18: syncCheckpoints

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
/**
 * Read available checkpoints from storage agent for all operators.
 * @param startTime
 * @param currentTime
 * @throws IOException
 */
public void syncCheckpoints(long startTime, long currentTime) throws IOException
{
  for (PTOperator oper : getAllOperators().values()) {
    StorageAgent sa = oper.operatorMeta.getValue(OperatorContext.STORAGE_AGENT);
    long[] windowIds = sa.getWindowIds(oper.getId());
    Arrays.sort(windowIds);
    oper.checkpoints.clear();
    for (long wid : windowIds) {
      if (wid != Stateless.WINDOW_ID) {
        oper.addCheckpoint(wid, startTime);
      }
    }
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:21,代码来源:PhysicalPlan.java


示例19: isOperatorStateLess

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
public boolean isOperatorStateLess()
{
  if (operatorMeta.getDAG().getValue(OperatorContext.STATELESS) || operatorMeta.getValue(OperatorContext.STATELESS)) {
    return true;
  }

  return operatorMeta.getOperator().getClass().isAnnotationPresent(Stateless.class);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:9,代码来源:PTOperator.java


示例20: cleanUp

import com.datatorrent.api.Context.OperatorContext; //导入依赖的package包/类
private void cleanUp(Context.OperatorContext operatorContext)
{
  FSWindowDataManager windowDataManager = new FSWindowDataManager();
  windowDataManager.setup(operatorContext);
  try {
    windowDataManager.committed(windowDataManager.getLargestCompletedWindow());
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:11,代码来源:KafkaOutputOperatorTest.java



注:本文中的com.datatorrent.api.Context.OperatorContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Classes类代码示例发布时间:2022-05-22
下一篇:
Java MENetworkPowerStatusChange类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap