Commit 0b0f2414 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed Minor Bugs



Fixed a bug where Nek5000 Models had "conj_ht.rea" hardcoded in as the
first file to load.

Fixed a bug where remote actions would attempt to get the wrong kind of
PTP connection.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 1a6e1d47
......@@ -12,6 +12,7 @@
package org.eclipse.ice.item.action;
import java.util.Dictionary;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
......@@ -26,8 +27,8 @@ import org.eclipse.remote.core.exception.RemoteConnectionException;
/**
* The RemoteFileDownloadAction is an ICE Action that downloads files from a
* remote directory to the current localhost. It requires the following input
* parameters:
* remote directory to the current localhost. It requires the following input
* parameters:
* </p>
* <table border="1">
* <col width="50.0%"></col><col width="50.0%"></col>
......@@ -121,20 +122,22 @@ public class RemoteFileDownloadAction extends RemoteAction {
@Override
public FormStatus execute(Dictionary<String, String> dictionary) {
// Set the status to Processing since we are
// Set the status to Processing since we are
// starting this execution.
status = FormStatus.Processing;
// Get the remote and local directory
String localDir = dictionary.get("localJobLaunchDirectory");
String hostName = dictionary.get("hostname");
// Let's use parts of the ExecutionHelper...
ExecutionHelper helper = new ExecutionHelper(dictionary);
// Check that we've been given valid directories
if (localDir == null || hostName == null) {
return actionError("No remote host name or remote/local directory provided. Can't download files.", null);
return actionError(
"No remote host name or remote/local directory provided. Can't download files.",
null);
}
// Get the remote connection
......@@ -142,8 +145,29 @@ public class RemoteFileDownloadAction extends RemoteAction {
if (connectionName == null) {
connection = getRemoteConnection(hostName);
} else {
IRemoteConnectionType connectionType = getService(IRemoteServicesManager.class).getRemoteConnectionTypes()
.get(0);
// Get the types of available remote connections
List<IRemoteConnectionType> types = getService(
IRemoteServicesManager.class).getRemoteConnectionTypes();
// The type of connection being used, SSH in this case
IRemoteConnectionType connectionType = null;
// Search for the connections of type SSH.
for (IRemoteConnectionType type : types) {
if ("SSH".equals(type.getName())) {
connectionType = type;
break;
}
}
// If the SSH connections were not found, give an error
if (connectionType == null) {
return actionError(
"Remote File Upload Action could not find the PTP SSH connection service.",
null);
}
for (IRemoteConnection c : connectionType.getConnections()) {
if (connectionName.equals(c.getName())) {
connection = c;
......@@ -151,34 +175,42 @@ public class RemoteFileDownloadAction extends RemoteAction {
}
}
if (connection == null) {
return actionError("Could not get a valid connection to " + hostName, null);
return actionError(
"Could not get a valid connection to " + hostName, null);
}
// Make sure the connection is actually open
if (!connection.isOpen()) {
try {
connection.open(null);
} catch (RemoteConnectionException e) {
return actionError("Remote File Download could not open the IRemoteConnection.", e);
return actionError(
"Remote File Download could not open the IRemoteConnection.",
e);
}
}
// Get the remote file manager
IRemoteFileService fileManager = connection.getService(IRemoteFileService.class);
IRemoteFileService fileManager = connection
.getService(IRemoteFileService.class);
// Get the Local Directory
IFileStore localDirectory = EFS.getLocalFileSystem()
.fromLocalFile(helper.getLocalLaunchFolder().getLocation().toFile());
IFileStore localDirectory = EFS.getLocalFileSystem().fromLocalFile(
helper.getLocalLaunchFolder().getLocation().toFile());
// Get the remote directory.
String remoteSeparator = connection.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY);
String userHome = connection.getProperty(IRemoteConnection.USER_HOME_PROPERTY);
IFileStore downloadFileStore = fileManager.getResource(userHome + remoteSeparator + "ICEJobs" + remoteSeparator + localDir);
// Try to download the files.
String remoteSeparator = connection
.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY);
String userHome = connection
.getProperty(IRemoteConnection.USER_HOME_PROPERTY);
IFileStore downloadFileStore = fileManager.getResource(userHome
+ remoteSeparator + "ICEJobs" + remoteSeparator + localDir);
// Try to download the files.
try {
// Get the children
IFileStore[] remoteStores = downloadFileStore.childStores(EFS.NONE, null);
IFileStore[] remoteStores = downloadFileStore.childStores(EFS.NONE,
null);
// Download all of the children
for (IFileStore remoteFile : remoteStores) {
// Get the information about the current child
......@@ -186,13 +218,15 @@ public class RemoteFileDownloadAction extends RemoteAction {
if (fileInfo.getLength() < maxFileSize) {
// Print some debug information about the download
String msg = "Remote File Download - " + "Downloading " + fileInfo.getName()
+ " with length " + fileInfo.getLength() + ".";
String msg = "Remote File Download - " + "Downloading "
+ fileInfo.getName() + " with length "
+ fileInfo.getLength() + ".";
logger.info(msg);
postConsoleText(msg);
// Get a handle to the local file. Note that it may
// not exist yet.
IFileStore childStore = localDirectory.getChild(remoteFile.getName());
IFileStore childStore = localDirectory
.getChild(remoteFile.getName());
// Copy the file from the remote machine to the
// local machine.
......@@ -202,16 +236,19 @@ public class RemoteFileDownloadAction extends RemoteAction {
// Print a debug note saying that the file is too
// big to
// download.
String msg = "RemoteFileDownloadAction Message: " + "File exceeds download limit. "
+ "File with size " + fileInfo.getLength() + " is " + sizeDiff + " bytes over the "
+ maxFileSize + " byte limit.";
String msg = "RemoteFileDownloadAction Message: "
+ "File exceeds download limit. "
+ "File with size " + fileInfo.getLength() + " is "
+ sizeDiff + " bytes over the " + maxFileSize
+ " byte limit.";
postConsoleText(msg);
logger.info(msg);
}
}
} catch (CoreException e) {
return actionError(getClass().getName() + " Exception! Error in downloading the files.", e);
return actionError(getClass().getName()
+ " Exception! Error in downloading the files.", e);
}
status = FormStatus.Processed;
......@@ -220,6 +257,7 @@ public class RemoteFileDownloadAction extends RemoteAction {
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.item.action.Action#cancel()
*/
@Override
......@@ -229,6 +267,7 @@ public class RemoteFileDownloadAction extends RemoteAction {
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.item.action.Action#getActionName()
*/
@Override
......
......@@ -41,83 +41,83 @@ import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
/**
* The RemoteFileUploadAction is a subclass of Action that uploads a list
* of files to a remote host. Clients can specify those files in two ways:
* (1) and XML-serialized DataComponent containing File Entries, (2) a local
* directory name. This Action checks for the DataComponent first, and if it
* is not provided tries to find files in the local directory.
*
* This Action requires a key-value pair list that contains the following:
* </p>
* <table border="1">
* <col width="50.0%"></col><col width="50.0%"></col>
* <tr>
* <td>
* <p>
* <b>Key</b>
* </p>
* </td>
* <td>
* <p>
* <b>Value</b>
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* hostname
* </p>
* </td>
* <td>
* <p>
* The name of the remote host to upload files to.
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* localJobLaunchDirectory
* </p>
* </td>
* <td>
* <p>
* The name of the directory within the project/jobs folder where
* the files to be uploaded can be found (optional).
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* filesDataComponent
* </p>
* </td>
* <td>
* <p>
* The XML-serialized DataComponent String (optional).
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* projectSpaceDir
* </p>
* </td>
* <td>
* <p>
* The absolute path string of the ICE project directory. This can be found with
* IProject.getLocation().toOSString().
* </p>
* </td>
* </tr>
* </table>
*
* @author Alex McCaskey
*
*/
* The RemoteFileUploadAction is a subclass of Action that uploads a list of
* files to a remote host. Clients can specify those files in two ways: (1) and
* XML-serialized DataComponent containing File Entries, (2) a local directory
* name. This Action checks for the DataComponent first, and if it is not
* provided tries to find files in the local directory.
*
* This Action requires a key-value pair list that contains the following:
* </p>
* <table border="1">
* <col width="50.0%"></col><col width="50.0%"></col>
* <tr>
* <td>
* <p>
* <b>Key</b>
* </p>
* </td>
* <td>
* <p>
* <b>Value</b>
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* hostname
* </p>
* </td>
* <td>
* <p>
* The name of the remote host to upload files to.
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* localJobLaunchDirectory
* </p>
* </td>
* <td>
* <p>
* The name of the directory within the project/jobs folder where the files to
* be uploaded can be found (optional).
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* filesDataComponent
* </p>
* </td>
* <td>
* <p>
* The XML-serialized DataComponent String (optional).
* </p>
* </td>
* </tr>
* <tr>
* <td>
* <p>
* projectSpaceDir
* </p>
* </td>
* <td>
* <p>
* The absolute path string of the ICE project directory. This can be found with
* IProject.getLocation().toOSString().
* </p>
* </td>
* </tr>
* </table>
*
* @author Alex McCaskey
*
*/
public class RemoteFileUploadAction extends RemoteAction {
/**
......@@ -155,10 +155,10 @@ public class RemoteFileUploadAction extends RemoteAction {
@Override
public FormStatus execute(Dictionary<String, String> dictionary) {
// Now that we're executing, set the status
// as Processing
// Now that we're executing, set the status
// as Processing
status = FormStatus.Processing;
// Get the input parameters we need.
String hostName = dictionary.get("hostname");
String localFilesDir = dictionary.get("localJobLaunchDirectory");
......@@ -173,7 +173,8 @@ public class RemoteFileUploadAction extends RemoteAction {
}
// Get the project reference
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(new File(projectDir).getName());
IProject project = ResourcesPlugin.getWorkspace().getRoot()
.getProject(new File(projectDir).getName());
// We can get our files to upload in 2 ways:
// (1) Clients can pass an XML serialized DataComponent
......@@ -181,33 +182,41 @@ public class RemoteFileUploadAction extends RemoteAction {
// (2) If there is no XML, then we look for a localJobLaunchDirectory
// and upload all files in that directory
if (filesDataComponent != null) {
// De-serialize the DataComponent with the file Entries.
// De-serialize the DataComponent with the file Entries.
DataComponent data = loadComponent(filesDataComponent);
if (data == null) {
return actionError("Remote File Upload - Invalid DataComponent XML.", null);
return actionError(
"Remote File Upload - Invalid DataComponent XML.",
null);
}
// Add those files to the list
// Add those files to the list
for (IEntry e : data.retrieveAllEntries()) {
filesToUpload.add(project.getFile(e.getName()).getLocation().toFile());
filesToUpload.add(
project.getFile(e.getName()).getLocation().toFile());
}
} else if (localFilesDir != null) {
// If we weren't given a DataComponent, look for all files in the
//provided localJobLaunchDirectory folder
// If we weren't given a DataComponent, look for all files in the
// provided localJobLaunchDirectory folder
try {
for (IResource resource : new ExecutionHelper(dictionary).getLocalLaunchFolder().members()) {
if (!resource.getName().contains("processOutput") && !resource.getName().contains("stderr")
for (IResource resource : new ExecutionHelper(dictionary)
.getLocalLaunchFolder().members()) {
if (!resource.getName().contains("processOutput")
&& !resource.getName().contains("stderr")
&& !resource.getName().contains("stdout")) {
filesToUpload.add(resource.getLocation().toFile());
}
}
} catch (CoreException e) {
return actionError("Exception in adding files from " + localFilesDir + ". See error log.", e);
return actionError("Exception in adding files from "
+ localFilesDir + ". See error log.", e);
}
} else {
return actionError("Invalid input parameters for Remote File Upload. Clients must "
+ "provided an XML serialized DataComponent with files added as "
+ "Entries, or a local job launch directory name.", null);
return actionError(
"Invalid input parameters for Remote File Upload. Clients must "
+ "provided an XML serialized DataComponent with files added as "
+ "Entries, or a local job launch directory name.",
null);
}
// Get the remote connection
......@@ -215,8 +224,29 @@ public class RemoteFileUploadAction extends RemoteAction {
if (connectionName == null) {
connection = getRemoteConnection(hostName);
} else {
IRemoteConnectionType connectionType = getService(IRemoteServicesManager.class).getRemoteConnectionTypes()
.get(0);
// Get the types of available remote connections
List<IRemoteConnectionType> types = getService(
IRemoteServicesManager.class).getRemoteConnectionTypes();
// The type of connection being used, SSH in this case
IRemoteConnectionType connectionType = null;
// Search for the connections of type SSH.
for (IRemoteConnectionType type : types) {
if ("SSH".equals(type.getName())) {
connectionType = type;
break;
}
}
// If the SSH connections were not found, give an error
if (connectionType == null) {
return actionError(
"Remote File Upload Action could not find the PTP SSH connection service.",
null);
}
for (IRemoteConnection c : connectionType.getConnections()) {
if (connectionName.equals(c.getName())) {
connection = c;
......@@ -224,41 +254,55 @@ public class RemoteFileUploadAction extends RemoteAction {
}
}
if (connection == null) {
return actionError("Remote File Upload could not get a valid connection to " + hostName + ".", null);
return actionError(
"Remote File Upload could not get a valid connection to "
+ hostName + ".",
null);
}
// Make sure the connection is actually open
if (!connection.isOpen()) {
try {
connection.open(null);
} catch (RemoteConnectionException e) {
return actionError("Remote File Upload could not open the IRemoteConnection.", e);
return actionError(
"Remote File Upload could not open the IRemoteConnection.",
e);
}
}
// Get the remote file manager
IRemoteFileService fileManager = connection.getService(IRemoteFileService.class);
IRemoteFileService fileManager = connection
.getService(IRemoteFileService.class);
// Get the IRemoteProcessService
IRemoteProcessService processService = connection.getService(IRemoteProcessService.class);
IRemoteProcessService processService = connection
.getService(IRemoteProcessService.class);
// Set the working directory as $HOME/ICEJobs/`localFilesLocation`
String remoteSeparator = connection.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY);
String userHome = connection.getProperty(IRemoteConnection.USER_HOME_PROPERTY);
processService.setWorkingDirectory(userHome + remoteSeparator + "ICEJobs" + remoteSeparator + localFilesDir);
String remoteSeparator = connection
.getProperty(IRemoteConnection.FILE_SEPARATOR_PROPERTY);
String userHome = connection
.getProperty(IRemoteConnection.USER_HOME_PROPERTY);
processService.setWorkingDirectory(userHome + remoteSeparator
+ "ICEJobs" + remoteSeparator + localFilesDir);
// Get the working directory
try {
remoteDirectory = EFS.getStore(fileManager.toURI(processService.getWorkingDirectory()));
remoteDirectory = EFS.getStore(
fileManager.toURI(processService.getWorkingDirectory()));
} catch (CoreException e1) {
return actionError("Remote File Upload could not get a reference to the remote working directory.", e1);
return actionError(
"Remote File Upload could not get a reference to the remote working directory.",
e1);
}
// Create the remote working directory and upload required files.
try {
// Make that directory if necessary
remoteDirectory.mkdir(EFS.NONE, null);
logger.info("RemoteFileUploadAction Message: " + "Created directory on remote system, "
logger.info("RemoteFileUploadAction Message: "
+ "Created directory on remote system, "
+ remoteDirectory.getName());
// Loop over all of the files in the file table and upload them
......@@ -271,17 +315,22 @@ public class RemoteFileUploadAction extends RemoteAction {
// Get a handle where the input file will be stored
// remotely
IFileStore remoteFileStore = remoteDirectory.getChild(file.getName());
IFileStore remoteFileStore = remoteDirectory
.getChild(file.getName());
// Get a file store handle to the local copy of the
// input file
IFileStore localFileStore = EFS.getLocalFileSystem().fromLocalFile(file);
IFileStore localFileStore = EFS.getLocalFileSystem()
.fromLocalFile(file);
// Copy the local file to the remote file
localFileStore.copy(remoteFileStore, EFS.OVERWRITE, null);
postConsoleText("Remote File Upload - Uploaded " + file.getName() + " to " + hostName + ":" + userHome
+ remoteSeparator + "ICEJobs" + remoteSeparator + localFilesDir + ".");
logger.info("RemoteFileUploadAction Message: " + "Uploaded file " + file.getName());
postConsoleText("Remote File Upload - Uploaded "
+ file.getName() + " to " + hostName + ":" + userHome
+ remoteSeparator + "ICEJobs" + remoteSeparator
+ localFilesDir + ".");
logger.info("RemoteFileUploadAction Message: "
+ "Uploaded file " + file.getName());
}
} catch (CoreException e) {
......@@ -297,6 +346,7 @@ public class RemoteFileUploadAction extends RemoteAction {
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.item.action.Action#cancel()
*/
@Override
......@@ -308,6 +358,7 @@ public class RemoteFileUploadAction extends RemoteAction {
/*
* (non-Javadoc)
*
* @see org.eclipse.ice.item.action.Action#getActionName()
*/
@Override
......@@ -343,10 +394,12 @@ public class RemoteFileUploadAction extends RemoteAction {
try {
// Create the unmarshaller and load the item
Unmarshaller unmarshaller = context.createUnmarshaller();
comp = (T) unmarshaller.unmarshal(new ByteArrayInputStream(xmlForm.getBytes()));
comp = (T) unmarshaller
.unmarshal(new ByteArrayInputStream(xmlForm.getBytes()));
} catch (JAXBException e) {
// Complain
actionError("Remote File Upload error in unmarshalling XML data.", e);
actionError("Remote File Upload error in unmarshalling XML data.",
e);
// Null out the Item so that it can't be returned uninitialized
comp = null;
}
......
......@@ -55,7 +55,7 @@ public class NekLauncher extends SuiteLauncher {
// Setup the Form