Package com.ibm.wsspi.collective.plugins
Interface CollectivePlugin
public interface CollectivePlugin
Defines the bridge to exploit collective-based features and services.
This plug point must be implemented to provide collective-based services such as routing.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
checkServerLevelAccess
(String hostName, String userDir, String serverName, String path, boolean readOnly) createRemoteAccess
(String hostName, String userDir, String serverName, Map<String, String> credentials, Map<String, String> envVariables) Create a new remote access connection to the specified target.void
deleteFile
(RemoteAccessWrapper remoteAccess, String remoteFile, boolean recursiveDelete) Delete a remote file.void
deleteFile
(String hostName, String userDir, String serverName, String remoteFile) Delete a remote file.boolean
existsInRemoteFileSystem
(RemoteAccessWrapper remoteAccess, String filePath) boolean
existsInRepository
(String nodePath) void
expandArchive
(RemoteAccessWrapper remoteAccess, String[] cmdArgs, String targetDir, boolean mustBeLiberty) Expand a remote archive.void
expandArchive
(String hostName, String userDir, String serverName, String[] cmdArgs, String targetDir, boolean mustBeLiberty) Expand a remote archive.getAttribute
(String hostName, String userDir, String serverName, String objectName, String attributeName) Get the MBean attribute value for the given Object name and attribute.getAttributes
(String hostName, String userDir, String serverName, String objectName) Get the MBean attributes for the given Object name.Fetch the controller's host nameFetch the controllers secure (https) port.getHostPaths
(String hostName, boolean failIfNull) Retrieves a Map that contains the read and write lists of the remote host.getJavaCommand
(RemoteAccessWrapper remoteAccess, String hostName) Retrieve the java home on the remote machinegetNodeValue
(String nodePath) Gets the value for the given node.getPrivateNodeValue
(String nodePath) Gets the value for the given node.getPrivateServerNode
(String hostName, String userDir, String serverName, String node) Computes the appropriate repository server path for the desired node, and then retrieves the value.getServerNode
(String hostName, String userDir, String serverName, String node) Computes the appropriate repository server path for the desired node, and then retrieves the value.getSSLContent
(String sslAlias) Convenience method to retrieve the SSLContext for the given alias.boolean
isReadOnly
(RemoteAccessWrapper remoteAccess, String remoteFile) Check if a remote file is read-onlyvoid
makeRemoteDirectories
(RemoteAccessWrapper remoteAccess, String remoteDirectory) Creates a directory tree in the remote target.postTransferAction
(RemoteAccessWrapper remoteAccess, String targetDir, String action, String actionOptions) Perform an action after a file has been transferred remotely.postTransferAction
(String hostName, String targetDir, String action, String actionOptions) Perform an action after a file has been transferred remotely.preTransferAction
(RemoteAccessWrapper remoteAccess, String executableDir, String action, String actionOption) Perform an action before a file is deleted remotely.void
receiveFile
(RemoteAccessWrapper remoteAccess, String remoteFile, File localDir) Download a remote file.void
Download a remote file.runCommand
(RemoteAccessWrapper remoteAccess, String cmd, String targetDir) Run a command remotely.void
sendFile
(RemoteAccessWrapper remoteAccess, File localFile, String remoteDir) Upload a file to a remote location.void
Upload a file to a remote location.
-
Method Details
-
getServerNode
Object getServerNode(String hostName, String userDir, String serverName, String node) throws IllegalArgumentException, IOException Computes the appropriate repository server path for the desired node, and then retrieves the value.- Parameters:
hostName
- the name of the host in the pathuserDir
- the user directory in the pathserverName
- the name of the server in the pathnode
- the leaf node in the path- Returns:
- the value at the calculated path
- Throws:
IllegalArgumentException
IOException
-
getNodeValue
Gets the value for the given node.- Parameters:
nodePath
- the full path of the node- Returns:
- the value of that node
- Throws:
IllegalArgumentException
IOException
-
getPrivateServerNode
Object getPrivateServerNode(String hostName, String userDir, String serverName, String node) throws IllegalArgumentException, IOException Computes the appropriate repository server path for the desired node, and then retrieves the value. The target path is considered to be private, and not exposed externally.- Parameters:
hostName
- the name of the host in the pathuserDir
- the user directory in the pathserverName
- the name of the server in the pathnode
- the leaf node in the path- Returns:
- the value at the calculated path
- Throws:
IllegalArgumentException
IOException
-
getPrivateNodeValue
Object getPrivateNodeValue(String nodePath) throws IllegalArgumentException, IOException, NoSuchElementException Gets the value for the given node. The target path is considered to be private, and not exposed externally.- Parameters:
nodePath
- the full path of the node- Returns:
- the value of that node
- Throws:
IllegalArgumentException
IOException
NoSuchElementException
-
getSSLContent
Convenience method to retrieve the SSLContext for the given alias.- Parameters:
sslAlias
- name of the SSL alias we're trying to retrieve- Returns:
- the corresponding SSLContext that matches the alias.
- Throws:
com.ibm.websphere.ssl.SSLException
IOException
-
getAttributes
AttributeList getAttributes(String hostName, String userDir, String serverName, String objectName) throws IllegalArgumentException, IOException Get the MBean attributes for the given Object name.- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server nameobjectName
- the String representation of the MBean's ObjectName- Returns:
- an AttributeList with all the attributes for that MBean.
- Throws:
IllegalArgumentException
IOException
-
getAttribute
Object getAttribute(String hostName, String userDir, String serverName, String objectName, String attributeName) throws IllegalArgumentException, IOException Get the MBean attribute value for the given Object name and attribute.- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server nameobjectName
- the String representation of the MBean's ObjectNameattributeName
- the name of a specific attribute- Returns:
- the value of that attribute.
- Throws:
IllegalArgumentException
IOException
-
createRemoteAccess
RemoteAccessWrapper createRemoteAccess(String hostName, String userDir, String serverName, Map<String, String> credentials, Map<String, throws IOExceptionString> envVariables) Create a new remote access connection to the specified target. The returning object can be passed into various methods of this interface, and must have its session explicitly ended (seeRemoteAccessWrapper.endSession()
).- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server namecredentials
- the map of credentials to use to upload the file. If the map is null, the default credentials for the target will be used. See CollectiveRegistrationMBean for details on the credentials map.envVariables
- the map of environment variables to be set for this remote access connection- Returns:
- a RemoteAccessWrapper object that can be used as the remote connection
- Throws:
IOException
-
receiveFile
void receiveFile(String hostName, String userDir, String serverName, String remoteFile, File localDir) throws ConnectException, IOException Download a remote file. This method will create a new remote connection and end its session before existing.- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server nameremoteFile
- the absolute path of the remote filelocalDir
- the local directory where the file will be downloaded to- Throws:
ConnectException
IOException
-
receiveFile
void receiveFile(RemoteAccessWrapper remoteAccess, String remoteFile, File localDir) throws ConnectException, IOException Download a remote file.- Parameters:
remoteAccess
- the remote access object to be usedremoteFile
- the absolute path of the remote filelocalDir
- the local directory where the file will be downloaded to- Throws:
ConnectException
IOException
-
sendFile
void sendFile(String hostName, String userDir, String serverName, File localFile, String remoteDir) throws ConnectException, IOException Upload a file to a remote location. This method will create a new remote connection and end its session before existing.- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server namelocalFile
- the absolute local file locationremoteDir
- the target remote directory that will receive the uploaded file- Throws:
ConnectException
IOException
-
sendFile
void sendFile(RemoteAccessWrapper remoteAccess, File localFile, String remoteDir) throws ConnectException, IOException Upload a file to a remote location.- Parameters:
remoteAccess
- the remote access object to be usedlocalFile
- the absolute local file locationremoteDir
- the target remote directory that will receive the uploaded file- Throws:
ConnectException
IOException
-
deleteFile
void deleteFile(String hostName, String userDir, String serverName, String remoteFile) throws ConnectException, IOException Delete a remote file. This method will create a new remote connection and end its session before existing.- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server nameremoteFile
- the absolute remote file path- Throws:
ConnectException
IOException
-
deleteFile
void deleteFile(RemoteAccessWrapper remoteAccess, String remoteFile, boolean recursiveDelete) throws ConnectException, IOException Delete a remote file.- Parameters:
remoteAccess
- the remote access object to be usedremoteFile
- the absolute remote file pathrecursiveDelete
- a boolean that toggles recursive deletion of directories.- Throws:
ConnectException
IOException
-
expandArchive
void expandArchive(String hostName, String userDir, String serverName, String[] cmdArgs, String targetDir, boolean mustBeLiberty) throws ConnectException, IOException Expand a remote archive. This method will create a new remote connection and end its session before existing.- Parameters:
hostName
- the target host nameuserDir
- the target user directoryserverName
- the target server namecmdArgs
- the commands for the archive expansion. Cell 0 should specific the absolute source file location, and cell 1 should specific the absolute target file locationtargetDir
- the directory from where the file expansion action will be executedmustBeLiberty
- if true, then the archive will be enforced to be a proper Liberty archive. If false, the archive could be a Liberty archive or another archive.- Throws:
ConnectException
IOException
-
expandArchive
void expandArchive(RemoteAccessWrapper remoteAccess, String[] cmdArgs, String targetDir, boolean mustBeLiberty) throws ConnectException, IOException Expand a remote archive.- Parameters:
remoteAccess
- the remote access object to be usedcmdArgs
- the commands for the archive expansion. Cell 0 should specific the absolute source file location, and cell 1 should specific the absolute target file locationtargetDir
- the directory from where the file expansion action will be executedmustBeLiberty
- if true, then the archive will be enforced to be a proper Liberty archive. If false, the archive could be a Liberty archive or another archive.- Throws:
ConnectException
IOException
-
postTransferAction
CommandResult postTransferAction(String hostName, String targetDir, String action, String actionOptions) throws ConnectException, IOException Perform an action after a file has been transferred remotely.- Parameters:
hostName
- the target host nametargetDir
- the directory from where the action will be performedaction
- the action to be performedactionOptions
- options that will be passed to the action- Returns:
- the result of the action
- Throws:
ConnectException
IOException
-
postTransferAction
CommandResult postTransferAction(RemoteAccessWrapper remoteAccess, String targetDir, String action, String actionOptions) throws ConnectException, IOException Perform an action after a file has been transferred remotely.- Parameters:
remoteAccess
- the remote access object to be usedtargetDir
- the directory from where the action will be performedaction
- the action to be performedactionOptions
- options that will be passed to the action- Returns:
- the result of the action
- Throws:
ConnectException
IOException
-
getControllerHost
Fetch the controller's host name- Returns:
- the controller's host name
- Throws:
IOException
-
getControllerPort
Fetch the controllers secure (https) port.- Returns:
- the controller's secure port
- Throws:
IOException
-
preTransferAction
CommandResult preTransferAction(RemoteAccessWrapper remoteAccess, String executableDir, String action, String actionOption) throws ConnectException, IOException Perform an action before a file is deleted remotely.- Parameters:
remoteAccess
- the remote access object to be usedexecutableDir
- the directory from where the action will be performedaction
- the action to be performedactionOptions
- options that will be passed to the action- Returns:
- the result of the action
- Throws:
ConnectException
IOException
-
isReadOnly
boolean isReadOnly(RemoteAccessWrapper remoteAccess, String remoteFile) throws ConnectException, FileNotFoundException Check if a remote file is read-only- Parameters:
remoteAccess
- the remote access object to be usedremoteFile
- the file that will be checked- Returns:
- a boolean that is true is the file is read-only, false otherwise
- Throws:
FileNotFoundException
ConnectException
-
getJavaCommand
Retrieve the java home on the remote machine- Parameters:
remoteAccess
- the remote access object to be usedhostName
- the name of the remote machine- Returns:
- the java home, surrounded by quotes
- Throws:
IOException
-
getHostPaths
Retrieves a Map that contains the read and write lists of the remote host.- Parameters:
hostName
- the name of the remote machinefailIfNull
- when true, this flag will cause the method to throw an exception if the host maps are not found- Returns:
- a map that contains the read and write paths of the host
- Throws:
IOException
-
runCommand
Map<String,Object> runCommand(RemoteAccessWrapper remoteAccess, String cmd, String targetDir) throws ConnectException, IOException Run a command remotely. The keys of the returning Map are: returnCode(int), systemOut(String), systemErr(String) and isTimeoutExpired(boolean).- Parameters:
remoteAccess
- the remote access object to be usedcmd
- the command that will be executedtargetDir
- is the remote directory where the command will be executed- Returns:
- a map with the command results
- Throws:
ConnectException
IOException
-
makeRemoteDirectories
void makeRemoteDirectories(RemoteAccessWrapper remoteAccess, String remoteDirectory) throws ConnectException, FileNotFoundException, IOException Creates a directory tree in the remote target.- Parameters:
remoteAccess
- the remote access object to be usedremoteDirectory
- the remote directory to be created, including any parent directories- Throws:
ConnectException
FileNotFoundException
IOException
-
checkServerLevelAccess
boolean checkServerLevelAccess(String hostName, String userDir, String serverName, String path, boolean readOnly) throws IOException - Parameters:
hostName
- the host name of the remote targetuserDir
- the user directory of the remote targetserverName
- the server name of the remote targetpath
- the remote file path that is being checked for accessreadOnly
- whether or not we're checking for read-only access- Returns:
- a boolean that indicates if the given remote file path is within the appropriate white list
- Throws:
IOException
-
existsInRepository
boolean existsInRepository(String nodePath) throws IllegalArgumentException, IllegalStateException, IOException - Parameters:
nodePath
- the collective repository path to check- Returns:
- true if the path exists in the collective repository, false otherwise.
- Throws:
IllegalArgumentException
IllegalStateException
IOException
-
existsInRemoteFileSystem
boolean existsInRemoteFileSystem(RemoteAccessWrapper remoteAccess, String filePath) throws IllegalArgumentException, IllegalStateException, IOException - Parameters:
remoteAccess
- the remote access object to be usedfilePath
- the remote path to check- Returns:
- true if the path exists in the remote file system, false otherwise.
- Throws:
IllegalArgumentException
IllegalStateException
IOException
-