Search in sources :

Example 46 with Connection

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

the class ConnectionReferenceImpl method setConnection.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setConnection(Connection newConnection) {
    Connection oldConnection = connection;
    connection = newConnection;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.CONNECTION_REFERENCE__CONNECTION, oldConnection, connection));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Connection(org.osate.aadl2.Connection)

Example 47 with Connection

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

the class ComponentInstanceImpl method isSameOrRefined.

/**
 * determine whether two connections are the same or one is a refinement of the other
 * @param firstconn Connection
 * @param secondconn Connection
 * @return boolean true if same or refined
 */
private static boolean isSameOrRefined(Connection firstconn, Connection secondconn) {
    if (firstconn == secondconn) {
        return true;
    }
    Connection cfi = firstconn;
    while (cfi != null) {
        if (secondconn == cfi) {
            return true;
        }
        cfi = cfi.getRefined();
    }
    cfi = secondconn;
    while (cfi != null) {
        if (firstconn == cfi) {
            return true;
        }
        cfi = cfi.getRefined();
    }
    return false;
}
Also used : Connection(org.osate.aadl2.Connection)

Example 48 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project MyJavaProject by ykdsg.

the class Basic method main.

public static void main(String[] args) {
    String hostname = "test.ssh";
    String username = "admin";
    String password = "Yangtuojia001";
    try {
        /* Create a connection instance */
        Connection conn = new Connection(hostname);
        /* Now connect */
        conn.connect();
        /*
             * Authenticate. If you get an IOException saying something like
             * "Authentication method password not supported by the server at this stage." then please check the FAQ.
             */
        boolean isAuthenticated = conn.authenticateWithPassword(username, password);
        if (isAuthenticated == false)
            throw new IOException("Authentication failed.");
        /* Create a session */
        Session sess = conn.openSession();
        sess.execCommand("uname -a && date && uptime && who");
        System.out.println("Here is some information about the remote host:");
        /*
             * This basic example does not handle stderr, which is sometimes dangerous (please read the FAQ).
             */
        InputStream stdout = new StreamGobbler(sess.getStdout());
        BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
        while (true) {
            String line = br.readLine();
            if (line == null) {
                br.close();
                break;
            }
            System.out.println(line);
        }
        /* Show exit status, if available (otherwise "null") */
        System.out.println("ExitCode: " + sess.getExitStatus());
        /* Close this session */
        sess.close();
        /* Close the connection */
        conn.close();
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.exit(2);
    }
}
Also used : StreamGobbler(ch.ethz.ssh2.StreamGobbler) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Connection(ch.ethz.ssh2.Connection) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) Session(ch.ethz.ssh2.Session)

Example 49 with Connection

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

the class CacheContainedPropertyAssociationsSwitch method processContainedPropertyAssociations.

/**
 * Copy contained property associations to the instance model.
 * Don't fully evaluate the property expression. Just replace reference values with
 * a reference to the referenced instance object.
 *
 * @param modeContext
 * @param ci
 * @param propertyAssociations
 */
protected void processContainedPropertyAssociations(final ComponentInstance modeContext, final ComponentInstance ci, final EList<PropertyAssociation> propertyAssociations) {
    for (PropertyAssociation pa : propertyAssociations) {
        // OsateDebug.osateDebug ("[CacheContainedProperty] Process contained property association: " + pa.getProperty().getName());
        Property prop = pa.getProperty();
        if (Aadl2Util.isNull(prop) || Aadl2Util.isNull(prop.getType())) {
            continue;
        }
        for (ContainedNamedElement cne : pa.getAppliesTos()) {
            final EList<ContainmentPathElement> cpes = cne.getContainmentPathElements();
            if (cpes != null && !cpes.isEmpty()) {
                final NamedElement last = cpes.get(cpes.size() - 1).getNamedElement();
                final List<InstanceObject> ios = ci.findInstanceObjects(cpes);
                for (InstanceObject io : ios) {
                    // OsateDebug.osateDebug (" io=" + io);
                    PropertyAssociationInstance newPA = InstanceFactory.eINSTANCE.createPropertyAssociationInstance();
                    newPA.setProperty(prop);
                    newPA.setPropertyAssociation(pa);
                    newPA.getOwnedValues().addAll(EcoreUtil.copyAll(pa.getOwnedValues()));
                    // replace reference values in the context of the contained PA's owner
                    for (Iterator<Element> content = EcoreUtil.getAllProperContents(newPA, false); content.hasNext(); ) {
                        Element elem = content.next();
                        if (elem instanceof ReferenceValue) {
                            // TODO: LW what if ref to connection?
                            try {
                                PropertyExpression irv = ((ReferenceValue) elem).instantiate(ci);
                                if (irv != null) {
                                    EcoreUtil.replace(elem, irv);
                                }
                            } catch (InvalidModelException e) {
                                error(io, e.getMessage());
                            }
                        }
                    }
                    if (last instanceof Connection) {
                        final PropertyAssociation existingPA = scProps.retrieveSCProperty((ConnectionInstance) io, prop, (Connection) last);
                        if (existingPA != null && isConstant(existingPA)) {
                            /*
								 * Cannot put the error on the property association that is affected because it might
								 * be a declarative model element at this point. Need to report the error on the
								 * instance object itself.
								 */
                            getErrorManager().error(io, "Property association for \"" + prop.getQualifiedName() + "\" is constant.  A contained property association in classifier \"" + pa.getContainingClassifier().getQualifiedName() + "\" tries to replace it.");
                        } else {
                            scProps.recordSCProperty((ConnectionInstance) io, prop, (Connection) last, newPA);
                        }
                    } else {
                        final PropertyAssociation existingPA = io.getPropertyValue(prop, false).first();
                        if (existingPA != null && isConstant(existingPA)) {
                            /*
								 * Cannot put the error on the property association that is affected because it might
								 * be a declarative model element at this point. Need to report the error on the
								 * instance object itself.
								 */
                            getErrorManager().error(io, "Property association for \"" + prop.getQualifiedName() + "\" is constant.  A contained property association in classifier \"" + pa.getContainingClassifier().getQualifiedName() + "\" tries to replace it.");
                        } else {
                            io.removePropertyAssociations(prop);
                            io.getOwnedPropertyAssociations().add(newPA);
                        }
                    }
                }
            }
        }
        checkIfCancelled();
        if (cancelled()) {
            break;
        }
    }
}
Also used : PropertyAssociation(org.osate.aadl2.PropertyAssociation) ReferenceValue(org.osate.aadl2.ReferenceValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Connection(org.osate.aadl2.Connection) InstanceObject(org.osate.aadl2.instance.InstanceObject) InvalidModelException(org.osate.aadl2.properties.InvalidModelException) PropertyAssociationInstance(org.osate.aadl2.instance.PropertyAssociationInstance) PropertyExpression(org.osate.aadl2.PropertyExpression) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 50 with Connection

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

the class CreateEndToEndFlowsSwitch method processSubcomponentFlow.

/**
 * Instantiate a flow specification by recursively following its
 * implementation until a leaf element is reached In case of a leaf element
 * add it as a flow step
 *
 * @param ci the component whose flow specification is to be processed
 * @param etei the end to end flow instance
 * @param fs the flow specification to be processed
 */
protected void processSubcomponentFlow(final ComponentInstance ci, EndToEndFlowInstance etei, final FlowSpecification fs, FlowIterator iter) {
    final ComponentImplementation subImpl = InstanceUtil.getComponentImplementation(ci, 0, classifierCache);
    final EList<FlowImplementation> flowImpls = new BasicEList<FlowImplementation>(10);
    // Collect flow impls for this flow spec
    if (subImpl != null) {
        for (FlowImplementation fl : subImpl.getAllFlowImplementations()) {
            if (fl.getSpecification().getName().equalsIgnoreCase(fs.getName())) {
                flowImpls.add(fl);
            }
        }
    }
    if (flowImpls.isEmpty()) {
        // we are at a leaf
        processFlowStep(ci, etei, fs, iter);
        if (subImpl != null && AadlUtil.hasPortComponents(subImpl)) {
            warning(etei, "End-to-end flow " + etei.getName() + " contains component " + ci.getName() + " with subcomponents, but no flow implementation " + fs.getName() + " to them");
        }
    } else {
        Iterator<FlowImplementation> itt = flowImpls.iterator();
        state.push(iter);
        while (itt.hasNext()) {
            EndToEndFlowInstance eteiClone = null;
            Stack<FlowIterator> stateClone = null;
            FlowIterator iterClone = null;
            List<Connection> connectionsClone = new ArrayList<Connection>();
            FlowImplementation flowImpl = itt.next();
            boolean prepareNext = itt.hasNext();
            if (prepareNext) {
                stateClone = clone(state);
                eteiClone = EcoreUtil.copy(etei);
                iterClone = iter.clone();
                connectionsClone = new ArrayList<Connection>(connections);
                eteiClone.getModesList().addAll(etei.getModesList());
            }
            /*
				 * Special case for Issue 1953: If flowImpl is a flow in a Thread, and has a non-trivial implementation
				 * (i.e, it doesn't just pass through), then we ignore the flow implementation details and just use the
				 * flow specification. Specifically, we are trying NOT to ignore the case where the flow specification
				 * uses a feature group and the flow implementation refines the feature group to a specific feature
				 * of that feature group. THese cases are necessary to reduce the combinatorics of the instance model.
				 *
				 * CAVEAT: Make sure we don't discard the mode information from the flow implementation, even if we are
				 * ignoring the flow segments.
				 */
            if (subImpl instanceof ThreadClassifier && flowImpl.getOwnedFlowSegments().size() != 0) {
                // Do use the modes from the flow implementation
                etei.getModesList().add(getModeInstances(ci, flowImpl));
                state.pop();
                // Revert to using the flow specification
                processFlowStep(ci, etei, fs, iter);
            } else {
                if (!processFlowImpl(ci, etei, flowImpl)) {
                    processFlowStep(ci, etei, fs, flowImpl, iter);
                }
            }
            if (prepareNext) {
                // add clone
                etei.getContainingComponentInstance().getEndToEndFlows().add(eteiClone);
                etei = eteiClone;
                state = stateClone;
                iter = iterClone;
                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));
                }
                connections = connectionsClone;
            }
        }
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) FlowImplementation(org.osate.aadl2.FlowImplementation) BasicEList(org.eclipse.emf.common.util.BasicEList) Connection(org.osate.aadl2.Connection) ArrayList(java.util.ArrayList) ThreadClassifier(org.osate.aadl2.ThreadClassifier) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance)

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