use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.
the class SchedulerFactory method startLocal.
/**
* Creates and starts a Scheduler on the local host.
* This call considered that the JVM is correctly configured for starting Scheduler.
* The "pa.scheduler.home" and required JVM properties MUST be set.
*
* @param rmURL the URL of a started Resource Manager
* @param policy the full class name of the Scheduling policy to use.
*
* @return a Scheduler authentication that allow you to administer the Scheduler or get its connection URL.
*
* @throws ActiveObjectCreationException If Scheduler cannot be created
*/
public static SchedulerAuthenticationInterface startLocal(URI rmURL, String policy) throws Exception {
SchedulerInitializer init = new SchedulerInitializer();
init.setPolicyFullClassName(policy);
allowNullInit = true;
SchedulerAuthenticationInterface sai = startLocal(rmURL, init);
allowNullInit = false;
return sai;
}
use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.
the class SchedulerFactory method createScheduler.
/**
* Create a new scheduler on the local host plugged on the given resource manager.<br>
* This will provide a connection interface to allow the access to a restricted number of user.<br>
* Use {@link SchedulerConnection} class to join the Scheduler.
*
* @param rmURL the resource manager URL on which the scheduler will connect
* @param policyFullClassName the full policy class name for the scheduler.
* @throws AdminSchedulerException If an error occurred during creation process
*/
public static void createScheduler(URI rmURL, String policyFullClassName) throws AdminSchedulerException {
logger.debug("Starting new Scheduler");
// check arguments...
if (rmURL == null) {
String msg = "The Resource Manager URL must not be null";
logger.error(msg);
throw new AdminSchedulerException(msg);
}
try {
// creating the scheduler
// if this fails then it will not continue.
logger.debug("Creating scheduler frontend...");
PAActiveObject.newActive(SchedulerFrontend.class.getName(), new Object[] { rmURL, policyFullClassName });
// ready
logger.debug("Scheduler is now ready to be started!");
ServerJobAndTaskLogs.configure();
} catch (Exception e) {
logger.error(e);
e.printStackTrace();
throw new AdminSchedulerException(e.getMessage());
}
}
use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.
the class SchedulerFactory method createScheduler.
/**
* Create a new scheduler on the local host plugged on the given resource manager.<br>
* This constructor also requires the credentials of the client to connect.<br><br>
* It will return a client scheduler able to managed the scheduler.<br><br>
* <font color="red">WARNING :</font> this method provides a way to connect to the scheduler after its creation,
* BUT if the scheduler is restarting after failure, this method will create the scheduler
* but will throw a SchedulerException due to the failure of client connection.<br>
* In fact, while the scheduler is restarting after a crash, no one can connect it during the whole restore process.<br><br>
* In any other case, the method will block until connection is allowed or error occurred.
*
* @param rmURL the resource manager URL on which the scheduler will connect
* @param policyFullClassName the full policy class name for the scheduler.
* @return a scheduler interface to manage the scheduler.
* @throws SchedulerException if the scheduler cannot be created.
* @throws AdminSchedulerException if a client connection exception occurs.
* @throws LoginException if a user login/password exception occurs.
*/
public static Scheduler createScheduler(Credentials creds, URI rmURL, String policyFullClassName) throws AdminSchedulerException, SchedulerException, LoginException {
createScheduler(rmURL, policyFullClassName);
SchedulerAuthenticationInterface auth = SchedulerConnection.waitAndJoin(null);
return auth.login(creds);
}
use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.
the class SchedulerFactory method startLocal.
/**
* Creates and starts a Scheduler on the local host using the given initializer to configure it.
* Only one Scheduler can be started by JVM.
*
* @param rmURL the URL of a started Resource Manager
* @param initializer Use to configure the Scheduler before starting it.
* This parameter cannot be null.
*
* @return a Scheduler authentication that allow you to administer it or get its connection URL.
*
* @throws InternalSchedulerException If Scheduler cannot be created
*/
public static synchronized SchedulerAuthenticationInterface startLocal(URI rmURL, SchedulerInitializer initializer) throws InternalSchedulerException {
if (!schedulerStarted) {
if (!allowNullInit) {
if (initializer != null) {
// configure application
configure(initializer);
} else {
throw new IllegalArgumentException("Initializer cannot be null!");
}
}
if (rmURL == null) {
throw new IllegalArgumentException("RM url is null!");
}
try {
String policy = initializer.getPolicyFullClassName();
// start scheduler
createScheduler(rmURL, policy);
SchedulerAuthenticationInterface sai = SchedulerConnection.waitAndJoin(null);
schedulerStarted = true;
return sai;
} catch (Exception e) {
throw new InternalSchedulerException(e);
}
} else {
throw new InternalSchedulerException("Scheduler already localy running");
}
}
use of org.ow2.proactive.authentication.Connection in project scheduling by ow2-proactive.
the class SchedulerStateRest method getSchedulerPropertiesFromSessionId.
@GET
@Override
@Path("properties")
@Produces("application/json")
public Map<String, Object> getSchedulerPropertiesFromSessionId(@HeaderParam("sessionid") final String sessionId) throws NotConnectedRestException, PermissionRestException {
SchedulerProxyUserInterface scheduler = checkAccess(sessionId, "properties");
Map<String, Object> schedulerProperties = new HashMap<String, Object>();
try {
schedulerProperties = scheduler.getSchedulerProperties();
} catch (NotConnectedException e) {
logger.warn("Attempt to retrieve scheduler properties but failed because connection exception", e);
throw new PermissionRestException(e);
} catch (PermissionException e) {
logger.warn("Attempt to retrieve scheduler properties but failed because permission exception", e);
throw new NotConnectedRestException(e);
}
return schedulerProperties;
}
Aggregations