Search in sources :

Example 56 with Connection

use of org.osate.aadl2.Connection in project GreenHouse by utsanjan.

the class StreamAllocation method noNewStreams.

public void noNewStreams() {
    Connection releasedConnection;
    Socket socket;
    synchronized (this.connectionPool) {
        releasedConnection = this.connection;
        socket = deallocate(true, false, false);
        if (this.connection != null) {
            releasedConnection = null;
        }
    }
    Util.closeQuietly(socket);
    if (releasedConnection != null) {
        this.eventListener.connectionReleased(this.call, releasedConnection);
    }
}
Also used : Connection(okhttp3.Connection) Socket(java.net.Socket)

Example 57 with Connection

use of org.osate.aadl2.Connection in project GreenHouse by utsanjan.

the class StreamAllocation method streamFinished.

public void streamFinished(boolean noNewStreams, HttpCodec codec, long bytesRead, IOException e) {
    Connection releasedConnection;
    Socket socket;
    boolean callEnd;
    this.eventListener.responseBodyEnd(this.call, bytesRead);
    synchronized (this.connectionPool) {
        if (codec != null) {
            if (codec == this.codec) {
                if (!noNewStreams) {
                    this.connection.successCount++;
                }
                releasedConnection = this.connection;
                socket = deallocate(noNewStreams, false, true);
                if (this.connection != null) {
                    releasedConnection = null;
                }
                callEnd = this.released;
            }
        }
        throw new IllegalStateException("expected " + this.codec + " but was " + codec);
    }
    Util.closeQuietly(socket);
    if (releasedConnection != null) {
        this.eventListener.connectionReleased(this.call, releasedConnection);
    }
    if (e != null) {
        this.eventListener.callFailed(this.call, Internal.instance.timeoutExit(this.call, e));
    } else if (callEnd) {
        Internal.instance.timeoutExit(this.call, null);
        this.eventListener.callEnd(this.call);
    }
}
Also used : Connection(okhttp3.Connection) Socket(java.net.Socket)

Example 58 with Connection

use of org.osate.aadl2.Connection in project GreenHouse by utsanjan.

the class StreamAllocation method release.

public void release() {
    Connection releasedConnection;
    Socket socket;
    synchronized (this.connectionPool) {
        releasedConnection = this.connection;
        socket = deallocate(false, true, false);
        if (this.connection != null) {
            releasedConnection = null;
        }
    }
    Util.closeQuietly(socket);
    if (releasedConnection != null) {
        Internal.instance.timeoutExit(this.call, null);
        this.eventListener.connectionReleased(this.call, releasedConnection);
        this.eventListener.callEnd(this.call);
    }
}
Also used : Connection(okhttp3.Connection) Socket(java.net.Socket)

Example 59 with Connection

use of org.osate.aadl2.Connection in project GreenHouse by utsanjan.

the class StreamAllocation method findConnection.

private RealConnection findConnection(int connectTimeout, int readTimeout, int writeTimeout, int pingIntervalMillis, boolean connectionRetryEnabled) throws IOException {
    Socket toClose;
    Connection releasedConnection;
    boolean newRouteSelection;
    RouteSelector.Selection selection;
    boolean foundPooledConnection = false;
    RealConnection result = null;
    Route selectedRoute = null;
    synchronized (this.connectionPool) {
        if (this.released) {
            throw new IllegalStateException("released");
        } else if (this.codec != null) {
            throw new IllegalStateException("codec != null");
        } else if (!this.canceled) {
            Connection releasedConnection2 = this.connection;
            toClose = releaseIfNoNewStreams();
            if (this.connection != null) {
                result = this.connection;
                releasedConnection2 = null;
            }
            if (!this.reportedAcquired) {
                releasedConnection = null;
            } else {
                releasedConnection = releasedConnection2;
            }
            if (result == null) {
                Internal.instance.get(this.connectionPool, this.address, this, null);
                if (this.connection != null) {
                    foundPooledConnection = true;
                    result = this.connection;
                } else {
                    selectedRoute = this.route;
                }
            }
        } else {
            throw new IOException("Canceled");
        }
    }
    Util.closeQuietly(toClose);
    if (releasedConnection != null) {
        this.eventListener.connectionReleased(this.call, releasedConnection);
    }
    if (foundPooledConnection) {
        this.eventListener.connectionAcquired(this.call, result);
    }
    if (result != null) {
        return result;
    }
    if (selectedRoute != null || ((selection = this.routeSelection) != null && selection.hasNext())) {
        newRouteSelection = false;
    } else {
        this.routeSelection = this.routeSelector.next();
        newRouteSelection = true;
    }
    synchronized (this.connectionPool) {
        if (!this.canceled) {
            if (newRouteSelection) {
                List<Route> routes = this.routeSelection.getAll();
                int i = 0;
                int size = routes.size();
                while (true) {
                    if (i >= size) {
                        break;
                    }
                    Route route = routes.get(i);
                    Internal.instance.get(this.connectionPool, this.address, this, route);
                    if (this.connection != null) {
                        foundPooledConnection = true;
                        result = this.connection;
                        this.route = route;
                        break;
                    }
                    i++;
                }
            }
            if (!foundPooledConnection) {
                if (selectedRoute == null) {
                    selectedRoute = this.routeSelection.next();
                }
                this.route = selectedRoute;
                this.refusedStreamCount = 0;
                result = new RealConnection(this.connectionPool, selectedRoute);
                acquire(result, false);
            }
        } else {
            throw new IOException("Canceled");
        }
    }
    if (foundPooledConnection) {
        this.eventListener.connectionAcquired(this.call, result);
        return result;
    }
    result.connect(connectTimeout, readTimeout, writeTimeout, pingIntervalMillis, connectionRetryEnabled, this.call, this.eventListener);
    routeDatabase().connected(result.route());
    Socket socket = null;
    synchronized (this.connectionPool) {
        this.reportedAcquired = true;
        Internal.instance.put(this.connectionPool, result);
        if (result.isMultiplexed()) {
            socket = Internal.instance.deduplicate(this.connectionPool, this.address, this);
            result = this.connection;
        }
    }
    Util.closeQuietly(socket);
    this.eventListener.connectionAcquired(this.call, result);
    return result;
}
Also used : RouteSelector(okhttp3.internal.connection.RouteSelector) Connection(okhttp3.Connection) IOException(java.io.IOException) Socket(java.net.Socket) Route(okhttp3.Route)

Example 60 with Connection

use of org.osate.aadl2.Connection in project VERDICT by ge-high-assurance.

the class Aadl2CsvTranslator method buildScnBusBindingsTable.

/**
 * Build the scenario bus bindings table
 */
Table buildScnBusBindingsTable() {
    Table scnBusBindingsTable = new Table("Scenario", "Comp", "Impl", "ActualConnectionBindingSrcComp", "ActualConnectionBindingSrcImpl", "ActualConnectionBindingSrcCompInst", "ActualConnectionBindingSrcBusInst", "ActualConnectionBindingDestConnComp", "ActualConnectionBindingDestConnImpl", "ActualConnectionBindingDestConnCompInst", "ActualConnectionBindingDestConn");
    for (ComponentImplementation sysImpl : compImpls) {
        for (PropertyAssociation propAssoc : sysImpl.getOwnedPropertyAssociations()) {
            if (propAssoc.getOwnedValues().size() != 1) {
                throw new RuntimeException("Unexpected number of property owned values: " + propAssoc.getOwnedValues().size());
            }
            PropertyExpression expr = propAssoc.getOwnedValues().get(0).getOwnedValue();
            // Obtain the bus reference values
            String[] compImplInstBusNames = getStrRepofExpr(expr);
            // We only consider the case where the length of compImplInstBusNames is 4
            if (compImplInstBusNames.length != 4) {
                throw new RuntimeException("Unexpected number of values in property expression: " + compImplInstBusNames.length);
            }
            // property: bus connection binding applies to connections
            for (ContainedNamedElement appliesToImpl : propAssoc.getAppliesTos()) {
                PortConnection appliesToConn = null;
                SystemSubcomponent appliesToSubcomp = null;
                scnBusBindingsTable.addValue(scenario);
                scnBusBindingsTable.addValue(sysImpl.getTypeName());
                scnBusBindingsTable.addValue(sysImpl.getName());
                scnBusBindingsTable.addValue(compImplInstBusNames[0]);
                scnBusBindingsTable.addValue(compImplInstBusNames[1]);
                scnBusBindingsTable.addValue(compImplInstBusNames[2]);
                scnBusBindingsTable.addValue(compImplInstBusNames[3]);
                if (appliesToImpl.getContainmentPathElements().size() > 2) {
                    throw new RuntimeException("Unexpected number of values in ContainedNamedElement: " + appliesToImpl.getContainmentPathElements().size());
                }
                for (ContainmentPathElement element : appliesToImpl.getContainmentPathElements()) {
                    NamedElement namedElement = element.getNamedElement();
                    if (namedElement instanceof SystemSubcomponent) {
                        appliesToSubcomp = (SystemSubcomponent) namedElement;
                    } else if (namedElement instanceof PortConnection) {
                        appliesToConn = (PortConnection) namedElement;
                    } else {
                        throw new RuntimeException("Unexpected value: " + namedElement);
                    }
                }
                if (appliesToSubcomp != null) {
                    ComponentImplementation compImpl = appliesToSubcomp.getComponentImplementation();
                    scnBusBindingsTable.addValue(compImpl.getTypeName());
                    scnBusBindingsTable.addValue(compImpl.getName());
                    scnBusBindingsTable.addValue(appliesToSubcomp.getName());
                } else {
                    scnBusBindingsTable.addValue(sysImpl.getTypeName());
                    scnBusBindingsTable.addValue(sysImpl.getName());
                    scnBusBindingsTable.addValue("");
                }
                scnBusBindingsTable.addValue(appliesToConn.getName());
                scnBusBindingsTable.capRow();
            }
        }
    }
    return scnBusBindingsTable;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) PropertyAssociation(org.osate.aadl2.PropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) PropertyExpression(org.osate.aadl2.PropertyExpression) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) PortConnection(org.osate.aadl2.PortConnection)

Aggregations

IOException (java.io.IOException)77 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)64 Connection (org.ovirt.engine.sdk4.Connection)64 Connection (com.trilead.ssh2.Connection)61 Connection (org.osate.aadl2.Connection)57 ConnectionInstance (org.osate.aadl2.instance.ConnectionInstance)51 ArrayList (java.util.ArrayList)36 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)35 Connection (ch.ethz.ssh2.Connection)34 Session (com.trilead.ssh2.Session)33 Connection (org.jboss.remoting3.Connection)33 Test (org.junit.Test)32 ConnectionInstanceEnd (org.osate.aadl2.instance.ConnectionInstanceEnd)32 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 Connection (okhttp3.Connection)29 ConnectionReference (org.osate.aadl2.instance.ConnectionReference)29 Subcomponent (org.osate.aadl2.Subcomponent)28