Exemplo n.º 1
0
  void createSampleNode(int index) {
    NodeID id;
    SingleProducer producer11;
    SingleProducer producer12;
    SingleProducer producer13;
    SingleConsumer consumer11;
    SingleConsumer consumer12;
    SingleConsumer consumer13;

    id = new NodeID(new byte[] {0, 0, 0, 0, 0, (byte) index});

    // create and connect the nodes
    producer11 = new SingleProducer(id, sg.getConnection(), new EventID(id, 1, 1));
    sg.register(producer11);

    producer12 = new SingleProducer(id, sg.getConnection(), new EventID(id, 1, 2));
    sg.register(producer12);

    producer13 = new SingleProducer(id, sg.getConnection(), new EventID(id, 1, 3));
    sg.register(producer13);

    consumer11 = new SingleConsumer(id, sg.getConnection(), new EventID(id, 0, 1));
    sg.register(consumer11);

    consumer12 = new SingleConsumer(id, sg.getConnection(), new EventID(id, 0, 2));
    sg.register(consumer12);

    consumer13 = new SingleConsumer(id, sg.getConnection(), new EventID(id, 0, 3));
    sg.register(consumer13);

    // composite GUI
    java.util.List<SingleProducer> producers = new ArrayList<SingleProducer>();
    producers.add(producer11);
    producers.add(producer12);
    producers.add(producer13);

    java.util.List<SingleConsumer> consumers = new ArrayList<SingleConsumer>();
    consumers.add(consumer11);
    consumers.add(consumer12);
    consumers.add(consumer13);
    JFrame f = new BGnodeFrame("BG simulated node " + index, producers, consumers, id, sg);
    f.pack();
    f.setVisible(true);
  }
Exemplo n.º 2
0
  void startDemo() {
    startButton.setEnabled(false);

    sg = new ScatterGather();

    // show a monitor frame
    JFrame f = new JFrame();
    f.setTitle("Blue-Gold Check");
    MonPane m = new MonPane();
    f.add(m);
    m.initComponents();
    f.pack();
    f.setVisible(true);
    sg.register(m.getConnection());

    createSampleNode(1);
    createSampleNode(2);
    createSampleNode(3);
    createSampleNode(4);
  }