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);
}
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations