Search in sources :

Example 1 with FakeSource

use of streamer.debug.FakeSource in project cloudstack by apache.

the class OutputStreamSink method main.

/**
     * Example.
     */
public static void main(String[] args) {
    Element source = new FakeSource("source") {

        {
            verbose = true;
            numBuffers = 3;
            incommingBufLength = 5;
            delay = 100;
        }
    };
    OutputStreamSink sink = new OutputStreamSink("sink") {

        {
            verbose = true;
        }
    };
    Link link = new SyncLink();
    source.setLink(STDOUT, link, Direction.OUT);
    sink.setLink(STDIN, link, Direction.IN);
    sink.setOutputStream(new ByteArrayOutputStream());
    link.sendEvent(Event.STREAM_START, Direction.IN);
    link.run();
}
Also used : FakeSource(streamer.debug.FakeSource) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 2 with FakeSource

use of streamer.debug.FakeSource in project cloudstack by apache.

the class PipelineImpl method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    // System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    Pipeline pipeline = new PipelineImpl("main");
    // Create elements
    pipeline.add(new FakeSource("source") {

        {
            incommingBufLength = 3;
            numBuffers = 10;
            delay = 100;
        }
    });
    pipeline.add(new BaseElement("tee"));
    pipeline.add(new FakeSink("sink") {

        {
            verbose = true;
        }
    });
    pipeline.add(new FakeSink("sink2") {

        {
            verbose = true;
        }
    });
    // Link elements
    pipeline.link("source", "tee", "sink");
    pipeline.link("tee >out2", "sink2");
    // Run main loop
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : FakeSink(streamer.debug.FakeSink) FakeSource(streamer.debug.FakeSource)

Example 3 with FakeSource

use of streamer.debug.FakeSource in project cloudstack by apache.

the class AwtBellAdapter method main.

/**
     * Example.
     */
public static void main(String[] args) {
    System.setProperty("streamer.Element.debug", "true");
    Element source = new FakeSource("source") {

        {
            incommingBufLength = 0;
            delay = 1000;
            numBuffers = 3;
        }
    };
    Element sink = new AwtBellAdapter("sink");
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.addAndLink(source, sink);
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) FakeSource(streamer.debug.FakeSource) Pipeline(streamer.Pipeline)

Example 4 with FakeSource

use of streamer.debug.FakeSource in project cloudstack by apache.

the class Queue method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    Element source1 = new FakeSource("source1") {

        {
            delay = 100;
            numBuffers = 10;
            incommingBufLength = 10;
        }
    };
    Element source2 = new FakeSource("source2") {

        {
            delay = 100;
            numBuffers = 10;
            incommingBufLength = 10;
        }
    };
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source1);
    pipeline.add(source2);
    pipeline.add(new Queue("queue"));
    pipeline.add(new FakeSink("sink"));
    // Main flow
    pipeline.link("source1", "in1< queue");
    pipeline.link("source2", "in2< queue");
    pipeline.link("queue", "sink");
    new Thread(pipeline.getLink("source1", STDOUT)).start();
    new Thread(pipeline.getLink("source2", STDOUT)).start();
    pipeline.getLink("sink", STDIN).run();
}
Also used : FakeSink(streamer.debug.FakeSink) FakeSource(streamer.debug.FakeSource) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Aggregations

FakeSource (streamer.debug.FakeSource)4 FakeSink (streamer.debug.FakeSink)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 BaseElement (streamer.BaseElement)1 Element (streamer.Element)1 Pipeline (streamer.Pipeline)1 PipelineImpl (streamer.PipelineImpl)1