Search in sources :

Example 51 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class CreateEndToEndFlowsSwitch method processEndToEndFlow.

/**
 * @param ci
 * @param etei
 * @param ete
 * @param iter
 */
// TODO-LW: Detect cyclic dependencies between ETEs
// restore iterator after each nested
// add preConn before addNested
private void processEndToEndFlow(ComponentInstance ci, EndToEndFlowInstance etei, EndToEndFlow ete, FlowIterator iter) {
    List<ETEInfo> nestedETEs;
    // instantiate the nested ete if that hasn't been done already
    if (!ete2info.containsKey(ete)) {
        new CreateEndToEndFlowsSwitch(monitor, getErrorManager(), classifierCache).instantiateEndToEndFlow(ci, ete, ete2info);
    }
    nestedETEs = ete2info.get(ete);
    if (nestedETEs.isEmpty()) {
        error(etei, "No nested end to end flows instantiated for " + ete.getQualifiedName());
        connections.clear();
        return;
    }
    // add connection(s), will be empty when starting the ETE
    if (connections.isEmpty()) {
        EndToEndFlowInstance eteiClone = null;
        Stack<FlowIterator> stateClone = null;
        Iterator<ETEInfo> nestedIter = nestedETEs.iterator();
        state.push(iter);
        while (nestedIter.hasNext()) {
            ETEInfo nested = nestedIter.next();
            boolean prepareNext = nestedIter.hasNext();
            if (prepareNext) {
                stateClone = clone(state);
                eteiClone = EcoreUtil.copy(etei);
                etei.setName(etei.getEndToEndFlow().getName());
                eteiClone.getModesList().addAll(etei.getModesList());
            }
            addNestedETE(etei, nested);
            // prepare next connection filter
            connections.clear();
            connections.addAll(nested.postConns);
            if (iter.hasNext()) {
                Element obj = iter.next();
                Connection conn = null;
                if (obj instanceof FlowSegment) {
                    FlowElement fe = ((FlowSegment) obj).getFlowElement();
                    if (fe instanceof Connection) {
                        conn = (Connection) fe;
                    }
                } else if (obj instanceof EndToEndFlowSegment) {
                    EndToEndFlowElement fe = ((EndToEndFlowSegment) obj).getFlowElement();
                    if (fe instanceof Connection) {
                        conn = (Connection) fe;
                    }
                }
                if (conn != null) {
                    connections.add(conn);
                }
            }
            continueFlow(ci, etei, state.pop(), ci);
            if (prepareNext) {
                // add clone
                etei.getContainingComponentInstance().getEndToEndFlows().add(eteiClone);
                etei = eteiClone;
                state = stateClone;
                addETEI.add(etei);
                if (etei.getFlowElements() == null || etei.getFlowElements().isEmpty()) {
                    created.add(myInfo = new ETEInfo(etei));
                } else {
                    created.add(myInfo = new ETEInfo(myInfo.preConns, etei));
                }
            }
        }
    } else {
        List<ConnectionInstance> connis = collectConnectionInstances(ci, etei);
        if (connis.isEmpty()) {
            error(etei, "Incomplete end-to-end flow instance " + etei.getName() + ": Missing connection instance to " + ((NamedElement) ete).getName());
            connections.clear();
        } else {
            Iterator<ConnectionInstance> connIter = connis.iterator();
            state.push(iter);
            while (connIter.hasNext()) {
                EndToEndFlowInstance eteiClone = null;
                Stack<FlowIterator> stateClone = null;
                ConnectionInstance conni = connIter.next();
                Iterator<ETEInfo> nestedIter = nestedETEs.iterator();
                while (nestedIter.hasNext()) {
                    ETEInfo nested = nestedIter.next();
                    boolean prepareNext = nestedIter.hasNext() || connIter.hasNext();
                    if (prepareNext) {
                        stateClone = clone(state);
                        eteiClone = EcoreUtil.copy(etei);
                        etei.setName(etei.getEndToEndFlow().getName());
                        eteiClone.getModesList().addAll(etei.getModesList());
                    }
                    etei.getFlowElements().add(conni);
                    addNestedETE(etei, nested);
                    // prepare next connection filter
                    connections.clear();
                    connections.addAll(nested.postConns);
                    if (iter.hasNext()) {
                        connections.add((Connection) iter.next());
                    }
                    continueFlow(ci, etei, state.pop(), ci);
                    if (prepareNext) {
                        // add clone
                        etei.getContainingComponentInstance().getEndToEndFlows().add(eteiClone);
                        etei = eteiClone;
                        state = stateClone;
                        addETEI.add(etei);
                        if (etei.getFlowElements() == null || etei.getFlowElements().isEmpty()) {
                            created.add(myInfo = new ETEInfo(etei));
                        } else {
                            created.add(myInfo = new ETEInfo(myInfo.preConns, etei));
                        }
                    }
                }
            }
        }
    }
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ModalElement(org.osate.aadl2.ModalElement) Element(org.osate.aadl2.Element) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) NamedElement(org.osate.aadl2.NamedElement) ConnectedElement(org.osate.aadl2.ConnectedElement) Connection(org.osate.aadl2.Connection) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) EndToEndFlowElement(org.osate.aadl2.EndToEndFlowElement) FlowElement(org.osate.aadl2.FlowElement) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance) EndToEndFlowSegment(org.osate.aadl2.EndToEndFlowSegment) FlowSegment(org.osate.aadl2.FlowSegment) NamedElement(org.osate.aadl2.NamedElement)

Example 52 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class CreateConnectionsSwitch method addConnectionInstance.

protected ConnectionInstance addConnectionInstance(final SystemInstance systemInstance, final ConnectionInfo connInfo, final ConnectionInstanceEnd dstI) {
    // with aggregate data ports will be sources/destinations missing
    int numConns = connInfo.connections.size();
    if (connInfo.sources.size() != numConns || connInfo.destinations.size() != numConns) {
        // happens if conn leaves system to aggregate data port
        warning(connInfo.container, "Connection from " + connInfo.sources.get(0).getInstanceObjectPath() + " to " + dstI.getInstanceObjectPath() + " could not be instantiated.");
        return null;
    }
    // check for duplicate connection instance
    // with arrays we can get duplicates that we don't need
    ComponentInstance container = connInfo.container;
    List<Connection> conns = connInfo.connections;
    if (container == null) {
        container = systemInstance;
    }
    for (ConnectionInstance test : container.getConnectionInstances()) {
        // check for duplicates and do not create
        if (connInfo.src == test.getSource() && dstI == test.getDestination() && conns.size() == test.getConnectionReferences().size()) {
            ListIterator<Connection> i = conns.listIterator();
            boolean isDuplicate = true;
            for (ConnectionReference ref : test.getConnectionReferences()) {
                if (ref.getConnection() != i.next()) {
                    isDuplicate = false;
                    break;
                }
            }
            if (!isDuplicate) {
                // also test reverse direction
                isDuplicate = true;
                i = conns.listIterator(conns.size());
                for (ConnectionReference ref : test.getConnectionReferences()) {
                    if (ref.getConnection() != i.previous()) {
                        isDuplicate = false;
                        break;
                    }
                }
            }
            if (isDuplicate) {
                return null;
            }
        }
    }
    boolean duplicate = false;
    // Generate a name for the connection
    String containerPath = (connInfo.container != null) ? container.getInstanceObjectPath() : systemInstance.getName();
    int len = containerPath.length() + 1;
    String srcPath = connInfo.src.getInstanceObjectPath();
    StringBuffer sb = new StringBuffer();
    String dstPath = "xxx";
    int i = (srcPath.startsWith(containerPath)) ? len : 0;
    srcPath = srcPath.substring(i);
    sb.append(srcPath);
    sb.append(" -> ");
    if (dstI != null) {
        dstPath = dstI.getInstanceObjectPath();
        i = (dstPath.startsWith(containerPath)) ? len : 0;
        dstPath = dstPath.substring(i);
        sb.append(dstPath);
    }
    ConnectionInstance conni = null;
    if (!duplicate) {
        conni = connInfo.createConnectionInstance(sb.toString(), dstI);
        if (conni == null) {
            warning(container, "Connection sequence from " + srcPath + " to " + dstPath + " is only outgoing. No connection instance created.");
            return null;
        } else {
            container.getConnectionInstances().add(conni);
        }
        fillInModes(conni);
        fillInModeTransitions(conni);
    }
    return conni;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection)

Example 53 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class CreateConnectionsSwitch method filterOutgoingConnections.

/**
 * Get outgoing connections for specified feature port group connections are
 * non-directional, i.e., they are always added
 *
 * @param conns
 *            a list of connections that go away from a subcomponent
 * @param feature
 *            subcomponent feature that can be the source of a connection
 * @return connections with feature as source for ConnectionInstances
 */
public List<Connection> filterOutgoingConnections(List<Connection> conns, Feature feature, Subcomponent sub) {
    List<Connection> result = new ArrayList<Connection>(conns.size());
    List<Feature> features = feature.getAllFeatureRefinements();
    EList<Subcomponent> subs = sub.getAllSubcomponentRefinements();
    for (Connection conn : conns) {
        if ((features.contains(conn.getAllSource()) && subs.contains(conn.getAllSourceContext())) || (conn.isAllBidirectional() && features.contains(conn.getAllDestination()) && subs.contains(conn.getAllDestinationContext()))) {
            result.add(conn);
        }
    }
    return result;
}
Also used : SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection) ArrayList(java.util.ArrayList) InternalFeature(org.osate.aadl2.InternalFeature) ProcessorFeature(org.osate.aadl2.ProcessorFeature) Feature(org.osate.aadl2.Feature)

Example 54 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class CreateConnectionsSwitch method filterOutgoingConnections.

/**
 * Filter connections that leave a subcomponent through one of its features.
 *
 * @param connlist
 *            all connections in the component instance that contains the
 *            subcomponent
 * @param sub
 *            a subcomponent
 * @return those connections from connlist that go out of the subcomponent
 */
private List<Connection> filterOutgoingConnections(List<Connection> connlist, Subcomponent sub) {
    List<Connection> result = new ArrayList<Connection>();
    List<Subcomponent> subs = sub.getAllSubcomponentRefinements();
    for (Connection conn : connlist) {
        if (subs.contains(conn.getAllSourceContext()) || conn.isAllBidirectional() && subs.contains(conn.getAllDestinationContext())) {
            result.add(conn);
        }
    }
    return result;
}
Also used : SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ParameterConnection(org.osate.aadl2.ParameterConnection) AccessConnection(org.osate.aadl2.AccessConnection) FeatureGroupConnection(org.osate.aadl2.FeatureGroupConnection) Connection(org.osate.aadl2.Connection) PortConnection(org.osate.aadl2.PortConnection) ArrayList(java.util.ArrayList)

Example 55 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project osate2 by osate.

the class CreateEndToEndFlowsSwitch method isValidContinuation.

boolean isValidContinuation(EndToEndFlowInstance etei, ConnectionInstance conni, FlowSpecification fspec) {
    /*
		 * Issue 2009: Check if the connection instance connects to the flow spec. Here we have a weird
		 * situation. If the subcomponent the flow spec is qualified by is only described by a component type, then
		 * connection end is going to match up with the beginning of the flow. That's fine. If the component
		 * has a classifier implementation AND the flow spec has a flow implementation, then everything will also
		 * fine: either the connection instance is correct and reaches the start of the flow implementation, or it
		 * is incorrect and doesn't. But we can also have the case that the subcomponent is described by a
		 * component implementation but the flow spec does not have a flow implementation. In this case we
		 * still may have the case the connection instance continues into the subcomponent and terminates at a
		 * subsubcomponent. But the flow spec that we have here will be at the edge of the original subcomponent.
		 * so the end connection instance will not match up with the start of the flow spec.
		 *
		 * So what we really need to do is walk backwards along the connections that make up the connection instance
		 * until we find one that connects to the flow because as wee the connection instance may "punch through" the
		 * subcomponent.
		 */
    final FlowEnd inEnd = fspec.getAllInEnd();
    final Context flowCxt = inEnd.getContext();
    final Feature flowIn = inEnd.getFeature();
    final List<Feature> flowInRefined = flowIn.getAllFeatureRefinements();
    final EList<ConnectionReference> connRefs = conni.getConnectionReferences();
    int idx = connRefs.size() - 1;
    boolean result = false;
    while (!result && idx >= 0) {
        final Connection conn = connRefs.get(idx).getConnection();
        result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getDestination());
        if (!result && conn.isBidirectional()) {
            result = isValidContinuationConnectionEnd(flowCxt, flowIn, flowInRefined, conn.getSource());
        }
        idx -= 1;
    }
    return result;
}
Also used : Context(org.osate.aadl2.Context) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) Connection(org.osate.aadl2.Connection) Feature(org.osate.aadl2.Feature) FlowEnd(org.osate.aadl2.FlowEnd)

Aggregations

IOException (java.io.IOException)87 Connection (com.trilead.ssh2.Connection)70 Connection (org.ovirt.engine.sdk4.Connection)64 Connection (org.osate.aadl2.Connection)58 Connection (ch.ethz.ssh2.Connection)47 Test (org.junit.Test)35 Session (com.trilead.ssh2.Session)33 Connection (okhttp3.Connection)33 Connection (org.jboss.remoting3.Connection)33 Connection (com.google.cloud.bigquery.connection.v1.Connection)31 InputStream (java.io.InputStream)31 VmsService (org.ovirt.engine.sdk4.services.VmsService)30 Vm (org.ovirt.engine.sdk4.types.Vm)30 Request (okhttp3.Request)23 Response (okhttp3.Response)20 Subcomponent (org.osate.aadl2.Subcomponent)20 ArrayList (java.util.ArrayList)19 FeatureGroupConnection (org.osate.aadl2.FeatureGroupConnection)19 VmService (org.ovirt.engine.sdk4.services.VmService)18 ResponseBody (okhttp3.ResponseBody)17