Permalink
Browse files

Merge branch 'cassandra-1.2.0' into cassandra-1.2

  • Loading branch information...
2 parents 8c16833 + bac9794 commit fc416fab0b21db5d9c9a14fb99f7c139cec64247 @pcmanus pcmanus committed Dec 7, 2012
Showing with 148 additions and 147 deletions.
  1. +2 −0 CHANGES.txt
  2. +29 −23 src/java/org/apache/cassandra/config/CFMetaData.java
  3. +1 −1 src/java/org/apache/cassandra/db/RowMutation.java
  4. +1 −1 src/java/org/apache/cassandra/db/marshal/UUIDType.java
  5. +1 −13 src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
  6. +1 −1 src/java/org/apache/cassandra/service/AntiEntropyService.java
  7. +2 −0 src/java/org/apache/cassandra/service/MigrationManager.java
  8. +1 −1 src/java/org/apache/cassandra/streaming/StreamInSession.java
  9. +1 −1 src/java/org/apache/cassandra/streaming/StreamOutSession.java
  10. +1 −1 src/java/org/apache/cassandra/streaming/StreamingRepairTask.java
  11. +1 −1 src/java/org/apache/cassandra/thrift/CassandraServer.java
  12. +1 −1 src/java/org/apache/cassandra/tracing/TraceState.java
  13. +1 −1 src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java
  14. +1 −1 src/java/org/apache/cassandra/transport/messages/PrepareMessage.java
  15. +1 −1 src/java/org/apache/cassandra/transport/messages/QueryMessage.java
  16. +1 −1 src/java/org/apache/cassandra/utils/CounterId.java
  17. +21 −0 src/java/org/apache/cassandra/utils/FBUtilities.java
  18. +47 −52 src/java/org/apache/cassandra/utils/UUIDGen.java
  19. +1 −1 test/unit/org/apache/cassandra/cql/jdbc/ClientUtilsTest.java
  20. +1 −1 test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
  21. +1 −1 test/unit/org/apache/cassandra/db/marshal/DynamicCompositeTypeTest.java
  22. +2 −2 test/unit/org/apache/cassandra/db/marshal/RoundTripTest.java
  23. +7 −7 test/unit/org/apache/cassandra/db/marshal/TimeUUIDTypeTest.java
  24. +9 −22 test/unit/org/apache/cassandra/db/marshal/UUIDTypeTest.java
  25. +1 −1 test/unit/org/apache/cassandra/io/LazilyCompactedRowTest.java
  26. +3 −3 test/unit/org/apache/cassandra/streaming/SerializationsTest.java
  27. +7 −7 test/unit/org/apache/cassandra/utils/UUIDTests.java
  28. +1 −1 tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java
  29. +1 −1 tools/stress/src/org/apache/cassandra/stress/util/Operation.java
View
@@ -12,6 +12,8 @@
* Fix preparing insert queries (CASSANDRA-5016)
* Fix preparing queries with counter increment (CASSANDRA-5022)
* Fix preparing updates with collections (CASSANDRA-5017)
+ * Don't generate UUID based on other node address (CASSANDRA-5002)
+ * Fix message when trying to alter a clustering key type (CASSANDRA-5012)
Merged from 1.1
* Improve schema propagation performance (CASSANDRA-5025)
@@ -731,30 +731,8 @@ public void reload()
public void apply(CFMetaData cfm) throws ConfigurationException
{
logger.debug("applying {} to {}", cfm, this);
- // validate
- if (!cfm.ksName.equals(ksName))
- throw new ConfigurationException(String.format("Keyspace mismatch (found %s; expected %s)",
- cfm.ksName, ksName));
- if (!cfm.cfName.equals(cfName))
- throw new ConfigurationException(String.format("Column family mismatch (found %s; expected %s)",
- cfm.cfName, cfName));
- if (!cfm.cfId.equals(cfId))
- throw new ConfigurationException(String.format("Column family ID mismatch (found %s; expected %s)",
- cfm.cfId, cfId));
- if (!cfm.cfType.equals(cfType))
- throw new ConfigurationException("types do not match.");
-
- if (!cfm.comparator.isCompatibleWith(comparator))
- throw new ConfigurationException("comparators do not match or are not compatible.");
- if (cfm.subcolumnComparator == null)
- {
- if (subcolumnComparator != null)
- throw new ConfigurationException("subcolumncomparators do not match.");
- // else, it's null and we're good.
- }
- else if (!cfm.subcolumnComparator.isCompatibleWith(subcolumnComparator))
- throw new ConfigurationException("subcolumncomparators do not match or are note compatible.");
+ validateCompatility(cfm);
// TODO: this method should probably return a new CFMetaData so that
// 1) we can keep comparator and subcolumnComparator final
@@ -813,6 +791,34 @@ else if (!cfm.subcolumnComparator.isCompatibleWith(subcolumnComparator))
logger.debug("application result is {}", this);
}
+ public void validateCompatility(CFMetaData cfm) throws ConfigurationException
+ {
+ // validate
+ if (!cfm.ksName.equals(ksName))
+ throw new ConfigurationException(String.format("Keyspace mismatch (found %s; expected %s)",
+ cfm.ksName, ksName));
+ if (!cfm.cfName.equals(cfName))
+ throw new ConfigurationException(String.format("Column family mismatch (found %s; expected %s)",
+ cfm.cfName, cfName));
+ if (!cfm.cfId.equals(cfId))
+ throw new ConfigurationException(String.format("Column family ID mismatch (found %s; expected %s)",
+ cfm.cfId, cfId));
+
+ if (!cfm.cfType.equals(cfType))
+ throw new ConfigurationException("types do not match.");
+
+ if (!cfm.comparator.isCompatibleWith(comparator))
+ throw new ConfigurationException("comparators do not match or are not compatible.");
+ if (cfm.subcolumnComparator == null)
+ {
+ if (subcolumnComparator != null)
+ throw new ConfigurationException("subcolumncomparators do not match.");
+ // else, it's null and we're good.
+ }
+ else if (!cfm.subcolumnComparator.isCompatibleWith(subcolumnComparator))
+ throw new ConfigurationException("subcolumncomparators do not match or are note compatible.");
+ }
+
public static Class<? extends AbstractCompactionStrategy> createCompactionStrategy(String className) throws ConfigurationException
{
className = className.contains(".") ? className : "org.apache.cassandra.db.compaction." + className;
@@ -105,7 +105,7 @@ public ColumnFamily getColumnFamily(UUID cfId)
public static RowMutation hintFor(RowMutation mutation, UUID targetId) throws IOException
{
RowMutation rm = new RowMutation(Table.SYSTEM_KS, UUIDType.instance.decompose(targetId));
- UUID hintId = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress());
+ UUID hintId = UUIDGen.getTimeUUID();
// determine the TTL for the RowMutation
// this is set at the smallest GCGraceSeconds for any of the CFs in the RM
@@ -212,7 +212,7 @@ public ByteBuffer fromString(String source) throws MarshalException
}
else if (source.toLowerCase().equals("now"))
{
- idBytes = ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress())));
+ idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
}
// Milliseconds since epoch?
else if (source.matches("^\\d+$"))
@@ -19,8 +19,6 @@
import java.io.IOException;
import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.*;
@@ -197,17 +195,7 @@ public boolean nextKeyValue() throws IOException
// not necessarily on Cassandra machines, too. This should be adequate for single-DC clusters, at least.
private String getLocation()
{
- ArrayList<InetAddress> localAddresses = new ArrayList<InetAddress>();
- try
- {
- Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
- while (nets.hasMoreElements())
- localAddresses.addAll(Collections.list(nets.nextElement().getInetAddresses()));
- }
- catch (SocketException e)
- {
- throw new AssertionError(e);
- }
+ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses();
for (InetAddress address : localAddresses)
{
@@ -603,7 +603,7 @@ public RepairSession(TreeRequest req, String tablename, String... cfnames)
public RepairSession(Range<Token> range, String tablename, boolean isSequential, boolean isLocal, String... cfnames)
{
- this(UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress()).toString(), range, tablename, isSequential, isLocal, cfnames);
+ this(UUIDGen.getTimeUUID().toString(), range, tablename, isSequential, isLocal, cfnames);
}
private RepairSession(String id, Range<Token> range, String tablename, boolean isSequential, boolean isLocal, String[] cfnames)
@@ -220,6 +220,8 @@ public static void announceColumnFamilyUpdate(CFMetaData cfm) throws Configurati
if (oldCfm == null)
throw new ConfigurationException(String.format("Cannot update non existing column family '%s' in keyspace '%s'.", cfm.cfName, cfm.ksName));
+ oldCfm.validateCompatility(cfm);
+
logger.info(String.format("Update ColumnFamily '%s/%s' From %s To %s", cfm.ksName, cfm.cfName, oldCfm, cfm));
announce(oldCfm.toSchemaUpdate(cfm, FBUtilities.timestampMicros()));
}
@@ -59,7 +59,7 @@ private StreamInSession(InetAddress host, UUID sessionId, IStreamCallback callba
public static StreamInSession create(InetAddress host, IStreamCallback callback)
{
- StreamInSession session = new StreamInSession(host, UUIDGen.makeType1UUIDFromHost(host), callback);
+ StreamInSession session = new StreamInSession(host, UUIDGen.getTimeUUID(), callback);
sessions.put(session.getSessionId(), session);
return session;
}
@@ -44,7 +44,7 @@
public static StreamOutSession create(String table, InetAddress host, IStreamCallback callback)
{
- return create(table, host, UUIDGen.makeType1UUIDFromHost(host), callback);
+ return create(table, host, UUIDGen.getTimeUUID(), callback);
}
public static StreamOutSession create(String table, InetAddress host, UUID sessionId)
@@ -90,7 +90,7 @@ private StreamingRepairTask(UUID id, InetAddress owner, InetAddress src, InetAdd
public static StreamingRepairTask create(InetAddress ep1, InetAddress ep2, String tableName, String cfName, Collection<Range<Token>> ranges, Runnable callback)
{
InetAddress local = FBUtilities.getBroadcastAddress();
- UUID id = UUIDGen.makeType1UUIDFromHost(local);
+ UUID id = UUIDGen.getTimeUUID();
// We can take anyone of the node as source or destination, however if one is localhost, we put at source to avoid a forwarding
InetAddress src = ep2.equals(local) ? ep2 : ep1;
InetAddress dst = ep2.equals(local) ? ep1 : ep2;
@@ -1817,7 +1817,7 @@ public void set_cql_version(String version) throws InvalidRequestException
public ByteBuffer trace_next_query() throws TException
{
- UUID sessionId = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress());
+ UUID sessionId = UUIDGen.getTimeUUID();
state().getQueryState().prepareTracingSession(sessionId);
return TimeUUIDType.instance.decompose(sessionId);
}
@@ -85,7 +85,7 @@ public void trace(String format, Object[] args)
public void trace(final String message)
{
final int elapsed = elapsed();
- final ByteBuffer eventId = ByteBufferUtil.bytes(UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress()));
+ final ByteBuffer eventId = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
final String threadName = Thread.currentThread().getName();
@@ -108,7 +108,7 @@ public ChannelBuffer encode()
UUID tracingId = null;
if (isTracingRequested())
{
- tracingId = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress());
+ tracingId = UUIDGen.getTimeUUID();
state.prepareTracingSession(tracingId);
}
@@ -65,7 +65,7 @@ public ChannelBuffer encode()
UUID tracingId = null;
if (isTracingRequested())
{
- tracingId = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress());
+ tracingId = UUIDGen.getTimeUUID();
state.prepareTracingSession(tracingId);
}
@@ -75,7 +75,7 @@ public ChannelBuffer encode()
UUID tracingId = null;
if (isTracingRequested())
{
- tracingId = UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress());
+ tracingId = UUIDGen.getTimeUUID();
state.prepareTracingSession(tracingId);
}
@@ -117,7 +117,7 @@ private CounterId(ByteBuffer id)
public static CounterId generate()
{
- return new CounterId(ByteBuffer.wrap(UUIDGen.decompose(UUIDGen.makeType1UUIDFromHost(FBUtilities.getBroadcastAddress()))));
+ return new CounterId(ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes()));
}
/*
@@ -22,6 +22,8 @@
import java.lang.reflect.InvocationTargetException;
import java.math.BigInteger;
import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
@@ -154,6 +156,25 @@ public static InetAddress getBroadcastAddress()
return broadcastInetAddress;
}
+ public static Collection<InetAddress> getAllLocalAddresses()
+ {
+ Set<InetAddress> localAddresses = new HashSet<InetAddress>();
+ try
+ {
+ Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
+ if (nets != null)
+ {
+ while (nets.hasMoreElements())
+ localAddresses.addAll(Collections.list(nets.nextElement().getInetAddresses()));
+ }
+ }
+ catch (SocketException e)
+ {
+ throw new AssertionError(e);
+ }
+ return localAddresses;
+ }
+
/**
* Given two bit arrays represented as BigIntegers, containing the given
* number of significant bits, calculate a midpoint.
Oops, something went wrong.

0 comments on commit fc416fa

Please sign in to comment.