cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r799331 [29/29] - in /incubator/cassandra/trunk: ./ src/java/org/apache/cassandra/concurrent/ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/dht/ src/java/org/apache/cassandra/gms/ src/...
Date Thu, 30 Jul 2009 15:30:27 GMT
Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/HashingSchemes.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/HashingSchemes.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/HashingSchemes.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/HashingSchemes.java Thu Jul 30 15:30:21 2009
@@ -1,34 +1,34 @@
-/**
- * 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.utils;
-
-/**
- * Created by IntelliJ IDEA.
- * User: lakshman
- * Date: Aug 17, 2005
- * Time: 3:32:42 PM
- * To change this template use File | Settings | File Templates.
- */
-
-public final class HashingSchemes
-{
-    public static final String SHA_1 = "SHA-1";
-    public static final String SHA1 = "SHA1";
-    public static final String MD5 = "MD5";
-}
+/**
+ * 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.utils;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lakshman
+ * Date: Aug 17, 2005
+ * Time: 3:32:42 PM
+ * To change this template use File | Settings | File Templates.
+ */
+
+public final class HashingSchemes
+{
+    public static final String SHA_1 = "SHA-1";
+    public static final String SHA1 = "SHA1";
+    public static final String MD5 = "MD5";
+}

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICacheExpungeHook.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICacheExpungeHook.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICacheExpungeHook.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICacheExpungeHook.java Thu Jul 30 15:30:21 2009
@@ -1,31 +1,31 @@
-/**
- * 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.utils;
-
-/**
- * Created by IntelliJ IDEA.
- * User: lakshman
- * Date: Aug 16, 2005
- * Time: 1:08:58 PM
- * To change this template use File | Settings | File Templates.
- */
-public interface ICacheExpungeHook<K,V>
-{
-    public void callMe(K key , V value);
-}
+/**
+ * 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.utils;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: lakshman
+ * Date: Aug 16, 2005
+ * Time: 1:08:58 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface ICacheExpungeHook<K,V>
+{
+    public void callMe(K key , V value);
+}

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICachetable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICachetable.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICachetable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/ICachetable.java Thu Jul 30 15:30:21 2009
@@ -1,36 +1,36 @@
-/**
- * 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.utils;
-
-import java.util.Enumeration;
-import java.util.Set;
-
-public interface ICachetable<K,V>
-{
-    public void put(K key, V value);
-    public void put(K key, V value, ICacheExpungeHook<K,V> hook);
-	public V get(K key);
-    public V remove(K key);
-    public int size();
-    public boolean containsKey(K key);
-    public boolean containsValue(V value);
-    public boolean isEmpty();    
-    public Set<K> keySet();
-    public void shutdown();
-}
+/**
+ * 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.utils;
+
+import java.util.Enumeration;
+import java.util.Set;
+
+public interface ICachetable<K,V>
+{
+    public void put(K key, V value);
+    public void put(K key, V value, ICacheExpungeHook<K,V> hook);
+	public V get(K key);
+    public V remove(K key);
+    public int size();
+    public boolean containsKey(K key);
+    public boolean containsValue(V value);
+    public boolean isEmpty();    
+    public Set<K> keySet();
+    public void shutdown();
+}

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/Log4jLogger.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/Log4jLogger.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/Log4jLogger.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/Log4jLogger.java Thu Jul 30 15:30:21 2009
@@ -1,52 +1,52 @@
-/**
- * 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.utils;
-
-/**
- * Log4j configurations may change while the application is running, 
- * potentially invalidating a logger's appender(s).  This is a convenience
- * class to wrap logger calls so that a logger is always explicitly 
- * invoked.
- */
-
-
-public class Log4jLogger {
-    
-    private String name_ = null;
-    
-    public Log4jLogger(String name){
-        name_ = name;
-    }
-    
-    public void debug(Object arg){ 
-        LogUtil.getLogger(name_).debug(LogUtil.getTimestamp() + " - " + arg);
-    }    
-    public void info(Object arg){
-        LogUtil.getLogger(name_).info(LogUtil.getTimestamp() + " - " + arg);
-    }
-    public void warn(Object arg){
-        LogUtil.getLogger(name_).warn(LogUtil.getTimestamp() + " - " + arg);
-    }
-    public void error(Object arg){
-        LogUtil.getLogger(name_).error(LogUtil.getTimestamp() + " - " + arg);
-    }
-    public void fatal(Object arg){
-        LogUtil.getLogger(name_).fatal(LogUtil.getTimestamp() + " - " + arg);
-    } 
-}
+/**
+ * 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.utils;
+
+/**
+ * Log4j configurations may change while the application is running, 
+ * potentially invalidating a logger's appender(s).  This is a convenience
+ * class to wrap logger calls so that a logger is always explicitly 
+ * invoked.
+ */
+
+
+public class Log4jLogger {
+    
+    private String name_ = null;
+    
+    public Log4jLogger(String name){
+        name_ = name;
+    }
+    
+    public void debug(Object arg){ 
+        LogUtil.getLogger(name_).debug(LogUtil.getTimestamp() + " - " + arg);
+    }    
+    public void info(Object arg){
+        LogUtil.getLogger(name_).info(LogUtil.getTimestamp() + " - " + arg);
+    }
+    public void warn(Object arg){
+        LogUtil.getLogger(name_).warn(LogUtil.getTimestamp() + " - " + arg);
+    }
+    public void error(Object arg){
+        LogUtil.getLogger(name_).error(LogUtil.getTimestamp() + " - " + arg);
+    }
+    public void fatal(Object arg){
+        LogUtil.getLogger(name_).fatal(LogUtil.getTimestamp() + " - " + arg);
+    } 
+}

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/LogUtil.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/LogUtil.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/LogUtil.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/LogUtil.java Thu Jul 30 15:30:21 2009
@@ -1,119 +1,119 @@
-/**
- * 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.utils;
-
-import java.io.*;
-import java.text.*;
-import java.util.*;
-import org.apache.log4j.*;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.xml.DOMConfigurator;
-
-public class LogUtil
-{
-
-    public LogUtil()
-    {
-    }
-
-    public static void init()
-    {
-        //BasicConfigurator.configure();
-        String file = System.getProperty("storage-config");
-        file += File.separator + "log4j.properties";
-        PropertyConfigurator.configure(file);
-    }
-
-    public static Logger getLogger(String name)
-    {
-        return Logger.getLogger(name);
-    }
-    
-    public static String stackTrace(Throwable e)
-    {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        e.printStackTrace(pw);
-        return sw.toString();
-    }
-
-    public static String getTimestamp()
-    {
-        Date date = new Date();
-        DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
-        return df.format(date);
-    }
-    
-    public static String throwableToString(Throwable e)
-    {
-        StringBuilder sbuf = new StringBuilder("");
-        String trace = stackTrace(e);
-        sbuf.append((new StringBuilder())
-        	.append("Exception was generated at : ")
-        	.append(getTimestamp())
-        	.append(" on thread ")
-        	.append(Thread.currentThread().getName())
-        	.toString());
-        sbuf.append(System.getProperty("line.separator"));
-        String message = e.getMessage();
-        if(message != null)
-            sbuf.append(message);
-        sbuf.append(System.getProperty("line.separator"))
-        	.append(trace);
-        return sbuf.toString();
-    }
-
-    public static String getLogMessage(String message)
-    {
-        StringBuilder sbuf = new StringBuilder((new StringBuilder())
-        		.append("Log started at : ")
-        		.append(getTimestamp())
-        		.toString());
-        sbuf.append(File.separator)
-        	.append(message);
-        return sbuf.toString();
-    }
-
-    public static void setLogLevel(String logger, String level)
-    {        
-        Logger loggerObj = LogManager.getLogger(logger);
-        if(null == loggerObj)
-            return;
-        level = level.toUpperCase();
-        if(level.equals("DEBUG"))
-            loggerObj.setLevel(Level.DEBUG);
-        else
-        if(level.equals("ERROR"))
-            loggerObj.setLevel(Level.ERROR);
-        else
-        if(level.equals("FATAL"))
-            loggerObj.setLevel(Level.FATAL);
-        else
-        if(level.equals("INFO"))
-            loggerObj.setLevel(Level.INFO);
-        else
-        if(level.equals("OFF"))
-            loggerObj.setLevel(Level.OFF);
-        else
-        if(level.equals("WARN"))
-            loggerObj.setLevel(Level.WARN);
-        else
-            loggerObj.setLevel(Level.ALL);
-    }
-}
+/**
+ * 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.utils;
+
+import java.io.*;
+import java.text.*;
+import java.util.*;
+import org.apache.log4j.*;
+import org.apache.log4j.spi.LoggerFactory;
+import org.apache.log4j.xml.DOMConfigurator;
+
+public class LogUtil
+{
+
+    public LogUtil()
+    {
+    }
+
+    public static void init()
+    {
+        //BasicConfigurator.configure();
+        String file = System.getProperty("storage-config");
+        file += File.separator + "log4j.properties";
+        PropertyConfigurator.configure(file);
+    }
+
+    public static Logger getLogger(String name)
+    {
+        return Logger.getLogger(name);
+    }
+    
+    public static String stackTrace(Throwable e)
+    {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        e.printStackTrace(pw);
+        return sw.toString();
+    }
+
+    public static String getTimestamp()
+    {
+        Date date = new Date();
+        DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
+        return df.format(date);
+    }
+    
+    public static String throwableToString(Throwable e)
+    {
+        StringBuilder sbuf = new StringBuilder("");
+        String trace = stackTrace(e);
+        sbuf.append((new StringBuilder())
+        	.append("Exception was generated at : ")
+        	.append(getTimestamp())
+        	.append(" on thread ")
+        	.append(Thread.currentThread().getName())
+        	.toString());
+        sbuf.append(System.getProperty("line.separator"));
+        String message = e.getMessage();
+        if(message != null)
+            sbuf.append(message);
+        sbuf.append(System.getProperty("line.separator"))
+        	.append(trace);
+        return sbuf.toString();
+    }
+
+    public static String getLogMessage(String message)
+    {
+        StringBuilder sbuf = new StringBuilder((new StringBuilder())
+        		.append("Log started at : ")
+        		.append(getTimestamp())
+        		.toString());
+        sbuf.append(File.separator)
+        	.append(message);
+        return sbuf.toString();
+    }
+
+    public static void setLogLevel(String logger, String level)
+    {        
+        Logger loggerObj = LogManager.getLogger(logger);
+        if(null == loggerObj)
+            return;
+        level = level.toUpperCase();
+        if(level.equals("DEBUG"))
+            loggerObj.setLevel(Level.DEBUG);
+        else
+        if(level.equals("ERROR"))
+            loggerObj.setLevel(Level.ERROR);
+        else
+        if(level.equals("FATAL"))
+            loggerObj.setLevel(Level.FATAL);
+        else
+        if(level.equals("INFO"))
+            loggerObj.setLevel(Level.INFO);
+        else
+        if(level.equals("OFF"))
+            loggerObj.setLevel(Level.OFF);
+        else
+        if(level.equals("WARN"))
+            loggerObj.setLevel(Level.WARN);
+        else
+            loggerObj.setLevel(Level.ALL);
+    }
+}

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/SafeMessageDigest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/SafeMessageDigest.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/SafeMessageDigest.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/utils/SafeMessageDigest.java Thu Jul 30 15:30:21 2009
@@ -1,85 +1,85 @@
-/**
- * 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.utils;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-/**
- * Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )
- */
-
-public class SafeMessageDigest
-{
-    private MessageDigest md_ = null;
-
-    public static SafeMessageDigest digest_;
-    static
-    {
-        try
-        {
-            digest_ = new SafeMessageDigest(MessageDigest.getInstance("SHA-1"));
-        }
-        catch (NoSuchAlgorithmException e)
-        {
-            assert (false);
-        }
-    }
-
-    public SafeMessageDigest(MessageDigest md)
-    {
-        md_ = md;
-    }
-
-    public synchronized void update(byte[] theBytes)
-    {
-        md_.update(theBytes);
-    }
-
-    //NOTE: This should be used instead of seperate update() and then digest()
-    public synchronized byte[] digest(byte[] theBytes)
-    {
-        //this does an implicit update()
-        return md_.digest(theBytes);
-    }
-
-    public synchronized byte[] digest()
-    {
-        return md_.digest();
-    }
-
-    public byte[] unprotectedDigest()
-    {
-        return md_.digest();
-    }
-
-    public void unprotectedUpdate(byte[] theBytes)
-    {
-        md_.update(theBytes);
-    }
-
-    public byte[] unprotectedDigest(byte[] theBytes)
-    {
-        return md_.digest(theBytes);
-    }
-
-    public int getDigestLength()
-    {
-        return md_.getDigestLength();
-    }
-}
+/**
+ * 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.utils;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+/**
+ * Author : Avinash Lakshman ( alakshman@facebook.com) & Prashant Malik ( pmalik@facebook.com )
+ */
+
+public class SafeMessageDigest
+{
+    private MessageDigest md_ = null;
+
+    public static SafeMessageDigest digest_;
+    static
+    {
+        try
+        {
+            digest_ = new SafeMessageDigest(MessageDigest.getInstance("SHA-1"));
+        }
+        catch (NoSuchAlgorithmException e)
+        {
+            assert (false);
+        }
+    }
+
+    public SafeMessageDigest(MessageDigest md)
+    {
+        md_ = md;
+    }
+
+    public synchronized void update(byte[] theBytes)
+    {
+        md_.update(theBytes);
+    }
+
+    //NOTE: This should be used instead of seperate update() and then digest()
+    public synchronized byte[] digest(byte[] theBytes)
+    {
+        //this does an implicit update()
+        return md_.digest(theBytes);
+    }
+
+    public synchronized byte[] digest()
+    {
+        return md_.digest();
+    }
+
+    public byte[] unprotectedDigest()
+    {
+        return md_.digest();
+    }
+
+    public void unprotectedUpdate(byte[] theBytes)
+    {
+        md_.update(theBytes);
+    }
+
+    public byte[] unprotectedDigest(byte[] theBytes)
+    {
+        return md_.digest(theBytes);
+    }
+
+    public int getDigestLength()
+    {
+        return md_.getDigestLength();
+    }
+}

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java Thu Jul 30 15:30:21 2009
@@ -1,360 +1,360 @@
-/**
- * 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;
-
-import java.util.*;
-import java.io.IOException;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.ArrayUtils;
-import org.junit.Test;
-
-import static junit.framework.Assert.*;
-import org.apache.cassandra.CleanupHelper;
-import static org.apache.cassandra.Util.column;
-import static org.apache.cassandra.Util.getBytes;
-import org.apache.cassandra.db.filter.NamesQueryFilter;
-import org.apache.cassandra.db.filter.QueryPath;
-import org.apache.cassandra.db.marshal.LongType;
-import org.apache.cassandra.io.SSTableReader;
-
-public class TableTest extends CleanupHelper
-{
-    private static final String KEY2 = "key2";
-    private static final String TEST_KEY = "key1";
-
-    interface Runner
-    {
-        public void run() throws Exception;
-    }
-
-    private void reTest(Runner setup, ColumnFamilyStore cfs, Runner verify) throws Exception
-    {
-        setup.run();
-        verify.run();
-        cfs.forceBlockingFlush();
-        verify.run();
-    }
-
-    @Test
-    public void testOpen() throws Throwable {
-        Table table = Table.open("Mailbox");
-        Row row = table.get("35300190:1");
-        assertNotNull(row);
-    }
-    
-    @Test
-    public void testGetRowSingleColumn() throws Throwable
-    {
-        final Table table = Table.open("Keyspace1");
-        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
-
-        Runner setup = new Runner()
-        {
-            public void run() throws Exception
-            {
-                RowMutation rm = makeSimpleRowMutation();
-                rm.apply();
-            }
-        };
-        Runner verify = new Runner()
-        {
-            public void run() throws Exception
-            {
-                ColumnFamily cf;
-
-                cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard1"), "col1".getBytes()));
-                assertColumns(cf, "col1");
-
-                cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard1"), "col3".getBytes()));
-                assertColumns(cf, "col3");
-            }
-        };
-        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
-    }
-            
-    @Test
-    public void testGetRowSliceByRange() throws Throwable
-    {
-    	String key = TEST_KEY+"slicerow";
-    	Table table = Table.open("Keyspace1");
-        ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
-    	RowMutation rm = new RowMutation("Keyspace1", key);
-        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
-        // First write "a", "b", "c"
-        cf.addColumn(column("a", "val1", 1L));
-        cf.addColumn(column("b", "val2", 1L));
-        cf.addColumn(column("c", "val3", 1L));
-        rm.add(cf);
-        rm.apply();
-        
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(), true, 100);
-        assertEquals(2, cf.getColumnCount());
-        
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "b".getBytes(), true, 100);
-        assertEquals(1, cf.getColumnCount());
-        
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(), true, 1);
-        assertEquals(1, cf.getColumnCount());
-        
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "c".getBytes(), "b".getBytes(), true, 1);
-        assertNull(cf);
-    }
-
-    private RowMutation makeSimpleRowMutation()
-    {
-        RowMutation rm = new RowMutation("Keyspace1",TEST_KEY);
-        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
-        cf.addColumn(column("col1","val1", 1L));
-        cf.addColumn(column("col2","val2", 1L));
-        cf.addColumn(column("col3","val3", 1L));
-        rm.add(cf);
-        return rm;
-    }
-
-    @Test
-    public void testGetSliceNoMatch() throws Throwable
-    {
-        Table table = Table.open("Keyspace1");
-        RowMutation rm = new RowMutation("Keyspace1", "row1000");
-        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard2");
-        cf.addColumn(column("col1", "val1", 1));
-        rm.add(cf);
-        rm.apply();
-
-        validateGetSliceNoMatch(table);
-        table.getColumnFamilyStore("Standard2").forceBlockingFlush();
-        validateGetSliceNoMatch(table);
-
-        Collection<SSTableReader> ssTables = table.getColumnFamilyStore("Standard2").getSSTables();
-        assertEquals(1, ssTables.size());
-        ssTables.iterator().next().forceBloomFilterFailures();
-        validateGetSliceNoMatch(table);
-    }
-
-    private void validateGetSliceNoMatch(Table table) throws IOException
-    {
-        ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard2");
-        ColumnFamily cf;
-
-        // key before the rows that exists
-        cf = cfStore.getColumnFamily("a", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
-        assertColumns(cf);
-
-        // key after the rows that exist
-        cf = cfStore.getColumnFamily("z", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
-        assertColumns(cf);
-    }
-
-    @Test
-    public void testGetSliceFromBasic() throws Throwable
-    {
-        // tests slicing against data from one row in a memtable and then flushed to an sstable
-        final Table table = Table.open("Keyspace1");
-        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
-        final String ROW = "row1";
-        Runner setup = new Runner()
-        {
-            public void run() throws Exception
-            {
-                RowMutation rm = new RowMutation("Keyspace1", ROW);
-                ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
-                cf.addColumn(column("col1", "val1", 1L));
-                cf.addColumn(column("col3", "val3", 1L));
-                cf.addColumn(column("col4", "val4", 1L));
-                cf.addColumn(column("col5", "val5", 1L));
-                cf.addColumn(column("col7", "val7", 1L));
-                cf.addColumn(column("col9", "val9", 1L));
-                rm.add(cf);
-                rm.apply();
-
-                rm = new RowMutation("Keyspace1", ROW);
-                rm.delete(new QueryPath("Standard1", null, "col4".getBytes()), 2L);
-                rm.apply();
-            }
-        };
-
-        Runner verify = new Runner()
-        {
-            public void run() throws Exception
-            {
-                Row result;
-                ColumnFamily cf;
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
-                assertColumns(cf, "col5", "col7");
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col4".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
-                assertColumns(cf, "col4", "col5", "col7");
-                assertColumns(ColumnFamilyStore.removeDeleted(cf, Integer.MAX_VALUE), "col5", "col7");
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
-                assertColumns(cf, "col3", "col4", "col5");
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col6".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
-                assertColumns(cf, "col3", "col4", "col5");
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col95".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
-                assertColumns(cf);
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col0".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
-                assertColumns(cf);
-            }
-        };
-
-        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
-    }
-
-    @Test
-    public void testGetSliceFromAdvanced() throws Throwable
-    {
-        // tests slicing against data from one row spread across two sstables
-        final Table table = Table.open("Keyspace1");
-        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
-        final String ROW = "row2";
-        Runner setup = new Runner()
-        {
-            public void run() throws Exception
-            {
-                RowMutation rm = new RowMutation("Keyspace1", ROW);
-                ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
-                cf.addColumn(column("col1", "val1", 1L));
-                cf.addColumn(column("col2", "val2", 1L));
-                cf.addColumn(column("col3", "val3", 1L));
-                cf.addColumn(column("col4", "val4", 1L));
-                cf.addColumn(column("col5", "val5", 1L));
-                cf.addColumn(column("col6", "val6", 1L));
-                rm.add(cf);
-                rm.apply();
-                cfStore.forceBlockingFlush();
-
-                rm = new RowMutation("Keyspace1", ROW);
-                cf = ColumnFamily.create("Keyspace1", "Standard1");
-                cf.addColumn(column("col1", "valx", 2L));
-                cf.addColumn(column("col2", "valx", 2L));
-                cf.addColumn(column("col3", "valx", 2L));
-                rm.add(cf);
-                rm.apply();
-            }
-        };
-
-        Runner verify = new Runner()
-        {
-            public void run() throws Exception
-            {
-                ColumnFamily cf;
-
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col2".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
-                assertColumns(cf, "col2", "col3", "col4");
-                assertEquals(new String(cf.getColumn("col2".getBytes()).value()), "valx");
-                assertEquals(new String(cf.getColumn("col3".getBytes()).value()), "valx");
-                assertEquals(new String(cf.getColumn("col4".getBytes()).value()), "val4");
-            }
-        };
-
-        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
-    }
-
-    @Test
-    public void testGetSliceFromLarge() throws Throwable
-    {
-        // tests slicing against 1000 columns in an sstable
-        Table table = Table.open("Keyspace1");
-        ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
-        String ROW = "row3";
-        RowMutation rm = new RowMutation("Keyspace1", ROW);
-        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
-        for (int i = 1000; i < 2000; i++)
-            cf.addColumn(column("col" + i, ("vvvvvvvvvvvvvvvv" + i), 1L));
-        rm.add(cf);
-        rm.apply();
-        cfStore.forceBlockingFlush();
-
-        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1000".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
-        assertColumns(cf, "col1000", "col1001", "col1002");
-        assertEquals(new String(cf.getColumn("col1000".getBytes()).value()), "vvvvvvvvvvvvvvvv1000");
-        assertEquals(new String(cf.getColumn("col1001".getBytes()).value()), "vvvvvvvvvvvvvvvv1001");
-        assertEquals(new String(cf.getColumn("col1002".getBytes()).value()), "vvvvvvvvvvvvvvvv1002");
-
-        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1195".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
-        assertColumns(cf, "col1195", "col1196", "col1197");
-        assertEquals(new String(cf.getColumn("col1195".getBytes()).value()), "vvvvvvvvvvvvvvvv1195");
-        assertEquals(new String(cf.getColumn("col1196".getBytes()).value()), "vvvvvvvvvvvvvvvv1196");
-        assertEquals(new String(cf.getColumn("col1197".getBytes()).value()), "vvvvvvvvvvvvvvvv1197");
-
-        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1196".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
-        assertColumns(cf, "col1194", "col1195", "col1196");
-        assertEquals(new String(cf.getColumn("col1194".getBytes()).value()), "vvvvvvvvvvvvvvvv1194");
-        assertEquals(new String(cf.getColumn("col1195".getBytes()).value()), "vvvvvvvvvvvvvvvv1195");
-        assertEquals(new String(cf.getColumn("col1196".getBytes()).value()), "vvvvvvvvvvvvvvvv1196");
-
-        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1990".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
-        assertColumns(cf, "col1990", "col1991", "col1992");
-        assertEquals(new String(cf.getColumn("col1990".getBytes()).value()), "vvvvvvvvvvvvvvvv1990");
-        assertEquals(new String(cf.getColumn("col1991".getBytes()).value()), "vvvvvvvvvvvvvvvv1991");
-        assertEquals(new String(cf.getColumn("col1992".getBytes()).value()), "vvvvvvvvvvvvvvvv1992");
-    }
-
-    @Test
-    public void testGetSliceFromSuperBasic() throws Throwable
-    {
-        // tests slicing against data from one row spread across two sstables
-        final Table table = Table.open("Keyspace1");
-        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Super1");
-        final String ROW = "row2";
-        Runner setup = new Runner()
-        {
-            public void run() throws Exception
-            {
-                RowMutation rm = new RowMutation("Keyspace1", ROW);
-                ColumnFamily cf = ColumnFamily.create("Keyspace1", "Super1");
-                SuperColumn sc = new SuperColumn("sc1".getBytes(), new LongType());
-                sc.addColumn(new Column(getBytes(1), "val1".getBytes(), 1L));
-                cf.addColumn(sc);
-                rm.add(cf);
-                rm.apply();
-            }
-        };
-
-        Runner verify = new Runner()
-        {
-            public void run() throws Exception
-            {
-                ColumnFamily cf = cfStore.getColumnFamily(ROW, new QueryPath("Super1"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 10);
-                assertColumns(cf, "sc1");
-                assertEquals(new String(cf.getColumn("sc1".getBytes()).getSubColumn(getBytes(1)).value()), "val1");
-            }
-        };
-
-        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
-    }
-
-    public static void assertColumns(ColumnFamily cf, String... columnNames)
-    {
-        Collection<IColumn> columns = cf == null ? new TreeSet<IColumn>() : cf.getSortedColumns();
-        List<String> L = new ArrayList<String>();
-        for (IColumn column : columns)
-        {
-            L.add(new String(column.name()));
-        }
-        assert Arrays.equals(L.toArray(new String[columns.size()]), columnNames)
-                : "Columns [" + ((cf == null) ? "" : cf.getComparator().getColumnsString(columns)) + "]"
-                  + " is not expected [" + StringUtils.join(columnNames, ",") + "]";
-    }
-}
+/**
+ * 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;
+
+import java.util.*;
+import java.io.IOException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.ArrayUtils;
+import org.junit.Test;
+
+import static junit.framework.Assert.*;
+import org.apache.cassandra.CleanupHelper;
+import static org.apache.cassandra.Util.column;
+import static org.apache.cassandra.Util.getBytes;
+import org.apache.cassandra.db.filter.NamesQueryFilter;
+import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.db.marshal.LongType;
+import org.apache.cassandra.io.SSTableReader;
+
+public class TableTest extends CleanupHelper
+{
+    private static final String KEY2 = "key2";
+    private static final String TEST_KEY = "key1";
+
+    interface Runner
+    {
+        public void run() throws Exception;
+    }
+
+    private void reTest(Runner setup, ColumnFamilyStore cfs, Runner verify) throws Exception
+    {
+        setup.run();
+        verify.run();
+        cfs.forceBlockingFlush();
+        verify.run();
+    }
+
+    @Test
+    public void testOpen() throws Throwable {
+        Table table = Table.open("Mailbox");
+        Row row = table.get("35300190:1");
+        assertNotNull(row);
+    }
+    
+    @Test
+    public void testGetRowSingleColumn() throws Throwable
+    {
+        final Table table = Table.open("Keyspace1");
+        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
+
+        Runner setup = new Runner()
+        {
+            public void run() throws Exception
+            {
+                RowMutation rm = makeSimpleRowMutation();
+                rm.apply();
+            }
+        };
+        Runner verify = new Runner()
+        {
+            public void run() throws Exception
+            {
+                ColumnFamily cf;
+
+                cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard1"), "col1".getBytes()));
+                assertColumns(cf, "col1");
+
+                cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard1"), "col3".getBytes()));
+                assertColumns(cf, "col3");
+            }
+        };
+        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
+    }
+            
+    @Test
+    public void testGetRowSliceByRange() throws Throwable
+    {
+    	String key = TEST_KEY+"slicerow";
+    	Table table = Table.open("Keyspace1");
+        ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
+    	RowMutation rm = new RowMutation("Keyspace1", key);
+        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
+        // First write "a", "b", "c"
+        cf.addColumn(column("a", "val1", 1L));
+        cf.addColumn(column("b", "val2", 1L));
+        cf.addColumn(column("c", "val3", 1L));
+        rm.add(cf);
+        rm.apply();
+        
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(), true, 100);
+        assertEquals(2, cf.getColumnCount());
+        
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "b".getBytes(), true, 100);
+        assertEquals(1, cf.getColumnCount());
+        
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(), true, 1);
+        assertEquals(1, cf.getColumnCount());
+        
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "c".getBytes(), "b".getBytes(), true, 1);
+        assertNull(cf);
+    }
+
+    private RowMutation makeSimpleRowMutation()
+    {
+        RowMutation rm = new RowMutation("Keyspace1",TEST_KEY);
+        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
+        cf.addColumn(column("col1","val1", 1L));
+        cf.addColumn(column("col2","val2", 1L));
+        cf.addColumn(column("col3","val3", 1L));
+        rm.add(cf);
+        return rm;
+    }
+
+    @Test
+    public void testGetSliceNoMatch() throws Throwable
+    {
+        Table table = Table.open("Keyspace1");
+        RowMutation rm = new RowMutation("Keyspace1", "row1000");
+        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard2");
+        cf.addColumn(column("col1", "val1", 1));
+        rm.add(cf);
+        rm.apply();
+
+        validateGetSliceNoMatch(table);
+        table.getColumnFamilyStore("Standard2").forceBlockingFlush();
+        validateGetSliceNoMatch(table);
+
+        Collection<SSTableReader> ssTables = table.getColumnFamilyStore("Standard2").getSSTables();
+        assertEquals(1, ssTables.size());
+        ssTables.iterator().next().forceBloomFilterFailures();
+        validateGetSliceNoMatch(table);
+    }
+
+    private void validateGetSliceNoMatch(Table table) throws IOException
+    {
+        ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard2");
+        ColumnFamily cf;
+
+        // key before the rows that exists
+        cf = cfStore.getColumnFamily("a", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
+        assertColumns(cf);
+
+        // key after the rows that exist
+        cf = cfStore.getColumnFamily("z", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
+        assertColumns(cf);
+    }
+
+    @Test
+    public void testGetSliceFromBasic() throws Throwable
+    {
+        // tests slicing against data from one row in a memtable and then flushed to an sstable
+        final Table table = Table.open("Keyspace1");
+        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
+        final String ROW = "row1";
+        Runner setup = new Runner()
+        {
+            public void run() throws Exception
+            {
+                RowMutation rm = new RowMutation("Keyspace1", ROW);
+                ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
+                cf.addColumn(column("col1", "val1", 1L));
+                cf.addColumn(column("col3", "val3", 1L));
+                cf.addColumn(column("col4", "val4", 1L));
+                cf.addColumn(column("col5", "val5", 1L));
+                cf.addColumn(column("col7", "val7", 1L));
+                cf.addColumn(column("col9", "val9", 1L));
+                rm.add(cf);
+                rm.apply();
+
+                rm = new RowMutation("Keyspace1", ROW);
+                rm.delete(new QueryPath("Standard1", null, "col4".getBytes()), 2L);
+                rm.apply();
+            }
+        };
+
+        Runner verify = new Runner()
+        {
+            public void run() throws Exception
+            {
+                Row result;
+                ColumnFamily cf;
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
+                assertColumns(cf, "col5", "col7");
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col4".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
+                assertColumns(cf, "col4", "col5", "col7");
+                assertColumns(ColumnFamilyStore.removeDeleted(cf, Integer.MAX_VALUE), "col5", "col7");
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                assertColumns(cf, "col3", "col4", "col5");
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col6".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                assertColumns(cf, "col3", "col4", "col5");
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col95".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
+                assertColumns(cf);
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col0".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                assertColumns(cf);
+            }
+        };
+
+        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
+    }
+
+    @Test
+    public void testGetSliceFromAdvanced() throws Throwable
+    {
+        // tests slicing against data from one row spread across two sstables
+        final Table table = Table.open("Keyspace1");
+        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
+        final String ROW = "row2";
+        Runner setup = new Runner()
+        {
+            public void run() throws Exception
+            {
+                RowMutation rm = new RowMutation("Keyspace1", ROW);
+                ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
+                cf.addColumn(column("col1", "val1", 1L));
+                cf.addColumn(column("col2", "val2", 1L));
+                cf.addColumn(column("col3", "val3", 1L));
+                cf.addColumn(column("col4", "val4", 1L));
+                cf.addColumn(column("col5", "val5", 1L));
+                cf.addColumn(column("col6", "val6", 1L));
+                rm.add(cf);
+                rm.apply();
+                cfStore.forceBlockingFlush();
+
+                rm = new RowMutation("Keyspace1", ROW);
+                cf = ColumnFamily.create("Keyspace1", "Standard1");
+                cf.addColumn(column("col1", "valx", 2L));
+                cf.addColumn(column("col2", "valx", 2L));
+                cf.addColumn(column("col3", "valx", 2L));
+                rm.add(cf);
+                rm.apply();
+            }
+        };
+
+        Runner verify = new Runner()
+        {
+            public void run() throws Exception
+            {
+                ColumnFamily cf;
+
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col2".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+                assertColumns(cf, "col2", "col3", "col4");
+                assertEquals(new String(cf.getColumn("col2".getBytes()).value()), "valx");
+                assertEquals(new String(cf.getColumn("col3".getBytes()).value()), "valx");
+                assertEquals(new String(cf.getColumn("col4".getBytes()).value()), "val4");
+            }
+        };
+
+        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
+    }
+
+    @Test
+    public void testGetSliceFromLarge() throws Throwable
+    {
+        // tests slicing against 1000 columns in an sstable
+        Table table = Table.open("Keyspace1");
+        ColumnFamilyStore cfStore = table.getColumnFamilyStore("Standard1");
+        String ROW = "row3";
+        RowMutation rm = new RowMutation("Keyspace1", ROW);
+        ColumnFamily cf = ColumnFamily.create("Keyspace1", "Standard1");
+        for (int i = 1000; i < 2000; i++)
+            cf.addColumn(column("col" + i, ("vvvvvvvvvvvvvvvv" + i), 1L));
+        rm.add(cf);
+        rm.apply();
+        cfStore.forceBlockingFlush();
+
+        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1000".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        assertColumns(cf, "col1000", "col1001", "col1002");
+        assertEquals(new String(cf.getColumn("col1000".getBytes()).value()), "vvvvvvvvvvvvvvvv1000");
+        assertEquals(new String(cf.getColumn("col1001".getBytes()).value()), "vvvvvvvvvvvvvvvv1001");
+        assertEquals(new String(cf.getColumn("col1002".getBytes()).value()), "vvvvvvvvvvvvvvvv1002");
+
+        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1195".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        assertColumns(cf, "col1195", "col1196", "col1197");
+        assertEquals(new String(cf.getColumn("col1195".getBytes()).value()), "vvvvvvvvvvvvvvvv1195");
+        assertEquals(new String(cf.getColumn("col1196".getBytes()).value()), "vvvvvvvvvvvvvvvv1196");
+        assertEquals(new String(cf.getColumn("col1197".getBytes()).value()), "vvvvvvvvvvvvvvvv1197");
+
+        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1196".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
+        assertColumns(cf, "col1194", "col1195", "col1196");
+        assertEquals(new String(cf.getColumn("col1194".getBytes()).value()), "vvvvvvvvvvvvvvvv1194");
+        assertEquals(new String(cf.getColumn("col1195".getBytes()).value()), "vvvvvvvvvvvvvvvv1195");
+        assertEquals(new String(cf.getColumn("col1196".getBytes()).value()), "vvvvvvvvvvvvvvvv1196");
+
+        cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col1990".getBytes(), ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        assertColumns(cf, "col1990", "col1991", "col1992");
+        assertEquals(new String(cf.getColumn("col1990".getBytes()).value()), "vvvvvvvvvvvvvvvv1990");
+        assertEquals(new String(cf.getColumn("col1991".getBytes()).value()), "vvvvvvvvvvvvvvvv1991");
+        assertEquals(new String(cf.getColumn("col1992".getBytes()).value()), "vvvvvvvvvvvvvvvv1992");
+    }
+
+    @Test
+    public void testGetSliceFromSuperBasic() throws Throwable
+    {
+        // tests slicing against data from one row spread across two sstables
+        final Table table = Table.open("Keyspace1");
+        final ColumnFamilyStore cfStore = table.getColumnFamilyStore("Super1");
+        final String ROW = "row2";
+        Runner setup = new Runner()
+        {
+            public void run() throws Exception
+            {
+                RowMutation rm = new RowMutation("Keyspace1", ROW);
+                ColumnFamily cf = ColumnFamily.create("Keyspace1", "Super1");
+                SuperColumn sc = new SuperColumn("sc1".getBytes(), new LongType());
+                sc.addColumn(new Column(getBytes(1), "val1".getBytes(), 1L));
+                cf.addColumn(sc);
+                rm.add(cf);
+                rm.apply();
+            }
+        };
+
+        Runner verify = new Runner()
+        {
+            public void run() throws Exception
+            {
+                ColumnFamily cf = cfStore.getColumnFamily(ROW, new QueryPath("Super1"), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 10);
+                assertColumns(cf, "sc1");
+                assertEquals(new String(cf.getColumn("sc1".getBytes()).getSubColumn(getBytes(1)).value()), "val1");
+            }
+        };
+
+        reTest(setup, table.getColumnFamilyStore("Standard1"), verify);
+    }
+
+    public static void assertColumns(ColumnFamily cf, String... columnNames)
+    {
+        Collection<IColumn> columns = cf == null ? new TreeSet<IColumn>() : cf.getSortedColumns();
+        List<String> L = new ArrayList<String>();
+        for (IColumn column : columns)
+        {
+            L.add(new String(column.name()));
+        }
+        assert Arrays.equals(L.toArray(new String[columns.size()]), columnNames)
+                : "Columns [" + ((cf == null) ? "" : cf.getComparator().getColumnsString(columns)) + "]"
+                  + " is not expected [" + StringUtils.join(columnNames, ",") + "]";
+    }
+}

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/gms/GossipDigestTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/gms/GossipDigestTest.java?rev=799331&r1=799330&r2=799331&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/gms/GossipDigestTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/gms/GossipDigestTest.java Thu Jul 30 15:30:21 2009
@@ -1,37 +1,37 @@
-package org.apache.cassandra.gms;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-
-import org.apache.cassandra.io.DataInputBuffer;
-import org.apache.cassandra.io.DataOutputBuffer;
-import org.apache.cassandra.net.EndPoint;
-import org.junit.Test;
-
-public class GossipDigestTest
-{
-
-    @Test
-    public void test() throws IOException
-    {
-        EndPoint endPoint = new EndPoint("127.0.0.1", 3333);
-        int generation = 0;
-        int maxVersion = 123;
-        GossipDigest expected = new GossipDigest(endPoint, generation, maxVersion);
-        //make sure we get the same values out
-        assertEquals(endPoint, expected.getEndPoint());
-        assertEquals(generation, expected.getGeneration());
-        assertEquals(maxVersion, expected.getMaxVersion());
-        
-        //test the serialization and equals
-        DataOutputBuffer output = new DataOutputBuffer();
-        GossipDigest.serializer().serialize(expected, output);
-        
-        DataInputBuffer input = new DataInputBuffer();
-        input.reset(output.getData(), output.getLength());
-        GossipDigest actual = GossipDigest.serializer().deserialize(input);
-        assertEquals(0, expected.compareTo(actual));
-    }
-
-}
+package org.apache.cassandra.gms;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.apache.cassandra.io.DataInputBuffer;
+import org.apache.cassandra.io.DataOutputBuffer;
+import org.apache.cassandra.net.EndPoint;
+import org.junit.Test;
+
+public class GossipDigestTest
+{
+
+    @Test
+    public void test() throws IOException
+    {
+        EndPoint endPoint = new EndPoint("127.0.0.1", 3333);
+        int generation = 0;
+        int maxVersion = 123;
+        GossipDigest expected = new GossipDigest(endPoint, generation, maxVersion);
+        //make sure we get the same values out
+        assertEquals(endPoint, expected.getEndPoint());
+        assertEquals(generation, expected.getGeneration());
+        assertEquals(maxVersion, expected.getMaxVersion());
+        
+        //test the serialization and equals
+        DataOutputBuffer output = new DataOutputBuffer();
+        GossipDigest.serializer().serialize(expected, output);
+        
+        DataInputBuffer input = new DataInputBuffer();
+        input.reset(output.getData(), output.getLength());
+        GossipDigest actual = GossipDigest.serializer().deserialize(input);
+        assertEquals(0, expected.compareTo(actual));
+    }
+
+}



Mime
View raw message