Class SystemTools

java.lang.Object
io.clonecloudstore.common.standard.system.SystemTools

public class SystemTools extends Object
  • Field Details

    • VIRTUAL_EXECUTOR_SERVICE

      public static final ExecutorService VIRTUAL_EXECUTOR_SERVICE
      Global Thread pool for Internal actions such as in TeeInputStream, ZstdCompressedInputStream, S3
    • DAEMON_THREAD_FACTORY

      public static final ThreadFactory DAEMON_THREAD_FACTORY
    • STANDARD_EXECUTOR_SERVICE

      public static final ExecutorService STANDARD_EXECUTOR_SERVICE
  • Method Details

    • toMillis

      public static Instant toMillis(Instant instant)
      Parameters:
      instant - instant to truncate
      Returns:
      an Instant truncated to Millisecond (since most of the DB truncated it)
    • silentlyCloseNoException

      public static void silentlyCloseNoException(InputStream inputStream)
      Silently close InputStream (no exception)
    • silentlyClose

      public static IOException silentlyClose(InputStream inputStream)
      Silently close InputStream (exception is returned if any)
    • silentlyCloseNoException

      public static void silentlyCloseNoException(OutputStream outputStream)
      Silently close OutputStream (no exception)
    • silentlyClose

      public static IOException silentlyClose(OutputStream outputStream)
      Silently close OutputStream (exception is returned if any)
    • consumeAll

      public static long consumeAll(Iterator<?> iterator)
      Parameters:
      iterator - to consume fully
      Returns:
      the number of items consumed
    • consumeAll

      public static long consumeAll(Stream<?> stream)
      Parameters:
      stream - to consume fully
      Returns:
      the number of items consumed
    • getField

      public static Object getField(Class<?> clasz, String fieldName, Object object) throws NoSuchFieldException, IllegalAccessException
      Get the field from the object named fieldName from Class
      Throws:
      NoSuchFieldException - field does not exist
      IllegalAccessException - issue on access
    • wait1ms

      public static void wait1ms()
      Thread.sleep(1 ms)
    • consumeWhileErrorInputStream

      public static void consumeWhileErrorInputStream(InputStream inputStream)
      Consume all InputStream in error case with no error
    • consumeWhileErrorInputStream

      public static void consumeWhileErrorInputStream(InputStream inputStream, long timeout)
      Consume all InputStream in error case with no error with a timeout
    • transferTo

      public static long transferTo(InputStream inputStream, OutputStream outputStream) throws IOException
      Transfer all inputStream to outputStream
      Returns:
      length of transferred bytes
      Throws:
      IOException
    • transferTo

      public static long transferTo(InputStream inputStream, OutputStream outputStream, boolean flushOnChunk) throws IOException
      Transfer all inputStream to outputStream
      Returns:
      length of transferred bytes
      Throws:
      IOException
    • skip

      public static long skip(InputStream inputStream, long skip) throws IOException
      Skip bytes from InputStream
      Returns:
      the number of really skipped bytes
      Throws:
      IOException