Search in sources :

Example 1 with RoutingConnection

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");
}
Also used : RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection) ConnectionEvent(com.swiftmq.impl.routing.single.manager.event.ConnectionEvent)

Example 2 with RoutingConnection

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");
}
Also used : RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection) ConnectionEvent(com.swiftmq.impl.routing.single.manager.event.ConnectionEvent)

Example 3 with RoutingConnection

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;
}
Also used : RoutingEvent(com.swiftmq.swiftlet.routing.event.RoutingEvent) RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection)

Example 4 with RoutingConnection

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;
}
Also used : RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection)

Example 5 with RoutingConnection

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");
}
Also used : Scheduler(com.swiftmq.impl.routing.single.schedule.Scheduler) RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection) List(java.util.List)

Aggregations

RoutingConnection (com.swiftmq.impl.routing.single.connection.RoutingConnection)8 ConnectionEvent (com.swiftmq.impl.routing.single.manager.event.ConnectionEvent)3 List (java.util.List)3 Scheduler (com.swiftmq.impl.routing.single.schedule.Scheduler)2 Entity (com.swiftmq.mgmt.Entity)1 Property (com.swiftmq.mgmt.Property)1 RoutingEvent (com.swiftmq.swiftlet.routing.event.RoutingEvent)1