use of java.io.PipedOutputStream in project symmetric-ds by JumpMind.
the class InternalTransportManager method getFilePushTransport.
public IOutgoingWithResponseTransport getFilePushTransport(final Node targetNode, final Node sourceNode, String securityToken, String registrationUrl) throws IOException {
final PipedOutputStream pushOs = new PipedOutputStream();
final PipedInputStream pushIs = new PipedInputStream(pushOs);
final PipedOutputStream respOs = new PipedOutputStream();
final PipedInputStream respIs = new PipedInputStream(respOs);
runAtClient(targetNode.getSyncUrl(), pushIs, respOs, new IClientRunnable() {
public void run(ISymmetricEngine engine, InputStream is, OutputStream os) throws Exception {
// This should be basically what the push servlet does ...
engine.getFileSyncService().loadFilesFromPush(sourceNode.getNodeId(), is, os);
}
});
return new InternalOutgoingWithResponseTransport(pushOs, respIs);
}
use of java.io.PipedOutputStream in project flink by apache.
the class OutputEmitterTest method testWrongKeyClass.
@Test
public void testWrongKeyClass() throws Exception {
// Test for IntValue
final TypeComparator<Record> doubleComp = new RecordComparatorFactory(new int[] { 0 }, new Class[] { DoubleValue.class }).createComparator();
final ChannelSelector<SerializationDelegate<Record>> selector = createChannelSelector(ShipStrategyType.PARTITION_HASH, doubleComp, 100);
final SerializationDelegate<Record> delegate = new SerializationDelegate<>(new RecordSerializerFactory().getSerializer());
PipedInputStream pipedInput = new PipedInputStream(1024 * 1024);
DataInputView in = new DataInputViewStreamWrapper(pipedInput);
DataOutputView out = new DataOutputViewStreamWrapper(new PipedOutputStream(pipedInput));
Record record = new Record(1);
record.setField(0, new IntValue());
record.write(out);
record = new Record();
record.read(in);
try {
delegate.setInstance(record);
selector.selectChannel(delegate);
} catch (DeserializationException re) {
return;
}
Assert.fail("Expected a NullKeyFieldException.");
}
use of java.io.PipedOutputStream in project flink by apache.
the class YarnTestBase method startWithArgs.
/**
* This method returns once the "startedAfterString" has been seen.
*/
protected Runner startWithArgs(String[] args, String startedAfterString, RunTypes type) throws IOException {
LOG.info("Running with args {}", Arrays.toString(args));
outContent = new ByteArrayOutputStream();
errContent = new ByteArrayOutputStream();
PipedOutputStream out = new PipedOutputStream();
PipedInputStream in = new PipedInputStream(out);
PrintStream stdinPrintStream = new PrintStream(out);
System.setOut(new PrintStream(outContent));
System.setErr(new PrintStream(errContent));
System.setIn(in);
final int startTimeoutSeconds = 60;
Runner runner = new Runner(args, flinkConfiguration, CliFrontend.getConfigurationDirectoryFromEnv(), type, 0, stdinPrintStream);
runner.setName("Frontend (CLI/YARN Client) runner thread (startWithArgs()).");
runner.start();
for (int second = 0; second < startTimeoutSeconds; second++) {
sleep(1000);
// check output for correct TaskManager startup.
if (outContent.toString().contains(startedAfterString) || errContent.toString().contains(startedAfterString)) {
LOG.info("Found expected output in redirected streams");
return runner;
}
// check if thread died
if (!runner.isAlive()) {
resetStreamsAndSendOutput();
if (runner.getRunnerError() != null) {
throw new RuntimeException("Runner failed with exception.", runner.getRunnerError());
}
Assert.fail("Runner thread died before the test was finished.");
}
}
resetStreamsAndSendOutput();
Assert.fail("During the timeout period of " + startTimeoutSeconds + " seconds the " + "expected string did not show up");
return null;
}
use of java.io.PipedOutputStream in project nanohttpd by NanoHttpd.
the class TestNanolets method setUp.
@BeforeClass
public static void setUp() throws Exception {
stdIn = new PipedOutputStream();
System.setIn(new PipedInputStream(stdIn));
serverStartThread = new Thread(new Runnable() {
@Override
public void run() {
String[] args = {};
AppNanolets.main(args);
}
});
serverStartThread.start();
// give the server some tine to start.
Thread.sleep(200);
}
use of java.io.PipedOutputStream in project nanohttpd by NanoHttpd.
the class TestCorsHttpServer method setUp.
@BeforeClass
public static void setUp() throws Exception {
stdIn = new PipedOutputStream();
System.setIn(new PipedInputStream(stdIn));
serverStartThread = new Thread(new Runnable() {
@Override
public void run() {
String[] args = { "--host", "localhost", "--port", "9090", "--dir", "src/test/resources", "--cors" };
SimpleWebServer.main(args);
}
});
serverStartThread.start();
// give the server some tine to start.
Thread.sleep(100);
}
Aggregations