Merge branch 'cassandra-2.1' into cassandra-2.2

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/4aa859e5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4aa859e5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4aa859e5

Branch: refs/heads/cassandra-2.2
Commit: 4aa859e51a38d0856ba4ee2d0c177d83722271dd
Parents: 63efa07 b851792
Author: Yuki Morishita <yu...@apache.org>
Authored: Thu May 26 09:47:04 2016 -0500
Committer: Yuki Morishita <yu...@apache.org>
Committed: Thu May 26 09:47:04 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |   1 +
 .../org/apache/cassandra/io/FSErrorHandler.java |  30 ++++++
 .../org/apache/cassandra/io/util/FileUtils.java |  76 +++-----------
 .../cassandra/service/CassandraDaemon.java      |   2 +
 .../service/DefaultFSErrorHandler.java          | 101 +++++++++++++++++++
 .../apache/cassandra/db/DirectoriesTest.java    |   2 +
 6 files changed, 152 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4aa859e5/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 190c2fa,ad9d00c..f2276f0
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,24 -1,5 +1,25 @@@
 -2.1.15
 +2.2.7
 + * Enable client encryption in sstableloader with cli options 
(CASSANDRA-11708)
 + * Possible memory leak in NIODataInputStream (CASSANDRA-11867)
 + * Fix commit log replay after out-of-order flush completion (CASSANDRA-9669)
 + * Add seconds to cqlsh tracing session duration (CASSANDRA-11753)
 + * Prohibit Reverse Counter type as part of the PK (CASSANDRA-9395)
 + * cqlsh: correctly handle non-ascii chars in error messages (CASSANDRA-11626)
 + * Exit JVM if JMX server fails to startup (CASSANDRA-11540)
 + * Produce a heap dump when exiting on OOM (CASSANDRA-9861)
 + * Avoid read repairing purgeable tombstones on range slices (CASSANDRA-11427)
 + * Restore ability to filter on clustering columns when using a 2i 
(CASSANDRA-11510)
 + * JSON datetime formatting needs timezone (CASSANDRA-11137)
 + * Fix is_dense recalculation for Thrift-updated tables (CASSANDRA-11502)
 + * Remove unnescessary file existence check during anticompaction 
(CASSANDRA-11660)
 + * Add missing files to debian packages (CASSANDRA-11642)
 + * Avoid calling Iterables::concat in loops during 
ModificationStatement::getFunctions (CASSANDRA-11621)
 + * cqlsh: COPY FROM should use regular inserts for single statement batches 
and
 +   report errors correctly if workers processes crash on initialization 
(CASSANDRA-11474)
 + * Always close cluster with connection in CqlRecordWriter (CASSANDRA-11553)
 + * Fix slice queries on ordered COMPACT tables (CASSANDRA-10988)
 +Merged from 2.1:
+  * Backport CASSANDRA-11578 (CASSANDRA-11750)
   * Clear out parent repair session if repair coordinator dies 
(CASSANDRA-11824)
   * Set default streaming_socket_timeout_in_ms to 24 hours (CASSANDRA-11840)
   * Do not consider local node a valid source during replace (CASSANDRA-11848)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4aa859e5/src/java/org/apache/cassandra/io/util/FileUtils.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/io/util/FileUtils.java
index ce45370,f69ed01..3124fcd
--- a/src/java/org/apache/cassandra/io/util/FileUtils.java
+++ b/src/java/org/apache/cassandra/io/util/FileUtils.java
@@@ -17,14 -17,23 +17,15 @@@
   */
  package org.apache.cassandra.io.util;
  
 -import java.io.Closeable;
 -import java.io.DataInput;
 -import java.io.EOFException;
 -import java.io.File;
 -import java.io.FileNotFoundException;
 -import java.io.IOException;
 -import java.io.RandomAccessFile;
 +import java.io.*;
  import java.nio.ByteBuffer;
 -import java.nio.MappedByteBuffer;
 -import java.nio.file.AtomicMoveNotSupportedException;
 -import java.nio.file.Files;
 -import java.nio.file.Path;
 -import java.nio.file.StandardCopyOption;
 +import java.nio.channels.FileChannel;
 +import java.nio.file.*;
  import java.text.DecimalFormat;
  import java.util.Arrays;
+ import java.util.concurrent.atomic.AtomicReference;
  
 +import org.apache.cassandra.config.Config;
  import sun.nio.ch.DirectBuffer;
  
  import org.slf4j.Logger;
@@@ -38,13 -45,9 +37,12 @@@ import org.apache.cassandra.io.FSErrorH
  import org.apache.cassandra.io.FSReadError;
  import org.apache.cassandra.io.FSWriteError;
  import org.apache.cassandra.io.sstable.CorruptSSTableException;
- import org.apache.cassandra.service.StorageService;
  import org.apache.cassandra.utils.JVMStabilityInspector;
  
 +import static org.apache.cassandra.utils.Throwables.maybeFail;
 +import static org.apache.cassandra.utils.Throwables.merge;
 +
- public class FileUtils
+ public final class FileUtils
  {
      private static final Logger logger = 
LoggerFactory.getLogger(FileUtils.class);
      private static final double KB = 1024d;
@@@ -487,39 -423,8 +439,43 @@@
          return length;
      }
  
- 
 +    public static void copyTo(DataInput in, OutputStream out, int length) 
throws IOException
 +    {
 +        byte[] buffer = new byte[64 * 1024];
 +        int copiedBytes = 0;
 +
 +        while (copiedBytes + buffer.length < length)
 +        {
 +            in.readFully(buffer);
 +            out.write(buffer);
 +            copiedBytes += buffer.length;
 +        }
 +
 +        if (copiedBytes < length)
 +        {
 +            int left = length - copiedBytes;
 +            in.readFully(buffer, 0, left);
 +            out.write(buffer, 0, left);
 +        }
 +    }
 +
 +    public static boolean isSubDirectory(File parent, File child) throws 
IOException
 +    {
 +        parent = parent.getCanonicalFile();
 +        child = child.getCanonicalFile();
 +
 +        File toCheck = child;
 +        while (toCheck != null)
 +        {
 +            if (parent.equals(toCheck))
 +                return true;
 +            toCheck = toCheck.getParentFile();
 +        }
 +        return false;
 +    }
++
+     public static void setFSErrorHandler(FSErrorHandler handler)
+     {
+         fsErrorHandler.getAndSet(handler);
+     }
  }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4aa859e5/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/service/CassandraDaemon.java
index 7e33e9c,5a1fb14..1e9378b
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@@ -149,32 -146,81 +149,34 @@@ public class CassandraDaemo
       */
      protected void setup()
      {
+         FileUtils.setFSErrorHandler(new DefaultFSErrorHandler());
+ 
 -        try
 -        {
 -            logger.info("Hostname: {}", 
InetAddress.getLocalHost().getHostName());
 -        }
 -        catch (UnknownHostException e1)
 -        {
 -            logger.info("Could not resolve local host");
 -        }
 +        // Delete any failed snapshot deletions on Windows - see 
CASSANDRA-9658
 +        if (FBUtilities.isWindows())
 +            WindowsFailedSnapshotTracker.deleteOldSnapshots();
  
 -        long now = System.currentTimeMillis();
 -        if (now < EARLIEST_LAUNCH_DATE)
 -        {
 -            logger.error("current machine time is {}, but that is seemingly 
incorrect. exiting now.", new Date(now));
 -            System.exit(3);
 -        }
 +        logSystemInfo();
 +
 +        CLibrary.tryMlockall();
  
 -        // log warnings for different kinds of sub-optimal JVMs.  tldr use 
64-bit Oracle >= 1.6u32
 -        if (!DatabaseDescriptor.hasLargeAddressSpace())
 -            logger.info("32bit JVM detected.  It is recommended to run 
Cassandra on a 64bit JVM for better performance.");
 -        String javaVersion = System.getProperty("java.version");
 -        String javaVmName = System.getProperty("java.vm.name");
 -        logger.info("JVM vendor/version: {}/{}", javaVmName, javaVersion);
 -        if (javaVmName.contains("OpenJDK"))
 +        try
          {
 -            // There is essentially no QA done on OpenJDK builds, and
 -            // clusters running OpenJDK have seen many heap and load issues.
 -            logger.warn("OpenJDK is not recommended. Please upgrade to the 
newest Oracle Java release");
 +            startupChecks.verify();
          }
 -        else if (!javaVmName.contains("HotSpot"))
 +        catch (StartupException e)
          {
 -            logger.warn("Non-Oracle JVM detected.  Some features, such as 
immediate unmap of compacted SSTables, may not work as intended");
 +            exitOrFail(e.returnCode, e.getMessage(), e.getCause());
          }
 -     /*   else
 +
 +        try
          {
 -            String[] java_version = javaVersion.split("_");
 -            String java_major = java_version[0];
 -            int java_minor;
 -            try
 -            {
 -                java_minor = (java_version.length > 1) ? 
Integer.parseInt(java_version[1]) : 0;
 -            }
 -            catch (NumberFormatException e)
 -            {
 -                // have only seen this with java7 so far but no doubt there 
are other ways to break this
 -                logger.info("Unable to parse java version {}", 
Arrays.toString(java_version));
 -                java_minor = 32;
 -            }
 +            SystemKeyspace.snapshotOnVersionChange();
          }
 -     */
 -        logger.info("Heap size: {}/{}", Runtime.getRuntime().totalMemory(), 
Runtime.getRuntime().maxMemory());
 -        for(MemoryPoolMXBean pool: ManagementFactory.getMemoryPoolMXBeans())
 -            logger.info("{} {}: {}", pool.getName(), pool.getType(), 
pool.getPeakUsage());
 -        logger.info("Classpath: {}", System.getProperty("java.class.path"));
 -
 -        logger.info("JVM Arguments: {}", 
ManagementFactory.getRuntimeMXBean().getInputArguments());
 -
 -        // Fail-fast if JNA is not available or failing to initialize properly
 -        // except with -Dcassandra.boot_without_jna=true. See CASSANDRA-6575.
 -        if (!CLibrary.jnaAvailable())
 +        catch (IOException e)
          {
 -            boolean jnaRequired = 
!Boolean.getBoolean("cassandra.boot_without_jna");
 -
 -            if (jnaRequired)
 -            {
 -                logger.error("JNA failing to initialize properly. Use 
-Dcassandra.boot_without_jna=true to bootstrap even so.");
 -                System.exit(3);
 -            }
 +            exitOrFail(3, e.getMessage(), e.getCause());
          }
  
 -        CLibrary.tryMlockall();
 -
          maybeInitJmx();
  
          Thread.setDefaultUncaughtExceptionHandler(new 
Thread.UncaughtExceptionHandler()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/4aa859e5/test/unit/org/apache/cassandra/db/DirectoriesTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/DirectoriesTest.java
index f92cecf,4267c1f..008e343
--- a/test/unit/org/apache/cassandra/db/DirectoriesTest.java
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@@ -36,9 -44,9 +36,10 @@@ import org.apache.cassandra.db.Director
  import org.apache.cassandra.io.sstable.Component;
  import org.apache.cassandra.io.sstable.Descriptor;
  import org.apache.cassandra.io.util.FileUtils;
+ import org.apache.cassandra.service.DefaultFSErrorHandler;
  import org.apache.cassandra.utils.ByteBufferUtil;
  import org.apache.cassandra.io.FSWriteError;
 +import org.apache.cassandra.utils.Pair;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;

Reply via email to