cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobrown <...@git.apache.org>
Subject [GitHub] cassandra pull request #236: 9608 trunk
Date Mon, 23 Jul 2018 11:58:21 GMT
Github user jasobrown commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/236#discussion_r204368353
  
    --- Diff: src/java/org/apache/cassandra/io/util/FileUtils.java ---
    @@ -64,24 +68,31 @@
         public static final long ONE_TB = 1024 * ONE_GB;
     
         private static final DecimalFormat df = new DecimalFormat("#.##");
    -    public static final boolean isCleanerAvailable;
         private static final AtomicReference<Optional<FSErrorHandler>> fsErrorHandler
= new AtomicReference<>(Optional.empty());
     
    +    private static Class clsDirectBuffer;
    +    private static MethodHandle mhDirectBufferCleaner;
    +    private static MethodHandle mhCleanerClean;
    +
         static
         {
    -        boolean canClean = false;
             try
             {
    +            clsDirectBuffer = Class.forName("sun.nio.ch.DirectBuffer");
    +            Method mDirectBufferCleaner = clsDirectBuffer.getMethod("cleaner");
    +            mhDirectBufferCleaner = MethodHandles.lookup().unreflect(mDirectBufferCleaner);
    +            Method mCleanerClean = mDirectBufferCleaner.getReturnType().getMethod("clean");
    +            mhCleanerClean = MethodHandles.lookup().unreflect(mCleanerClean);
    +
                 ByteBuffer buf = ByteBuffer.allocateDirect(1);
    -            ((DirectBuffer) buf).cleaner().clean();
    -            canClean = true;
    +            clean(buf);
             }
             catch (Throwable t)
             {
    +            logger.info("Cannot initialize optimized memory deallocator. Some data, both
in-memory and on-disk, may live longer due to garbage collection.");
                 JVMStabilityInspector.inspectThrowable(t);
    -            logger.info("Cannot initialize un-mmaper.  (Are you using a non-Oracle JVM?)
 Compacted data files will not be removed promptly.  Consider using an Oracle JVM or using
standard disk access mode");
    +            throw new RuntimeException(t);
    --- End diff --
    
    So, this is a change in semantics (throwing a RuntimeException). Previously, we would
just complain if we couldn't get to the buffer cleaner, now we're basically terminating the
process. Is that intended? If it is, at minimum the log statement a few lines up should be
`FATAL`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message