Java Code Examples for org.apache.flink.streaming.api.functions.sink.PrintSinkFunction#open()

The following examples show how to use org.apache.flink.streaming.api.functions.sink.PrintSinkFunction#open() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintSinkFunctionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkStdOut() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>();
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));

	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 2
Source File: PrintSinkFunctionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkStdErr() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>(true);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.err", printSink.toString());
	assertEquals("hello world!" + line, arrayErrorStream.toString());
	printSink.close();
}
 
Example 3
Source File: PrintSinkFunctionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>();
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("2> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 4
Source File: PrintSinkFunctionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithIdentifierAndPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("mySink:2> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 5
Source File: PrintSinkFunctionTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithIdentifierButNoPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("mySink> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 6
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkStdOut() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>();
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));

	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 7
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkStdErr() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>(true);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.err", printSink.toString());
	assertEquals("hello world!" + line, arrayErrorStream.toString());
	printSink.close();
}
 
Example 8
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>();
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("2> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 9
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithIdentifierAndPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("mySink:2> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 10
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithIdentifierButNoPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("mySink> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 11
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkStdOut() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>();
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));

	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 12
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkStdErr() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>(true);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.err", printSink.toString());
	assertEquals("hello world!" + line, arrayErrorStream.toString());
	printSink.close();
}
 
Example 13
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>();
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("2> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 14
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithIdentifierAndPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 2, 1));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("mySink:2> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}
 
Example 15
Source File: PrintSinkFunctionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testPrintSinkWithIdentifierButNoPrefix() throws Exception {
	PrintSinkFunction<String> printSink = new PrintSinkFunction<>("mySink", false);
	printSink.setRuntimeContext(new MockStreamingRuntimeContext(false, 1, 0));
	printSink.open(new Configuration());

	printSink.invoke("hello world!", SinkContextUtil.forTimestamp(0));

	assertEquals("Print to System.out", printSink.toString());
	assertEquals("mySink> hello world!" + line, arrayOutputStream.toString());
	printSink.close();
}