Package eu.admire.dispel.graph

Examples of eu.admire.dispel.graph.ProcessingElementNode


  @Override
  public Graph transform(RequestContext context, Graph graph)
      throws TransformationException {

    RequestNode gathererNode = new ProcessingElementNode("eu.admire.Gatherer");
    List<RequestNode> list = new ArrayList<RequestNode>();

    int i = 0; // number of created Observers

    for (RequestNode node : graph.getNodes()) {

      Map<String, Map<Integer, Connection>> outputs = node
          .getAllOutputs();

      for (String keyName : outputs.keySet()) {
        for (Integer keyIndex : outputs.get(keyName).keySet()) {
          Connection conn = outputs.get(keyName).get(keyIndex);

              int targetCount = 0;
              for(RequestNodeInput target : conn.getTargets()) {
         
                       
                        RequestNode observerNode = new ProcessingElementNode("eu.admire.Observer");
                       
                        Connection output = observerNode.getOutput("out", 0);
                        target.getRequestNode().replaceInput(target.getName(), target.getIndex(), output);
                       
                        Connection input = observerNode.getInput("in", 0);
                       
                        if (targetCount == 0)
                        {
                            node.replaceOutput(keyName, keyIndex, input);
                        }
                        else
                        {
                            observerNode.connectInput("in", 0, node.getOutput(keyName, keyIndex));
                        }
                        targetCount++;

                        Connection gathConn = observerNode.getOutput("observed", 0);
                        gathererNode.connectInput("input", i++, gathConn);


                       
                        list.add(observerNode);
View Full Code Here


{

    @Test
    public void testGetConnectedComponent()
    {
        ProcessingElementNode a = new ProcessingElementNode("A");
        ProcessingElementNode b = new ProcessingElementNode("B");
        b.connectInput("in1", 0, a.getOutput("out", 0));
        ProcessingElementNode c = new ProcessingElementNode("C");
        b.connectInput("in2", 0, c.getOutput("out", 0));
        ProcessingElementNode d = new ProcessingElementNode("D");
        ProcessingElementNode e = new ProcessingElementNode("E");
        Graph graph = GraphUtilities.getConnectedComponent(a);
        List<RequestNode> nodes = graph.getNodes();
        Assert.assertEquals(3, nodes.size());
        Assert.assertTrue(nodes.contains(a));
        Assert.assertTrue(nodes.contains(b));
View Full Code Here

    }
   
    @Test
    public void testCycle() throws Exception
    {
        ProcessingElementNode a = new ProcessingElementNode("A");
        ProcessingElementNode b = new ProcessingElementNode("B");
        ProcessingElementNode c = new ProcessingElementNode("C");
        b.connectInput("in", 0, a.getOutput("out", 0));
        c.connectInput("in", 0, b.getOutput("out", 0));
        a.connectInput("in", 0, c.getOutput("out", 0));
        ProcessingElementNode d = new ProcessingElementNode("D");
        d.connectInput("in", 0, b.getOutput("out2", 0));
        ProcessingElementNode e = new ProcessingElementNode("E");
        Graph graph = GraphUtilities.getConnectedComponent(a);
        List<RequestNode> nodes = graph.getNodes();
        Assert.assertEquals(4, nodes.size());
        Assert.assertTrue(nodes.contains(a));
        Assert.assertTrue(nodes.contains(b));
View Full Code Here

    public void testSimple() throws Exception
    {
        GatewayLocation gw1 = new SimpleGatewayLocation("GWA", "EPR");
        GatewayLocation gw2 = new SimpleGatewayLocation("GWB", "EPR");
        Graph graph = new Graph();
        ProcessingElementNode a = new ProcessingElementNode("A");
        a.addAnnotation(AnnotationKeys.GATEWAY, gw1);
        ProcessingElementNode b = new ProcessingElementNode("B");
        b.addAnnotation(AnnotationKeys.GATEWAY, gw1);
        ProcessingElementNode c = new ProcessingElementNode("C");
        c.addAnnotation(AnnotationKeys.GATEWAY, gw2);
        b.connectInput("in", 0, a.getOutput("out", 0));
        graph.add(a); graph.add(b); graph.add(c);
       
        SimplePartitioner partitioner = new SimplePartitioner();
        Map<GatewayLocation, Graph> partitions = partitioner.partition(graph);
View Full Code Here

    }
   
    @Test
    public void testSingleNode()
    {
        ProcessingElementNode a = new ProcessingElementNode("A");
        Graph graph = GraphUtilities.getConnectedComponent(a);
        List<RequestNode> nodes = graph.getNodes();
        Assert.assertEquals(1, nodes.size());
        Assert.assertTrue(nodes.contains(a));
    }
View Full Code Here

    @Test
    public void testOneGraph() throws Exception
    {
        GatewayLocation gw = new SimpleGatewayLocation("GWA", "EPR");
        Graph graph = new Graph();
        ProcessingElementNode a = new ProcessingElementNode("A");
        a.addAnnotation(AnnotationKeys.GATEWAY, gw);
        ProcessingElementNode b = new ProcessingElementNode("B");
        b.addAnnotation(AnnotationKeys.GATEWAY, gw);
        ProcessingElementNode c = new ProcessingElementNode("C");
        c.addAnnotation(AnnotationKeys.GATEWAY, gw);
        b.connectInput("in", 0, a.getOutput("out", 0));
        c.connectInput("in", 0, b.getOutput("out", 0));
        graph.add(a); graph.add(b); graph.add(c);
       
        SimplePartitioner partitioner = new SimplePartitioner();
        Map<GatewayLocation, Graph> partitions = partitioner.partition(graph);
        TestCase.assertEquals(1, partitions.size());
View Full Code Here

    }

    @Test
    public void testComposite()
    {
        ProcessingElementNode a = new ProcessingElementNode("A");
        ProcessingElementNode b = new ProcessingElementNode("B");
        ProcessingElementNode c = new ProcessingElementNode("C");
        a.connectInput("in", 0, b.getOutput("out", 0));
        CompositeProcessingElement composite =
            new CompositeProcessingElement("C", Arrays.<RequestNode>asList(a, b));
        composite.setInput("in", 0, b.getInput("in", 0));
        c.connectOutput("out", 0, composite.getInput("in", 0));
        Graph graph = GraphUtilities.getConnectedComponent(composite);
        List<RequestNode> nodes = graph.getNodes();
        System.out.println(graph);
        Assert.assertEquals(2, nodes.size());
        Assert.assertTrue(nodes.contains(composite));
View Full Code Here


    @Test
    public void testSink()
    {
        ProcessingElementNode a = new ProcessingElementNode("A");
        ProcessingElementNode b = new ProcessingElementNode("B");
        ProcessingElementNode c = new ProcessingElementNode("C");
        ProcessingElementNode d = new ProcessingElementNode("D");
        a.connectInput("in1", 0, b.getOutput("out", 0));
        a.connectInput("in2", 0, c.getOutput("out", 0));
        a.connectInput("in3", 0, d.getOutput("out", 0));
        Graph graph = GraphUtilities.getConnectedComponent(a);
        List<RequestNode> nodes = graph.getNodes();
        Assert.assertEquals(4, nodes.size());
        Assert.assertTrue(nodes.contains(a));
        Assert.assertTrue(nodes.contains(b));
View Full Code Here

{

    @Test
    public void testConnectOutput() throws Exception
    {
        ProcessingElementNode a = new ProcessingElementNode("A");
        ProcessingElementNode b = new ProcessingElementNode("B");
        CompositeProcessingElement composite =
            new CompositeProcessingElement(
                    "Composite",
                    Arrays.<RequestNode>asList(a, b));
        composite.setOutput("out", 0, b.getOutput("out", 0));
        ProcessingElementNode c = new ProcessingElementNode("C");
        c.connectInput("in", 0, composite.getOutput("out", 0));
        System.out.println(composite);
        System.out.println(c);
    }
View Full Code Here

        TestCase.assertTrue(result instanceof CompositeProcessingElement);
        CompositeProcessingElement composite = (CompositeProcessingElement)result;
        List<RequestNodeInput> targets = composite.getInput("input", 0).getTargets();
        TestCase.assertEquals(1, targets.size());
        ProcessingElementNode convert = (ProcessingElementNode) targets.get(0).getRequestNode();
        TestCase.assertEquals(SimpleTupleTypeConverter.TUPLE_CONVERT, convert.getName());
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.graph.ProcessingElementNode

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.