Search in sources :

Example 1 with COMPSsStream

use of streams.components.COMPSsStream in project compss by bsc-wdc.

the class Main method main.

public static void main(String[] args) throws ProducerException, ConsumerException {
    // Check and get parameters
    if (args.length != 1) {
        System.out.println("[ERROR] Bad number of parameters");
        System.out.println("    Usage: streams.Main <numMessages>");
        System.exit(-1);
    }
    int numMessages = Integer.parseInt(args[0]);
    // Add a sleep to wait for both workers to be ready
    try {
        Thread.sleep(WAIT_FOR_RUNTIME);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    // ------------------------------------------------------------------------
    // Create stream
    COMPSsStream stream = new COMPSsStream();
    // Launch producer task
    Integer exitP = Producer.sendMessages(stream, numMessages);
    // Launch consumer task
    Result resultC = Consumer.receiveMessages(stream);
    // Synchronize
    if (exitP != 0) {
        throw new ProducerException("ERROR: Producer ended with exitValue " + exitP);
    }
    Integer exitC = resultC.getExitValue();
    if (exitC != 0) {
        throw new ConsumerException("ERROR: Consumer ended with exitValue " + exitC);
    }
    System.out.println("Consumer has returned:");
    System.out.println("- NumMessages = " + resultC.getNumMessages());
    System.out.println("- AcumValue = " + resultC.getAccumValue());
}
Also used : ProducerException(streams.exceptions.ProducerException) ConsumerException(streams.exceptions.ConsumerException) COMPSsStream(streams.components.COMPSsStream) Result(streams.types.Result)

Aggregations

COMPSsStream (streams.components.COMPSsStream)1 ConsumerException (streams.exceptions.ConsumerException)1 ProducerException (streams.exceptions.ProducerException)1 Result (streams.types.Result)1