Interface INodeClient

All Known Implementing Classes:
LocalNodeClient

public interface INodeClient
local or remote BM Host manipulation API.
  • Method Details

    • ping

      void ping() throws ServerFault
      Checks we can connect to a node.
      Throws:
      ServerFault - if the connection does not work
    • read

      byte[] read(String path) throws ServerFault
      Fetches a file content into ram. If the file does not exist, a zero-length byte array is returned.
      Parameters:
      path -
      Returns:
      Throws:
      ServerFault
    • exists

      boolean exists(String path)
      Check if path exists
      Parameters:
      path -
      Returns:
    • openStream

      InputStream openStream(String path) throws ServerFault
      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.
      Parameters:
      path -
      Returns:
      Throws:
      ServerFault
    • writeFile

      void writeFile(String path, InputStream content) throws ServerFault
      (Over)writes the file at path with content. Content is closed by this method. You don't need to do it in your code.
      Parameters:
      path -
      content -
      Throws:
      ServerFault
    • executeCommand

      TaskRef executeCommand(List<String> argv) throws ServerFault
      Starts a command in backend and returns a ref to track its progress. Task return a String list as output.
      Parameters:
      argv -
      Returns:
      Throws:
      ServerFault
    • executeCommand

      default TaskRef executeCommand(String... argv) throws ServerFault
      Throws:
      ServerFault
    • executeCommand

      TaskRef executeCommand(ExecRequest tsk) throws ServerFault
      Runs a command. The optional ExecRequest.group and ExecRequest.name can be used to provide a stable name to tasks
      Parameters:
      tsk -
      Returns:
      Throws:
      ServerFault
    • asyncExecute

      void asyncExecute(ExecRequest req, ProcessHandler ph)
    • getActiveExecutions

      List<ExecDescriptor> getActiveExecutions(ActiveExecQuery query)
      Returns a list of running process matching the given query object. ActiveExecQuery.group and ActiveExecQuery.name might be null for wider matches.
      Returns:
    • interrupt

      void interrupt(ExecDescriptor runningTask)
    • executeCommandNoOut

      TaskRef executeCommandNoOut(List<String> argv) throws ServerFault
      Starts a command in backend and returns a ref to track its progress No output, receive "Done" when command finish.
      Parameters:
      argv -
      Returns:
      Throws:
      ServerFault
    • executeCommandNoOut

      default TaskRef executeCommandNoOut(String... argv) throws ServerFault
      Throws:
      ServerFault
    • getExecutionStatus

      TaskStatus getExecutionStatus(TaskRef task) throws ServerFault
      Tracks the progress of a task
      Parameters:
      task -
      Returns:
      Throws:
      ServerFault
    • listFiles

      List<FileDescription> listFiles(String path, String extensionPattern) throws ServerFault
      List files from path matching extension. Task return a list of FileDescription as output
      Parameters:
      path -
      extensionPattern -
      Returns:
      empty list when the path does not exist
      Throws:
      ServerFault
    • listFiles

      List<FileDescription> listFiles(String path) throws ServerFault
      List files from path. Task return a FileDescription list as output.
      Parameters:
      path -
      Returns:
      empty list when the path does not exist
      Throws:
      ServerFault
    • getFile

      default Optional<FileDescription> getFile(String path) throws ServerFault
      Get single file from path. Task return a FileDescription as output.
      Parameters:
      path -
      Returns:
      Optional.empty() when the path does not exist
      Throws:
      ServerFault
    • browsePage

      FilePage browsePage(String path, String filenamePattern, int pageSize, String after) throws ServerFault
      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.
      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:
      ServerFault
    • browse

      default Iterable<FileDescription> browse(String path, String filenamePattern, int pageSize)
      Iterate over the regular files of a directory, one page at a time. The iteration always moves forward: files the caller leaves in place are not handed back a second time, so it terminates whatever the caller does with them.
      Parameters:
      path - scanned directory
      filenamePattern - regular expression the file names must match, null to keep them all
      pageSize - number of files fetched per round trip
    • deleteFile

      void deleteFile(String path) throws ServerFault
      Delete a file
      Parameters:
      path -
      Throws:
      ServerFault
    • moveFile

      void moveFile(String origin, String destination) throws ServerFault
      Moves a file from a path, to another
      Parameters:
      origin - : Original path
      destination - : Destination path
      Throws:
      ServerFault
    • mkdirs

      void mkdirs(String dst, String permissions, String owner, String group) throws ServerFault
      Create a directory and all required parents
      Parameters:
      dst - : directory to create
      permissions - : "java" permissions, like: "rwxrwx---", or "rw--------"
      Throws:
      ServerFault
    • mkdirs

      default void mkdirs(String dst, String permissions) throws ServerFault
      Throws:
      ServerFault
    • mkdirs

      default void mkdirs(String dst) throws ServerFault
      Throws:
      ServerFault