Search in sources :

Example 1 with Service

use of org.objectweb.proactive.Service in project scheduling by ow2-proactive.

the class RMCore method runActivity.

/**
 * RunActivity periodically send "alive" event to listeners
 */
public void runActivity(Body body) {
    Service service = new Service(body);
    // recalculating nodes number only once per policy period
    while (body.isActive()) {
        Request request = null;
        try {
            request = service.blockingRemoveOldest(PAResourceManagerProperties.RM_ALIVE_EVENT_FREQUENCY.getValueAsLong());
            if (request != null) {
                try {
                    try {
                        caller = checkMethodCallPermission(request.getMethodName(), request.getSourceBodyID());
                        service.serve(request);
                    } catch (SecurityException ex) {
                        logger.warn("Cannot serve request: " + request, ex);
                        service.serve(new ThrowExceptionRequest(request, ex));
                    }
                } catch (Throwable e) {
                    logger.error("Cannot serve request: " + request, e);
                }
            }
        } catch (InterruptedException e) {
            logger.warn("runActivity interrupted", e);
        }
    }
}
Also used : Request(org.objectweb.proactive.core.body.request.Request) ImmediateService(org.objectweb.proactive.annotation.ImmediateService) Service(org.objectweb.proactive.Service)

Example 2 with Service

use of org.objectweb.proactive.Service in project scheduling by ow2-proactive.

the class NodeSource method runActivity.

public void runActivity(Body body) {
    Service service = new Service(body);
    long timeStamp = System.currentTimeMillis();
    long delta = 0;
    // recalculating nodes number only once per policy period
    while (body.isActive()) {
        try {
            service.blockingServeOldest(pingFrequency);
            delta += System.currentTimeMillis() - timeStamp;
            timeStamp = System.currentTimeMillis();
            if (delta > pingFrequency) {
                logger.info("[" + name + "] Pinging alive nodes : " + getAliveNodes().size());
                for (Node node : getAliveNodes()) {
                    pingNode(node);
                }
                delta = 0;
            }
        } catch (InterruptedException e) {
            logger.warn("runActivity interrupted", e);
        }
    }
}
Also used : RMDeployingNode(org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode) Service(org.objectweb.proactive.Service) ImmediateService(org.objectweb.proactive.annotation.ImmediateService)

Aggregations

Service (org.objectweb.proactive.Service)2 ImmediateService (org.objectweb.proactive.annotation.ImmediateService)2 Request (org.objectweb.proactive.core.body.request.Request)1 Node (org.objectweb.proactive.core.node.Node)1 AbstractRMNode (org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)1 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)1 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)1