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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean checkServerLevelAccess​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String path, boolean readOnly)  
      RemoteAccessWrapper createRemoteAccess​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.util.Map<java.lang.String,​java.lang.String> credentials, java.util.Map<java.lang.String,​java.lang.String> envVariables)
      Create a new remote access connection to the specified target.
      void deleteFile​(RemoteAccessWrapper remoteAccess, java.lang.String remoteFile, boolean recursiveDelete)
      Delete a remote file.
      void deleteFile​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String remoteFile)
      Delete a remote file.
      boolean existsInRemoteFileSystem​(RemoteAccessWrapper remoteAccess, java.lang.String filePath)  
      boolean existsInRepository​(java.lang.String nodePath)  
      void expandArchive​(RemoteAccessWrapper remoteAccess, java.lang.String[] cmdArgs, java.lang.String targetDir, boolean mustBeLiberty)
      Expand a remote archive.
      void expandArchive​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String[] cmdArgs, java.lang.String targetDir, boolean mustBeLiberty)
      Expand a remote archive.
      java.lang.Object getAttribute​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String objectName, java.lang.String attributeName)
      Get the MBean attribute value for the given Object name and attribute.
      javax.management.AttributeList getAttributes​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String objectName)
      Get the MBean attributes for the given Object name.
      java.lang.String getControllerHost()
      Fetch the controller's host name
      java.lang.String getControllerPort()
      Fetch the controllers secure (https) port.
      java.util.Map<java.lang.String,​java.lang.Object> getHostPaths​(java.lang.String hostName, boolean failIfNull)
      Retrieves a Map that contains the read and write lists of the remote host.
      java.lang.String getJavaCommand​(RemoteAccessWrapper remoteAccess, java.lang.String hostName)
      Retrieve the java home on the remote machine
      java.lang.Object getNodeValue​(java.lang.String nodePath)
      Gets the value for the given node.
      java.lang.Object getPrivateNodeValue​(java.lang.String nodePath)
      Gets the value for the given node.
      java.lang.Object getPrivateServerNode​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String node)
      Computes the appropriate repository server path for the desired node, and then retrieves the value.
      java.lang.Object getServerNode​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String node)
      Computes the appropriate repository server path for the desired node, and then retrieves the value.
      javax.net.ssl.SSLContext getSSLContent​(java.lang.String sslAlias)
      Convenience method to retrieve the SSLContext for the given alias.
      boolean isReadOnly​(RemoteAccessWrapper remoteAccess, java.lang.String remoteFile)
      Check if a remote file is read-only
      void makeRemoteDirectories​(RemoteAccessWrapper remoteAccess, java.lang.String remoteDirectory)
      Creates a directory tree in the remote target.
      CommandResult postTransferAction​(RemoteAccessWrapper remoteAccess, java.lang.String targetDir, java.lang.String action, java.lang.String actionOptions)
      Perform an action after a file has been transferred remotely.
      CommandResult postTransferAction​(java.lang.String hostName, java.lang.String targetDir, java.lang.String action, java.lang.String actionOptions)
      Perform an action after a file has been transferred remotely.
      CommandResult preTransferAction​(RemoteAccessWrapper remoteAccess, java.lang.String executableDir, java.lang.String action, java.lang.String actionOption)
      Perform an action before a file is deleted remotely.
      void receiveFile​(RemoteAccessWrapper remoteAccess, java.lang.String remoteFile, java.io.File localDir)
      Download a remote file.
      void receiveFile​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.lang.String remoteFile, java.io.File localDir)
      Download a remote file.
      java.util.Map<java.lang.String,​java.lang.Object> runCommand​(RemoteAccessWrapper remoteAccess, java.lang.String cmd, java.lang.String targetDir)
      Run a command remotely.
      void sendFile​(RemoteAccessWrapper remoteAccess, java.io.File localFile, java.lang.String remoteDir)
      Upload a file to a remote location.
      void sendFile​(java.lang.String hostName, java.lang.String userDir, java.lang.String serverName, java.io.File localFile, java.lang.String remoteDir)
      Upload a file to a remote location.
    • Method Detail

      • getServerNode

        java.lang.Object getServerNode​(java.lang.String hostName,
                                       java.lang.String userDir,
                                       java.lang.String serverName,
                                       java.lang.String node)
                                throws java.lang.IllegalArgumentException,
                                       java.io.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 path
        userDir - the user directory in the path
        serverName - the name of the server in the path
        node - the leaf node in the path
        Returns:
        the value at the calculated path
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • getNodeValue

        java.lang.Object getNodeValue​(java.lang.String nodePath)
                               throws java.lang.IllegalArgumentException,
                                      java.io.IOException
        Gets the value for the given node.
        Parameters:
        nodePath - the full path of the node
        Returns:
        the value of that node
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • getPrivateServerNode

        java.lang.Object getPrivateServerNode​(java.lang.String hostName,
                                              java.lang.String userDir,
                                              java.lang.String serverName,
                                              java.lang.String node)
                                       throws java.lang.IllegalArgumentException,
                                              java.io.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 path
        userDir - the user directory in the path
        serverName - the name of the server in the path
        node - the leaf node in the path
        Returns:
        the value at the calculated path
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • getPrivateNodeValue

        java.lang.Object getPrivateNodeValue​(java.lang.String nodePath)
                                      throws java.lang.IllegalArgumentException,
                                             java.io.IOException,
                                             java.util.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:
        java.lang.IllegalArgumentException
        java.io.IOException
        java.util.NoSuchElementException
      • getSSLContent

        javax.net.ssl.SSLContext getSSLContent​(java.lang.String sslAlias)
                                        throws com.ibm.websphere.ssl.SSLException,
                                               java.io.IOException
        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
        java.io.IOException
      • getAttributes

        javax.management.AttributeList getAttributes​(java.lang.String hostName,
                                                     java.lang.String userDir,
                                                     java.lang.String serverName,
                                                     java.lang.String objectName)
                                              throws java.lang.IllegalArgumentException,
                                                     java.io.IOException
        Get the MBean attributes for the given Object name.
        Parameters:
        hostName - the target host name
        userDir - the target user directory
        serverName - the target server name
        objectName - the String representation of the MBean's ObjectName
        Returns:
        an AttributeList with all the attributes for that MBean.
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • getAttribute

        java.lang.Object getAttribute​(java.lang.String hostName,
                                      java.lang.String userDir,
                                      java.lang.String serverName,
                                      java.lang.String objectName,
                                      java.lang.String attributeName)
                               throws java.lang.IllegalArgumentException,
                                      java.io.IOException
        Get the MBean attribute value for the given Object name and attribute.
        Parameters:
        hostName - the target host name
        userDir - the target user directory
        serverName - the target server name
        objectName - the String representation of the MBean's ObjectName
        attributeName - the name of a specific attribute
        Returns:
        the value of that attribute.
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • createRemoteAccess

        RemoteAccessWrapper createRemoteAccess​(java.lang.String hostName,
                                               java.lang.String userDir,
                                               java.lang.String serverName,
                                               java.util.Map<java.lang.String,​java.lang.String> credentials,
                                               java.util.Map<java.lang.String,​java.lang.String> envVariables)
                                        throws java.io.IOException
        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 (see RemoteAccessWrapper.endSession()).
        Parameters:
        hostName - the target host name
        userDir - the target user directory
        serverName - the target server name
        credentials - 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:
        java.io.IOException
      • receiveFile

        void receiveFile​(java.lang.String hostName,
                         java.lang.String userDir,
                         java.lang.String serverName,
                         java.lang.String remoteFile,
                         java.io.File localDir)
                  throws java.net.ConnectException,
                         java.io.IOException
        Download a remote file. This method will create a new remote connection and end its session before existing.
        Parameters:
        hostName - the target host name
        userDir - the target user directory
        serverName - the target server name
        remoteFile - the absolute path of the remote file
        localDir - the local directory where the file will be downloaded to
        Throws:
        java.net.ConnectException
        java.io.IOException
      • receiveFile

        void receiveFile​(RemoteAccessWrapper remoteAccess,
                         java.lang.String remoteFile,
                         java.io.File localDir)
                  throws java.net.ConnectException,
                         java.io.IOException
        Download a remote file.
        Parameters:
        remoteAccess - the remote access object to be used
        remoteFile - the absolute path of the remote file
        localDir - the local directory where the file will be downloaded to
        Throws:
        java.net.ConnectException
        java.io.IOException
      • sendFile

        void sendFile​(java.lang.String hostName,
                      java.lang.String userDir,
                      java.lang.String serverName,
                      java.io.File localFile,
                      java.lang.String remoteDir)
               throws java.net.ConnectException,
                      java.io.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 name
        userDir - the target user directory
        serverName - the target server name
        localFile - the absolute local file location
        remoteDir - the target remote directory that will receive the uploaded file
        Throws:
        java.net.ConnectException
        java.io.IOException
      • sendFile

        void sendFile​(RemoteAccessWrapper remoteAccess,
                      java.io.File localFile,
                      java.lang.String remoteDir)
               throws java.net.ConnectException,
                      java.io.IOException
        Upload a file to a remote location.
        Parameters:
        remoteAccess - the remote access object to be used
        localFile - the absolute local file location
        remoteDir - the target remote directory that will receive the uploaded file
        Throws:
        java.net.ConnectException
        java.io.IOException
      • deleteFile

        void deleteFile​(java.lang.String hostName,
                        java.lang.String userDir,
                        java.lang.String serverName,
                        java.lang.String remoteFile)
                 throws java.net.ConnectException,
                        java.io.IOException
        Delete a remote file. This method will create a new remote connection and end its session before existing.
        Parameters:
        hostName - the target host name
        userDir - the target user directory
        serverName - the target server name
        remoteFile - the absolute remote file path
        Throws:
        java.net.ConnectException
        java.io.IOException
      • deleteFile

        void deleteFile​(RemoteAccessWrapper remoteAccess,
                        java.lang.String remoteFile,
                        boolean recursiveDelete)
                 throws java.net.ConnectException,
                        java.io.IOException
        Delete a remote file.
        Parameters:
        remoteAccess - the remote access object to be used
        remoteFile - the absolute remote file path
        recursiveDelete - a boolean that toggles recursive deletion of directories.
        Throws:
        java.net.ConnectException
        java.io.IOException
      • expandArchive

        void expandArchive​(java.lang.String hostName,
                           java.lang.String userDir,
                           java.lang.String serverName,
                           java.lang.String[] cmdArgs,
                           java.lang.String targetDir,
                           boolean mustBeLiberty)
                    throws java.net.ConnectException,
                           java.io.IOException
        Expand a remote archive. This method will create a new remote connection and end its session before existing.
        Parameters:
        hostName - the target host name
        userDir - the target user directory
        serverName - the target server name
        cmdArgs - the commands for the archive expansion. Cell 0 should specific the absolute source file location, and cell 1 should specific the absolute target file location
        targetDir - the directory from where the file expansion action will be executed
        mustBeLiberty - 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:
        java.net.ConnectException
        java.io.IOException
      • expandArchive

        void expandArchive​(RemoteAccessWrapper remoteAccess,
                           java.lang.String[] cmdArgs,
                           java.lang.String targetDir,
                           boolean mustBeLiberty)
                    throws java.net.ConnectException,
                           java.io.IOException
        Expand a remote archive.
        Parameters:
        remoteAccess - the remote access object to be used
        cmdArgs - the commands for the archive expansion. Cell 0 should specific the absolute source file location, and cell 1 should specific the absolute target file location
        targetDir - the directory from where the file expansion action will be executed
        mustBeLiberty - 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:
        java.net.ConnectException
        java.io.IOException
      • postTransferAction

        CommandResult postTransferAction​(java.lang.String hostName,
                                         java.lang.String targetDir,
                                         java.lang.String action,
                                         java.lang.String actionOptions)
                                  throws java.net.ConnectException,
                                         java.io.IOException
        Perform an action after a file has been transferred remotely.
        Parameters:
        hostName - the target host name
        targetDir - the directory from where the action will be performed
        action - the action to be performed
        actionOptions - options that will be passed to the action
        Returns:
        the result of the action
        Throws:
        java.net.ConnectException
        java.io.IOException
      • postTransferAction

        CommandResult postTransferAction​(RemoteAccessWrapper remoteAccess,
                                         java.lang.String targetDir,
                                         java.lang.String action,
                                         java.lang.String actionOptions)
                                  throws java.net.ConnectException,
                                         java.io.IOException
        Perform an action after a file has been transferred remotely.
        Parameters:
        remoteAccess - the remote access object to be used
        targetDir - the directory from where the action will be performed
        action - the action to be performed
        actionOptions - options that will be passed to the action
        Returns:
        the result of the action
        Throws:
        java.net.ConnectException
        java.io.IOException
      • getControllerHost

        java.lang.String getControllerHost()
                                    throws java.io.IOException
        Fetch the controller's host name
        Returns:
        the controller's host name
        Throws:
        java.io.IOException
      • getControllerPort

        java.lang.String getControllerPort()
                                    throws java.io.IOException
        Fetch the controllers secure (https) port.
        Returns:
        the controller's secure port
        Throws:
        java.io.IOException
      • preTransferAction

        CommandResult preTransferAction​(RemoteAccessWrapper remoteAccess,
                                        java.lang.String executableDir,
                                        java.lang.String action,
                                        java.lang.String actionOption)
                                 throws java.net.ConnectException,
                                        java.io.IOException
        Perform an action before a file is deleted remotely.
        Parameters:
        remoteAccess - the remote access object to be used
        executableDir - the directory from where the action will be performed
        action - the action to be performed
        actionOptions - options that will be passed to the action
        Returns:
        the result of the action
        Throws:
        java.net.ConnectException
        java.io.IOException
      • isReadOnly

        boolean isReadOnly​(RemoteAccessWrapper remoteAccess,
                           java.lang.String remoteFile)
                    throws java.net.ConnectException,
                           java.io.FileNotFoundException
        Check if a remote file is read-only
        Parameters:
        remoteAccess - the remote access object to be used
        remoteFile - the file that will be checked
        Returns:
        a boolean that is true is the file is read-only, false otherwise
        Throws:
        java.io.FileNotFoundException
        java.net.ConnectException
      • getJavaCommand

        java.lang.String getJavaCommand​(RemoteAccessWrapper remoteAccess,
                                        java.lang.String hostName)
                                 throws java.io.IOException
        Retrieve the java home on the remote machine
        Parameters:
        remoteAccess - the remote access object to be used
        hostName - the name of the remote machine
        Returns:
        the java home, surrounded by quotes
        Throws:
        java.io.IOException
      • getHostPaths

        java.util.Map<java.lang.String,​java.lang.Object> getHostPaths​(java.lang.String hostName,
                                                                            boolean failIfNull)
                                                                     throws java.io.IOException
        Retrieves a Map that contains the read and write lists of the remote host.
        Parameters:
        hostName - the name of the remote machine
        failIfNull - 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:
        java.io.IOException
      • runCommand

        java.util.Map<java.lang.String,​java.lang.Object> runCommand​(RemoteAccessWrapper remoteAccess,
                                                                          java.lang.String cmd,
                                                                          java.lang.String targetDir)
                                                                   throws java.net.ConnectException,
                                                                          java.io.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 used
        cmd - the command that will be executed
        targetDir - is the remote directory where the command will be executed
        Returns:
        a map with the command results
        Throws:
        java.net.ConnectException
        java.io.IOException
      • makeRemoteDirectories

        void makeRemoteDirectories​(RemoteAccessWrapper remoteAccess,
                                   java.lang.String remoteDirectory)
                            throws java.net.ConnectException,
                                   java.io.FileNotFoundException,
                                   java.io.IOException
        Creates a directory tree in the remote target.
        Parameters:
        remoteAccess - the remote access object to be used
        remoteDirectory - the remote directory to be created, including any parent directories
        Throws:
        java.net.ConnectException
        java.io.FileNotFoundException
        java.io.IOException
      • checkServerLevelAccess

        boolean checkServerLevelAccess​(java.lang.String hostName,
                                       java.lang.String userDir,
                                       java.lang.String serverName,
                                       java.lang.String path,
                                       boolean readOnly)
                                throws java.io.IOException
        Parameters:
        hostName - the host name of the remote target
        userDir - the user directory of the remote target
        serverName - the server name of the remote target
        path - the remote file path that is being checked for access
        readOnly - 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:
        java.io.IOException
      • existsInRepository

        boolean existsInRepository​(java.lang.String nodePath)
                            throws java.lang.IllegalArgumentException,
                                   java.lang.IllegalStateException,
                                   java.io.IOException
        Parameters:
        nodePath - the collective repository path to check
        Returns:
        true if the path exists in the collective repository, false otherwise.
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalStateException
        java.io.IOException
      • existsInRemoteFileSystem

        boolean existsInRemoteFileSystem​(RemoteAccessWrapper remoteAccess,
                                         java.lang.String filePath)
                                  throws java.lang.IllegalArgumentException,
                                         java.lang.IllegalStateException,
                                         java.io.IOException
        Parameters:
        remoteAccess - the remote access object to be used
        filePath - the remote path to check
        Returns:
        true if the path exists in the remote file system, false otherwise.
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalStateException
        java.io.IOException