use of com.swiftmq.impl.routing.single.connection.RoutingConnection in project swiftmq-ce by iitsoftware.
the class ConnectionManager method visit.
public void visit(PORemoveObject por) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/visitConnectionRemove...");
RoutingConnection rc = por.getConnection();
removeConnection(rc, true);
por.setSuccess(true);
if (por.getCallback() != null)
por.getCallback().onSuccess(por);
if (por.getSemaphore() != null)
por.getSemaphore().notifySingleWaiter();
fireConnectionRemoved(new ConnectionEvent(rc));
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/visitConnectionRemove done");
}
use of com.swiftmq.impl.routing.single.connection.RoutingConnection in project swiftmq-ce by iitsoftware.
the class ConnectionManager method removeAll.
private void removeAll() {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/removeAll...");
for (Iterator iter = connections.entrySet().iterator(); iter.hasNext(); ) {
RoutingConnection rc = (RoutingConnection) ((Map.Entry) iter.next()).getValue();
removeConnection(rc, false);
iter.remove();
fireConnectionRemoved(new ConnectionEvent(rc));
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/removeAll done");
}
use of com.swiftmq.impl.routing.single.connection.RoutingConnection in project swiftmq-ce by iitsoftware.
the class DefaultScheduler method getNextConnection.
protected synchronized RoutingConnection getNextConnection() {
RoutingConnection rc = null;
if (connections.size() == 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 0, rc=" + rc);
return null;
}
if (connections.size() == 1) {
rc = ((ConnectionEntry) connections.get(0)).getRoutingConnection();
if (rc.isClosed()) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 1, rc is closed");
connections.clear();
rc = null;
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 1, rc=" + rc);
} else {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == " + connections.size() + " ...");
for (Iterator iter = connections.iterator(); iter.hasNext(); ) {
rc = ((ConnectionEntry) iter.next()).getRoutingConnection();
if (rc.isClosed()) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == " + connections.size() + ", rc is closed");
iter.remove();
rc = null;
} else
break;
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == " + connections.size() + ", rc=" + rc);
}
if (rc == null && connections.size() == 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 0, rc=" + rc + ", destinationDeactivated");
ctx.routingSwiftlet.fireRoutingEvent("destinationDeactivated", new RoutingEvent(ctx.routingSwiftlet, destinationRouter));
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, rc=" + rc);
return rc;
}
use of com.swiftmq.impl.routing.single.connection.RoutingConnection in project swiftmq-ce by iitsoftware.
the class RoundRobinScheduler method getNextConnection.
protected synchronized RoutingConnection getNextConnection() {
if (connections.size() == 0)
return null;
if (next > connections.size() - 1)
next = 0;
RoutingConnection rc = connections.size() == 0 ? null : ((ConnectionEntry) connections.get(next)).getRoutingConnection();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, rc=" + rc);
next++;
return rc;
}
use of com.swiftmq.impl.routing.single.connection.RoutingConnection in project swiftmq-ce by iitsoftware.
the class RouteExchanger method visit.
public void visit(PORouteObject po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/visit, po=" + po + " ...");
Route route = po.getRoute();
try {
Scheduler scheduler = ctx.schedulerRegistry.getScheduler(route.getDestinationRouter());
if (route.getType() == Route.ADD) {
routeTable.addRoute(route);
scheduler.addRoute(route);
} else {
routeTable.removeRoute(route);
scheduler.removeRoute(route);
}
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/visit, po=" + po + ", exception scheduling: " + e);
}
List connections = routeTable.getRoutingConnections();
if (connections != null) {
for (int i = 0; i < connections.size(); i++) {
RoutingConnection rc = (RoutingConnection) connections.get(i);
sendRoute(rc, route);
}
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/visit, po=" + po + " done");
}
Aggregations