Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into USERGRID-1200
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Dunker committed Jan 19, 2016
2 parents 90d5d66 + d796b68 commit a33698b
Show file tree
Hide file tree
Showing 97 changed files with 2,350 additions and 2,840 deletions.
1 change: 0 additions & 1 deletion stack/awscluster/src/main/dist/lib/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ log4j.logger.org.apache.usergrid.persistence.cassandra.ConnectionRefImpl=WARN, s
log4j.logger.me.prettyprint.cassandra.hector.TimingLogger=WARN, stdout
log4j.logger.org.apache.usergrid.rest.security.AllowAjaxFilter=WARN, stdout
log4j.logger.me.prettyprint.hector.api.beans.AbstractComposite=ERROR, stdout
log4j.logger.org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl=DEBUG, stdout

#log4j.logger.org.apache.usergrid.persistence=INFO
#log4j.logger.org.apache.usergrid.corepersistence=DEBUG
Expand Down
5 changes: 0 additions & 5 deletions stack/config/src/test/resources/usergrid-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ usergrid.binary.bucketname=usergrid-test-bucket
# Where to store temporary files
usergrid.temp.files=/tmp/usergrid

# Zookeeper instances
zookeeper.hosts=localhost:2180
zookeeper.sessionTimeout = 3000
zookeeper.maxAttempts = 3

usergrid.api.url.base=http://localhost:8080

AWS_ACCESS_KEY_ID=
Expand Down
10 changes: 5 additions & 5 deletions stack/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,6 @@
<artifactId>commons-beanutils</artifactId>
</dependency>

<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</dependency>

<!-- SUN, Javax Package, and Other Commercial Dependencies -->

<dependency>
Expand Down Expand Up @@ -219,6 +214,11 @@
<artifactId>curator-recipes</artifactId>
</dependency>

<dependency>
<groupId>com.netflix.astyanax</groupId>
<artifactId>astyanax-recipes</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.concurrent.TimeUnit;

import org.elasticsearch.common.inject.Inject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.apache.usergrid.batch.Job;
Expand All @@ -37,7 +38,7 @@
@Component("OnlyOnceJob")
public abstract class OnlyOnceJob implements Job {

@Autowired
@Inject
private LockManager lockManager;

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.apache.usergrid.corepersistence;


import org.apache.usergrid.locking.guice.LockModule;
import org.apache.usergrid.persistence.cache.guice.CacheModule;
import java.util.concurrent.ThreadPoolExecutor;

Expand Down Expand Up @@ -94,6 +95,7 @@ public class CoreModule extends AbstractModule {
protected void configure() {

install( new CommonModule());
install( new LockModule());
install( new CacheModule());
install( new CollectionModule() {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public interface AsyncEventsSchedulerFig extends GuicyFig {



@Default( "100" )
@Default( "40" )
@Key( IO_SCHEDULER_THREADS )
int getMaxIoThreads();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public interface IndexProcessorFig extends GuicyFig {
/**
* The number of worker threads used when handing off messages from the SQS thread
*/
@Default( "20" )
@Default( "5" )
@Key( EVENT_CONCURRENCY_FACTOR )
int getEventConcurrencyFactor();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,76 @@
package org.apache.usergrid.locking.cassandra;


import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import com.netflix.astyanax.recipes.locks.ColumnPrefixDistributedRowLock;

import com.netflix.astyanax.retry.RetryPolicy;
import com.netflix.astyanax.retry.RunOnce;
import org.apache.usergrid.locking.Lock;
import org.apache.usergrid.locking.exception.UGLockException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import me.prettyprint.hector.api.locking.HLock;
import me.prettyprint.hector.api.locking.HLockManager;
import me.prettyprint.hector.api.locking.HLockTimeoutException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;


/** @author tnine */
public class HectorLockImpl implements Lock {
public class AstyanaxLockImpl implements Lock {

private HLock lock;
private HLockManager lm;
private AtomicInteger count = new AtomicInteger();
private ColumnPrefixDistributedRowLock lock;


public AstyanaxLockImpl( ColumnPrefixDistributedRowLock lock ) {

/**
*
*/
public HectorLockImpl( HLock lock, HLockManager lm ) {
this.lock = lock;
this.lm = lm;

}


/* (non-Javadoc)
* @see org.apache.usergrid.locking.Lock#acquire(long, java.util.concurrent.TimeUnit)
*/
@Override
public boolean tryLock( long timeout, TimeUnit time ) throws UGLockException {

try {
lm.acquire( this.lock, time.toMillis( timeout ) );

lock.acquire();
count.incrementAndGet();
}
catch ( HLockTimeoutException hlte ) {

} catch (Exception e) {
return false;
}

return true;
}


/* (non-Javadoc)
* @see org.apache.usergrid.locking.Lock#lock()
*/
@Override
public void lock() throws UGLockException {
lm.acquire( lock );
count.incrementAndGet();
}

try {

lock.acquire();
count.incrementAndGet();

} catch (Exception e) {
throw new UGLockException("Unable to acquire lock with id: " + lock.getLockId());
}
}

/* (non-Javadoc)
* @see org.apache.usergrid.locking.Lock#release()
*/
@Override
public void unlock() throws UGLockException {

// all re-entrant locks to be used and only release them all when the count is 0
int current = count.decrementAndGet();

if ( current == 0 ) {
lm.release( this.lock );
try {

if ( current == 0 ) {
lock.release();
}

} catch (Exception e) {
throw new UGLockException("Unable to release lock with id: " + lock.getLockId());
}

}

}
Loading

0 comments on commit a33698b

Please sign in to comment.