本文整理汇总了Java中com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions.operatorProvider方法的典型用法代码示例。如果您正苦于以下问题:Java EPDataFlowInstantiationOptions.operatorProvider方法的具体用法?Java EPDataFlowInstantiationOptions.operatorProvider怎么用?Java EPDataFlowInstantiationOptions.operatorProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions
的用法示例。
在下文中一共展示了EPDataFlowInstantiationOptions.operatorProvider方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runAssertion
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
private void runAssertion(String typeName, Object[] events, boolean append) throws Exception {
// test classpath file
String filename = "regression/out_1.csv";
FileUtil.findDeleteClasspathFile(filename);
String graph = "create dataflow WriteCSV " +
"DefaultSupportSourceOp -> instream<" + typeName + ">{}" +
"FileSink(instream) { file: '" + filename + "', classpathFile: true, append: " + append + "}";
EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);
DefaultSupportSourceOp source = new DefaultSupportSourceOp(events);
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(source));
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("WriteCSV", options);
instance.run();
String[] contents = FileUtil.readClasspathTextFile(filename);
EPAssertionUtil.assertEqualsExactOrder("1.1,1,\"one\";2.2,2,\"two\"".split(";"), contents);
FileUtil.findDeleteClasspathFile(filename);
stmtGraph.destroy();
}
示例2: runAssertionAllTypes
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
private void runAssertionAllTypes(EPServiceProvider epService, String typeName, Object[] events) throws Exception {
String graph = "create dataflow MyGraph " +
"DefaultSupportSourceOp -> instream<" + typeName + ">{}" +
"EventBusSink(instream) {}";
EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from " + typeName);
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
DefaultSupportSourceOp source = new DefaultSupportSourceOp(events);
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(source));
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyGraph", options);
instance.run();
EPAssertionUtil.assertPropsPerRow(listener.getNewDataListFlattened(), "myDouble,myInt,myString".split(","), new Object[][]{{1.1d, 1, "one"}, {2.2d, 2, "two"}});
listener.reset();
stmtGraph.destroy();
}
示例3: runAssertionAllTypes
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
private void runAssertionAllTypes(String typeName, Object[] events) throws Exception
{
String graph = "create dataflow MyGraph " +
"DefaultSupportSourceOp -> instream<" + typeName + ">{}" +
"EventBusSink(instream) {}";
EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from " + typeName);
stmt.addListener(listener);
DefaultSupportSourceOp source = new DefaultSupportSourceOp(events);
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(source));
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyGraph", options);
instance.run();
EPAssertionUtil.assertPropsPerRow(listener.getNewDataListFlattened(), "myDouble,myInt,myString".split(","), new Object[][] {{1.1d, 1, "one"}, {2.2d, 2, "two"}});
listener.reset();
stmtGraph.destroy();
}
示例4: trySource
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
private void trySource(AdapterInputSource source) throws Exception {
CSVInputAdapterSpec spec = new CSVInputAdapterSpec(source, "TypeC");
epService = EPServiceProviderManager.getProvider("testPlayFromInputStream", makeConfig("TypeC"));
epService.initialize();
InputAdapter feed = new CSVInputAdapter(epService, spec);
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from TypeC#length(100)");
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
feed.start();
assertEquals(1, listener.getNewDataList().size());
if (source.getAsReader() != null) {
source.getAsReader().reset();
} else {
source.getAsStream().reset();
}
// test graph
String graph = "create dataflow ReadCSV " +
"FileSource -> mystream<TypeC> { hasTitleLine: true, classpathFile: true }" +
"DefaultSupportCaptureOp(mystream) {}";
epService.getEPAdministrator().createEPL(graph);
DefaultSupportCaptureOp<Object> outputOp = new DefaultSupportCaptureOp<Object>();
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(outputOp));
options.parameterProvider(new DefaultSupportGraphParamProvider(Collections.<String, Object>singletonMap("adapterInputSource", source)));
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("ReadCSV", options);
instance.run();
Object[] received = outputOp.getAndReset().get(0).toArray();
assertEquals(1, received.length);
}
示例5: runAssertionAllTypes
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
private void runAssertionAllTypes(EPServiceProvider epService, String typeName, Object[] events) throws Exception {
String graph = "create dataflow MySelect\n" +
"DefaultSupportSourceOp -> instream.with.dot<" + typeName + ">{}\n" +
"Filter(instream.with.dot) -> outstream.dot {filter: myString = 'two'}\n" +
"DefaultSupportCaptureOp(outstream.dot) {}";
EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);
DefaultSupportSourceOp source = new DefaultSupportSourceOp(events);
DefaultSupportCaptureOp<Object> capture = new DefaultSupportCaptureOp<>(2);
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.setDataFlowInstanceUserObject("myuserobject");
options.setDataFlowInstanceId("myinstanceid");
options.operatorProvider(new DefaultSupportGraphOpProvider(source, capture));
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MySelect", options);
assertEquals("myuserobject", instance.getUserObject());
assertEquals("myinstanceid", instance.getInstanceId());
instance.run();
Object[] result = capture.getAndReset().get(0).toArray();
assertEquals(1, result.length);
assertSame(events[1], result[0]);
instance.cancel();
stmtGraph.destroy();
}
示例6: run
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
public void run(EPServiceProvider epService) throws Exception {
epService.getEPAdministrator().getConfiguration().addImport(this.getClass().getName());
String epl = "create dataflow RollingTopWords\n" +
"create objectarray schema WordEvent (word string),\n" +
"Emitter -> wordstream<WordEvent> {name:'a'} // Produces word stream\n" +
"Select(wordstream) -> wordcount { // Sliding time window count per word\n" +
" select: (select word, count(*) as wordcount from wordstream#time(30) group by word)\n" +
"}\n" +
"Select(wordcount) -> wordranks { // Rank of words\n" +
" select: (select window(*) as rankedWords from wordcount#sort(3, wordcount desc) output snapshot every 2 seconds)\n" +
"}\n" +
"DefaultSupportCaptureOp(wordranks) {}";
epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
epService.getEPAdministrator().createEPL(epl);
// prepare test
DefaultSupportCaptureOp capture = new DefaultSupportCaptureOp();
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(capture));
EPDataFlowInstance instanceOne = epService.getEPRuntime().getDataFlowRuntime().instantiate("RollingTopWords", options);
Emitter emitter = instanceOne.startCaptive().getEmitters().get("a");
for (String word : new String[]{"this", "is", "a", "test", "that", "is", "a", "word", "test"}) {
emitter.submit(new Object[]{word});
}
assertEquals(0, capture.getCurrentAndReset().length);
epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));
assertEquals(1, capture.getCurrent().length);
Map map = (Map) capture.getCurrent()[0];
Object[][] rows = (Object[][]) map.get("rankedWords");
EPAssertionUtil.assertPropsPerRow(rows, "word,count".split(","), new Object[][]{{"is", 2L}, {"a", 2L}, {"test", 2L}});
instanceOne.cancel();
}
示例7: testAMQPOutput
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
public void testAMQPOutput() throws Exception {
String queueName = TestAMQPGraphs.class.getSimpleName() + "-OutputQueue";
String[] fields = "myString,myInt,myDouble".split(",");
epService.getEPAdministrator().createEPL("create schema MyMapEvent(myString string, myInt int, myDouble double)");
String graph = "create dataflow WriteAMQPGraph " +
"DefaultSupportSourceOp -> outstream<MyMapEvent> {}" +
"AMQPSink(outstream) {" +
" host: 'localhost', " +
" queueName: '" + queueName + "', " +
" collector: {class: 'ObjectToAMQPCollectorSerializable'}, " +
"}";
epService.getEPAdministrator().createEPL(graph);
DefaultSupportSourceOp source = new DefaultSupportSourceOp(new Object[]{makeEvent("E10", 0, 0), makeEvent("E11", 1, 1), makeEvent("E12", 2, 2)});
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(source));
EPDataFlowInstance df = epService.getEPRuntime().getDataFlowRuntime().instantiate("WriteAMQPGraph", options);
df.start();
ReceiverHelper receiverHelper = new ReceiverHelper();
AMQPSupportReceiveRunnable runnable = new AMQPSupportReceiveRunnable("localhost", queueName, 20000, receiverHelper);
Thread runner = new Thread(runnable);
runner.start();
receiverHelper.getWaitReceived(3);
EPAssertionUtil.assertPropsPerRow(toMapArray(receiverHelper.getReceived()), fields, new Object[][]{{"E10", 0, 0d}, {"E11", 1, 1d}, {"E12", 2, 2d}});
runner.interrupt();
runner.join();
df.cancel();
}
示例8: testGraph
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
public void testGraph() throws Exception {
String epl = "create dataflow RollingTopWords\n" +
"create objectarray schema WordEvent (word string),\n" +
"Emitter -> wordstream<WordEvent> {name:'a'} // Produces word stream\n" +
"Select(wordstream) -> wordcount { // Sliding time window count per word\n" +
" select: (select word, count(*) as wordcount from wordstream.win:time(30) group by word)\n" +
"}\n" +
"Select(wordcount) -> wordranks { // Rank of words\n" +
" select: (select window(*) as rankedWords from wordcount.ext:sort(3, wordcount desc) output snapshot every 2 seconds)\n" +
"}\n" +
"DefaultSupportCaptureOp(wordranks) {}";
epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
epService.getEPAdministrator().createEPL(epl);
// prepare test
DefaultSupportCaptureOp capture = new DefaultSupportCaptureOp();
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.operatorProvider(new DefaultSupportGraphOpProvider(capture));
EPDataFlowInstance instanceOne = epService.getEPRuntime().getDataFlowRuntime().instantiate("RollingTopWords", options);
Emitter emitter = instanceOne.startCaptive().getEmitters().get("a");
for (String word : new String[] {"this", "is", "a", "test", "that", "is", "a", "word", "test"}) {
emitter.submit(new Object[] {word});
}
assertEquals(0, capture.getCurrentAndReset().length);
epService.getEPRuntime().sendEvent(new CurrentTimeEvent(2000));
assertEquals(1, capture.getCurrent().length);
Map map = (Map) capture.getCurrent()[0];
Object[][] rows = (Object[][]) map.get("rankedWords");
EPAssertionUtil.assertPropsPerRow(rows, "word,count".split(","), new Object[][]{{"is", 2L}, {"a", 2L}, {"test", 2L}});
instanceOne.cancel();
}
示例9: runAssertionAllTypes
import com.espertech.esper.client.dataflow.EPDataFlowInstantiationOptions; //导入方法依赖的package包/类
private void runAssertionAllTypes(String typeName, Object[] events) throws Exception
{
String graph = "create dataflow MySelect\n" +
"DefaultSupportSourceOp -> instream.with.dot<" + typeName + ">{}\n" +
"Filter(instream.with.dot) -> outstream.dot {filter: myString = 'two'}\n" +
"DefaultSupportCaptureOp(outstream.dot) {}";
EPStatement stmtGraph = epService.getEPAdministrator().createEPL(graph);
DefaultSupportSourceOp source = new DefaultSupportSourceOp(events);
DefaultSupportCaptureOp<Object> capture = new DefaultSupportCaptureOp<Object>(2);
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
options.setDataFlowInstanceUserObject("myuserobject");
options.setDataFlowInstanceId("myinstanceid");
options.operatorProvider(new DefaultSupportGraphOpProvider(source, capture));
EPDataFlowInstance instance = epService.getEPRuntime().getDataFlowRuntime().instantiate("MySelect", options);
assertEquals("myuserobject", instance.getUserObject());
assertEquals("myinstanceid", instance.getInstanceId());
instance.run();
Object[] result = capture.getAndReset().get(0).toArray();
assertEquals(1, result.length);
assertSame(events[1], result[0]);
instance.cancel();
stmtGraph.destroy();
}