Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made ack size configurable. The first 10 elements is more than #551

Merged
merged 1 commit into from Nov 7, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -49,12 +49,14 @@ public class HLockManagerImpl extends AbstractLockManager {
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();
}

/*
Expand Down Expand Up @@ -281,7 +283,8 @@ private Map<String, String> readExistingLocks(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();

Expand Down
Expand Up @@ -3,6 +3,7 @@
/**
*
* @author patricioe (Patricio Echague - patricioe@gmail.com)
* @author tnine (Todd Nine)
*
*/
public class HLockManagerConfigurator {
Expand All @@ -17,6 +18,7 @@ public class HLockManagerConfigurator {
private long backOffRetryDelayInMillis = 100L;
private int replicationFactor = 3;
private int numberOfLockObserverThreads = 1;
private int maxSelectSize = 10;

public String getLockManagerCF() {
return lockManagerCF;
Expand Down Expand Up @@ -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 + "]";
}



}
4 changes: 2 additions & 2 deletions core/src/test/resources/log4j.xml
Expand Up @@ -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" />
Expand Down