Permalink
Browse files

Merge pull request #551 from apigee/locking

Made ack size configurable.  The first 10 elements is more than
  • Loading branch information...
2 parents 0080431 + ea13a02 commit 0ef3b1f0f6dd018c2c30f04adb27c6b14c92ab59 @zznate zznate committed Nov 7, 2012
@@ -49,12 +49,14 @@
private ScheduledExecutorService scheduler;
private long lockTtl = 5000;
private int colTtl = 5;
-
+ private int maxSelectSize = 10;
+
public HLockManagerImpl(Cluster cluster, HLockManagerConfigurator hlc) {
super(cluster, hlc);
scheduler = Executors.newScheduledThreadPool(lockManagerConfigurator.getNumberOfLockObserverThreads());
lockTtl = lockManagerConfigurator.getLocksTTLInMillis();
colTtl = (int) (lockTtl / 1000);
+ maxSelectSize = hlc.getMaxSelectSize();
}
/*
@@ -281,7 +283,8 @@ private void deleteLock(HLock lock) {
.createSliceQuery(keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get())
.setColumnFamily(lockManagerConfigurator.getLockManagerCF()).setKey(lock.getPath());
- sliceQuery.setRange(null, null, false, Integer.MAX_VALUE);
+ //we only care about the first 2 locks, anything else is simply queued. Select 10 just to be safe if the clients aren't ordered properly
+ sliceQuery.setRange(null, null, false, maxSelectSize);
QueryResult<ColumnSlice<String, String>> queryResult = sliceQuery.execute();
@@ -3,6 +3,7 @@
/**
*
* @author patricioe (Patricio Echague - patricioe@gmail.com)
+ * @author tnine (Todd Nine)
*
*/
public class HLockManagerConfigurator {
@@ -17,6 +18,7 @@
private long backOffRetryDelayInMillis = 100L;
private int replicationFactor = 3;
private int numberOfLockObserverThreads = 1;
+ private int maxSelectSize = 10;
public String getLockManagerCF() {
return lockManagerCF;
@@ -80,25 +82,31 @@ public void setNumberOfLockObserverThreads(int numberOfLockObserverThreads) {
this.numberOfLockObserverThreads = numberOfLockObserverThreads;
}
+ /**
+ * @return the maxSelectSize
+ */
+ public int getMaxSelectSize() {
+ return maxSelectSize;
+ }
+
+ /**
+ * @param maxSelectSize the maxSelectSize to set
+ */
+ public void setMaxSelectSize(int maxSelectSize) {
+ this.maxSelectSize = maxSelectSize;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
@Override
public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("HLockManagerConfigurator [keyspaceName=");
- builder.append(keyspaceName);
- builder.append(", lockManagerCF=");
- builder.append(lockManagerCF);
- builder.append(", rowsCacheEnabled=");
- builder.append(rowsCacheEnabled);
- builder.append(", locksTTLInMillis=");
- builder.append(locksTTLInMillis);
- builder.append(", backOffRetryDelayInMillis=");
- builder.append(backOffRetryDelayInMillis);
- builder.append(", replicationFactor=");
- builder.append(replicationFactor);
- builder.append(", numberOfLockObserverThreads=");
- builder.append(numberOfLockObserverThreads);
- builder.append("]");
- return builder.toString();
+ return "HLockManagerConfigurator [keyspaceName=" + keyspaceName + ", lockManagerCF=" + lockManagerCF
+ + ", rowsCacheEnabled=" + rowsCacheEnabled + ", locksTTLInMillis=" + locksTTLInMillis
+ + ", backOffRetryDelayInMillis=" + backOffRetryDelayInMillis + ", replicationFactor=" + replicationFactor
+ + ", numberOfLockObserverThreads=" + numberOfLockObserverThreads + ", maxSelectSize=" + maxSelectSize + "]";
}
+
+
}
@@ -6,11 +6,11 @@
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
</layout>
</appender>
- <!-- -->
+ <!--
<logger name="me.prettyprint.cassandra.locking" additivity="false">
<level value="debug" />
<appender-ref ref="stdout" />
- </logger>
+ </logger>-->
<root>
<priority value="info"></priority>
<appender-ref ref="stdout" />

0 comments on commit 0ef3b1f

Please sign in to comment.