本文整理汇总了Java中com.datatorrent.api.Context.PortContext类的典型用法代码示例。如果您正苦于以下问题:Java PortContext类的具体用法?Java PortContext怎么用?Java PortContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PortContext类属于com.datatorrent.api.Context包,在下文中一共展示了PortContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNumberOfUnifiers
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Test
public void testNumberOfUnifiers()
{
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>(5));
dag.setOutputPortAttribute(node1.outport1, PortContext.UNIFIER_LIMIT, 3);
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", 8, totalOperators);
Assert.assertEquals("Number of unifiers", 2, unifierCount);
}
示例2: testNumberOfUnifiersWithEvenPartitions
import com.datatorrent.api.Context.PortContext; //导入依赖的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);
}
示例3: testParallelPartitionForSlidingWindow
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Test
public void testParallelPartitionForSlidingWindow()
{
LogicalPlan dag = new LogicalPlan();
dag.setAttribute(OperatorContext.STORAGE_AGENT, new StramTestSupport.MemoryStorageAgent());
GenericTestOperator o1 = dag.addOperator("o1", GenericTestOperator.class);
GenericTestOperator o2 = dag.addOperator("o2", GenericTestOperator.class);
GenericTestOperator o3 = dag.addOperator("o3", GenericTestOperator.class);
dag.setOperatorAttribute(o1, OperatorContext.SLIDE_BY_WINDOW_COUNT, 2);
dag.setOperatorAttribute(o1, OperatorContext.PARTITIONER, new StatelessPartitioner<>(2));
dag.setInputPortAttribute(o2.inport1, PortContext.PARTITION_PARALLEL, true);
dag.setOperatorAttribute(o1, OperatorContext.APPLICATION_WINDOW_COUNT, 4);
dag.addStream("o1.outport1", o1.outport1, o2.inport1);
dag.addStream("o2.outport1", o2.outport1, o3.inport1);
PhysicalPlan plan = new PhysicalPlan(dag, new TestPlanContext());
Assert.assertEquals("number of containers", 7, plan.getContainers().size());
}
示例4: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
// RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
// rand.setMinvalue(0);
// rand.setMaxvalue(999999);
// rand.setTuplesBlastIntervalMillis(50);
// dag.getMeta(rand).getMeta(rand.integer_data).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
IntegerOperator intInput = dag.addOperator("intInput", new IntegerOperator());
StreamDuplicater stream = dag.addOperator("stream", new StreamDuplicater());
dag.getMeta(stream).getMeta(stream.data).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
dag.addStream("streamdup1", intInput.integer_data, stream.data).setLocality(locality);
DevNull<Integer> dev1 = dag.addOperator("dev1", new DevNull());
DevNull<Integer> dev2 = dag.addOperator("dev2", new DevNull());
dag.addStream("streamdup2", stream.out1, dev1.data).setLocality(locality);
dag.addStream("streamdup3", stream.out2, dev2.data).setLocality(locality);
}
示例5: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
rand.setMaxvalue(3000);
rand.setTuplesBlast(120);
RandomMapOutput randMap = dag.addOperator("randMap", new RandomMapOutput());
randMap.setKey("val");
RubyOperator ruby = dag.addOperator("ruby", new RubyOperator());
String setupScript = "def square(val)\n";
setupScript += " return val*val\nend\n";
ruby.addSetupScript(setupScript);
ruby.setInvoke("square");
ruby.setPassThru(true);
ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
dag.getMeta(console).getMeta(console.input).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
dag.getMeta(ruby).getMeta(ruby.result).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
dag.addStream("rand_randMap", rand.integer_data, randMap.input).setLocality(Locality.THREAD_LOCAL);
dag.addStream("randMap_ruby", randMap.map_data, ruby.inBindings).setLocality(locality);
dag.addStream("ruby_console", ruby.result, console.input).setLocality(locality);
}
示例6: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的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);
}
示例7: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
WordCountOperator<HashMap<String, Double>> counterString =
dag.addOperator("counterString", new WordCountOperator<HashMap<String, Double>>());
dag.getMeta(counterString).getMeta(counterString.input).getAttributes()
.put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
EventClassifierNumberToHashDouble eventClassify =
dag.addOperator("eventClassify", new EventClassifierNumberToHashDouble());
dag.getMeta(eventClassify).getMeta(eventClassify.data)
.getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
IntegerOperator intInput = dag.addOperator("intInput", new IntegerOperator());
dag.addStream("eventclassifier2", intInput.integer_data, eventClassify.event).setLocality(locality);
dag.addStream("eventclassifier1", eventClassify.data, counterString.input).setLocality(locality);
}
示例8: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
EventGenerator eventGenerator = dag.addOperator("eventGenerator", new EventGenerator());
dag.getMeta(eventGenerator).getMeta(eventGenerator.count).getAttributes()
.put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
DevNull<String> devString = dag.addOperator("devString", new DevNull());
DevNull<HashMap<String, Double>> devMap = dag.addOperator("devMap", new DevNull());
DevNull<HashMap<String, Number>> devInt = dag.addOperator("devInt", new DevNull());
dag.addStream("EventGenString", eventGenerator.string_data, devString.data).setLocality(locality);
dag.addStream("EventGenMap", eventGenerator.hash_data, devMap.data).setLocality(locality);
dag.addStream("EventGenInt", eventGenerator.count, devInt.data).setLocality(locality);
}
示例9: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
JsonGenerator generator = dag.addOperator("JsonGenerator", JsonGenerator.class);
JsonParser jsonParser = dag.addOperator("jsonParser", JsonParser.class);
CsvFormatter formatter = dag.addOperator("formatter", CsvFormatter.class);
formatter.setSchema(SchemaUtils.jarResourceFileToString(filename));
dag.setInputPortAttribute(formatter.in, PortContext.TUPLE_CLASS, PojoEvent.class);
HDFSOutputOperator<String> hdfsOutput = dag.addOperator("HDFSOutputOperator", HDFSOutputOperator.class);
hdfsOutput.setLineDelimiter("");
dag.addStream("parserStream", generator.out, jsonParser.in);
dag.addStream("formatterStream", jsonParser.out, formatter.in);
dag.addStream("outputStream", formatter.out, hdfsOutput.input);
}
示例10: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
JdbcPOJOPollInputOperator poller = dag.addOperator("JdbcPoller", new JdbcPOJOPollInputOperator());
JdbcStore store = new JdbcStore();
poller.setStore(store);
poller.setFieldInfos(addFieldInfos());
FileLineOutputOperator writer = dag.addOperator("Writer", new FileLineOutputOperator());
dag.setInputPortAttribute(writer.input, PortContext.PARTITION_PARALLEL, true);
writer.setRotationWindows(60);
dag.addStream("dbrecords", poller.outputPort, writer.input);
}
示例11: setup
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
public void setup(PortContext context)
{
jsonParser = new JSONParser();
finder = new JsonKeyFinder();
columnFields = new ArrayList<String>();
columnFieldSetters = Lists.newArrayList();
setPojoClass(context.getValue(Context.PortContext.TUPLE_CLASS));
if (getFieldMappingString() == null) {
setFieldInfos(createFieldInfoMap(generateFieldInfoInputs(getPojoClass())));
} else {
setFieldInfos(createFieldInfoMap(getFieldMappingString()));
}
initColumnFieldSetters(getFieldInfos());
initializeActiveFieldSetters();
ListIterator<FieldInfo> itr = fieldInfos.listIterator();
while (itr.hasNext()) {
columnFields.add(itr.next().getColumnName());
}
finder.setMatchKeyList(columnFields);
}
示例12: setup
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
public void setup(PortContext context)
{
setPojoClass(context.getValue(Context.PortContext.TUPLE_CLASS));
columnFieldSetters = Lists.newArrayList();
/**
* Check if the mapping of Generic record fields to POJO is given, else
* use reflection
*/
if (getGenericRecordToPOJOFieldsMapping() == null) {
setFieldInfos(createFieldInfoMap(generateFieldInfoInputs(getPojoClass())));
} else {
setFieldInfos(createFieldInfoMap(getGenericRecordToPOJOFieldsMapping()));
}
initColumnFieldSetters(getFieldInfos());
initializeActiveFieldSetters();
}
示例13: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
BlockWriter blockWriter = dag.addOperator("BlockWriter", new BlockWriter());
Synchronizer synchronizer = dag.addOperator("BlockSynchronizer", new Synchronizer());
dag.setInputPortAttribute(blockWriter.input, PortContext.PARTITION_PARALLEL, true);
dag.setInputPortAttribute(blockWriter.blockMetadataInput, PortContext.PARTITION_PARALLEL, true);
dag.addStream("CompletedBlockmetadata", blockWriter.blockMetadataOutput, synchronizer.blocksMetadataInput);
HDFSFileMerger merger = new HDFSFileMerger();
merger = dag.addOperator("FileMerger", merger);
dag.addStream("MergeTrigger", synchronizer.trigger, merger.input);
merger.setFilePath(outputDirectoryPath);
merger.setOverwriteOnConflict(overwriteOnConflict);
blockWriter.setBlocksDirectory(blocksDirectory);
merger.setBlocksDirectory(blocksDirectory);
filesMetadataInput.set(synchronizer.filesMetadataInput);
blocksMetadataInput.set(blockWriter.blockMetadataInput);
blockData.set(blockWriter.input);
}
示例14: populateDAG
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
@Override
public void populateDAG(DAG dag, Configuration conf)
{
TestStatsListener sl = new TestStatsListener();
sl.adjustRate = conf.getBoolean("dt.hdsbench.adjustRate", false);
TestGenerator gen = dag.addOperator("Generator", new TestGenerator());
dag.setAttribute(gen, OperatorContext.STATS_LISTENERS, Lists.newArrayList((StatsListener)sl));
TestStoreOperator store = dag.addOperator("Store", new TestStoreOperator());
dag.setAttribute(store, OperatorContext.STATS_LISTENERS, Lists.newArrayList((StatsListener)sl));
FileAccessFSImpl hfa = new HFileImpl();
hfa.setBasePath(this.getClass().getSimpleName());
store.setFileStore(hfa);
dag.setInputPortAttribute(store.input, PortContext.PARTITION_PARALLEL, true);
dag.getOperatorMeta("Store").getAttributes().put(Context.OperatorContext.COUNTERS_AGGREGATOR,
new HDHTWriter.BucketIOStatAggregator());
dag.addStream("Events", gen.data, store.input).setLocality(Locality.THREAD_LOCAL);
}
示例15: setup
import com.datatorrent.api.Context.PortContext; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void setup(PortContext context)
{
if (Boolean.getBoolean(THREAD_AFFINITY_DISABLE_CHECK) == false) {
operatorThread = Thread.currentThread();
logger.debug("Enforcing emit on {}", operatorThread.getName());
}
}