Package eu.admire.dispel.graph

Examples of eu.admire.dispel.graph.ProcessingElementNode


        registry.registerProcessingElement(desc, implementation);
        insert.setAdmireRegistry(registry);
        insert.setDispelOptimiser(new SimpleDispelOptimiser());
        RequestContext context = new MockRequestContext();
        Graph graph = new Graph();
        ProcessingElementNode a = new ProcessingElementNode("eu.admire.A");
        ProcessingElementNode b = new ProcessingElementNode("B");
        b.connectInput("in", 0, a.getOutput("out", 0));
        ProcessingElementNode c = new ProcessingElementNode("eu.admire.C");
        c.connectInput("in", 0, b.getOutput("out", 0));
        graph.add(a);
        graph.add(b);
        graph.add(c);
        Graph transformed = insert.transform(context, graph);
        List<RequestNode> nodes = transformed.getNodes();
View Full Code Here


    public void testComposite() throws Exception
    {
        Graph graph = new Graph();
        LiteralValuesNode nodeL = new LiteralValuesNode("VALUE");
        graph.add(nodeL);
        ProcessingElementNode nodeA = new ProcessingElementNode("uk.org.ogsadai.SQLQuery");
        nodeA.connectInput("expression", 0, nodeL.getOutput());
        ProcessingElementNode nodeB = new ProcessingElementNode("uk.org.ogsadai.TupleToWebRowSetCharArrays");
        Connection connection = new TeeConnection();
        nodeA.connectOutput("out1", 0, connection);
        nodeB.connectInput("in1", 0, connection);
        Connection out = new TeeConnection();
        nodeB.connectOutput("out2", 0, out);
        CompositeProcessingElement nodeC = new CompositeProcessingElement(
                "Composite",
                Arrays.<RequestNode>asList(nodeA, nodeB));
        Map<String, Map<Integer, Connection>> inputs = new HashMap<String, Map<Integer, Connection>>();
        nodeC.setInputs(inputs);
        Map<String, Map<Integer, Connection>> outputs = new HashMap<String, Map<Integer, Connection>>();
        Map<Integer, Connection> map = new HashMap<Integer, Connection>();
        map.put(0, out);
        outputs.put("out2", map);
        nodeC.setOutputs(outputs);
        graph.add(nodeC);
        ProcessingElementNode nodeD = new ProcessingElementNode("uk.org.ogsadai.DeliverToRequestStatus");
        graph.add(nodeD);
        nodeD.connectInput("data", 0, out);
        String dot = DotGenerator.generate(graph);
//        writeFile(dot);
        System.out.println(dot);
    }
View Full Code Here

        InMemoryAdmireRegistry registry = new InMemoryAdmireRegistry();
        insert.setAdmireRegistry(registry);
        insert.setDispelOptimiser(new SimpleDispelOptimiser());
        RequestContext context = new MockRequestContext();
        Graph graph = new Graph();
        ProcessingElementNode a = new ProcessingElementNode("eu.admire.A");
        graph.add(a);
        try
        {
            insert.transform(context, graph);
            TestCase.fail("Expected a TransformationException.");
View Full Code Here

       
        for( RequestNode graphNode : graph.getNodes())
        {
            if (graphNode instanceof ProcessingElementNode)
            {
                ProcessingElementNode peNode =
                    (ProcessingElementNode) graphNode;

                if (peNode.getName().equals(expectedNodeName))
                {
                    assertEquals(
                        "Node " + expectedNodeName + " should have single PE",
                        1, peNode.getCandidatePEs().size());
                   
                    boolean expectedPEFound = false;
                    for( String peName : expectedPENames)
                    {
                        if (peNode.getCandidatePEs().contains(peName))
                        {
                            expectedPEFound = true;
                            break;
                        }
                    }
                   
                    assertTrue(
                        "Node " + expectedNodeName +
                            ": expected PE on of : " + expectedPENames +
                            " actual: " + peNode.getCandidatePEs(),
                        expectedPEFound);

                    found = true;
                    break;
                }
View Full Code Here

    public void testUnconnectedComposite() throws Exception
    {
        Graph graph = new Graph();
        LiteralValuesNode nodeL = new LiteralValuesNode("VALUE");
        graph.add(nodeL);
        ProcessingElementNode nodeA = new ProcessingElementNode("uk.org.ogsadai.SQLQuery");
        nodeA.connectInput("expression", 0, nodeL.getOutput());
        ProcessingElementNode nodeB = new ProcessingElementNode("uk.org.ogsadai.TupleToWebRowSetCharArrays");
        Connection connection = new TeeConnection();
        nodeA.connectOutput("out1", 0, connection);
        nodeB.connectInput("in1", 0, connection);
        Connection out = new TeeConnection();
        nodeB.connectOutput("out2", 0, out);
        CompositeProcessingElement nodeC = new CompositeProcessingElement(
                "Composite",
                Arrays.<RequestNode>asList(nodeA, nodeB));
        Map<String, Map<Integer, Connection>> inputs = new HashMap<String, Map<Integer, Connection>>();
        nodeC.setInputs(inputs);
View Full Code Here

    {
        for (RequestNode node : graph.getNodes())
        {
            if (node instanceof ProcessingElementNode)
            {
                ProcessingElementNode peNode = (ProcessingElementNode) node;
   
                String dataSourceName = (String)node.getAnnotation(AnnotationKeys.DATA_SOURCE_ANCHOR);
                if (dataSourceName != null)
                {
                    Set<String> gateways =
                        mGatewayRegistry.findGatewaysForDataSource(
                            dataSourceName);
                   
                    // Adjust the candidate gateways to only
                    // those that support this data source
                   
                    for (Entry<String, Set<String>> entry :
                         peNode.getCandidateGateways().entrySet())
                    {
                        entry.getValue().retainAll(gateways);
                    }
                }
            }
View Full Code Here

        for (RequestNode node : graph.getNodes())
        {
            if (node instanceof ProcessingElementNode &&
                    !(node instanceof CompositeProcessingElement))
            {
                ProcessingElementNode pen = (ProcessingElementNode) node;
               
                Set<String> candidatePEs = pen.getCandidatePEs();
                String choosenPE = null;
                for (String peName : candidatePEs)
                {
                    if (pen.getCandidateGateways().get(peName).size() > 0)
                    {
                        choosenPE = peName;
                        break;
                    }
                }
View Full Code Here

        {
            somethingChanged = false;
           
            // If we have an annotation we have not visited then propagate
            // from it.
            ProcessingElementNode node = findNonVisitedAnnotatedNode(graph);
           
            if (node != null)
            {
                String gateway =
                    (String) node.getAnnotation(AnnotationKeys.GATEWAY);
                visit(node, gateway);
                somethingChanged = true;
            }
            else
            {
                // We do not have any not visited annotation node.  Find the
                // most restrictive node and choose one of its candidate
                // gateways
                node = findPEWithFewestGatewayChoices(graph);
                if (node != null)
                {
                    String gateway = chooseGateway(node);
                    visit(node, gateway);
                    somethingChanged = true;
                }
            }
        }
       
        // Remove the visited annotations and any data exchange nodes
        List<RequestNode> nodesToBeRemoved = new LinkedList<RequestNode>();
        for( RequestNode node : graph.getNodes())
        {
            if (DATA_EXCHANGE_NAME.equals(node.getName()))
            {
                nodesToBeRemoved.add(node);
            }
            else if (node.getAnnotationKeys().contains(VISITED_ANNOTATION))
            {
                // TODO: remove annotations
                //node.removeAnnotation(VISITED_ANNOTATION);
            }
        }
View Full Code Here

     * @return the non-visited PE with the smallest set of candidate gateways.
     */
    private ProcessingElementNode findPEWithFewestGatewayChoices(Graph graph)
    {
        int fewestChoices = 10000;
        ProcessingElementNode nodeWithFewestChoices = null;
       
        for (RequestNode node : graph.getNodes())
        {
            if (node instanceof ProcessingElementNode)
            {
                ProcessingElementNode peNode = (ProcessingElementNode) node;
               
                if (!peNode.getAnnotationKeys().contains(VISITED_ANNOTATION))
                {
                    if (nodeWithFewestChoices == null ||
                        getCandidateGateways(peNode).size() < fewestChoices)
                    {
                        nodeWithFewestChoices = peNode;
View Full Code Here

    {
        for (RequestNode node : graph.getNodes())
        {
            if (node instanceof ProcessingElementNode)
            {
                ProcessingElementNode peNode = (ProcessingElementNode) node;
               
                Set<String> candidatePEs = peNode.getCandidatePEs();
                if (candidatePEs.size() != 1)
                {
                    throw new TransformationException(
                        "Process Element " + peNode.getName() + " does not " +
                        "have a single candidate PE implementation: " +
                        candidatePEs);
                }
                String choosenPE = candidatePEs.iterator().next();
               
                Map<String, Set<String>> candidateGatewayMap =
                    peNode.getCandidateGateways();
               
                Set<String> candidateGateways =
                    candidateGatewayMap.get(choosenPE);
               
                if (candidateGateways == null)
                {
                    throw new TransformationException(
                        "Process Element " + peNode.getName() + " does not " +
                        "have a set of candidate gateways for choosen PE " +
                        "implementation: " + choosenPE);
                }
               
                if (candidateGateways.size() == 0)
                {
                    throw new TransformationException(
                        "Process Element " + peNode.getName() + " has an " +
                        "empty set of candidate gateways for choosen PE " +
                        "implementation: " + choosenPE);
                }
               
                if (peNode.getAnnotationKeys().contains(AnnotationKeys.GATEWAY))
                {
                    String choosenGateway =
                        peNode.getAnnotation(AnnotationKeys.GATEWAY).toString();
                    if (!candidateGateways.contains(choosenGateway))
                    {
                        throw new TransformationException(
                            "Process Element " + peNode.getName() + " has " +
                            "gateway annotation: " + choosenGateway + ", that" +
                            " is not in set of candidate gateways " +
                            candidateGateways);
                    }
                }
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.