Search in sources :

Example 61 with Connection

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

the class ComponentImplementationImpl method getAllConnections.

/**
 * Get list of all connections of a component implementation in a given mode, including ancestor
 * implementations.  In case of refined connections the refined connection is returned in the list.
 *
 * @param mode Mode for which connections are to be retrieved.
 * @return List of connections
 */
public EList<Connection> getAllConnections(Mode mode) {
    final EList<Classifier> ancestors = getSelfPlusAllExtended();
    final BasicEList<Connection> returnlist = new BasicEList<Connection>();
    // Process from farthest ancestor to self
    for (ListIterator<Classifier> li = ancestors.listIterator(ancestors.size()); li.hasPrevious(); ) {
        final ComponentImplementation current = (ComponentImplementation) li.previous();
        final EList<Connection> currentItems = current.getOwnedConnections(mode);
        for (final Connection fe : currentItems) {
            final Connection rfe = fe.getRefined();
            if (rfe != null) {
                returnlist.remove(rfe);
            }
            returnlist.add(fe);
        }
    }
    return returnlist;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) BasicEList(org.eclipse.emf.common.util.BasicEList) FeatureConnection(org.osate.aadl2.FeatureConnection) 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) Classifier(org.osate.aadl2.Classifier)

Example 62 with Connection

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

the class ConnectionImpl method setRefined.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setRefined(Connection newRefined) {
    Connection oldRefined = refined;
    refined = newRefined;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.CONNECTION__REFINED, oldRefined, refined));
    }
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) Connection(org.osate.aadl2.Connection)

Example 63 with Connection

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

the class ConnectionImpl method getPropertyValueInternal.

public final void getPropertyValueInternal(final Property pn, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
    final ComponentImplementation partOf = (ComponentImplementation) getContainingClassifier();
    // First look in the container's contained property associations
    if (!fromInstanceSlaveCall && pas.addLocalContained(this, partOf)) {
        if (!all) {
            return;
        }
    }
    /*
		 * Next see if the property is defined in connection's properties
		 * subclause (could merge this with the loop below, but I want to make
		 * the steps more explicit.)
		 */
    if (pas.addLocal(this)) {
        if (!all) {
            return;
        }
    }
    // Next find the value by walking up the connection's refinement
    // sequence
    Connection refined = getRefined();
    while (refined != null) {
        if (!fromInstanceSlaveCall && pas.addLocalContained(refined, refined.getContainingClassifier())) {
            if (!all) {
                return;
            }
        }
        if (pas.addLocal(refined)) {
            if (!all) {
                return;
            }
        }
        refined = refined.getRefined();
    }
    /*
		 * if still not set, and the property is "inherit", try the containing
		 * component implementation.
		 */
    if (!fromInstanceSlaveCall && pn.isInherit()) {
        partOf.getPropertyValueInternal(pn, pas, fromInstanceSlaveCall, all);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Connection(org.osate.aadl2.Connection)

Example 64 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project hydrator-plugins by cdapio.

the class SSHAction method run.

@Override
public void run(final ActionContext context) throws Exception {
    // Now that macros have been substituted, try validation again
    FailureCollector collector = context.getFailureCollector();
    config.validate(collector);
    collector.getOrThrowException();
    Connection connection = new Connection(config.host, config.port);
    try {
        connection.connect();
        if (!connection.authenticateWithPublicKey(config.user, config.privateKey.toCharArray(), config.passphrase)) {
            throw new IOException(String.format("SSH authentication error when connecting to %s@%s on port %d", config.user, config.host, config.port));
        }
        LOG.debug("Connection established with the host {}", config.host);
        Session session = connection.openSession();
        session.execCommand(config.command);
        InputStream stdout = new StreamGobbler(session.getStdout());
        BufferedReader outBuffer = new BufferedReader(new InputStreamReader(stdout, Charsets.UTF_8));
        InputStream stderr = new StreamGobbler(session.getStderr());
        BufferedReader errBuffer = new BufferedReader(new InputStreamReader(stderr, Charsets.UTF_8));
        String out = CharStreams.toString(outBuffer);
        String err = CharStreams.toString(errBuffer);
        if (out.length() > 0) {
            LOG.debug("Stdout: {}", out);
        }
        if (err.length() > 0) {
            LOG.error("Stderr: {}", err);
        }
        Integer exitCode = session.getExitStatus();
        if (exitCode != null && exitCode != 0) {
            throw new IOException(String.format("Error: command %s running on hostname %s finished with exit code: %d", config.command, config.host, exitCode));
        }
        // Removes the carriage return at the end of the line
        out = out.endsWith("\n") ? out.substring(0, out.length() - 1) : out;
        context.getArguments().set(config.outputKey, out);
    } finally {
        connection.close();
    }
}
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) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Session(ch.ethz.ssh2.Session)

Example 65 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project study-by-myself by Howinfun.

the class HttpLoggingInterceptor method printRequestStart.

private void printRequestStart(Chain chain, Request request, boolean logHeaders, RequestBody requestBody, boolean hasRequestBody) throws IOException {
    Connection connection = chain.connection();
    String requestStartMessage = "--> " + request.method() + ' ' + request.url() + (connection != null ? " " + connection.protocol() : "");
    if (!logHeaders && hasRequestBody) {
        requestStartMessage += " (" + requestBody.contentLength() + "-byte body)";
    }
    logger.log(requestStartMessage);
}
Also used : Connection(okhttp3.Connection)

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