use of org.objectweb.proactive.core.node.NodeException in project scheduling by ow2-proactive.
the class SchedulerStateRest method login.
/**
* Login to the scheduler using a form containing 2 fields (username and
* password).
*
* @param username
* username
* @param password
* password
* @return the session id associated to the login.
* @throws LoginException
*/
@Override
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("login")
@Produces("application/json")
public String login(@FormParam("username") String username, @FormParam("password") 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 e) {
throw new SchedulerRestException(e);
} catch (SchedulerException e) {
throw new SchedulerRestException(e);
} catch (NodeException e) {
throw new SchedulerRestException(e);
}
}
use of org.objectweb.proactive.core.node.NodeException in project scheduling by ow2-proactive.
the class SchedulerStateRest method loginWithCredential.
/**
* Login to the scheduler using a multipart form can be used either by
* submitting 2 fields ({@code username} and {@code password}) or by sending
* a credential file with field name {@code credential}.
*
* @return the session id associated to this new connection.
* @throws KeyException
* @throws LoginException
* @throws SchedulerRestException
*/
@Override
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("login")
@Produces("application/json")
public String loginWithCredential(@MultipartForm 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 (PermissionException e) {
throw new SchedulerRestException(e);
} catch (ActiveObjectCreationException e) {
throw new SchedulerRestException(e);
} catch (SchedulerException e) {
throw new SchedulerRestException(e);
} catch (NodeException e) {
throw new SchedulerRestException(e);
}
}
use of org.objectweb.proactive.core.node.NodeException in project scheduling by ow2-proactive.
the class NodesPinger method ping.
/**
* Pings remote nodes and returns distances to hosts where these nodes are located.
*
* @param nodes to ping
* @return distances map to hosts where these nodes are located
*/
public HashMap<InetAddress, Long> ping(NodeSet nodes) {
HashMap<InetAddress, Long> results = new HashMap<>();
for (Node node : nodes) {
try {
InetAddress current = NodeFactory.getDefaultNode().getVMInformation().getInetAddress();
InetAddress nodeAddress = node.getVMInformation().getInetAddress();
if (current.equals(nodeAddress)) {
// nodes on the same host
results.put(nodeAddress, new Long(0));
} else {
results.put(nodeAddress, pingNode(node));
}
} catch (NodeException e) {
}
}
return results;
}
use of org.objectweb.proactive.core.node.NodeException 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) {
rmcoreStub.shutdown(true);
}
synchronized (nodeRM) {
if (!shutedDown) {
try {
// wait for rmcore shutdown (5 min at most)
nodeRM.wait(5 * 60 * 60 * 1000);
} catch (InterruptedException e) {
logger.warn("shutdown hook interrupted", e);
}
}
}
}
});
// Creating RM started event
this.monitoring.rmEvent(new RMEvent(RMEventType.STARTED));
authentication.setActivated(true);
clientPinger.ping();
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.core.node.NodeException in project scheduling by ow2-proactive.
the class TopologyManager method pingNode.
/**
* Launches the pinging process from new host. It will ping all other hosts
* according to the pinger logic.
*/
private HashMap<InetAddress, Long> pingNode(Node node, NodeSet nodes) {
try {
logger.debug("Launching ping process on node " + node.getNodeInformation().getURL());
long timeStamp = System.currentTimeMillis();
Pinger pinger = PAActiveObject.newActive(pingerClass, null, node);
HashMap<InetAddress, Long> result = pinger.ping(nodes);
PAFuture.waitFor(result);
logger.debug(result.size() + " hosts were pinged from " + node.getNodeInformation().getURL() + " in " + (System.currentTimeMillis() - timeStamp) + " ms");
if (logger.isDebugEnabled()) {
logger.debug("Distances are:");
for (InetAddress host : result.keySet()) {
logger.debug(result.get(host) + " to " + host);
}
}
try {
PAActiveObject.terminateActiveObject(pinger, true);
} catch (RuntimeException e) {
logger.error("Cannot kill the pinger active object", e);
}
return result;
} catch (ActiveObjectCreationException e) {
logger.warn(e.getMessage(), e);
} catch (NodeException e) {
logger.warn(e.getMessage(), e);
}
return null;
}
Aggregations