Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

account for clock skew

  • Loading branch information...
commit 3408a305b9f1ce9bc19f3079a21f334a58052b19 1 parent a680256
@tjake authored
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/lucandra/cluster/CassandraIndexManager.java
View
16 src/lucandra/cluster/CassandraIndexManager.java
@@ -54,6 +54,7 @@
private int[] randomSeq;
+ private final Random r;
public static final int maxDocsPerShard = Integer
.valueOf(CassandraUtils.properties
.getProperty(
@@ -78,7 +79,8 @@
public final String indexName;
private long ttl;
public final ConcurrentSkipListMap<Integer, NodeInfo> shards = new ConcurrentSkipListMap<Integer, NodeInfo>();
-
+
+
public ShardInfo(String indexName)
{
this.indexName = indexName;
@@ -87,7 +89,7 @@ public ShardInfo(String indexName)
public void renew()
{
- ttl = System.currentTimeMillis() + (expirationTime * 1000) - 1000;
+ ttl = System.currentTimeMillis() + (expirationTime * 1000) + r.nextInt(5000);
}
public long ttl()
@@ -272,7 +274,7 @@ public CassandraIndexManager(int shardsAtOnce)
logger.info("Shards at once: " + shardsAtOnce);
// get our unique sequence
- Random r = null;
+
try
{
r = new Random(getNodeSeed(getToken()));
@@ -705,6 +707,14 @@ private Long nextReservedId(String indexName, NodeInfo[] shards, String myToken)
CassandraUtils.robustInsert(ConsistencyLevel.QUORUM, rm);
+ //Give it time to sink in, in-case clocks are off...
+ try
+ {
+ Thread.sleep(100);
+ } catch (InterruptedException e1)
+ {
+ }
+
// Read the columns back
IColumn supercol = null;
int attempts = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.