Package eu.admire.dispel.graph.optimise

Examples of eu.admire.dispel.graph.optimise.TransformationException


    public Graph transform(RequestContext context, Graph graph)
        throws TransformationException
    {
        if (mTypeChecker == null)
        {
            throw new TransformationException("Type checker must not be null.");
        }
        List<RequestNode> newNodes = new ArrayList<RequestNode>();
        for (RequestNode requestNode : graph.getNodes())
        {
            if (!(requestNode instanceof ProcessingElementNode))
            {
                continue;
            }
           
            ProcessingElementNode pe = (ProcessingElementNode)requestNode;
            ProcessingElementDescriptor descriptor =
                pe.getProcessingElementDescriptor();
            for (ProcessingElementInputDescriptor inputDescriptor : descriptor.getInputs())
            {
                Map<Integer, Connection> input =
                    requestNode.getAllInputs().get(inputDescriptor.getName());
                if (input == null)
                {
                    // we have an optional input that is not connected
                    // this is valid so we're just ignoring it
                        continue;
                }
                for (Entry<Integer, Connection> connection : input.entrySet())
                {
                    RequestNode source = connection.getValue().getSource();
                    String name = connection.getValue().getSourceOutputName();
                    ProcessingElementOutputDescriptor outputDescriptor =
                        getOutputDescriptor(source, name);
                    try
                    {
                        RequestNode converter =
                            mTypeChecker.checkCompatibility(
                                    outputDescriptor, inputDescriptor);
                        insertConverter(
                                newNodes,
                                requestNode,
                                connection.getValue(),
                                converter);
                    }
                    catch (Exception e)
                    {
                        throw new TransformationException(
                                "Types in output descriptor " + name
                                + "[" + connection.getValue().getSourceOutputIndex()
                                + "] of PE " + source.getName()
                                + " are not compatible with input descriptor "
                                + inputDescriptor.getName()
View Full Code Here


           
            return graph;
        }
        catch(UnknownGatewayException e)
        {
            throw new TransformationException(
                "No gateway location for gateway " + e.getGatewayName(),
                e);
        }
    }
View Full Code Here

                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

            {
                remove.add(node);
                String name = getResultName(node, remove);
                if (node.getAllInputs().get(ResultNode.INPUT_NAME) == null)
                {
                    throw new TransformationException(
                            "No input " + ResultNode.INPUT_NAME
                            + " defined for processing element "
                            + ResultNode.NAME);
                }
                ResultNode result = new ResultNode(name);
View Full Code Here

                for (Entry<Integer, Connection> input : entry.getValue().entrySet())
                {
                    Connection connection = input.getValue();
                    if (connection.getSource() == null)
                    {
                        throw new TransformationException(
                                new UnconnectedInputException(
                                        node, entry.getKey(), input.getKey()));
                    }
                       
                }
            }
           
            for (Entry<String, Map<Integer, Connection>> entry : node.getAllOutputs().entrySet())
            {
                for (Entry<Integer, Connection> output : entry.getValue().entrySet())
                {
                    Connection connection = output.getValue();
                    if (connection.getTargets().isEmpty())
                    {
                        throw new TransformationException(
                                new UnconnectedOutputException(
                                            node, entry.getKey(), output.getKey()));
                    }
                       
                }
View Full Code Here

            throws TransformationException
    {
        LOG.debug("Inserting composite processing elements.");
        if (mAdmireRegistry == null)
        {
            throw new TransformationException(
                "Cannot detect registered processing elements because " +
                "optimiser has not been given a processing element registry");
        }

        boolean processedComposite;
       
        do
        {
            processedComposite = false;

            Graph newGraph = new Graph();
            for (RequestNode node : graph.getNodes())
            {
                // Don't process a CPE twice - the optimiser set includes
                // flatten then we will never get a CPE here.
                if (!(node instanceof CompositeProcessingElement))
                {
                    String impl = null;
                    if (node instanceof ProcessingElementNode)
                    {
                        String name = ((ProcessingElementNode)node).getChosenPEOrNodeName();
                        Map<String, Set<DispelObject>> reg;
                        try
                        {
                            reg = mAdmireRegistry.lookup(Collections.singleton(name));
                        }
                        catch (LookupFailedException e)
                        {
                            throw new TransformationException(e);
                        }
                        Iterator<DispelObject> iterator = reg.get(name).iterator();
                        // assume that there is at least one PE
                        if (!iterator.hasNext())
                        {
                            throw new TransformationException(
                                    new UnregisteredUsedObjectException(name));
                        }
                        impl = iterator.next().dispel;
                    }
                   
View Full Code Here

        SimpleErrorListener errorListener = new SimpleErrorListener();
        compiler.addErrorListener(errorListener);
        compiler.parse(impl);
        if (errorListener.haveErrors())
        {
            throw new TransformationException(
                    "Implementation of processing element '" +
                    node.getName() + "' cannot be parsed.");

        }

        RegisteredObject registeredObject = builder.getRegistered().get(node.getName());
       
        if (!(registeredObject.getObject() instanceof ProcessingElementType))
        {
            throw new TransformationException(
                "Cannot handle registered objects of type: " +
                registeredObject.getClass().getCanonicalName());
        }
       
        ProcessingElementType peType =
            (ProcessingElementType) registeredObject.getObject();

        CompositeProcessingElement cpe =
            (CompositeProcessingElement) peType.getImplementation();
           
        if (cpe != null)
        {
            GraphUtilities.replaceNode(node, cpe);
            graph.add(cpe);
        }
        else
        {
            throw new TransformationException(
                    "Implementation of processing element '" +
                    node.getName() + "' cannot be found.");
        }
    }
View Full Code Here

                    remove.add(node);
                    String name = getValue(node, ExternalOutputNode.INPUT_RESULT, remove);
                    String gateway = getValue(node, ExternalOutputNode.INPUT_GATEWAY, remove);
                    if (node.getAllInputs().get(ExternalOutputNode.INPUT_NAME) == null)
                    {
                        throw new TransformationException(
                                "No input " + ExternalOutputNode.INPUT_NAME
                                + " defined for processing element "
                                + ExternalOutputNode.NAME);
                    }
                    Connection data =
                        node.getInput(ExternalOutputNode.INPUT_NAME, 0);
                    ExternalOutputNode output = new ExternalOutputNode(name, gateway);
                    output.copyAnnotations(node);
                    GraphUtilities.replaceTarget(
                            data,
                            node,
                            new SingleRequestNodeInput(output, ExternalOutputNode.INPUT_NAME, 0));
                    output.setInput(data);
                    add.add(output);
                    LOG.debug("Created new external output node, name: " + name);
                }
                else if (ExternalInputNode.NAME.equals(node.getName()))
                {
                    remove.add(node);
                    String name = getValue(node, ExternalInputNode.INPUT_RESULT, remove);
                    String gateway = getValue(node, ExternalInputNode.INPUT_GATEWAY, remove);
                    if (node.getAllOutputs().get(ExternalInputNode.OUTPUT_NAME) == null)
                    {
                        throw new TransformationException(
                                "No output " + ExternalInputNode.OUTPUT_NAME
                                + " defined for processing element "
                                + ExternalInputNode.NAME);
                    }
                    Connection data =
View Full Code Here

                ProcessingElementDescriptor descriptor =
                    peNode.getProcessingElementDescriptor();
               
                if (descriptor == null)
                {
                    throw new TransformationException(
                        "No processing element descriptor for PE : " +
                        peNode.getName());
                }
               
                for( ProcessingElementInputDescriptor inputDesc :
View Full Code Here

                {
                    location = mRegistry.getLocation(executionEngine);
                }
                catch (UnknownExecutionEngineException e)
                {
                    throw new TransformationException(e);
                }
                node.addAnnotation(
                        AnnotationKeys.LOCATION,
                        location);
            }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.graph.optimise.TransformationException

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.