use of org.ow2.proactive.resourcemanager.authentication.RMAuthentication in project scheduling by ow2-proactive.
the class NonBlockingCoreTest method action.
@Test
public void action() throws Exception {
String rmconf = new File(PAResourceManagerProperties.getAbsolutePath(getClass().getResource("/functionaltests/config/functionalTRMProperties-long-selection-script-timeout.ini").getFile())).getAbsolutePath();
rmHelper.startRM(rmconf);
ResourceManager resourceManager = rmHelper.getResourceManager();
int initialNodeNumber = 2;
rmHelper.createNodeSource("NonBlockingCoreTest1", initialNodeNumber);
long coreScriptExecutionTimeout = PAResourceManagerProperties.RM_SELECT_SCRIPT_TIMEOUT.getValueAsLong();
long scriptSleepingTime = coreScriptExecutionTimeout * 2;
log("Selecting node with timeout script");
// create the static selection script object
final SelectionScript sScript = new SelectionScript(new File(selectionScriptWithtimeOutPath.toURI()), new String[] { Long.toString(scriptSleepingTime) }, false);
// mandatory to use RMUser AO, otherwise, getAtMostNode we be send in
// RMAdmin request queue
final RMAuthentication auth = rmHelper.getRMAuth();
final Credentials cred = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), auth.getPublicKey());
// cannot connect twice from the same active object
// so creating another thread
Thread t = new Thread() {
public void run() {
ResourceManager rm2;
try {
rm2 = auth.login(cred);
nodes = rm2.getAtMostNodes(2, sScript);
} catch (LoginException e) {
}
}
};
t.start();
String nodeName = "node_non_blocking_test";
testNode = RMTHelper.createNode(nodeName);
String nodeUrl = testNode.getNode().getNodeInformation().getURL();
log("Adding node " + nodeUrl);
resourceManager.addNode(nodeUrl);
rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, nodeUrl);
// waiting for node to be in free state, it is in configuring state when
// added...
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
assertEquals(resourceManager.getState().getTotalNodesNumber(), initialNodeNumber + 1);
assertEquals(resourceManager.getState().getFreeNodesNumber(), initialNodeNumber + 1);
// preemptive removal is useless for this case, because node is free
log("Removing node " + nodeUrl);
resourceManager.removeNode(nodeUrl, false);
rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, nodeUrl);
assertEquals(resourceManager.getState().getTotalNodesNumber(), initialNodeNumber);
assertEquals(resourceManager.getState().getFreeNodesNumber(), initialNodeNumber);
String nsName = "NonBlockingCoreTest";
log("Creating a node source " + nsName);
int nsNodesNumber = 1;
rmHelper.createNodeSource(nsName, nsNodesNumber);
assertEquals(resourceManager.getState().getTotalNodesNumber(), nsNodesNumber + initialNodeNumber);
assertEquals(resourceManager.getState().getFreeNodesNumber(), nsNodesNumber + initialNodeNumber);
log("Removing node source " + nsName);
resourceManager.removeNodeSource(nsName, true);
boolean selectionInProgress = PAFuture.isAwaited(nodes);
if (!selectionInProgress) {
// normally we are looking for 2 nodes with timeout script,
// so the selection procedure has to finish not earlier than
// coreScriptExecutionTimeout * nodesNumber
// it should be sufficient to perform all admin operations
// concurrently
//
// if the core is blocked admin operations will be performed after
// selection
fail("Blocked inside RMCore");
} else {
log("No blocking inside RMCore");
}
t.interrupt();
}
use of org.ow2.proactive.resourcemanager.authentication.RMAuthentication in project scheduling by ow2-proactive.
the class RMNodeStarter method joinResourceManager.
private RMAuthentication joinResourceManager(String rmURL) {
// Create the full url to contact the Resource Manager
logger.info("Joining Resource Manager at " + rmURL);
final String fullUrl = rmURL.endsWith("/") ? rmURL + RMConstants.NAME_ACTIVE_OBJECT_RMAUTHENTICATION : rmURL + "/" + RMConstants.NAME_ACTIVE_OBJECT_RMAUTHENTICATION;
// Try to join the Resource Manager with a specified timeout
try {
RMAuthentication auth = RMConnection.waitAndJoin(fullUrl, WAIT_ON_JOIN_TIMEOUT_IN_MS);
if (auth == null) {
logger.error(ExitStatus.RMAUTHENTICATION_NULL.description);
System.exit(ExitStatus.RMAUTHENTICATION_NULL.exitCode);
}
logger.info("Resource Manager joined.");
return auth;
} catch (Throwable t) {
logger.error("Unable to join the Resource Manager at " + rmURL, t);
System.exit(ExitStatus.RMNODE_ADD_ERROR.exitCode);
}
return null;
}
use of org.ow2.proactive.resourcemanager.authentication.RMAuthentication in project scheduling by ow2-proactive.
the class RMNodeStarter method loginToResourceManager.
private ResourceManager loginToResourceManager(final Credentials credentials, final RMAuthentication auth) {
try {
ResourceManager rm = auth.login(credentials);
if (rm == null) {
logger.error(ExitStatus.RM_NULL.description);
System.exit(ExitStatus.RM_NULL.exitCode);
}
return rm;
} catch (Throwable t) {
logger.error("Unable to log into the Resource Manager at " + rmURL, t);
System.exit(ExitStatus.RMNODE_ADD_ERROR.exitCode);
}
return null;
}
use of org.ow2.proactive.resourcemanager.authentication.RMAuthentication 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.authentication.RMAuthentication in project scheduling by ow2-proactive.
the class SchedulerStartForFunctionalTest method createRMAndScheduler.
private static void createRMAndScheduler(String[] args) throws Exception {
final boolean deployLocalNodes = Boolean.valueOf(args[0]);
String schedPropPath = args[1];
String rmPropPath = args[2];
PAResourceManagerProperties.updateProperties(rmPropPath);
PASchedulerProperties.updateProperties(schedPropPath);
RMFactory.setOsJavaProperty();
new SchedulerHsqldbStarter().startIfNeeded();
new Thread() {
public void run() {
try {
RMFactory.startLocal();
// waiting the initialization
RMAuthentication rmAuth = RMConnection.waitAndJoin(schedulerUrl);
if (deployLocalNodes) {
Credentials credentials = Credentials.getCredentials(PAResourceManagerProperties.getAbsolutePath(PAResourceManagerProperties.RM_CREDS.getValueAsString()));
ResourceManager rmAdmin = rmAuth.login(credentials);
rmAdmin.createNodeSource(RM_NODE_NAME, LocalInfrastructure.class.getName(), new Object[] { credentials.getBase64(), RM_NODE_NUMBER, RM_NODE_DEPLOYMENT_TIMEOUT, getJavaPropertiesLine() }, StaticPolicy.class.getName(), new Object[] { "ALL", "ALL" }, NODES_NOT_RECOVERABLE);
rmAdmin.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
schedulerUrl = "pnp://localhost:" + PNPConfig.PA_PNP_PORT.getValue() + "/";
SchedulerFactory.createScheduler(new URI(schedulerUrl), PASchedulerProperties.SCHEDULER_DEFAULT_POLICY.getValueAsString());
SchedulerConnection.waitAndJoin(schedulerUrl);
}
Aggregations