Search in sources :

Example 31 with BooleanWrapper

use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.

the class RMCore method defineNodeSource.

/**
 * {@inheritDoc}
 */
@Override
public BooleanWrapper defineNodeSource(String nodeSourceName, String infrastructureType, Object[] infraParams, String policyType, Object[] policyParams, boolean nodesRecoverable) {
    this.validateNodeSourceNameOrFail(nodeSourceName);
    nodeSourceName = nodeSourceName.trim();
    logger.info("Define node source " + nodeSourceName + REQUESTED_BY_STRING + this.caller.getName());
    NodeSourceDescriptor nodeSourceDescriptor = this.persistNodeSourceAndGetDescriptor(nodeSourceName, infrastructureType, infraParams, policyType, policyParams, nodesRecoverable);
    NodeSource nodeSource = this.createNodeSourceInstance(nodeSourceDescriptor);
    this.definedNodeSources.put(nodeSourceName, nodeSource);
    this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(RMEventType.NODESOURCE_DEFINED, this.caller.getName(), nodeSourceName, nodeSource.getDescription(), nodeSourceDescriptor.getProvider().getName(), nodeSource.getStatus().toString()));
    logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully defined");
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeSourceDescriptor(org.ow2.proactive.resourcemanager.nodesource.NodeSourceDescriptor)

Example 32 with BooleanWrapper

use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.

the class RMCore method removeNode.

public BooleanWrapper removeNode(String nodeUrl, boolean preempt, boolean isTriggeredFromShutdownHook) {
    // if we get a "deploying node url" we change the flow
    if (RMNodeHelper.isDeployingNodeURL(nodeUrl)) {
        RMNode deployingNode = getNodeByUrlIncludingDeployingNodes(nodeUrl);
        if (!isTriggeredFromShutdownHook && deployingNode != null && deployingNode.isLocked()) {
            dbManager.createLockEntryOrUpdate(deployingNode.getNodeSourceName(), RMDBManager.NodeLockUpdateAction.DECREMENT);
        }
        return new BooleanWrapper(removeDeployingNode(nodeUrl));
    }
    if (this.allNodes.containsKey(nodeUrl)) {
        RMNode rmnode = this.allNodes.get(nodeUrl);
        logger.debug("Request to remove node " + rmnode);
        // checking if the caller is the node administrator
        checkNodeAdminPermission(rmnode, caller);
        if (!isTriggeredFromShutdownHook && rmnode.isLocked()) {
            dbManager.createLockEntryOrUpdate(rmnode.getNodeSourceName(), RMDBManager.NodeLockUpdateAction.DECREMENT);
        }
        if (rmnode.isDown() || preempt || rmnode.isFree() || rmnode.isLocked()) {
            removeNodeFromCoreAndSource(rmnode, caller);
        } else if (rmnode.isBusy() || rmnode.isConfiguring()) {
            internalSetToRemove(rmnode, caller);
        }
    } else {
        logger.warn("An attempt to remove a non existing node: " + nodeUrl + " was made. Ignoring it");
        return new BooleanWrapper(false);
    }
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode)

Example 33 with BooleanWrapper

use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.

the class NodeSource method removeNode.

/**
 * Removes the node from the node source.
 *
 * @param nodeUrl the url of the node to be released
 */
public BooleanWrapper removeNode(String nodeUrl, Client initiator) {
    // node could have fallen between remove request and the confirm
    if (this.nodes.containsKey(nodeUrl)) {
        logger.info("[" + name + "] removing node : " + nodeUrl);
        Node node = nodes.remove(nodeUrl);
        RMCore.topologyManager.removeNode(node);
        try {
            infrastructureManager.internalRemoveNode(node);
        } catch (RMException e) {
            logger.error(e.getCause().getMessage(), e);
        }
    } else {
        Node downNode = downNodes.remove(nodeUrl);
        if (downNode != null) {
            logger.info("[" + name + "] removing down node : " + nodeUrl);
        } else {
            logger.error("[" + name + "] removing node : " + nodeUrl + " which not belongs to this node source");
            return new BooleanWrapper(false);
        }
    }
    if (this.toShutdown && this.nodes.size() == 0) {
        this.shutdownNodeSourceServices(initiator);
    }
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) 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) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 34 with BooleanWrapper

use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.

the class CronPolicy method configure.

/**
 * Configure a policy with given parameters.
 * @param policyParameters parameters defined by user
 */
@Override
public BooleanWrapper configure(Object... policyParameters) {
    super.configure(policyParameters);
    try {
        cronScheduler = new Scheduler();
        int index = 2;
        nodeAcquision = policyParameters[index++].toString();
        nodeRemoval = policyParameters[index++].toString();
        preemptive = Boolean.parseBoolean(policyParameters[index++].toString());
        forceDeployment = Boolean.parseBoolean(policyParameters[index++].toString());
    } catch (Throwable t) {
        throw new IllegalArgumentException(t);
    }
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) Scheduler(it.sauronsoftware.cron4j.Scheduler)

Example 35 with BooleanWrapper

use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.

the class ReleaseResourcesWhenSchedulerIdle method configure.

/**
 * Configure a policy with given parameters.
 * @param policyParameters parameters defined by user
 */
@Override
public BooleanWrapper configure(Object... policyParameters) {
    super.configure(policyParameters);
    try {
        timer = new Timer("ReleaseResourcesWhenSchedulerIdle Timer(1)", true);
        idleTime = Long.parseLong(policyParameters[6].toString());
    } catch (RuntimeException e) {
        throw new IllegalArgumentException(e);
    }
    return new BooleanWrapper(true);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) Timer(java.util.Timer)

Aggregations

BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)36 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)10 Test (org.junit.Test)9 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)7 Matchers.anyString (org.mockito.Matchers.anyString)5 Node (org.objectweb.proactive.core.node.Node)5 HashSet (java.util.HashSet)4 Client (org.ow2.proactive.resourcemanager.authentication.Client)4 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)4 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)4 NodeSet (org.ow2.proactive.utils.NodeSet)4 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)3 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)3 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)3 RMTHelper (functionaltests.utils.RMTHelper)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 HttpResponse (org.apache.http.HttpResponse)2 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)2 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)2