use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class RMNodeStarter method killWorkerNodeIfRemovedByUser.
private void killWorkerNodeIfRemovedByUser(Map<String, Node> nodes, String unknownNodeUrl) {
Node node = nodes.get(unknownNodeUrl);
if (node == null) {
logger.warn("The RM has sent back an URL that was not published by the Node: " + unknownNodeUrl);
} else {
// The node URL which has been published to the RMCore is unknown.
// It means the node has been removed by a user
String nodeName = node.getNodeInformation().getName();
try {
// Kill the local worker node
node.getProActiveRuntime().killNode(nodeName);
} catch (Exception e) {
logger.warn("Killing the local node has failed: " + nodeName, e);
} finally {
nodes.remove(unknownNodeUrl);
logger.info("Node " + unknownNodeUrl + " has been removed ");
}
}
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class RMFactory method startLocal.
/**
* Creates and starts a Resource manager on the local host using the given initializer to configure it.
* Only one RM can be started by JVM.
*
* @param initializer Use to configure the Resource Manager before starting it.
* This parameter can be null, if so the Resource Manager will try to start on the JVM properties and
* the "pa.rm.home" property MUST be set to the root of the RM directory.
* @return a RM authentication that allow you to administer the RM or get its connection URL.
*
* @throws NodeException If the RM's node can't be created
* @throws ActiveObjectCreationException If RMCore cannot be created
* @throws AlreadyBoundException if a node with the same RMNode's name is already exist.
* @throws IOException If node and RMCore fails.
* @throws RMException if the connection to the authentication interface fails.
*/
public static RMAuthentication startLocal(RMInitializer initializer) throws Exception {
if (rmcore == null) {
if (initializer != null) {
// configure application
configure(initializer);
}
configureLog4j();
Node nodeRM = NodeFactory.createLocalNode(PAResourceManagerProperties.RM_NODE_NAME.getValueAsString(), false, null, null);
String RMCoreName = RMConstants.NAME_ACTIVE_OBJECT_RMCORE;
rmcore = (RMCore) // the class to deploy
PAActiveObject.newActive(// the class to deploy
RMCore.class.getName(), new Object[] { RMCoreName, nodeRM }, nodeRM);
logger.debug("New RM core started locally");
return RMConnection.waitAndJoin(null);
} else {
throw new RMException("RM Core already running locally");
}
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class RMAuthenticationImpl method login.
/**
* Performs user authentication
*/
public ResourceManager login(Credentials cred) throws LoginException {
Client client = new Client(authenticate(cred), true);
client.setCredentials(cred);
if (RMCore.clients.containsKey(client.getId())) {
logger.info(client + " reconnected.");
}
RMCore.clients.put(client.getId(), client);
UserHistory history = new UserHistory(client);
RMDBManager.getInstance().saveUserHistory(history);
client.setHistory(history);
logger.info(client + " connected from " + client.getId().shortString());
try {
// return the stub on ResourceManager interface to keep avoid using server class on client side
return PAActiveObject.lookupActive(ResourceManager.class, PAActiveObject.getUrl(rmcore));
} catch (ActiveObjectCreationException e) {
rethrowStubException(e);
} catch (IOException e) {
rethrowStubException(e);
}
return null;
}
Aggregations