Class FileManagerServiceImpl

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface com.github.akurilov.commons.concurrent.AsyncRunnable

        com.github.akurilov.commons.concurrent.AsyncRunnable.State
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deleteFile​(java.lang.String fileName)  
      protected void doStart()  
      long fileSize​(java.lang.String fileName)  
      java.lang.String logFileName​(java.lang.String loggerName, java.lang.String testStepId)
      Determine the file name for the given logger and step id pair
      java.lang.String name()  
      java.lang.String newTmpFileName()
      Generate the temporary file name
      byte[] readFromFile​(java.lang.String fileName, long offset)
      Read the next batch of bytes from the remote file
      void truncateFile​(java.lang.String fileName, long size)  
      void writeToFile​(java.lang.String fileName, byte[] buff)
      Write some bytes to the remote file.
      • Methods inherited from class com.github.akurilov.commons.concurrent.AsyncRunnableBase

        await, await, close, doClose, isClosed, isInitial, isShutdown, isStarted, isStopped, shutdown, start, state, stop
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.github.akurilov.commons.concurrent.AsyncRunnable

        await, await, close, isClosed, isInitial, isShutdown, isStarted, isStopped, shutdown, start, state, stop
      • Methods inherited from interface java.lang.AutoCloseable

        close
    • Constructor Detail

      • FileManagerServiceImpl

        public FileManagerServiceImpl​(int port)
    • Method Detail

      • name

        public java.lang.String name()
        Specified by:
        name in interface Service
      • logFileName

        public final java.lang.String logFileName​(java.lang.String loggerName,
                                                  java.lang.String testStepId)
                                           throws java.io.IOException
        Description copied from interface: FileManager
        Determine the file name for the given logger and step id pair
        Specified by:
        logFileName in interface FileManager
        Returns:
        the file name
        Throws:
        java.io.IOException
      • newTmpFileName

        public final java.lang.String newTmpFileName()
                                              throws java.io.IOException
        Description copied from interface: FileManager
        Generate the temporary file name
        Specified by:
        newTmpFileName in interface FileManager
        Returns:
        the temporary file name
        Throws:
        java.io.IOException
      • readFromFile

        public final byte[] readFromFile​(java.lang.String fileName,
                                         long offset)
                                  throws java.io.IOException
        Description copied from interface: FileManager
        Read the next batch of bytes from the remote file
        Specified by:
        readFromFile in interface FileManager
        Returns:
        The bytes been read, may return empty buffer in case of EOF
        Throws:
        java.io.EOFException - if end of file is reached
        java.io.IOException
      • writeToFile

        public final void writeToFile​(java.lang.String fileName,
                                      byte[] buff)
                               throws java.io.IOException
        Description copied from interface: FileManager
        Write some bytes to the remote file. Blocks until all the bytes are written.
        Specified by:
        writeToFile in interface FileManager
        buff - the bytes to write to the remote file another IOException
        Throws:
        java.io.IOException
      • fileSize

        public final long fileSize​(java.lang.String fileName)
                            throws java.io.IOException
        Specified by:
        fileSize in interface FileManager
        Throws:
        java.io.IOException
      • truncateFile

        public final void truncateFile​(java.lang.String fileName,
                                       long size)
                                throws java.io.IOException
        Specified by:
        truncateFile in interface FileManager
        Throws:
        java.io.IOException
      • deleteFile

        public final void deleteFile​(java.lang.String fileName)
                              throws java.io.IOException
        Specified by:
        deleteFile in interface FileManager
        Throws:
        java.io.IOException