usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [09/12] usergrid git commit: Remove unused SingleNodeLockImpl and any references to this.
Date Sat, 16 Jan 2016 00:44:49 GMT
Remove unused SingleNodeLockImpl and any references to this.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0071df0e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0071df0e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0071df0e

Branch: refs/heads/master
Commit: 0071df0e235181f47ac370257b99c4de1d7705f7
Parents: 5685092
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Thu Jan 14 18:53:14 2016 -0800
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Thu Jan 14 18:53:14 2016 -0800

----------------------------------------------------------------------
 .../src/main/dist/lib/log4j.properties          |   1 -
 .../locking/singlenode/SingleNodeLockImpl.java  |  71 --------
 .../singlenode/SingleNodeLockManagerImpl.java   |  96 -----------
 .../main/resources/usergrid-core-context.xml    |   5 -
 .../locking/SingleNodeLockTestSingleNode.java   | 163 -------------------
 stack/core/src/test/resources/log4j.properties  |   1 -
 stack/rest/src/test/resources/log4j.properties  |   1 -
 .../src/test/resources/log4j.properties         |   1 -
 stack/tools/src/main/resources/log4j.properties |   1 -
 9 files changed, 340 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/awscluster/src/main/dist/lib/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/lib/log4j.properties b/stack/awscluster/src/main/dist/lib/log4j.properties
index 52f99ce..013563b 100644
--- a/stack/awscluster/src/main/dist/lib/log4j.properties
+++ b/stack/awscluster/src/main/dist/lib/log4j.properties
@@ -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

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockImpl.java
b/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockImpl.java
deleted file mode 100644
index 109307d..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.locking.singlenode;
-
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.usergrid.locking.Lock;
-import org.apache.usergrid.locking.exception.UGLockException;
-
-
-/** @author tnine */
-public class SingleNodeLockImpl implements Lock {
-
-    private final ReentrantLock lock;
-
-
-    /**
-     *
-     */
-    public SingleNodeLockImpl( ReentrantLock lock ) {
-        this.lock = lock;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.locking.Lock#acquire(long)
-     */
-    @Override
-    public boolean tryLock( long timeout, TimeUnit time ) throws UGLockException {
-        try {
-            return this.lock.tryLock( timeout, time );
-        }
-        catch ( InterruptedException e ) {
-            throw new UGLockException( "Couldn't get the lock", e );
-        }
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.locking.Lock#lock()
-     */
-    @Override
-    public void lock() throws UGLockException {
-        this.lock.lock();
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.locking.Lock#release()
-     */
-    @Override
-    public void unlock() throws UGLockException {
-        this.lock.unlock();
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockManagerImpl.java
b/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockManagerImpl.java
deleted file mode 100644
index de33772..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/locking/singlenode/SingleNodeLockManagerImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.locking.singlenode;
-
-
-import java.util.UUID;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.locking.Lock;
-import org.apache.usergrid.locking.LockManager;
-import org.apache.usergrid.locking.LockPathBuilder;
-
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
-
-
-/**
- * Single Node implementation for {@link LockManager} Note that this implementation has not
been used in a production
- * environment.
- * <p/>
- * The hector based implementation is the preferred production locking system
- */
-public class SingleNodeLockManagerImpl implements LockManager {
-
-    private static final Logger logger = LoggerFactory.getLogger( SingleNodeLockManagerImpl.class
);
-
-    public static final long MILLI_EXPIRATION = 5000;
-
-    /** Lock cache that sill expire after 5 seconds of no use for a lock path */
-    private LoadingCache<String, ReentrantLock> locks =
-            CacheBuilder.newBuilder().expireAfterWrite( MILLI_EXPIRATION, TimeUnit.MILLISECONDS
)
-                    // use weakValues. We want want entries removed if they're not being
-                    // referenced by another
-                    // thread somewhere and GC occurs
-                    .weakValues().removalListener( new RemovalListener<String, ReentrantLock>()
{
-
-                @Override
-                public void onRemoval( RemovalNotification<String, ReentrantLock> notification
) {
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Evicting reentrant lock for {}", notification.getKey());
-                    }
-                }
-            } ).build( new CacheLoader<String, ReentrantLock>() {
-
-                @Override
-                public ReentrantLock load( String arg0 ) throws Exception {
-                    return new ReentrantLock( true );
-                }
-            } );
-
-
-    /** Default constructor. */
-    public SingleNodeLockManagerImpl() {
-    }
-
-
-    /*
-   * (non-Javadoc)
-   *
-   * @see org.apache.usergrid.locking.LockManager#createLock(java.util.UUID,
-   * java.lang.String[])
-   */
-    @Override
-    public Lock createLock( UUID applicationId, String... path ) {
-
-        String lockPath = LockPathBuilder.buildPath( applicationId, path );
-
-        try {
-            return new SingleNodeLockImpl( locks.get( lockPath ) );
-        }
-        catch ( ExecutionException e ) {
-            throw new RuntimeException( "Unable to create lock in cache", e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/core/src/main/resources/usergrid-core-context.xml
----------------------------------------------------------------------
diff --git a/stack/core/src/main/resources/usergrid-core-context.xml b/stack/core/src/main/resources/usergrid-core-context.xml
index fb668fa..1087f25 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -68,11 +68,6 @@
 
     <bean id="loadBalancingPolicy" class="me.prettyprint.cassandra.connection.DynamicLoadBalancingPolicy"/>
 
-	<!--  locking for a single node -->
-
-    <!-- <bean name="lockManager" class="org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl"
/> -->
-
-
     <bean id="injector"
    		class="org.apache.usergrid.corepersistence.GuiceFactory">
     </bean>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/core/src/test/java/org/apache/usergrid/locking/SingleNodeLockTestSingleNode.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/locking/SingleNodeLockTestSingleNode.java
b/stack/core/src/test/java/org/apache/usergrid/locking/SingleNodeLockTestSingleNode.java
deleted file mode 100644
index ba7b48d..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/locking/SingleNodeLockTestSingleNode.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.locking;
-
-
-import org.apache.usergrid.locking.exception.UGLockException;
-import org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.UUID;
-import java.util.concurrent.*;
-
-import static org.junit.Assert.assertTrue;
-
-
-public class SingleNodeLockTestSingleNode {
-
-    private static final Logger logger = LoggerFactory.getLogger( SingleNodeLockTestSingleNode.class
);
-
-    private LockManager manager;
-
-    private ExecutorService pool;
-
-
-    @Before
-    public void setUp() throws Exception {
-
-        manager = new SingleNodeLockManagerImpl();
-
-        // Create a different thread to lock the same node, that is held by the main
-        // thread.
-        pool = Executors.newFixedThreadPool( 1 );
-    }
-
-
-    @After
-    public void tearDown() throws Exception {
-        pool.shutdownNow();
-    }
-
-
-    /** Locks a path and launches a thread which also locks the same path. */
-    @Test
-    public void testLock() throws InterruptedException, ExecutionException, UGLockException
{
-
-        final UUID application = UUID.randomUUID();
-        final UUID entity = UUID.randomUUID();
-
-        logger.info( "Locking:" + application.toString() + "/" + entity.toString() );
-
-        // Lock a node twice to test reentrancy and validate.
-        Lock lock = manager.createLock( application, entity.toString() );
-        lock.lock();
-        lock.lock();
-
-        boolean wasLocked = lockInDifferentThread( application, entity );
-        Assert.assertEquals( false, wasLocked );
-
-        // Unlock once
-        lock.unlock();
-
-        // Try from the thread expecting to fail since we still hold one reentrant
-        // lock.
-        wasLocked = lockInDifferentThread( application, entity );
-        Assert.assertEquals( false, wasLocked );
-
-        // Unlock completely
-        logger.info( "Releasing lock:" + application.toString() + "/" + entity.toString()
);
-        lock.unlock();
-
-        // Try to effectively get the lock from the thread since the current one has
-        // already released it.
-        wasLocked = lockInDifferentThread( application, entity );
-        Assert.assertEquals( true, wasLocked );
-    }
-
-
-    /** Locks a couple of times and try to clean up. Later oin another thread successfully
acquire the lock */
-    @Test
-    public void testLock2() throws InterruptedException, ExecutionException, UGLockException
{
-
-        final UUID application = UUID.randomUUID();
-        final UUID entity = UUID.randomUUID();
-        final UUID entity2 = UUID.randomUUID();
-
-        logger.info( "Locking:" + application.toString() + "/" + entity.toString() );
-
-        // Acquire to locks. One of them twice.
-        Lock lock = manager.createLock( application, entity.toString() );
-        lock.lock();
-        lock.lock();
-
-        Lock second = manager.createLock( application, entity2.toString() );
-        second.lock();
-
-        // Cleanup the locks for main thread
-        logger.info( "Cleaning up locks for current thread..." );
-        lock.unlock();
-        lock.unlock();
-
-        second.unlock();
-
-        boolean locked = lockInDifferentThread( application, entity );
-        assertTrue( locked );
-
-        locked = lockInDifferentThread( application, entity2 );
-        assertTrue( locked );
-    }
-
-
-    /** Acquires a lock in a different thread. */
-    private boolean lockInDifferentThread( final UUID application, final UUID entity ) {
-        Future<Boolean> status = pool.submit( new Callable<Boolean>() {
-
-            @Override
-            public Boolean call() throws Exception {
-
-                Lock lock = manager.createLock( application, entity.toString() );
-
-                // False here means that the lock WAS NOT ACQUIRED. And that is
-                // what we expect.
-
-                boolean locked = lock.tryLock( 0, TimeUnit.MILLISECONDS );
-
-                // shouldn't lock, so unlock to avoid polluting future tests
-                if ( locked ) {
-                    lock.unlock();
-                }
-
-                return locked;
-            }
-        } );
-
-        boolean wasLocked = true;
-        try {
-            wasLocked = status.get( 2, TimeUnit.SECONDS );
-        }
-        catch ( Exception e ) {
-            wasLocked = false;
-        }
-
-        return wasLocked;
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/core/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/log4j.properties b/stack/core/src/test/resources/log4j.properties
index 4267293..714f2f7 100644
--- a/stack/core/src/test/resources/log4j.properties
+++ b/stack/core/src/test/resources/log4j.properties
@@ -38,7 +38,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.PerformanceEntityReadTest=DEBUG
 log4j.logger.org.apache.usergrid.persistence.PerformanceEntityRebuildIndexTest=DEBUG

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/rest/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/log4j.properties b/stack/rest/src/test/resources/log4j.properties
index 33a25c4..812fc12 100644
--- a/stack/rest/src/test/resources/log4j.properties
+++ b/stack/rest/src/test/resources/log4j.properties
@@ -48,7 +48,6 @@ log4j.logger.org.apache.usergrid.persistence.cassandra.ConnectionRefImpl=WARN
 log4j.logger.me.prettyprint.cassandra.hector.TimingLogger=WARN
 log4j.logger.org.apache.usergrid.rest.security.AllowAjaxFilter=WARN
 log4j.logger.me.prettyprint.hector.api.beans.AbstractComposite=ERROR
-log4j.logger.org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl=DEBUG
 log4j.logger.org.apache.usergrid.rest.filters.MeteringFilter=ERROR
 
 log4j.logger.org.apache.usergrid.rest=DEBUG

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/services/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/log4j.properties b/stack/services/src/test/resources/log4j.properties
index 07e2dde..a557928 100644
--- a/stack/services/src/test/resources/log4j.properties
+++ b/stack/services/src/test/resources/log4j.properties
@@ -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

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0071df0e/stack/tools/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/tools/src/main/resources/log4j.properties b/stack/tools/src/main/resources/log4j.properties
index 1b60906..2b06dc8 100644
--- a/stack/tools/src/main/resources/log4j.properties
+++ b/stack/tools/src/main/resources/log4j.properties
@@ -42,7 +42,6 @@ log4j.logger.me.prettyprint.cassandra.hector.TimingLogger=WARN
 log4j.logger.org.apache.usergrid.rest.security.AllowAjaxFilter=WARN
 log4j.logger.me.prettyprint.hector.api.beans.AbstractComposite=ERROR
 
-#log4j.logger.org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl=DEBUG, stdout
 
 #log4j.logger.org.apache.usergrid.persistence.hector.CountingMutator=INFO
 


Mime
View raw message