本文整理汇总了Java中com.datatorrent.api.DAG.Locality.CONTAINER_LOCAL属性的典型用法代码示例。如果您正苦于以下问题:Java Locality.CONTAINER_LOCAL属性的具体用法?Java Locality.CONTAINER_LOCAL怎么用?Java Locality.CONTAINER_LOCAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.datatorrent.api.DAG.Locality
的用法示例。
在下文中一共展示了Locality.CONTAINER_LOCAL属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateDAG
@Override
public void populateDAG(DAG dag, Configuration conf)
{
locality = Locality.CONTAINER_LOCAL;
dag.getAttributes().put(DAG.STREAMING_WINDOW_SIZE_MILLIS, 1000);
SimpleSinglePortZeroMQPullStringInputOperator input = dag.addOperator("input", new SimpleSinglePortZeroMQPullStringInputOperator(addr));
ApacheLogParseOperator parse = dag.addOperator("parse", new ApacheLogParseOperator());
UniqueCounter<String> ipAddrCount = dag.addOperator("ipAddrCount", new UniqueCounter<String>());
UniqueCounter<String> urlCount = dag.addOperator("urlCount", new UniqueCounter<String>());
UniqueCounter<String> httpStatusCount = dag.addOperator("httpStatusCount", new UniqueCounter<String>());
Sum<Long> numOfBytesSum = dag.addOperator("numOfBytesSum", new Sum<Long>());
//ArrayListAggregator<Long> agg = dag.addOperator("agg", new ArrayListAggregator<Long>());
//dag.getOperatorWrapper(agg).getAttributes().put(OperatorContext.APPLICATION_WINDOW_COUNT, 3);
dag.getMeta(numOfBytesSum).getAttributes().put(OperatorContext.APPLICATION_WINDOW_COUNT, 3);
dag.addStream("input-parse", input.outputPort, parse.data).setLocality(locality);
dag.addStream("parse-ipAddrCount", parse.outputIPAddress, ipAddrCount.data).setLocality(locality);
dag.addStream("parse-urlCount", parse.outputUrl, urlCount.data).setLocality(locality);
dag.addStream("parse-httpStatusCount", parse.outputStatusCode, httpStatusCount.data).setLocality(locality);
dag.addStream("parse-numOfBytesSum", parse.outputBytes, numOfBytesSum.data).setLocality(locality);
//dag.addStream("numOfBytesSum-agg", numOfBytesSum.sumLong, agg.input);
ConsoleOutputOperator consoleOperator1 = dag.addOperator("console1", new ConsoleOutputOperator());
ConsoleOutputOperator consoleOperator2 = dag.addOperator("console2", new ConsoleOutputOperator());
ConsoleOutputOperator consoleOperator3 = dag.addOperator("console3", new ConsoleOutputOperator());
ConsoleOutputOperator consoleOperator4 = dag.addOperator("console4", new ConsoleOutputOperator());
dag.addStream("ipAddrCount-console", ipAddrCount.count, consoleOperator1.input);
dag.addStream("urlCount-console", urlCount.count, consoleOperator2.input);
dag.addStream("httpStatusCount-console", httpStatusCount.count, consoleOperator3.input);
//dag.addStream("agg-console", agg.output, consoleOperator4.input);
dag.addStream("numOfBytesSum-console", numOfBytesSum.sumLong, consoleOperator4.input);
}
示例2: addLogicalOperator
/**
* Add logical operator to the plan. Assumes that upstream operators have been added before.
* @param om
*/
public final void addLogicalOperator(OperatorMeta om)
{
PMapping pnodes = new PMapping(om);
String host = pnodes.logicalOperator.getValue(OperatorContext.LOCALITY_HOST);
localityPrefs.add(pnodes, host);
PMapping upstreamPartitioned = null;
for (Map.Entry<LogicalPlan.InputPortMeta, StreamMeta> e : om.getInputStreams().entrySet()) {
if (e.getValue().getSource().getOperatorMeta().getOperator() instanceof Operator.DelayOperator) {
continue;
}
PMapping m = logicalToPTOperator.get(e.getValue().getSource().getOperatorMeta());
if (e.getKey().getValue(PortContext.PARTITION_PARALLEL).equals(true)) {
// operator partitioned with upstream
if (upstreamPartitioned != null) {
// need to have common root
if (!upstreamPartitioned.parallelPartitions.contains(m.logicalOperator) && upstreamPartitioned != m) {
String msg = String.format("operator cannot extend multiple partitions (%s and %s)", upstreamPartitioned.logicalOperator, m.logicalOperator);
throw new AssertionError(msg);
}
}
m.parallelPartitions.add(pnodes.logicalOperator);
pnodes.parallelPartitions = m.parallelPartitions;
upstreamPartitioned = m;
}
if (Locality.CONTAINER_LOCAL == e.getValue().getLocality() || Locality.THREAD_LOCAL == e.getValue().getLocality()) {
inlinePrefs.setLocal(m, pnodes);
} else if (Locality.NODE_LOCAL == e.getValue().getLocality()) {
localityPrefs.setLocal(m, pnodes);
}
}
//
// create operator instances
//
this.logicalToPTOperator.put(om, pnodes);
if (upstreamPartitioned != null) {
// parallel partition
//LOG.debug("Operator {} should be partitioned to {} partitions", pnodes.logicalOperator.getName(), upstreamPartitioned.partitions.size());
initPartitioning(pnodes, upstreamPartitioned.partitions.size());
} else {
initPartitioning(pnodes, 0);
}
updateStreamMappings(pnodes);
}
示例3: getLocality
@Override
public Locality getLocality()
{
return Locality.CONTAINER_LOCAL;
}