Package org.discoproject.worker

Examples of org.discoproject.worker.DiscoWorker


  @Test
  public void testInputFlow() throws IOException {
    final Pipe pipeFromDisco = Pipe.open();

    final DiscoWorker discoWorker = new DiscoWorker(pipeFromDisco.source(), new NullByteChannel());
    final SinkChannel disco = pipeFromDisco.sink();

    // Put messages in the input pipeline (from the disco master)
    final String okStr = "OK 4 \"ok\"\n";
    disco.write(ByteBuffer.wrap(okStr.getBytes()));
    final String taskStr = "TASK 327 {\"taskid\":0,\"master\":\"http://lhoersten-66113:8989\",\"disco_port\":8989,\"put_port\":8990,\"ddfs_data\":\"/srv/disco/ddfs\",\"disco_data\":\"/srv/disco/data\",\"mode\":\"map\",\"jobfile\":\"/srv/disco/data/localhost/5a/lhoersten-FunshineSimulator@524:7310e:1cb44/jobfile\",\"jobname\":\"lhoersten-FunshineSimulator@524:7310e:1cb44\",\"host\":\"localhost\"}\n";
    disco.write(ByteBuffer.wrap(taskStr.getBytes()));
    final String inputStr = "INPUT 110 [\"done\",[[0,\"ok\",[[0,\"raw://eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVD\"]]]]]\n";
    disco.write(ByteBuffer.wrap(inputStr.getBytes()));

    discoWorker.requestTask();
    final ReadableByteChannel mapInput = discoWorker.getMapInput();

    final String input = DiscoUtils.channelLineToString(mapInput);

    assertEquals("eyJlbnRyeWV4aXRsZXZlbCI6WyJERUMiLDEuNV0sInFyMiI6WyJERUMiLDFdLCJxcjEiOlsiREVD", input);
  }
View Full Code Here

TOP

Related Classes of org.discoproject.worker.DiscoWorker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.