cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject [7/13] git commit: Multiple values for CurrentLocal Node ID
Date Mon, 10 Sep 2012 22:13:31 GMT
Multiple values for CurrentLocal Node ID

patch by slebresne; reviewed by jbellis for CASSANDRA-4626


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

Branch: refs/heads/trunk
Commit: 19800189d76453cf08af60e21a544729565714ba
Parents: d391726
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Fri Sep 7 16:14:58 2012 +0200
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Sep 7 18:32:31 2012 +0200

----------------------------------------------------------------------
 CHANGES.txt                                       |    1 +
 src/java/org/apache/cassandra/db/SystemTable.java |   44 +++++----------
 2 files changed, 16 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/19800189/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 8a0ce59..6157022 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,7 @@
  * (Hadoop) fix setting key length for old-style mapred api (CASSANDRA-4534)
  * (Hadoop) fix iterating through a resultset consisting entirely
    of tombstoned rows (CASSANDRA-4466)
+ * Fix multiple values for CurrentLocal NodeID (CASSANDRA-4626)
 
 
 1.0.11

http://git-wip-us.apache.org/repos/asf/cassandra/blob/19800189/src/java/org/apache/cassandra/db/SystemTable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemTable.java b/src/java/org/apache/cassandra/db/SystemTable.java
index 628719b..7b96c6f 100644
--- a/src/java/org/apache/cassandra/db/SystemTable.java
+++ b/src/java/org/apache/cassandra/db/SystemTable.java
@@ -430,25 +430,19 @@ public class SystemTable
     {
         ByteBuffer id = null;
         Table table = Table.open(Table.SYSTEM_TABLE);
-        QueryFilter filter = QueryFilter.getIdentityFilter(decorate(CURRENT_LOCAL_NODE_ID_KEY),
-                new QueryPath(NODE_ID_CF));
+
+        // Get the last NodeId (since NodeId are timeuuid is thus ordered from the older
to the newer one)
+        QueryFilter filter = QueryFilter.getSliceFilter(decorate(ALL_LOCAL_NODE_ID_KEY),
+                                                        new QueryPath(NODE_ID_CF),
+                                                        ByteBufferUtil.EMPTY_BYTE_BUFFER,
+                                                        ByteBufferUtil.EMPTY_BYTE_BUFFER,
+                                                        true,
+                                                        1);
         ColumnFamily cf = table.getColumnFamilyStore(NODE_ID_CF).getColumnFamily(filter);
-        if (cf != null)
-        {
-            // Even though gc_grace==0 on System table, we can have a race where we get back
tombstones (see CASSANDRA-2824)
-            cf = ColumnFamilyStore.removeDeleted(cf, 0);
-            assert cf.getColumnCount() <= 1;
-            if (cf.getColumnCount() > 0)
-                id = cf.iterator().next().name();
-        }
-        if (id != null)
-        {
-            return NodeId.wrap(id);
-        }
+        if (cf != null && cf.getColumnCount() != 0)
+            return NodeId.wrap(cf.iterator().next().name());
         else
-        {
             return null;
-        }
     }
 
     /**
@@ -465,24 +459,17 @@ public class SystemTable
 
         ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_TABLE, NODE_ID_CF);
         cf.addColumn(new Column(newNodeId.bytes(), ip, now));
-        ColumnFamily cf2 = cf.cloneMe();
-        if (oldNodeId != null)
-        {
-            cf2.addColumn(new DeletedColumn(oldNodeId.bytes(), (int) (now / 1000), now));
-        }
-        RowMutation rmCurrent = new RowMutation(Table.SYSTEM_TABLE, CURRENT_LOCAL_NODE_ID_KEY);
-        RowMutation rmAll = new RowMutation(Table.SYSTEM_TABLE, ALL_LOCAL_NODE_ID_KEY);
-        rmCurrent.add(cf2);
-        rmAll.add(cf);
+        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, ALL_LOCAL_NODE_ID_KEY);
+        rm.add(cf);
         try
         {
-            rmCurrent.apply();
-            rmAll.apply();
+            rm.apply();
         }
         catch (IOException e)
         {
             throw new RuntimeException(e);
         }
+        forceBlockingFlush(NODE_ID_CF);
     }
 
     public static List<NodeId.NodeIdRecord> getOldLocalNodeIds()
@@ -490,8 +477,7 @@ public class SystemTable
         List<NodeId.NodeIdRecord> l = new ArrayList<NodeId.NodeIdRecord>();
 
         Table table = Table.open(Table.SYSTEM_TABLE);
-        QueryFilter filter = QueryFilter.getIdentityFilter(decorate(ALL_LOCAL_NODE_ID_KEY),
-                new QueryPath(NODE_ID_CF));
+        QueryFilter filter = QueryFilter.getIdentityFilter(decorate(ALL_LOCAL_NODE_ID_KEY),
new QueryPath(NODE_ID_CF));
         ColumnFamily cf = table.getColumnFamilyStore(NODE_ID_CF).getColumnFamily(filter);
 
         NodeId previous = null;


Mime
View raw message