Commit 9edcd054 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Add getAllJobs method and optimize imports

parent c8bb615f
......@@ -323,6 +323,14 @@ public class PAGateway {
LOGGER.info("Job created: " + newJob.toString());
}
/**
* Get all job skeletons
* @return List of all table Job's entries
*/
public List<Job> getAllJobs() {
return EntityManagerHelper.createQuery("SELECT j FROM Job j", Job.class).getResultList();
}
/**
* Find node candidates
* @param requirements List of NodeType or Attribute requirements
......@@ -607,7 +615,7 @@ public class PAGateway {
try {
resourceManagerGateway.undeployNodeSource(cloud.getNodeSourceNamePrefix() + entry.getKey(), preempt);
} catch (NotConnectedException | PermissionRestException e) {
LOGGER.error(String.valueOf(e.getStackTrace()));
LOGGER.error(Arrays.toString(e.getStackTrace()));
}
}
});
......@@ -621,8 +629,6 @@ public class PAGateway {
return EntityManagerHelper.createQuery("SELECT pac FROM PACloud pac", PACloud.class).getResultList();
}
/**
* Remove clouds
* @param cloudIDs List of cloud IDs to remove
......@@ -639,7 +645,7 @@ public class PAGateway {
LOGGER.info("Removing node source " + nodeSourceName + " from the ProActive server.");
resourceManagerGateway.removeNodeSource(nodeSourceName, preempt);
} catch (NotConnectedException | PermissionRestException e) {
LOGGER.error(String.valueOf(e.getStackTrace()));
LOGGER.error(Arrays.toString(e.getStackTrace()));
}
}
if (cloud.getDeployments() != null) {
......
......@@ -14,7 +14,6 @@ import org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestExc
import org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException;
import javax.security.auth.login.LoginException;
import javax.ws.rs.NotAuthorizedException;
import java.security.KeyException;
import java.util.ArrayList;
import java.util.Arrays;
......
......@@ -24,9 +24,7 @@ public class RMConnectionHelper {
private static RMRestInterface rmRestInterface;
/**
*
* Initialize the API to RM
*
* @param paURL PA rest URL
......@@ -36,28 +34,27 @@ public class RMConnectionHelper {
if (paURL.contains("trydev2.activeeon")) {
sessionPreferencesId = "RM_sessionId_trydev2";
} else if (paURL.contains("trydev.activeeon")) {
sessionPreferencesId = "RM_sessionId";
sessionPreferencesId = "RM_sessionId";
} else {
sessionPreferencesId = "TESTING_PREF";
}
// Initialize the client
rmRestInterface = new RMRestClient(paURL + RESOURCE_MANAGER_REST_PATH, null).getRm();
// Get the user session ID
sessionId = userPreferences.get(sessionPreferencesId,"");
sessionId = userPreferences.get(sessionPreferencesId, "");
LOGGER.debug("Gateway to the ProActive Resource Manager is established");
return rmRestInterface;
}
/**
*
* Connect to the RM
*
* @param username Username
* @param password Password
* @throws LoginException In case the login is not valid
* @throws KeyException In case the password is not valid
* @throws RMException In case an error happens in the RM
* @throws KeyException In case the password is not valid
* @throws RMException In case an error happens in the RM
*/
public static synchronized void connect(String username, String password) throws LoginException, KeyException, RMException {
LOGGER.debug("Connecting to RM ...");
......@@ -65,7 +62,7 @@ public class RMConnectionHelper {
// If the sessionId is equals to "" (empty), an exception will occurs.
// If the sessionId is valid ==> Already connected
// If the sessionId is invalid we create a new session by establishing a new connection to the RM
if(isActive()){
if (isActive()) {
LOGGER.info("Already Connected to RM");
} else {
// Connect and create a new session
......@@ -74,7 +71,7 @@ public class RMConnectionHelper {
userPreferences.put(sessionPreferencesId, sessionId);
LOGGER.info("Connected to RM");
}
} catch (Exception NAE){
} catch (Exception NAE) {
// Exception is triggered when the sessionId is equal to ""
sessionId = rmRestInterface.rmConnect(username, password);
userPreferences.put(sessionPreferencesId, sessionId);
......@@ -83,13 +80,11 @@ public class RMConnectionHelper {
}
/**
*
* Disconnect from the RM API
*
*/
public static synchronized void disconnect() {
try{
sessionId = userPreferences.get(sessionPreferencesId,"");
try {
sessionId = userPreferences.get(sessionPreferencesId, "");
// Check if the session still active
if (isActive()) {
try {
......
......@@ -20,7 +20,6 @@ public class SchedulerConnectionHelper {
/**
*
* Initialize the gateway URL
*
* @param url URL for the ProActive Rest service
......@@ -30,7 +29,6 @@ public class SchedulerConnectionHelper {
}
/**
*
* Connect to the Scheduler gateway
*
* @param username Username
......@@ -59,6 +57,7 @@ public class SchedulerConnectionHelper {
/**
* Disconnect from the Scheduler
*
* @return The disconnected Scheduler gateway
*/
public static synchronized RestSmartProxyImpl disconnect() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment