You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by xe...@apache.org on 2012/09/10 23:45:18 UTC
[4/8] git commit: Multiple values for CurrentLocal Node ID
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/9b08a7f1
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9b08a7f1
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9b08a7f1
Branch: refs/heads/trunk
Commit: 9b08a7f187e14e93ed06e7a07b34a0ce64c1aa46
Parents: dcf27a5
Author: Sylvain Lebresne <sy...@datastax.com>
Authored: Fri Sep 7 16:14:58 2012 +0200
Committer: Pavel Yaskevich <xe...@apache.org>
Committed: Tue Sep 11 00:12:09 2012 +0300
----------------------------------------------------------------------
CHANGES.txt | 3 +
src/java/org/apache/cassandra/db/SystemTable.java | 50 ++++++----------
2 files changed, 21 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b08a7f1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9ae8999..a6141f9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -97,6 +97,9 @@ Merged from 1.0:
(CASSANDRA-4494)
Merged from 1.0:
* (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)
* munmap commitlog segments before rename (CASSANDRA-4337)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/9b08a7f1/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 1cbab1a..8ff2b8d 100644
--- a/src/java/org/apache/cassandra/db/SystemTable.java
+++ b/src/java/org/apache/cassandra/db/SystemTable.java
@@ -450,25 +450,19 @@ public class SystemTable
{
ByteBuffer id = null;
Table table = Table.open(Table.SYSTEM_KS);
- 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);
- // 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);
- if (cf != null)
- {
- 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;
- }
}
/**
@@ -482,21 +476,14 @@ public class SystemTable
*/
public static void writeCurrentLocalNodeId(NodeId oldNodeId, NodeId newNodeId, long now)
{
+ ByteBuffer ip = ByteBuffer.wrap(FBUtilities.getBroadcastAddress().getAddress());
+
ColumnFamily cf = ColumnFamily.create(Table.SYSTEM_KS, NODE_ID_CF);
- cf.addColumn(new Column(newNodeId.bytes(), ByteBufferUtil.EMPTY_BYTE_BUFFER, now));
- ColumnFamily cf2 = cf.cloneMe();
- if (oldNodeId != null)
- {
- // previously used (int)(now /1000) for the localDeletionTime
- // tests use single digit long values for now, so use actual time.
- cf2.addColumn(new DeletedColumn(oldNodeId.bytes(), (int)(System.currentTimeMillis() / 1000), now));
- }
- RowMutation rmCurrent = new RowMutation(Table.SYSTEM_KS, CURRENT_LOCAL_NODE_ID_KEY);
- RowMutation rmAll = new RowMutation(Table.SYSTEM_KS, ALL_LOCAL_NODE_ID_KEY);
- rmCurrent.add(cf2);
- rmAll.add(cf);
- rmCurrent.apply();
- rmAll.apply();
+ cf.addColumn(new Column(newNodeId.bytes(), ip, now));
+ RowMutation rm = new RowMutation(Table.SYSTEM_KS, ALL_LOCAL_NODE_ID_KEY);
+ rm.add(cf);
+ rm.apply();
+ forceBlockingFlush(NODE_ID_CF);
}
public static List<NodeId.NodeIdRecord> getOldLocalNodeIds()
@@ -504,8 +491,7 @@ public class SystemTable
List<NodeId.NodeIdRecord> l = new ArrayList<NodeId.NodeIdRecord>();
Table table = Table.open(Table.SYSTEM_KS);
- 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;