cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [1/4] cassandra git commit: Make C* compile and run on Java 11 and Java 8
Date Thu, 26 Jul 2018 16:22:53 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 176d4bac2 -> 6ba2fb939


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java b/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
index 1db4b7f..16cb45d 100644
--- a/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
+++ b/src/java/org/apache/cassandra/utils/memory/SlabAllocator.java
@@ -26,9 +26,9 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.concurrent.OpOrder;
-import sun.nio.ch.DirectBuffer;
 
 /**
 + * The SlabAllocator is a bump-the-pointer allocator that allocates
@@ -116,7 +116,7 @@ public class SlabAllocator extends MemtableBufferAllocator
     public void setDiscarded()
     {
         for (Region region : offHeapRegions)
-            ((DirectBuffer) region.data).cleaner().clean();
+            FileUtils.clean(region.data);
         super.setDiscarded();
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/src/java11/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java
----------------------------------------------------------------------
diff --git a/src/java11/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java b/src/java11/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java
new file mode 100644
index 0000000..ac1a11d
--- /dev/null
+++ b/src/java11/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.db.partitions;
+
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.db.DecoratedKey;
+
+/**
+ * Java 11 version for the partition-locks in {@link AtomicBTreePartition}.
+ */
+public abstract class AtomicBTreePartitionBase extends AbstractBTreePartition
+{
+    private static final Logger logger = LoggerFactory.getLogger(AtomicBTreePartitionBase.class);
+
+    protected AtomicBTreePartitionBase(DecoratedKey partitionKey)
+    {
+        super(partitionKey);
+    }
+
+    // Replacement for Unsafe.monitorEnter/monitorExit.
+    private final ReentrantLock lock = new ReentrantLock();
+
+    static
+    {
+        logger.info("Initializing Java 11 support for AtomicBTreePartition");
+
+        if (Runtime.version().version().get(0) < 11)
+            throw new RuntimeException("Java 11 required, but found " + Runtime.version());
+    }
+
+    protected final void acquireLock()
+    {
+        lock.lock();
+    }
+
+    protected final void releaseLock()
+    {
+        lock.unlock();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/src/java8/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java
----------------------------------------------------------------------
diff --git a/src/java8/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java b/src/java8/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java
new file mode 100644
index 0000000..32209e9
--- /dev/null
+++ b/src/java8/org/apache/cassandra/db/partitions/AtomicBTreePartitionBase.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.db.partitions;
+
+import sun.misc.Unsafe;
+
+import java.lang.reflect.Field;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.db.DecoratedKey;
+
+/**
+ * Java 8 version for the partition-locks in {@link AtomicBTreePartition}.
+ */
+public abstract class AtomicBTreePartitionBase extends AbstractBTreePartition
+{
+    private static final Logger logger = LoggerFactory.getLogger(AtomicBTreePartitionBase.class);
+    private static final Unsafe unsafe;
+
+    static
+    {
+        logger.info("Initializing Java 8 support for AtomicBTreePartition");
+
+        if (!System.getProperty("java.version").startsWith("1.8.0"))
+            throw new RuntimeException("Java 8 required, but running " + System.getProperty("java.version"));
+
+        try
+        {
+            // Safety... in case someone builds only on Java 8 but runs on Java 11...
+            sun.misc.Unsafe.class.getDeclaredMethod("monitorEnter", Object.class);
+            sun.misc.Unsafe.class.getDeclaredMethod("monitorExit", Object.class);
+
+            Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
+            field.setAccessible(true);
+            unsafe = (sun.misc.Unsafe) field.get(null);
+        }
+        catch (NoSuchFieldException | NoSuchMethodException e)
+        {
+            throw new RuntimeException("This build of Cassandra has no support for Java 11 as only Java 8 was available during the build. This should never happen.");
+        }
+        catch (Exception e)
+        {
+            throw new AssertionError(e);
+        }
+    }
+
+    protected AtomicBTreePartitionBase(DecoratedKey partitionKey)
+    {
+        super(partitionKey);
+    }
+
+    protected final void acquireLock()
+    {
+        if (unsafe != null)
+            unsafe.monitorEnter(this);
+    }
+
+    protected final void releaseLock()
+    {
+        if (unsafe != null)
+            unsafe.monitorExit(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/src/jdkoverride/java/util/zip/CRC32.class
----------------------------------------------------------------------
diff --git a/src/jdkoverride/java/util/zip/CRC32.class b/src/jdkoverride/java/util/zip/CRC32.class
deleted file mode 100644
index 546199e..0000000
Binary files a/src/jdkoverride/java/util/zip/CRC32.class and /dev/null differ

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/audit/FullQueryLoggerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/audit/FullQueryLoggerTest.java b/test/unit/org/apache/cassandra/audit/FullQueryLoggerTest.java
index 14f7f23..0cc8094 100644
--- a/test/unit/org/apache/cassandra/audit/FullQueryLoggerTest.java
+++ b/test/unit/org/apache/cassandra/audit/FullQueryLoggerTest.java
@@ -46,6 +46,7 @@ import org.apache.cassandra.cql3.CQLTester;
 import org.apache.cassandra.cql3.QueryOptions;
 import org.apache.cassandra.audit.FullQueryLogger.WeighableMarshallableQuery;
 import org.apache.cassandra.audit.FullQueryLogger.WeighableMarshallableBatch;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.transport.ProtocolVersion;
 import org.apache.cassandra.utils.ObjectSizes;
 import org.apache.cassandra.utils.binlog.BinLogTest;
@@ -109,9 +110,9 @@ public class FullQueryLoggerTest extends CQLTester
     }
 
     @Test(expected = IllegalArgumentException.class)
-    public void testConfigureOverExistingFile() throws Exception
+    public void testConfigureOverExistingFile()
     {
-        File f = File.createTempFile("foo", "bar");
+        File f = FileUtils.createTempFile("foo", "bar");
         f.deleteOnExit();
         instance.configure(f.toPath(), "TEST_SECONDLY", true, 1, 1);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/config/DatabaseDescriptorRefTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/config/DatabaseDescriptorRefTest.java b/test/unit/org/apache/cassandra/config/DatabaseDescriptorRefTest.java
index 68435a8..07ab3dc 100644
--- a/test/unit/org/apache/cassandra/config/DatabaseDescriptorRefTest.java
+++ b/test/unit/org/apache/cassandra/config/DatabaseDescriptorRefTest.java
@@ -168,6 +168,13 @@ public class DatabaseDescriptorRefTest
 
             protected Class<?> findClass(String name) throws ClassNotFoundException
             {
+                if (name.startsWith("java."))
+                    // Java 11 does not allow a "custom" class loader (i.e. user code)
+                    // to define classes in protected packages (like java, java.sql, etc).
+                    // Therefore we have to delegate the call to the delegate class loader
+                    // itself.
+                    return delegate.loadClass(name);
+
                 Class<?> cls = classMap.get(name);
                 if (cls != null)
                     return cls;
@@ -182,7 +189,15 @@ public class DatabaseDescriptorRefTest
 
                 URL url = delegate.getResource(name.replace('.', '/') + ".class");
                 if (url == null)
-                    throw new ClassNotFoundException(name);
+                {
+                    // For Java 11: system class files are not readable via getResource(), so
+                    // try it this way
+                    cls = Class.forName(name, false, delegate);
+                    classMap.put(name, cls);
+                    return cls;
+                }
+
+                // Java8 way + all non-system class files
                 try (InputStream in = url.openConnection().getInputStream())
                 {
                     ByteArrayOutputStream os = new ByteArrayOutputStream();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/cql3/validation/entities/UFJavaTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFJavaTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFJavaTest.java
index 975b21a..36e7b29 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFJavaTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFJavaTest.java
@@ -106,7 +106,7 @@ public class UFJavaTest extends CQLTester
         catch (InvalidRequestException e)
         {
             Assert.assertTrue(e.getMessage(), e.getMessage().contains("Java source compilation failed"));
-            Assert.assertTrue(e.getMessage(), e.getMessage().contains("foobarbaz cannot be resolved to a type"));
+            Assert.assertTrue(e.getMessage(), e.getMessage().contains("foobarbaz cannot be resolved"));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/cql3/validation/entities/UFSecurityTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFSecurityTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFSecurityTest.java
index 4e45a8a..7422db43 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFSecurityTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFSecurityTest.java
@@ -57,11 +57,22 @@ public class UFSecurityTest extends CQLTester
             assertAccessControlException("System.getProperty(\"foo.bar.baz\"); return 0d;", e);
         }
 
+        String[] cfnSources =
+        { "try { Class.forName(\"" + UDHelper.class.getName() + "\"); } catch (Exception e) { throw new RuntimeException(e); } return 0d;",
+          "try { Class.forName(\"sun.misc.Unsafe\"); } catch (Exception e) { throw new RuntimeException(e); } return 0d;" };
+        for (String source : cfnSources)
+        {
+            assertInvalidMessage("Java UDF validation failed: [call to java.lang.Class.forName()]",
+                                 "CREATE OR REPLACE FUNCTION " + KEYSPACE + ".invalid_class_access(val double) " +
+                                 "RETURNS NULL ON NULL INPUT " +
+                                 "RETURNS double " +
+                                 "LANGUAGE JAVA\n" +
+                                 "AS '" + source + "';");
+        }
+
         String[][] typesAndSources =
         {
-        {"", "try { Class.forName(\"" + UDHelper.class.getName() + "\"); } catch (Exception e) { throw new RuntimeException(e); } return 0d;"},
         {"sun.misc.Unsafe",         "sun.misc.Unsafe.getUnsafe(); return 0d;"},
-        {"",                        "try { Class.forName(\"sun.misc.Unsafe\"); } catch (Exception e) { throw new RuntimeException(e); } return 0d;"},
         {"java.nio.file.FileSystems", "try {" +
                                       "     java.nio.file.FileSystems.getDefault(); return 0d;" +
                                       "} catch (Exception t) {" +

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/db/DirectoriesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DirectoriesTest.java b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
index fa23560..7629a54 100644
--- a/test/unit/org/apache/cassandra/db/DirectoriesTest.java
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@ -78,7 +78,7 @@ public class DirectoriesTest
                                  .build());
         }
 
-        tempDataDir = File.createTempFile("cassandra", "unittest");
+        tempDataDir = FileUtils.createTempFile("cassandra", "unittest");
         tempDataDir.delete(); // hack to create a temp dir
         tempDataDir.mkdir();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/db/MmapFileTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/MmapFileTest.java b/test/unit/org/apache/cassandra/db/MmapFileTest.java
index 0c67ff7..71a218e 100644
--- a/test/unit/org/apache/cassandra/db/MmapFileTest.java
+++ b/test/unit/org/apache/cassandra/db/MmapFileTest.java
@@ -29,7 +29,7 @@ import javax.management.ObjectName;
 import org.junit.Assert;
 import org.junit.Test;
 
-import sun.nio.ch.DirectBuffer;
+import org.apache.cassandra.io.util.FileUtils;
 
 public class MmapFileTest
 {
@@ -48,9 +48,9 @@ public class MmapFileTest
         Assert.assertEquals("# of mapped buffers should be 0", Long.valueOf(0L), mmapCount);
         Assert.assertEquals("amount of mapped memory should be 0", Long.valueOf(0L), mmapMemoryUsed);
 
-        File f1 = File.createTempFile("MmapFileTest1", ".bin");
-        File f2 = File.createTempFile("MmapFileTest2", ".bin");
-        File f3 = File.createTempFile("MmapFileTest2", ".bin");
+        File f1 = FileUtils.createTempFile("MmapFileTest1", ".bin");
+        File f2 = FileUtils.createTempFile("MmapFileTest2", ".bin");
+        File f3 = FileUtils.createTempFile("MmapFileTest2", ".bin");
 
         try
         {
@@ -87,8 +87,8 @@ public class MmapFileTest
                 buffer.putInt(42);
                 buffer.putInt(42);
                 buffer.putInt(42);
-
-                ((DirectBuffer) buffer).cleaner().clean();
+                
+                FileUtils.clean(buffer);
             }
 
             mmapCount = (Long) mbs.getAttribute(bpmName, "Count");
@@ -115,7 +115,7 @@ public class MmapFileTest
                 buffer.putInt(42);
                 buffer.putInt(42);
 
-                ((DirectBuffer) buffer).cleaner().clean();
+                FileUtils.clean(buffer);
             }
 
             mmapCount = (Long) mbs.getAttribute(bpmName, "Count");
@@ -140,7 +140,7 @@ public class MmapFileTest
                 buffer.putInt(42);
                 buffer.putInt(42);
 
-                ((DirectBuffer) buffer).cleaner().clean();
+                FileUtils.clean(buffer);
             }
 
             mmapCount = (Long) mbs.getAttribute(bpmName, "Count");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/db/RowIndexEntryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowIndexEntryTest.java b/test/unit/org/apache/cassandra/db/RowIndexEntryTest.java
index d1c4527..c52fd3d 100644
--- a/test/unit/org/apache/cassandra/db/RowIndexEntryTest.java
+++ b/test/unit/org/apache/cassandra/db/RowIndexEntryTest.java
@@ -165,12 +165,12 @@ public class RowIndexEntryTest extends CQLTester
         DoubleSerializer() throws IOException
         {
             SequentialWriterOption option = SequentialWriterOption.newBuilder().bufferSize(1024).build();
-            File f = File.createTempFile("RowIndexEntryTest-", "db");
+            File f = FileUtils.createTempFile("RowIndexEntryTest-", "db");
             dataWriterNew = new SequentialWriter(f, option);
             columnIndex = new org.apache.cassandra.db.ColumnIndex(header, dataWriterNew, version, Collections.emptyList(),
                                                                   rieSerializer.indexInfoSerializer());
 
-            f = File.createTempFile("RowIndexEntryTest-", "db");
+            f = FileUtils.createTempFile("RowIndexEntryTest-", "db");
             dataWriterOld = new SequentialWriter(f, option);
         }
 
@@ -421,7 +421,7 @@ public class RowIndexEntryTest extends CQLTester
 
         ImmutableBTreePartition partition = Util.getOnlyPartitionUnfiltered(Util.cmd(cfs).build());
 
-        File tempFile = File.createTempFile("row_index_entry_test", null);
+        File tempFile = FileUtils.createTempFile("row_index_entry_test", null);
         tempFile.deleteOnExit();
         SequentialWriter writer = new SequentialWriter(tempFile);
         ColumnIndex columnIndex = RowIndexEntryTest.ColumnIndex.writeAndBuildIndex(partition.unfilteredIterator(), writer, header, Collections.emptySet(), BigFormat.latestVersion);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/db/ScrubTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ScrubTest.java b/test/unit/org/apache/cassandra/db/ScrubTest.java
index 5513d2a..36af54f 100644
--- a/test/unit/org/apache/cassandra/db/ScrubTest.java
+++ b/test/unit/org/apache/cassandra/db/ScrubTest.java
@@ -318,7 +318,7 @@ public class ScrubTest
         DatabaseDescriptor.setPartitionerUnsafe(new ByteOrderedPartitioner());
 
         // Create out-of-order SSTable
-        File tempDir = File.createTempFile("ScrubTest.testScrubOutOfOrder", "").getParentFile();
+        File tempDir = FileUtils.createTempFile("ScrubTest.testScrubOutOfOrder", "").getParentFile();
         // create ks/cf directory
         File tempDataDir = new File(tempDir, String.join(File.separator, KEYSPACE, CF3));
         tempDataDir.mkdirs();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
index fb7dec3..e1bd96c 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
@@ -38,6 +38,7 @@ import org.junit.runners.Parameterized.Parameters;
 
 import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.Util;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.schema.TableId;
 import org.apache.cassandra.schema.TableMetadata;
 import org.apache.cassandra.config.DatabaseDescriptor;
@@ -500,9 +501,9 @@ public abstract class CommitLogTest
         return Collections.singletonMap(EncryptionContext.ENCRYPTION_IV, Hex.bytesToHex(buf));
     }
 
-    protected File tmpFile(int version) throws IOException
+    protected File tmpFile(int version)
     {
-        File logFile = File.createTempFile("CommitLog-" + version + "-", ".log");
+        File logFile = FileUtils.createTempFile("CommitLog-" + version + "-", ".log");
         assert logFile.length() == 0;
         return logFile;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/db/commitlog/SegmentReaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/commitlog/SegmentReaderTest.java b/test/unit/org/apache/cassandra/db/commitlog/SegmentReaderTest.java
index d9d5e4c..47e1afa 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/SegmentReaderTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/SegmentReaderTest.java
@@ -42,6 +42,7 @@ import org.apache.cassandra.io.compress.ICompressor;
 import org.apache.cassandra.io.compress.LZ4Compressor;
 import org.apache.cassandra.io.compress.SnappyCompressor;
 import org.apache.cassandra.io.util.FileDataInput;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.RandomAccessReader;
 import org.apache.cassandra.security.CipherFactory;
 import org.apache.cassandra.security.EncryptionUtils;
@@ -93,7 +94,7 @@ public class SegmentReaderTest
         compressor.compress(plainTextBuffer, compBuffer);
         compBuffer.flip();
 
-        File compressedFile = File.createTempFile("compressed-segment-", ".log");
+        File compressedFile = FileUtils.createTempFile("compressed-segment-", ".log");
         compressedFile.deleteOnExit();
         FileOutputStream fos = new FileOutputStream(compressedFile);
         fos.getChannel().write(compBuffer);
@@ -180,7 +181,7 @@ public class SegmentReaderTest
 
         ByteBuffer compressedBuffer = EncryptionUtils.compress(plainTextBuffer, null, true, context.getCompressor());
         Cipher cipher = cipherFactory.getEncryptor(context.getTransparentDataEncryptionOptions().cipher, context.getTransparentDataEncryptionOptions().key_alias);
-        File encryptedFile = File.createTempFile("encrypted-segment-", ".log");
+        File encryptedFile = FileUtils.createTempFile("encrypted-segment-", ".log");
         encryptedFile.deleteOnExit();
         FileChannel channel = new RandomAccessFile(encryptedFile, "rw").getChannel();
         channel.write(ByteBufferUtil.bytes(plainTextLength));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/hints/ChecksummedDataInputTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/hints/ChecksummedDataInputTest.java b/test/unit/org/apache/cassandra/hints/ChecksummedDataInputTest.java
index 7325e74..9f4cdfb 100644
--- a/test/unit/org/apache/cassandra/hints/ChecksummedDataInputTest.java
+++ b/test/unit/org/apache/cassandra/hints/ChecksummedDataInputTest.java
@@ -29,6 +29,7 @@ import org.junit.Test;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.io.util.DataOutputBuffer;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.RandomAccessReader;
 import org.apache.cassandra.io.util.SequentialWriter;
 import org.apache.cassandra.utils.ByteBufferUtil;
@@ -83,7 +84,7 @@ public class ChecksummedDataInputTest
         FBUtilities.updateChecksum(crc, buffer);
 
         // save the buffer to file to create a RAR
-        File file = File.createTempFile("testReadMethods", "1");
+        File file = FileUtils.createTempFile("testReadMethods", "1");
         file.deleteOnExit();
         try (SequentialWriter writer = new SequentialWriter(file))
         {
@@ -158,7 +159,7 @@ public class ChecksummedDataInputTest
         }
 
         // save the buffer to file to create a RAR
-        File file = File.createTempFile("testResetCrc", "1");
+        File file = FileUtils.createTempFile("testResetCrc", "1");
         file.deleteOnExit();
         try (SequentialWriter writer = new SequentialWriter(file))
         {
@@ -214,7 +215,7 @@ public class ChecksummedDataInputTest
         }
 
         // save the buffer to file to create a RAR
-        File file = File.createTempFile("testFailedCrc", "1");
+        File file = FileUtils.createTempFile("testFailedCrc", "1");
         file.deleteOnExit();
         try (SequentialWriter writer = new SequentialWriter(file))
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/index/sasi/disk/OnDiskIndexTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/index/sasi/disk/OnDiskIndexTest.java b/test/unit/org/apache/cassandra/index/sasi/disk/OnDiskIndexTest.java
index c0e6587..1afb7b4 100644
--- a/test/unit/org/apache/cassandra/index/sasi/disk/OnDiskIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/sasi/disk/OnDiskIndexTest.java
@@ -38,6 +38,7 @@ import org.apache.cassandra.db.marshal.Int32Type;
 import org.apache.cassandra.db.marshal.LongType;
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.io.util.DataOutputBuffer;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.MurmurHash;
 import org.apache.cassandra.utils.Pair;
 
@@ -82,7 +83,7 @@ public class OnDiskIndexTest
         for (Map.Entry<ByteBuffer, TokenTreeBuilder> e : data.entrySet())
             addAll(builder, e.getKey(), e.getValue());
 
-        File index = File.createTempFile("on-disk-sa-string", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-string", "db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -138,7 +139,7 @@ public class OnDiskIndexTest
         for (Map.Entry<ByteBuffer, TokenTreeBuilder> e : data.entrySet())
             addAll(builder, e.getKey(), e.getValue());
 
-        File index = File.createTempFile("on-disk-sa-int", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-int", "db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -226,7 +227,7 @@ public class OnDiskIndexTest
         for (int i = 0; i < iterCheckNums.size(); i++)
             iterTest.add(iterCheckNums.get(i), keyAt((long) i), i);
 
-        File iterIndex = File.createTempFile("sa-iter", ".db");
+        File iterIndex = FileUtils.createTempFile("sa-iter", ".db");
         iterIndex.deleteOnExit();
 
         iterTest.finish(iterIndex);
@@ -278,7 +279,7 @@ public class OnDiskIndexTest
                 addAll(this, UTF8Type.instance.decompose("Pavel"), keyBuilder(9L, 10L));
         }};
 
-        File index = File.createTempFile("on-disk-sa-multi-suffix-match", ".db");
+        File index = FileUtils.createTempFile("on-disk-sa-multi-suffix-match", ".db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -317,7 +318,7 @@ public class OnDiskIndexTest
         for (long i = 0; i < numIterations; i++)
             builder.add(LongType.instance.decompose(start + i), keyAt(i), i);
 
-        File index = File.createTempFile("on-disk-sa-sparse", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-sparse", "db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -375,7 +376,7 @@ public class OnDiskIndexTest
         for (Map.Entry<ByteBuffer, TokenTreeBuilder> e : data.entrySet())
             addAll(builder, e.getKey(), e.getValue());
 
-        File index = File.createTempFile("on-disk-sa-except-test", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-except-test", "db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -419,7 +420,7 @@ public class OnDiskIndexTest
         for (Map.Entry<ByteBuffer, TokenTreeBuilder> e : data.entrySet())
             addAll(builder, e.getKey(), e.getValue());
 
-        File index = File.createTempFile("on-disk-sa-except-int-test", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-except-int-test", "db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -443,7 +444,7 @@ public class OnDiskIndexTest
         for (long i = lower; i <= upper; i++)
             builder.add(LongType.instance.decompose(i), keyAt(i), i);
 
-        File index = File.createTempFile("on-disk-sa-except-long-ranges", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-except-long-ranges", "db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -535,8 +536,8 @@ public class OnDiskIndexTest
             builder2.add(e.getKey(), key, position);
         }
 
-        File index1 = File.createTempFile("on-disk-sa-int", "db");
-        File index2 = File.createTempFile("on-disk-sa-int2", "db");
+        File index1 = FileUtils.createTempFile("on-disk-sa-int", "db");
+        File index2 = FileUtils.createTempFile("on-disk-sa-int2", "db");
         index1.deleteOnExit();
         index2.deleteOnExit();
 
@@ -569,7 +570,7 @@ public class OnDiskIndexTest
         for (Map.Entry<ByteBuffer, TokenTreeBuilder> entry : terms.entrySet())
             addAll(builder, entry.getKey(), entry.getValue());
 
-        File index = File.createTempFile("on-disk-sa-try-superblocks", ".db");
+        File index = FileUtils.createTempFile("on-disk-sa-try-superblocks", ".db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -597,7 +598,7 @@ public class OnDiskIndexTest
         for (long i = 0; i < 100000; i++)
             builder.add(LongType.instance.decompose(i), keyAt(i), i);
 
-        File index = File.createTempFile("on-disk-sa-multi-superblock-match", ".db");
+        File index = FileUtils.createTempFile("on-disk-sa-multi-superblock-match", ".db");
         index.deleteOnExit();
 
         builder.finish(index);
@@ -652,10 +653,10 @@ public class OnDiskIndexTest
             putAll(offsets, keyBuilder(100L + i));
         }
 
-        File indexA = File.createTempFile("on-disk-sa-partition-a", ".db");
+        File indexA = FileUtils.createTempFile("on-disk-sa-partition-a", ".db");
         indexA.deleteOnExit();
 
-        File indexB = File.createTempFile("on-disk-sa-partition-b", ".db");
+        File indexB = FileUtils.createTempFile("on-disk-sa-partition-b", ".db");
         indexB.deleteOnExit();
 
         builderA.finish(indexA);
@@ -682,7 +683,7 @@ public class OnDiskIndexTest
 
         Assert.assertEquals(actual, expected);
 
-        File indexC = File.createTempFile("on-disk-sa-partition-final", ".db");
+        File indexC = FileUtils.createTempFile("on-disk-sa-partition-final", ".db");
         indexC.deleteOnExit();
 
         OnDiskIndexBuilder combined = new OnDiskIndexBuilder(UTF8Type.instance, LongType.instance, OnDiskIndexBuilder.Mode.PREFIX);
@@ -733,7 +734,7 @@ public class OnDiskIndexTest
         for (Map.Entry<ByteBuffer, TokenTreeBuilder> e : data.entrySet())
             addAll(builder, e.getKey(), e.getValue());
 
-        File index = File.createTempFile("on-disk-sa-prefix-contains-search", "db");
+        File index = FileUtils.createTempFile("on-disk-sa-prefix-contains-search", "db");
         index.deleteOnExit();
 
         builder.finish(index);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/index/sasi/disk/TokenTreeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/index/sasi/disk/TokenTreeTest.java b/test/unit/org/apache/cassandra/index/sasi/disk/TokenTreeTest.java
index 597993a..72b9e0d 100644
--- a/test/unit/org/apache/cassandra/index/sasi/disk/TokenTreeTest.java
+++ b/test/unit/org/apache/cassandra/index/sasi/disk/TokenTreeTest.java
@@ -116,7 +116,7 @@ public class TokenTreeTest
     public void testSerializedSize(final TokenTreeBuilder builder) throws Exception
     {
         builder.finish();
-        final File treeFile = File.createTempFile("token-tree-size-test", "tt");
+        final File treeFile = FileUtils.createTempFile("token-tree-size-test", "tt");
         treeFile.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT))
@@ -148,7 +148,7 @@ public class TokenTreeTest
     {
 
         builder.finish();
-        final File treeFile = File.createTempFile("token-tree-iterate-test1", "tt");
+        final File treeFile = FileUtils.createTempFile("token-tree-iterate-test1", "tt");
         treeFile.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT))
@@ -227,7 +227,7 @@ public class TokenTreeTest
     public void buildSerializeIterateAndSkip(TokenTreeBuilder builder, SortedMap<Long, LongSet> tokens) throws Exception
     {
         builder.finish();
-        final File treeFile = File.createTempFile("token-tree-iterate-test2", "tt");
+        final File treeFile = FileUtils.createTempFile("token-tree-iterate-test2", "tt");
         treeFile.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT))
@@ -286,7 +286,7 @@ public class TokenTreeTest
     public void skipPastEnd(TokenTreeBuilder builder, SortedMap<Long, LongSet> tokens) throws Exception
     {
         builder.finish();
-        final File treeFile = File.createTempFile("token-tree-skip-past-test", "tt");
+        final File treeFile = FileUtils.createTempFile("token-tree-skip-past-test", "tt");
         treeFile.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT))
@@ -430,7 +430,7 @@ public class TokenTreeTest
     private static TokenTree buildTree(TokenTreeBuilder builder) throws Exception
     {
         builder.finish();
-        final File treeFile = File.createTempFile("token-tree-", "db");
+        final File treeFile = FileUtils.createTempFile("token-tree-", "db");
         treeFile.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT))
@@ -648,7 +648,7 @@ public class TokenTreeTest
 
         final TokenTreeBuilder builder = isStatic ? new StaticTokenTreeBuilder(new FakeCombinedTerm(toks)) : new DynamicTokenTreeBuilder(toks);
         builder.finish();
-        final File treeFile = File.createTempFile("token-tree-get-test", "tt");
+        final File treeFile = FileUtils.createTempFile("token-tree-get-test", "tt");
         treeFile.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT))

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/index/sasi/utils/MappedBufferTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/index/sasi/utils/MappedBufferTest.java b/test/unit/org/apache/cassandra/index/sasi/utils/MappedBufferTest.java
index 7ffebf1..e55f6ba 100644
--- a/test/unit/org/apache/cassandra/index/sasi/utils/MappedBufferTest.java
+++ b/test/unit/org/apache/cassandra/index/sasi/utils/MappedBufferTest.java
@@ -449,7 +449,7 @@ public class MappedBufferTest
     @Test
     public void testOpenWithoutPageBits() throws IOException
     {
-        File tmp = File.createTempFile("mapped-buffer", "tmp");
+        File tmp = FileUtils.createTempFile("mapped-buffer", "tmp");
         tmp.deleteOnExit();
 
         RandomAccessFile file = new RandomAccessFile(tmp, "rw");
@@ -490,7 +490,7 @@ public class MappedBufferTest
 
     private MappedBuffer createTestFile(long numCount, int typeSize, int numPageBits, int padding) throws IOException
     {
-        final File testFile = File.createTempFile("mapped-buffer-test", "db");
+        final File testFile = FileUtils.createTempFile("mapped-buffer-test", "db");
         testFile.deleteOnExit();
 
         RandomAccessFile file = new RandomAccessFile(testFile, "rw");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/compress/CompressedRandomAccessReaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/compress/CompressedRandomAccessReaderTest.java b/test/unit/org/apache/cassandra/io/compress/CompressedRandomAccessReaderTest.java
index 06dd278..5153310 100644
--- a/test/unit/org/apache/cassandra/io/compress/CompressedRandomAccessReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/compress/CompressedRandomAccessReaderTest.java
@@ -54,46 +54,46 @@ public class CompressedRandomAccessReaderTest
     public void testResetAndTruncate() throws IOException
     {
         // test reset in current buffer or previous one
-        testResetAndTruncate(File.createTempFile("normal", "1"), false, false, 10, 0);
-        testResetAndTruncate(File.createTempFile("normal", "2"), false, false, CompressionParams.DEFAULT_CHUNK_LENGTH, 0);
+        testResetAndTruncate(FileUtils.createTempFile("normal", "1"), false, false, 10, 0);
+        testResetAndTruncate(FileUtils.createTempFile("normal", "2"), false, false, CompressionParams.DEFAULT_CHUNK_LENGTH, 0);
     }
 
     @Test
     public void testResetAndTruncateCompressed() throws IOException
     {
         // test reset in current buffer or previous one
-        testResetAndTruncate(File.createTempFile("compressed", "1"), true, false, 10, 0);
-        testResetAndTruncate(File.createTempFile("compressed", "2"), true, false, CompressionParams.DEFAULT_CHUNK_LENGTH, 0);
+        testResetAndTruncate(FileUtils.createTempFile("compressed", "1"), true, false, 10, 0);
+        testResetAndTruncate(FileUtils.createTempFile("compressed", "2"), true, false, CompressionParams.DEFAULT_CHUNK_LENGTH, 0);
     }
 
     @Test
     public void testResetAndTruncateCompressedMmap() throws IOException
     {
         // test reset in current buffer or previous one
-        testResetAndTruncate(File.createTempFile("compressed_mmap", "1"), true, true, 10, 0);
-        testResetAndTruncate(File.createTempFile("compressed_mmap", "2"), true, true, CompressionParams.DEFAULT_CHUNK_LENGTH, 0);
+        testResetAndTruncate(FileUtils.createTempFile("compressed_mmap", "1"), true, true, 10, 0);
+        testResetAndTruncate(FileUtils.createTempFile("compressed_mmap", "2"), true, true, CompressionParams.DEFAULT_CHUNK_LENGTH, 0);
     }
 
     @Test
     public void testResetAndTruncateCompressedUncompressedChunks() throws IOException
     {
         // test reset in current buffer or previous one
-        testResetAndTruncate(File.createTempFile("compressed_uchunks", "1"), true, false, 10, 3);
-        testResetAndTruncate(File.createTempFile("compressed_uchunks", "2"), true, false, CompressionParams.DEFAULT_CHUNK_LENGTH, 3);
+        testResetAndTruncate(FileUtils.createTempFile("compressed_uchunks", "1"), true, false, 10, 3);
+        testResetAndTruncate(FileUtils.createTempFile("compressed_uchunks", "2"), true, false, CompressionParams.DEFAULT_CHUNK_LENGTH, 3);
     }
 
     @Test
     public void testResetAndTruncateCompressedUncompressedChunksMmap() throws IOException
     {
         // test reset in current buffer or previous one
-        testResetAndTruncate(File.createTempFile("compressed_uchunks_mmap", "1"), true, true, 10, 3);
-        testResetAndTruncate(File.createTempFile("compressed_uchunks_mmap", "2"), true, true, CompressionParams.DEFAULT_CHUNK_LENGTH, 3);
+        testResetAndTruncate(FileUtils.createTempFile("compressed_uchunks_mmap", "1"), true, true, 10, 3);
+        testResetAndTruncate(FileUtils.createTempFile("compressed_uchunks_mmap", "2"), true, true, CompressionParams.DEFAULT_CHUNK_LENGTH, 3);
     }
 
     @Test
     public void test6791() throws IOException, ConfigurationException
     {
-        File f = File.createTempFile("compressed6791_", "3");
+        File f = FileUtils.createTempFile("compressed6791_", "3");
         String filename = f.getAbsolutePath();
         MetadataCollector sstableMetadataCollector = new MetadataCollector(new ClusteringComparator(BytesType.instance));
         try(CompressedSequentialWriter writer = new CompressedSequentialWriter(f, filename + ".metadata",

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java b/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
index e07381a..0c0a33f 100644
--- a/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
+++ b/test/unit/org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java
@@ -56,22 +56,22 @@ public class CompressedSequentialWriterTest extends SequentialWriterTest
     private void runTests(String testName) throws IOException
     {
         // Test small < 1 chunk data set
-        testWrite(File.createTempFile(testName + "_small", "1"), 25, false);
+        testWrite(FileUtils.createTempFile(testName + "_small", "1"), 25, false);
 
         // Test to confirm pipeline w/chunk-aligned data writes works
-        testWrite(File.createTempFile(testName + "_chunkAligned", "1"), CompressionParams.DEFAULT_CHUNK_LENGTH, false);
+        testWrite(FileUtils.createTempFile(testName + "_chunkAligned", "1"), CompressionParams.DEFAULT_CHUNK_LENGTH, false);
 
         // Test to confirm pipeline on non-chunk boundaries works
-        testWrite(File.createTempFile(testName + "_large", "1"), CompressionParams.DEFAULT_CHUNK_LENGTH * 3 + 100, false);
+        testWrite(FileUtils.createTempFile(testName + "_large", "1"), CompressionParams.DEFAULT_CHUNK_LENGTH * 3 + 100, false);
 
         // Test small < 1 chunk data set
-        testWrite(File.createTempFile(testName + "_small", "2"), 25, true);
+        testWrite(FileUtils.createTempFile(testName + "_small", "2"), 25, true);
 
         // Test to confirm pipeline w/chunk-aligned data writes works
-        testWrite(File.createTempFile(testName + "_chunkAligned", "2"), CompressionParams.DEFAULT_CHUNK_LENGTH, true);
+        testWrite(FileUtils.createTempFile(testName + "_chunkAligned", "2"), CompressionParams.DEFAULT_CHUNK_LENGTH, true);
 
         // Test to confirm pipeline on non-chunk boundaries works
-        testWrite(File.createTempFile(testName + "_large", "2"), CompressionParams.DEFAULT_CHUNK_LENGTH * 3 + 100, true);
+        testWrite(FileUtils.createTempFile(testName + "_large", "2"), CompressionParams.DEFAULT_CHUNK_LENGTH * 3 + 100, true);
 
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/compress/CompressorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/compress/CompressorTest.java b/test/unit/org/apache/cassandra/io/compress/CompressorTest.java
index 617e04e..1d37ad4 100644
--- a/test/unit/org/apache/cassandra/io/compress/CompressorTest.java
+++ b/test/unit/org/apache/cassandra/io/compress/CompressorTest.java
@@ -31,6 +31,7 @@ import static org.junit.Assert.*;
 import org.junit.Assert;
 import org.junit.Test;
 
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.RandomAccessReader;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
@@ -121,7 +122,7 @@ public class CompressorTest
         src.flip();
 
         // create a temp file
-        File temp = File.createTempFile("tempfile", ".tmp");
+        File temp = FileUtils.createTempFile("tempfile", ".tmp");
         temp.deleteOnExit();
 
         // Prepend some random bytes to the output and compress

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
index ef1b785..5671e22 100644
--- a/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/DescriptorTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
 
 import org.apache.cassandra.db.Directories;
 import org.apache.cassandra.io.sstable.format.SSTableFormat;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.Pair;
 
@@ -42,7 +43,7 @@ public class DescriptorTest
     public DescriptorTest() throws IOException
     {
         // create CF directories, one without CFID and one with it
-        tempDataDir = File.createTempFile("DescriptorTest", null).getParentFile();
+        tempDataDir = FileUtils.createTempFile("DescriptorTest", null).getParentFile();
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java b/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
index d3eef01..441a3b9 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.*;
 
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.schema.TableMetadata;
 import org.apache.cassandra.schema.Schema;
 import org.apache.cassandra.db.*;
@@ -71,7 +72,7 @@ public class SSTableUtils
 
     public static File tempSSTableFile(String keyspaceName, String cfname, int generation) throws IOException
     {
-        File tempdir = File.createTempFile(keyspaceName, cfname);
+        File tempdir = FileUtils.createTempFile(keyspaceName, cfname);
         if(!tempdir.delete() || !tempdir.mkdir())
             throw new IOException("Temporary directory creation failed.");
         tempdir.deleteOnExit();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/sstable/metadata/MetadataSerializerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/metadata/MetadataSerializerTest.java b/test/unit/org/apache/cassandra/io/sstable/metadata/MetadataSerializerTest.java
index 7d8150c..8ab1511 100644
--- a/test/unit/org/apache/cassandra/io/sstable/metadata/MetadataSerializerTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/metadata/MetadataSerializerTest.java
@@ -28,6 +28,7 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 
 import org.apache.cassandra.SchemaLoader;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.schema.TableMetadata;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.SerializationHeader;
@@ -79,7 +80,7 @@ public class MetadataSerializerTest
             throws IOException
     {
         // Serialize to tmp file
-        File statsFile = File.createTempFile(Component.STATS.name, null);
+        File statsFile = FileUtils.createTempFile(Component.STATS.name, null);
         try (DataOutputStreamPlus out = new BufferedDataOutputStreamPlus(new FileOutputStream(statsFile)))
         {
             serializer.serialize(metadata, out, version);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java b/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
index 2386160..764190c 100644
--- a/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
+++ b/test/unit/org/apache/cassandra/io/util/BufferedRandomAccessFileTest.java
@@ -143,7 +143,7 @@ public class BufferedRandomAccessFileTest
     @Test
     public void testReadAndWriteOnCapacity() throws IOException
     {
-        File tmpFile = File.createTempFile("readtest", "bin");
+        File tmpFile = FileUtils.createTempFile("readtest", "bin");
         try (SequentialWriter w = new SequentialWriter(tmpFile))
         {
             // Fully write the file and sync..
@@ -170,7 +170,7 @@ public class BufferedRandomAccessFileTest
     @Test
     public void testLength() throws IOException
     {
-        File tmpFile = File.createTempFile("lengthtest", "bin");
+        File tmpFile = FileUtils.createTempFile("lengthtest", "bin");
         try (SequentialWriter w = new SequentialWriter(tmpFile))
         {
             assertEquals(0, w.length());
@@ -423,7 +423,7 @@ public class BufferedRandomAccessFileTest
     @Test
     public void testBytesPastMark() throws IOException
     {
-        File tmpFile = File.createTempFile("overflowtest", "bin");
+        File tmpFile = FileUtils.createTempFile("overflowtest", "bin");
         tmpFile.deleteOnExit();
 
         // Create the BRAF by filename instead of by file.
@@ -588,7 +588,7 @@ public class BufferedRandomAccessFileTest
     @Test (expected=IllegalArgumentException.class)
     public void testSetNegativeLength() throws IOException, IllegalArgumentException
     {
-        File tmpFile = File.createTempFile("set_negative_length", "bin");
+        File tmpFile = FileUtils.createTempFile("set_negative_length", "bin");
         try (SequentialWriter file = new SequentialWriter(tmpFile))
         {
             file.truncate(-8L);
@@ -597,7 +597,7 @@ public class BufferedRandomAccessFileTest
 
     private SequentialWriter createTempFile(String name) throws IOException
     {
-        File tempFile = File.createTempFile(name, null);
+        File tempFile = FileUtils.createTempFile(name, null);
         tempFile.deleteOnExit();
 
         return new SequentialWriter(tempFile);
@@ -605,7 +605,7 @@ public class BufferedRandomAccessFileTest
 
     private File writeTemporaryFile(byte[] data) throws IOException
     {
-        File f = File.createTempFile("BRAFTestFile", null);
+        File f = FileUtils.createTempFile("BRAFTestFile", null);
         f.deleteOnExit();
         FileOutputStream fout = new FileOutputStream(f);
         fout.write(data);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/util/ChecksummedRandomAccessReaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/ChecksummedRandomAccessReaderTest.java b/test/unit/org/apache/cassandra/io/util/ChecksummedRandomAccessReaderTest.java
index 545c3e3..4963712 100644
--- a/test/unit/org/apache/cassandra/io/util/ChecksummedRandomAccessReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/util/ChecksummedRandomAccessReaderTest.java
@@ -42,8 +42,8 @@ public class ChecksummedRandomAccessReaderTest
     @Test
     public void readFully() throws IOException
     {
-        final File data = File.createTempFile("testReadFully", "data");
-        final File crc = File.createTempFile("testReadFully", "crc");
+        final File data = FileUtils.createTempFile("testReadFully", "data");
+        final File crc = FileUtils.createTempFile("testReadFully", "crc");
 
         final byte[] expected = new byte[70 * 1024];   // bit more than crc chunk size, so we can test rebuffering.
         ThreadLocalRandom.current().nextBytes(expected);
@@ -70,8 +70,8 @@ public class ChecksummedRandomAccessReaderTest
     @Test
     public void seek() throws IOException
     {
-        final File data = File.createTempFile("testSeek", "data");
-        final File crc = File.createTempFile("testSeek", "crc");
+        final File data = FileUtils.createTempFile("testSeek", "data");
+        final File crc = FileUtils.createTempFile("testSeek", "crc");
 
         final byte[] dataBytes = new byte[70 * 1024];   // bit more than crc chunk size
         ThreadLocalRandom.current().nextBytes(dataBytes);
@@ -104,8 +104,8 @@ public class ChecksummedRandomAccessReaderTest
     @Test(expected = CorruptFileException.class)
     public void corruptionDetection() throws IOException
     {
-        final File data = File.createTempFile("corruptionDetection", "data");
-        final File crc = File.createTempFile("corruptionDetection", "crc");
+        final File data = FileUtils.createTempFile("corruptionDetection", "data");
+        final File crc = FileUtils.createTempFile("corruptionDetection", "crc");
 
         final byte[] expected = new byte[5 * 1024];
         Arrays.fill(expected, (byte) 0);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/util/MmappedRegionsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/MmappedRegionsTest.java b/test/unit/org/apache/cassandra/io/util/MmappedRegionsTest.java
index cffb49d..2814bab 100644
--- a/test/unit/org/apache/cassandra/io/util/MmappedRegionsTest.java
+++ b/test/unit/org/apache/cassandra/io/util/MmappedRegionsTest.java
@@ -67,7 +67,7 @@ public class MmappedRegionsTest
 
     private static File writeFile(String fileName, ByteBuffer buffer) throws IOException
     {
-        File ret = File.createTempFile(fileName, "1");
+        File ret = FileUtils.createTempFile(fileName, "1");
         ret.deleteOnExit();
 
         try (SequentialWriter writer = new SequentialWriter(ret))
@@ -298,10 +298,10 @@ public class MmappedRegionsTest
         MmappedRegions.MAX_SEGMENT_SIZE = 1024;
 
         ByteBuffer buffer = allocateBuffer(128 * 1024);
-        File f = File.createTempFile("testMapForCompressionMetadata", "1");
+        File f = FileUtils.createTempFile("testMapForCompressionMetadata", "1");
         f.deleteOnExit();
 
-        File cf = File.createTempFile(f.getName() + ".metadata", "1");
+        File cf = FileUtils.createTempFile(f.getName() + ".metadata", "1");
         cf.deleteOnExit();
 
         MetadataCollector sstableMetadataCollector = new MetadataCollector(new ClusteringComparator(BytesType.instance));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/util/NIODataInputStreamTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/NIODataInputStreamTest.java b/test/unit/org/apache/cassandra/io/util/NIODataInputStreamTest.java
index 7b91ccb..7feeb43 100644
--- a/test/unit/org/apache/cassandra/io/util/NIODataInputStreamTest.java
+++ b/test/unit/org/apache/cassandra/io/util/NIODataInputStreamTest.java
@@ -222,7 +222,7 @@ public class NIODataInputStreamTest
         is.read(new byte[10]);
         assertEquals(8190 - 10 - 4096, is.available());
 
-        File f = File.createTempFile("foo", "bar");
+        File f = FileUtils.createTempFile("foo", "bar");
         RandomAccessFile fos = new RandomAccessFile(f, "rw");
         fos.write(new byte[10]);
         fos.seek(0);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/util/RandomAccessReaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/RandomAccessReaderTest.java b/test/unit/org/apache/cassandra/io/util/RandomAccessReaderTest.java
index 3a34855..d1dc35d 100644
--- a/test/unit/org/apache/cassandra/io/util/RandomAccessReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/util/RandomAccessReaderTest.java
@@ -266,7 +266,7 @@ public class RandomAccessReaderTest
 
     private static File writeFile(Parameters params) throws IOException
     {
-        final File f = File.createTempFile("testReadFully", "1");
+        final File f = FileUtils.createTempFile("testReadFully", "1");
         f.deleteOnExit();
 
         try(SequentialWriter writer = new SequentialWriter(f))
@@ -319,7 +319,7 @@ public class RandomAccessReaderTest
     @Test
     public void testReadBytes() throws IOException
     {
-        File f = File.createTempFile("testReadBytes", "1");
+        File f = FileUtils.createTempFile("testReadBytes", "1");
         final String expected = "The quick brown fox jumps over the lazy dog";
 
         try(SequentialWriter writer = new SequentialWriter(f))
@@ -348,7 +348,7 @@ public class RandomAccessReaderTest
     @Test
     public void testReset() throws IOException
     {
-        File f = File.createTempFile("testMark", "1");
+        File f = FileUtils.createTempFile("testMark", "1");
         final String expected = "The quick brown fox jumps over the lazy dog";
         final int numIterations = 10;
 
@@ -424,7 +424,7 @@ public class RandomAccessReaderTest
 
     private static void testSeek(int numThreads) throws IOException, InterruptedException
     {
-        final File f = File.createTempFile("testMark", "1");
+        final File f = FileUtils.createTempFile("testMark", "1");
         final byte[] expected = new byte[1 << 16];
 
         long seed = System.nanoTime();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/io/util/RewindableDataInputStreamPlusTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/util/RewindableDataInputStreamPlusTest.java b/test/unit/org/apache/cassandra/io/util/RewindableDataInputStreamPlusTest.java
index 1803c51..08c9ddf 100644
--- a/test/unit/org/apache/cassandra/io/util/RewindableDataInputStreamPlusTest.java
+++ b/test/unit/org/apache/cassandra/io/util/RewindableDataInputStreamPlusTest.java
@@ -42,7 +42,7 @@ public class RewindableDataInputStreamPlusTest
     @Before
     public void setup() throws Exception
     {
-        this.file = new File(System.getProperty("java.io.tmpdir"), "subdir/test.buffer");
+        this.file = new File(FileUtils.getTempDir(), "subdir/test.buffer");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/net/async/MessageOutHandlerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/net/async/MessageOutHandlerTest.java b/test/unit/org/apache/cassandra/net/async/MessageOutHandlerTest.java
index 86112ae..9aa2625 100644
--- a/test/unit/org/apache/cassandra/net/async/MessageOutHandlerTest.java
+++ b/test/unit/org/apache/cassandra/net/async/MessageOutHandlerTest.java
@@ -19,7 +19,6 @@
 package org.apache.cassandra.net.async;
 
 import java.io.IOException;
-import java.net.InetSocketAddress;
 import java.util.HashMap;
 import java.util.Optional;
 import java.util.UUID;
@@ -31,7 +30,6 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import com.sun.org.apache.bcel.internal.generic.DDIV;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelOutboundHandlerAdapter;
@@ -49,7 +47,6 @@ import org.apache.cassandra.net.MessageOut;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.net.ParameterType;
 import org.apache.cassandra.tracing.Tracing;
-import org.apache.cassandra.utils.UUIDGen;
 
 public class MessageOutHandlerTest
 {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/schema/MockSchema.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/schema/MockSchema.java b/test/unit/org/apache/cassandra/schema/MockSchema.java
index 05de7ac..98bf9ca 100644
--- a/test/unit/org/apache/cassandra/schema/MockSchema.java
+++ b/test/unit/org/apache/cassandra/schema/MockSchema.java
@@ -169,16 +169,9 @@ public class MockSchema
 
     private static File temp(String id)
     {
-        try
-        {
-            File file = File.createTempFile(id, "tmp");
-            file.deleteOnExit();
-            return file;
-        }
-        catch (IOException e)
-        {
-            throw new RuntimeException(e);
-        }
+        File file = FileUtils.createTempFile(id, "tmp");
+        file.deleteOnExit();
+        return file;
     }
 
     public static void cleanup()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/security/EncryptionUtilsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/security/EncryptionUtilsTest.java b/test/unit/org/apache/cassandra/security/EncryptionUtilsTest.java
index 70b327e..0fd46b8 100644
--- a/test/unit/org/apache/cassandra/security/EncryptionUtilsTest.java
+++ b/test/unit/org/apache/cassandra/security/EncryptionUtilsTest.java
@@ -38,6 +38,7 @@ import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.TransparentDataEncryptionOptions;
 import org.apache.cassandra.io.compress.ICompressor;
 import org.apache.cassandra.io.compress.LZ4Compressor;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.RandomAccessReader;
 
 public class EncryptionUtilsTest
@@ -79,7 +80,7 @@ public class EncryptionUtilsTest
         CipherFactory cipherFactory = new CipherFactory(tdeOptions);
         Cipher encryptor = cipherFactory.getEncryptor(tdeOptions.cipher, tdeOptions.key_alias);
 
-        File f = File.createTempFile("commitlog-enc-utils-", ".tmp");
+        File f = FileUtils.createTempFile("commitlog-enc-utils-", ".tmp");
         f.deleteOnExit();
         FileChannel channel = new RandomAccessFile(f, "rw").getChannel();
         EncryptionUtils.encryptAndWrite(ByteBuffer.wrap(buf), channel, true, encryptor);
@@ -108,7 +109,7 @@ public class EncryptionUtilsTest
         // encrypt
         CipherFactory cipherFactory = new CipherFactory(tdeOptions);
         Cipher encryptor = cipherFactory.getEncryptor(tdeOptions.cipher, tdeOptions.key_alias);
-        File f = File.createTempFile("commitlog-enc-utils-", ".tmp");
+        File f = FileUtils.createTempFile("commitlog-enc-utils-", ".tmp");
         f.deleteOnExit();
         FileChannel channel = new RandomAccessFile(f, "rw").getChannel();
         EncryptionUtils.encryptAndWrite(compressedBuffer, channel, true, encryptor);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/streaming/compression/CompressedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/streaming/compression/CompressedInputStreamTest.java b/test/unit/org/apache/cassandra/streaming/compression/CompressedInputStreamTest.java
index dbca906..14321fa 100644
--- a/test/unit/org/apache/cassandra/streaming/compression/CompressedInputStreamTest.java
+++ b/test/unit/org/apache/cassandra/streaming/compression/CompressedInputStreamTest.java
@@ -30,6 +30,7 @@ import org.apache.cassandra.io.compress.CompressedSequentialWriter;
 import org.apache.cassandra.io.compress.CompressionMetadata;
 import org.apache.cassandra.io.sstable.format.SSTableReader;
 import org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus;
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.SequentialWriterOption;
 import org.apache.cassandra.schema.CompressionParams;
 import org.apache.cassandra.io.sstable.Component;
@@ -108,7 +109,7 @@ public class CompressedInputStreamTest
         assert valuesToCheck != null && valuesToCheck.length > 0;
 
         // write compressed data file of longs
-        File parentDir = new File(System.getProperty("java.io.tmpdir"));
+        File parentDir = FileUtils.getTempDir();
         Descriptor desc = new Descriptor(parentDir, "ks", "cf", 1);
         File tmp = new File(desc.filenameFor(Component.DATA));
         MetadataCollector collector = new MetadataCollector(new ClusteringComparator(BytesType.instance));

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java b/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
index 64b0d4f..d564e41 100644
--- a/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
+++ b/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
@@ -36,6 +36,7 @@ import net.openhft.chronicle.queue.ExcerptTailer;
 import net.openhft.chronicle.queue.RollCycles;
 import net.openhft.chronicle.wire.WireOut;
 import org.apache.cassandra.Util;
+import org.apache.cassandra.io.util.FileUtils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -46,7 +47,7 @@ public class BinLogTest
 {
     public static Path tempDir() throws Exception
     {
-        File f = File.createTempFile("foo", "bar");
+        File f = FileUtils.createTempFile("foo", "bar");
         f.delete();
         f.mkdir();
         return Paths.get(f.getPath());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java b/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
index 7ea23eb..0d1f9f6 100644
--- a/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
+++ b/test/unit/org/apache/cassandra/utils/concurrent/RefCountedTest.java
@@ -36,6 +36,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.utils.ObjectSizes;
 import org.apache.cassandra.utils.Pair;
 import org.apache.cassandra.utils.concurrent.Ref.Visitor;
@@ -342,7 +343,7 @@ public class RefCountedTest
         for (int i = 0; i < entryCount; i += 2)
             objects[i] = new Object();
 
-        File f = File.createTempFile("foo", "bar");
+        File f = FileUtils.createTempFile("foo", "bar");
         RefCounted.Tidy tidier = new RefCounted.Tidy() {
             Object ref = objects;
             //Checking we don't get an infinite loop out of traversing file refs

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/cassandra-stress
----------------------------------------------------------------------
diff --git a/tools/bin/cassandra-stress b/tools/bin/cassandra-stress
index 82a3eb5..a5821d3 100755
--- a/tools/bin/cassandra-stress
+++ b/tools/bin/cassandra-stress
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/cassandra-stressd
----------------------------------------------------------------------
diff --git a/tools/bin/cassandra-stressd b/tools/bin/cassandra-stressd
index 48fbef6..83f8006 100755
--- a/tools/bin/cassandra-stressd
+++ b/tools/bin/cassandra-stressd
@@ -33,18 +33,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/cassandra.in.sh
----------------------------------------------------------------------
diff --git a/tools/bin/cassandra.in.sh b/tools/bin/cassandra.in.sh
index 2f0d1ec..869eb22 100644
--- a/tools/bin/cassandra.in.sh
+++ b/tools/bin/cassandra.in.sh
@@ -23,12 +23,18 @@ if [ "x$CASSANDRA_CONF" = "x" ]; then
     CASSANDRA_CONF="$CASSANDRA_HOME/conf"
 fi
 
+# The java classpath (required)
+CLASSPATH="$CASSANDRA_CONF"
+
 # This can be the path to a jar file, or a directory containing the
 # compiled classes. NOTE: This isn't needed by the startup script,
 # it's just used here in constructing the classpath.
-cassandra_bin="$CASSANDRA_HOME/build/classes/main"
-cassandra_bin="$cassandra_bin:$CASSANDRA_HOME/build/classes/stress"
-#cassandra_bin="$cassandra_home/build/cassandra.jar"
+if [ -d $CASSANDRA_HOME/build ] ; then
+    #cassandra_bin="$CASSANDRA_HOME/build/classes/main"
+    cassandra_bin=`ls -1 $CASSANDRA_HOME/build/apache-cassandra*.jar`
+    cassandra_bin="$cassandra_bin:$CASSANDRA_HOME/build/classes/stress"
+    CLASSPATH="$CLASSPATH:$cassandra_bin"
+fi
 
 # the default location for commitlogs, sstables, and saved caches
 # if not set in cassandra.yaml
@@ -37,12 +43,89 @@ cassandra_storagedir="$CASSANDRA_HOME/data"
 # JAVA_HOME can optionally be set here
 #JAVA_HOME=/usr/local/jdk6
 
-# The java classpath (required)
-CLASSPATH="$CASSANDRA_CONF:$cassandra_bin"
-
 for jar in "$CASSANDRA_HOME"/tools/lib/*.jar; do
     CLASSPATH="$CLASSPATH:$jar"
 done
 for jar in "$CASSANDRA_HOME"/lib/*.jar; do
     CLASSPATH="$CLASSPATH:$jar"
 done
+
+
+#
+# Java executable and per-Java version JVM settings
+#
+
+# Use JAVA_HOME if set, otherwise look for java in PATH
+if [ -n "$JAVA_HOME" ]; then
+    # Why we can't have nice things: Solaris combines x86 and x86_64
+    # installations in the same tree, using an unconventional path for the
+    # 64bit JVM.  Since we prefer 64bit, search the alternate path first,
+    # (see https://issues.apache.org/jira/browse/CASSANDRA-4638).
+    for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
+        if [ -x "$java" ]; then
+            JAVA="$java"
+            break
+        fi
+    done
+else
+    JAVA=java
+fi
+
+if [ -z $JAVA ] ; then
+    echo Unable to find java executable. Check JAVA_HOME and PATH environment variables. >&2
+    exit 1;
+fi
+
+# Determine the sort of JVM we'll be running on.
+java_ver_output=`"${JAVA:-java}" -version 2>&1`
+jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 'NR==1 {print $2}' | cut -d\- -f1`
+JVM_VERSION=${jvmver%_*}
+
+JAVA_VERSION=11
+if [ "$JVM_VERSION" = "1.8.0" ]  ; then
+    JVM_PATCH_VERSION=${jvmver#*_}
+    if [ "$JVM_VERSION" \< "1.8" ] || [ "$JVM_VERSION" \> "1.8.2" ] ; then
+        echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or Java 11 (or newer). Java $JVM_VERSION is not supported."
+        exit 1;
+    fi
+    if [ "$JVM_PATCH_VERSION" -lt 151 ] ; then
+        echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or Java 11 (or newer). Java 8 update $JVM_PATCH_VERSION is not supported."
+        exit 1;
+    fi
+    JAVA_VERSION=8
+elif [ "$JVM_VERSION" \< "11" ] ; then
+    echo "Cassandra 4.0 requires either Java 8 (update 151 or newer) or Java 11 (or newer)."
+    exit 1;
+fi
+
+jvm=`echo "$java_ver_output" | grep -A 1 '[openjdk|java] version' | awk 'NR==2 {print $1}'`
+case "$jvm" in
+    OpenJDK)
+        JVM_VENDOR=OpenJDK
+        # this will be "64-Bit" or "32-Bit"
+        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'`
+        ;;
+    "Java(TM)")
+        JVM_VENDOR=Oracle
+        # this will be "64-Bit" or "32-Bit"
+        JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'`
+        ;;
+    *)
+        # Help fill in other JVM values
+        JVM_VENDOR=other
+        JVM_ARCH=unknown
+        ;;
+esac
+
+# Read user-defined JVM options from jvm-server.options file
+JVM_OPTS_FILE=$CASSANDRA_CONF/jvm${jvmoptions_variant:--clients}.options
+if [ $JAVA_VERSION -ge 11 ] ; then
+    JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm11${jvmoptions_variant:--clients}.options
+else
+    JVM_DEP_OPTS_FILE=$CASSANDRA_CONF/jvm8${jvmoptions_variant:--clients}.options
+fi
+
+for opt in `grep "^-" $JVM_OPTS_FILE` `grep "^-" $JVM_DEP_OPTS_FILE`
+do
+  JVM_OPTS="$JVM_OPTS $opt"
+done

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/compaction-stress
----------------------------------------------------------------------
diff --git a/tools/bin/compaction-stress b/tools/bin/compaction-stress
index f169f2f..d531561 100755
--- a/tools/bin/compaction-stress
+++ b/tools/bin/compaction-stress
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstabledump
----------------------------------------------------------------------
diff --git a/tools/bin/sstabledump b/tools/bin/sstabledump
index 92ad5c5..0f4cfd3 100755
--- a/tools/bin/sstabledump
+++ b/tools/bin/sstabledump
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstableexpiredblockers
----------------------------------------------------------------------
diff --git a/tools/bin/sstableexpiredblockers b/tools/bin/sstableexpiredblockers
index c1c7e41..a843a64 100755
--- a/tools/bin/sstableexpiredblockers
+++ b/tools/bin/sstableexpiredblockers
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstablelevelreset
----------------------------------------------------------------------
diff --git a/tools/bin/sstablelevelreset b/tools/bin/sstablelevelreset
index ec602fd..b63fff7 100755
--- a/tools/bin/sstablelevelreset
+++ b/tools/bin/sstablelevelreset
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstablemetadata
----------------------------------------------------------------------
diff --git a/tools/bin/sstablemetadata b/tools/bin/sstablemetadata
index addf39b..eb0d447 100755
--- a/tools/bin/sstablemetadata
+++ b/tools/bin/sstablemetadata
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstableofflinerelevel
----------------------------------------------------------------------
diff --git a/tools/bin/sstableofflinerelevel b/tools/bin/sstableofflinerelevel
index 4e34515..9e173a6 100755
--- a/tools/bin/sstableofflinerelevel
+++ b/tools/bin/sstableofflinerelevel
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstablerepairedset
----------------------------------------------------------------------
diff --git a/tools/bin/sstablerepairedset b/tools/bin/sstablerepairedset
index 225cd11..ecd7958 100755
--- a/tools/bin/sstablerepairedset
+++ b/tools/bin/sstablerepairedset
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/bin/sstablesplit
----------------------------------------------------------------------
diff --git a/tools/bin/sstablesplit b/tools/bin/sstablesplit
index 037cb63..77d0a5f 100755
--- a/tools/bin/sstablesplit
+++ b/tools/bin/sstablesplit
@@ -32,18 +32,6 @@ elif [ -r "$CASSANDRA_INCLUDE" ]; then
     . "$CASSANDRA_INCLUDE"
 fi
 
-# Use JAVA_HOME if set, otherwise look for java in PATH
-if [ -x "$JAVA_HOME/bin/java" ]; then
-    JAVA="$JAVA_HOME/bin/java"
-else
-    JAVA="`which java`"
-fi
-
-if [ "x$JAVA" = "x" ]; then
-    echo "Java executable not found (hint: set JAVA_HOME)" >&2
-    exit 1
-fi
-
 if [ -z "$CLASSPATH" ]; then
     echo "You must set the CLASSPATH var" >&2
     exit 1

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6ba2fb93/tools/stress/src/org/apache/cassandra/stress/settings/SettingsGraph.java
----------------------------------------------------------------------
diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsGraph.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsGraph.java
index 90bb99a..d040ccc 100644
--- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsGraph.java
+++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsGraph.java
@@ -30,6 +30,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.stress.util.ResultLogger;
 
 public class SettingsGraph implements Serializable
@@ -54,14 +55,7 @@ public class SettingsGraph implements Serializable
 
         if (inGraphMode())
         {
-            try
-            {
-                temporaryLogFile = File.createTempFile("cassandra-stress", ".log");
-            }
-            catch (IOException e)
-            {
-                throw new RuntimeException("Cannot open temporary file");
-            }
+            temporaryLogFile = FileUtils.createTempFile("cassandra-stress", ".log");
         }
         else
         {


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


Mime
View raw message