Class LocalNodeClient

java.lang.Object
net.bluemind.node.api.LocalNodeClient
All Implemented Interfaces:
INodeClient

public class LocalNodeClient extends Object implements INodeClient
  • Constructor Details

    • LocalNodeClient

      public LocalNodeClient()
  • Method Details

    • ping

      public void ping() throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Checks we can connect to a node.
      Specified by:
      ping in interface INodeClient
      Throws:
      net.bluemind.core.api.fault.ServerFault - if the connection does not work
    • read

      public byte[] read(String path) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Fetches a file content into ram. If the file does not exist, a zero-length byte array is returned.
      Specified by:
      read in interface INodeClient
      Parameters:
      path -
      Returns:
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • exists

      public boolean exists(String path)
      Description copied from interface: INodeClient
      Check if path exists
      Specified by:
      exists in interface INodeClient
      Parameters:
      path -
      Returns:
    • openStream

      public InputStream openStream(String path) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Opens a stream to a (maybe) remote file. Use this one when you can't predict the size of the file you want to read. WARNING: If you forget to close this stream, your BM Core will die from out of memory, too many open files, etc sooner or later.
      Specified by:
      openStream in interface INodeClient
      Parameters:
      path -
      Returns:
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • writeFile

      public void writeFile(String path, InputStream content) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      (Over)writes the file at path with content. Content is closed by this method. You don't need to do it in your code.
      Specified by:
      writeFile in interface INodeClient
      Parameters:
      path -
      content -
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • executeCommand

      public TaskRef executeCommand(List<String> argv) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Starts a command in backend and returns a ref to track its progress. Task return a String list as output.
      Specified by:
      executeCommand in interface INodeClient
      Parameters:
      argv -
      Returns:
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • executeCommand

      public TaskRef executeCommand(net.bluemind.node.shared.ExecRequest tsk) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Runs a command. The optional ExecRequest.group and ExecRequest.name can be used to provide a stable name to tasks
      Specified by:
      executeCommand in interface INodeClient
      Parameters:
      tsk -
      Returns:
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • asyncExecute

      public void asyncExecute(net.bluemind.node.shared.ExecRequest req, ProcessHandler ph)
      Specified by:
      asyncExecute in interface INodeClient
    • getActiveExecutions

      public List<net.bluemind.node.shared.ExecDescriptor> getActiveExecutions(net.bluemind.node.shared.ActiveExecQuery query)
      Description copied from interface: INodeClient
      Returns a list of running process matching the given query object. ActiveExecQuery.group and ActiveExecQuery.name might be null for wider matches.
      Specified by:
      getActiveExecutions in interface INodeClient
      Returns:
    • interrupt

      public void interrupt(net.bluemind.node.shared.ExecDescriptor runningTask)
      Specified by:
      interrupt in interface INodeClient
    • executeCommandNoOut

      public TaskRef executeCommandNoOut(List<String> argv) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Starts a command in backend and returns a ref to track its progress No output, receive "Done" when command finish.
      Specified by:
      executeCommandNoOut in interface INodeClient
      Parameters:
      argv -
      Returns:
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • getExecutionStatus

      public TaskStatus getExecutionStatus(TaskRef task) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Tracks the progress of a task
      Specified by:
      getExecutionStatus in interface INodeClient
      Parameters:
      task -
      Returns:
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • listFiles

      public List<FileDescription> listFiles(String path, String extensionPattern) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      List files from path matching extension. Task return a list of FileDescription as output
      Specified by:
      listFiles in interface INodeClient
      Parameters:
      path -
      extensionPattern -
      Returns:
      empty list when the path does not exist
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • listFiles

      public List<FileDescription> listFiles(String path) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      List files from path. Task return a FileDescription list as output.
      Specified by:
      listFiles in interface INodeClient
      Parameters:
      path -
      Returns:
      empty list when the path does not exist
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • deleteFile

      public void deleteFile(String path) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Delete a file
      Specified by:
      deleteFile in interface INodeClient
      Parameters:
      path -
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • moveFile

      public void moveFile(String origin, String destination)
      Description copied from interface: INodeClient
      Moves a file from a path, to another
      Specified by:
      moveFile in interface INodeClient
      Parameters:
      origin - : Original path
      destination - : Destination path
    • mkdirs

      public void mkdirs(String dst, String permissions, String owner, String group) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Create a directory and all required parents
      Specified by:
      mkdirs in interface INodeClient
      Parameters:
      dst - : directory to create
      permissions - : "java" permissions, like: "rwxrwx---", or "rw--------"
      Throws:
      net.bluemind.core.api.fault.ServerFault
    • browsePage

      public FilePage browsePage(String path, String filenamePattern, int pageSize, String after) throws net.bluemind.core.api.fault.ServerFault
      Description copied from interface: INodeClient
      Read one page of the regular files of a directory, ordered by file name. Sub directories are not recursed into and are not part of the result.
      Specified by:
      browsePage in interface INodeClient
      Parameters:
      path - scanned directory
      filenamePattern - regular expression the file names must match, null to keep them all
      pageSize - maximum number of files in the page
      after - FilePage.cursor() of the previous page, null to start at the beginning of the directory
      Returns:
      an empty page when the path does not exist
      Throws:
      net.bluemind.core.api.fault.ServerFault