use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.
the class SchedulerStateRest method login.
@Override
public String login(String username, String password) throws LoginException, SchedulerRestException {
try {
if ((username == null) || (password == null)) {
throw new LoginException("Empty login/password");
}
Session session = sessionStore.create(username);
session.connectToScheduler(new CredData(username, password));
logger.info("Binding user " + username + " to session " + session.getSessionId());
return session.getSessionId();
} catch (ActiveObjectCreationException | SchedulerException | NodeException e) {
throw new SchedulerRestException(e);
}
}
use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.
the class SchedulerStateRest method loginWithCredential.
@Override
public String loginWithCredential(LoginForm multipart) throws LoginException, KeyException, SchedulerRestException {
try {
Session session;
if (multipart.getCredential() != null) {
Credentials credentials;
try {
session = sessionStore.createUnnamedSession();
credentials = Credentials.getCredentials(multipart.getCredential());
session.connectToScheduler(credentials);
} catch (IOException e) {
throw new LoginException(e.getMessage());
}
} else {
if ((multipart.getUsername() == null) || (multipart.getPassword() == null)) {
throw new LoginException("empty login/password");
}
session = sessionStore.create(multipart.getUsername());
CredData credData = new CredData(CredData.parseLogin(multipart.getUsername()), CredData.parseDomain(multipart.getUsername()), multipart.getPassword(), multipart.getSshKey());
session.connectToScheduler(credData);
}
return session.getSessionId();
} catch (ActiveObjectCreationException | NodeException | SchedulerException e) {
throw new SchedulerRestException(e);
}
}
use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.
the class RMRest method loginWithCredential.
/*
* (non-Javadoc)
*
* @see org.ow2.proactive_grid_cloud_portal.SchedulerRestInterface#loginWithCredential(org.ow2.
* proactive_grid_cloud_portal.LoginForm)
*/
@Override
public String loginWithCredential(@MultipartForm LoginForm multipart) throws RMActiveObjectCreationException, RMNodeException, KeyException, IOException, LoginException, RMException {
Session session;
try {
if (multipart.getCredential() != null) {
session = sessionStore.createUnnamedSession();
Credentials credentials = Credentials.getCredentials(multipart.getCredential());
session.connectToRM(credentials);
} else {
session = sessionStore.create(multipart.getUsername());
CredData credData = new CredData(CredData.parseLogin(multipart.getUsername()), CredData.parseDomain(multipart.getUsername()), multipart.getPassword(), multipart.getSshKey());
session.connectToRM(credData);
}
} catch (ActiveObjectCreationException e) {
throw new RMActiveObjectCreationException(e);
} catch (NodeException e) {
throw new RMNodeException(e);
}
return session.getSessionId();
}
use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.
the class RMCore method initActivity.
/**
* Initialization part of the RMCore active object.
* Create RM's active objects and the default static Node Source named
* {@link RMConstants#DEFAULT_STATIC_SOURCE_NAME}. Finally, it throws the RM
* started event.
*
* @param body the active object's body.
*/
public void initActivity(Body body) {
if (logger.isDebugEnabled()) {
logger.debug("RMCore start : initActivity");
}
try {
// setting up the policy
logger.debug("Setting up the resource manager security policy");
ClientsPolicy.init();
StubObject rmCoreStub = PAActiveObject.getStubOnThis();
PAActiveObject.registerByName(rmCoreStub, RMConstants.NAME_ACTIVE_OBJECT_RMCORE);
dbManager = RMDBManager.getInstance();
if (logger.isDebugEnabled()) {
logger.debug("Creating RMAuthentication active object");
}
authentication = (RMAuthenticationImpl) PAActiveObject.newActive(RMAuthenticationImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating RMMonitoring active object");
}
// Boot the JMX infrastructure
this.jmxHelper.boot(authentication);
monitoring = (RMMonitoringImpl) PAActiveObject.newActive(RMMonitoringImpl.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating SelectionManager active object");
}
selectionManager = (SelectionManager) PAActiveObject.newActive(ProbablisticSelectionManager.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating ClientPinger active object");
}
clientPinger = (ClientPinger) PAActiveObject.newActive(ClientPinger.class.getName(), new Object[] { rmCoreStub }, nodeRM);
if (logger.isDebugEnabled()) {
logger.debug("Creating NodeCleaner active object");
}
nodesCleaner = (NodesCleaner) PAActiveObject.newActive(NodesCleaner.class.getName(), new Object[] { rmCoreStub }, nodeRM);
topologyManager = new TopologyManager();
nodeConfigurator = (RMNodeConfigurator) PAActiveObject.newActive(RMNodeConfigurator.class.getName(), new Object[] { rmCoreStub }, nodeRM);
// adding shutdown hook
final RMCore rmcoreStub = (RMCore) rmCoreStub;
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
if (!toShutDown) {
PAFuture.waitFor(rmcoreStub.shutdown(true), PAResourceManagerProperties.RM_SHUTDOWN_TIMEOUT.getValueAsInt() * 1000L);
}
}
});
// Creating RM started event
this.monitoring.rmEvent(new RMEvent(RMEventType.STARTED));
authentication.setActivated(true);
clientPinger.ping();
nodeSourceParameterHelper = new NodeSourceParameterHelper();
nodesHouseKeepingService = new NodesHouseKeepingService(rmcoreStub);
nodesHouseKeepingService.start();
initiateRecoveryIfRequired();
} catch (ActiveObjectCreationException e) {
logger.error("", e);
} catch (NodeException e) {
logger.error("", e);
} catch (ProActiveException e) {
logger.error("", e);
} catch (ClassNotFoundException e) {
logger.error("", e);
} finally {
signalRMCoreIsInitialized();
}
if (logger.isDebugEnabled()) {
logger.debug("RMCore end: initActivity");
}
}
use of org.objectweb.proactive.ActiveObjectCreationException in project scheduling by ow2-proactive.
the class SchedulingMethodImpl method selectAndStartTasks.
private int selectAndStartTasks(Policy currentPolicy, Map<JobId, JobDescriptor> jobMap, Set<String> freeResources, LinkedList<EligibleTaskDescriptor> tasksRetrievedFromPolicy) {
int numberOfTaskStarted = 0;
schedulingMainLoopTimingLogger.start("updateVariablesForTasksToSchedule");
int neededNodes = computeNeededNodes(tasksRetrievedFromPolicy);
if (logger.isDebugEnabled()) {
loggingEligibleTasksDetails(tasksRetrievedFromPolicy);
}
updateVariablesForTasksToSchedule(tasksRetrievedFromPolicy);
schedulingMainLoopTimingLogger.end("updateVariablesForTasksToSchedule");
schedulingMainLoopTimingLogger.start("loadAndInit");
for (Iterator<EligibleTaskDescriptor> iterator = tasksRetrievedFromPolicy.iterator(); iterator.hasNext(); ) {
EligibleTaskDescriptorImpl taskDescriptor = (EligibleTaskDescriptorImpl) iterator.next();
// load and Initialize the executable container
InternalTask internalTask = taskDescriptor.getInternal();
try {
loadAndInit(internalTask);
} catch (Exception e) {
handleLoadExecutableContainerError(internalTask, iterator, e);
}
}
schedulingMainLoopTimingLogger.end("loadAndInit");
while (!tasksRetrievedFromPolicy.isEmpty() && (!PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean() || !freeResources.isEmpty())) {
// get the next compatible tasks from the whole returned policy tasks
LinkedList<EligibleTaskDescriptor> tasksToSchedule = new LinkedList<>();
int neededResourcesNumber = 0;
schedulingMainLoopTimingLogger.start("getNextcompatibleTasks");
while (!tasksRetrievedFromPolicy.isEmpty() && neededResourcesNumber == 0) {
// the loop will search for next compatible task until it find something
neededResourcesNumber = getNextcompatibleTasks(jobMap, tasksRetrievedFromPolicy, tasksToSchedule);
}
schedulingMainLoopTimingLogger.end("getNextcompatibleTasks");
if (logger.isDebugEnabled()) {
logger.debug("tasksToSchedule : " + tasksToSchedule);
}
logger.debug("required number of nodes : " + neededResourcesNumber);
if (neededResourcesNumber == 0 || tasksToSchedule.isEmpty()) {
break;
}
schedulingMainLoopTimingLogger.start("getRMNodes");
NodeSet nodeSet = getRMNodes(jobMap, neededResourcesNumber, tasksToSchedule, freeResources);
schedulingMainLoopTimingLogger.end("getRMNodes");
if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean() && nodeSet != null) {
freeResources.removeAll(nodeSet.getAllNodesUrls());
}
// start selected tasks
Node node = null;
InternalJob currentJob = null;
try {
while (nodeSet != null && !nodeSet.isEmpty()) {
EligibleTaskDescriptor taskDescriptor = tasksToSchedule.removeFirst();
currentJob = ((JobDescriptorImpl) jobMap.get(taskDescriptor.getJobId())).getInternal();
InternalTask internalTask = ((EligibleTaskDescriptorImpl) taskDescriptor).getInternal();
if (currentPolicy.isTaskExecutable(nodeSet, taskDescriptor)) {
// create launcher and try to start the task
node = nodeSet.get(0);
schedulingMainLoopTimingLogger.start("createExecution");
if (createExecution(nodeSet, node, currentJob, internalTask, taskDescriptor)) {
neededNodes -= taskDescriptor.getNumberOfNodesNeeded();
numberOfTaskStarted++;
}
schedulingMainLoopTimingLogger.end("createExecution");
}
// if every task that should be launched have been removed
if (tasksToSchedule.isEmpty()) {
// get back unused nodes to the RManager
if (!nodeSet.isEmpty()) {
schedulingMainLoopTimingLogger.start("releaseNodes");
releaseNodes(currentJob, nodeSet);
if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean()) {
freeResources.addAll(nodeSet.getAllNodesUrls());
}
schedulingMainLoopTimingLogger.end("releaseNodes");
}
// and leave the loop
break;
}
}
} catch (ActiveObjectCreationException e1) {
// Something goes wrong with the active object creation (createLauncher)
logger.warn("An exception occured while creating the task launcher.", e1);
// so try to get back every remaining nodes to the resource manager
try {
releaseNodes(currentJob, nodeSet);
if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean()) {
freeResources.addAll(nodeSet.getAllNodesUrls());
}
} catch (Exception e2) {
logger.info("Unable to get back the nodeSet to the RM", e2);
}
if (--activeObjectCreationRetryTimeNumber == 0) {
break;
}
} catch (Exception e1) {
// if we are here, it is that something append while launching the current task.
logger.warn("An exception occured while starting task.", e1);
// so try to get back every remaining nodes to the resource manager
try {
releaseNodes(currentJob, nodeSet);
if (PASchedulerProperties.SCHEDULER_POLCY_STRICT_FIFO.getValueAsBoolean()) {
freeResources.addAll(nodeSet.getAllNodesUrls());
}
} catch (Exception e2) {
logger.info("Unable to get back the nodeSet to the RM", e2);
}
}
}
// number of nodes needed to start all pending tasks
updateNeededNodes(neededNodes);
return numberOfTaskStarted;
}
Aggregations