Remove unused zookeeper lock manager.

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

Branch: refs/heads/USERGRID-1047
Commit: 8849d8eb2cb443a70e4ad37c4dae119bb198ece4
Parents: 56eb80f
Author: Michael Russo <michaelaru...@gmail.com>
Authored: Wed Jan 13 09:13:39 2016 -0800
Committer: Michael Russo <michaelaru...@gmail.com>
Committed: Wed Jan 13 09:13:39 2016 -0800

----------------------------------------------------------------------
 .../src/test/resources/usergrid-test.properties |   5 -
 stack/core/pom.xml                              |   5 -
 .../zookeeper/ZooKeeperLockManagerImpl.java     | 115 --------
 .../locking/zookeeper/ZookeeperLockImpl.java    |  88 ------
 .../main/resources/usergrid-core-context.xml    |   8 -
 .../zookeeper/AbstractZooKeeperTest.java        | 127 ---------
 .../usergrid/locking/zookeeper/ZooPut.java      | 114 --------
 .../zookeeper/ZookeeperLockManagerTest.java     | 186 -------------
 .../resources/usergrid-standalone.properties    |   4 -
 stack/pom.xml                                   |  32 ---
 .../test/resources/testApplicationContext.xml   | 271 +++++++++----------
 11 files changed, 135 insertions(+), 820 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/config/src/test/resources/usergrid-test.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/test/resources/usergrid-test.properties 
b/stack/config/src/test/resources/usergrid-test.properties
index 111c750..0824673 100644
--- a/stack/config/src/test/resources/usergrid-test.properties
+++ b/stack/config/src/test/resources/usergrid-test.properties
@@ -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
-
 swagger.basepath=http://localhost:8080
 
 AWS_ACCESS_KEY_ID=

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index 7f7dcfb..ae9f915 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -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>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZooKeeperLockManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZooKeeperLockManagerImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZooKeeperLockManagerImpl.java
deleted file mode 100644
index 018e639..0000000
--- 
a/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZooKeeperLockManagerImpl.java
+++ /dev/null
@@ -1,115 +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.zookeeper;
-
-
-import java.util.UUID;
-
-import javax.annotation.PostConstruct;
-
-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.netflix.curator.RetryPolicy;
-import com.netflix.curator.framework.CuratorFramework;
-import com.netflix.curator.framework.CuratorFrameworkFactory;
-import com.netflix.curator.framework.recipes.locks.InterProcessMutex;
-import com.netflix.curator.retry.ExponentialBackoffRetry;
-
-
-/** Implementation for Zookeeper service that handles global locks. */
-public final class ZooKeeperLockManagerImpl implements LockManager {
-
-    private String hostPort;
-
-    private int sessionTimeout = 2000;
-
-    private int maxAttempts = 5;
-
-    private CuratorFramework client;
-
-
-    public ZooKeeperLockManagerImpl( String hostPort, int sessionTimeout, int 
maxAttemps ) {
-        this.hostPort = hostPort;
-        this.sessionTimeout = sessionTimeout;
-        this.maxAttempts = maxAttemps;
-        init();
-    }
-
-
-    public ZooKeeperLockManagerImpl() {
-    }
-
-
-    @PostConstruct
-    public void init() {
-        RetryPolicy retryPolicy = new ExponentialBackoffRetry( sessionTimeout, 
maxAttempts );
-        client = CuratorFrameworkFactory.newClient( hostPort, retryPolicy );
-        client.start();
-    }
-
-
-    protected static final Logger logger = LoggerFactory.getLogger( 
ZooKeeperLockManagerImpl.class );
-
-
-    /*
-     * (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 );
-
-
-        return new ZookeeperLockImpl( new InterProcessMutex( client, lockPath 
) );
-    }
-
-
-    public String getHostPort() {
-        return hostPort;
-    }
-
-
-    public void setHostPort( String hostPort ) {
-        this.hostPort = hostPort;
-    }
-
-
-    public int getSessionTimeout() {
-        return sessionTimeout;
-    }
-
-
-    public void setSessionTimeout( int sessionTimeout ) {
-        this.sessionTimeout = sessionTimeout;
-    }
-
-
-    public int getMaxAttempts() {
-        return maxAttempts;
-    }
-
-
-    public void setMaxAttempts( int maxAttemps ) {
-        this.maxAttempts = maxAttemps;
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockImpl.java
deleted file mode 100644
index a4aab31..0000000
--- 
a/stack/core/src/main/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockImpl.java
+++ /dev/null
@@ -1,88 +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.zookeeper;
-
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.usergrid.locking.Lock;
-import org.apache.usergrid.locking.exception.UGLockException;
-
-import com.netflix.curator.framework.recipes.locks.InterProcessMutex;
-
-
-/**
- * Wrapper for locks using curator
- *
- * @author tnine
- */
-public class ZookeeperLockImpl implements Lock {
-
-
-    private InterProcessMutex zkMutex;
-
-
-    /**
-     *
-     */
-    public ZookeeperLockImpl( InterProcessMutex zkMutex ) {
-        this.zkMutex = zkMutex;
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.locking.Lock#tryLock(long, 
java.util.concurrent.TimeUnit)
-     */
-    @Override
-    public boolean tryLock( long timeout, TimeUnit time ) throws 
UGLockException {
-
-        try {
-            return zkMutex.acquire( timeout, time );
-        }
-        catch ( Exception e ) {
-            throw new UGLockException( "Unable to obtain lock", e );
-        }
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.locking.Lock#lock()
-     */
-    @Override
-    public void lock() throws UGLockException {
-        try {
-            zkMutex.acquire();
-        }
-        catch ( Exception e ) {
-            throw new UGLockException( "Unable to obtain lock", e );
-        }
-    }
-
-
-    /* (non-Javadoc)
-     * @see org.apache.usergrid.locking.Lock#unlock()
-     */
-    @Override
-    public void unlock() throws UGLockException {
-        try {
-            zkMutex.release();
-        }
-        catch ( Exception e ) {
-            throw new UGLockException( "Unable to obtain lock", e );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/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 57d4de7..dc52b70 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -88,14 +88,6 @@
         <property name="defaultWriteConsistencyLevel" 
value="${cassandra.lock.writecl}"/>
     </bean>
 
-       <!--  zookeeper locks -->
-       <!--
-       <bean orgAppName="lockManager" 
class="org.apache.usergrid.locking.zookeeper.ZooKeeperLockManagerImpl" >
-               <property orgAppName="hostPort" value="${zookeeper.url}"/>
-               <property orgAppName="sessionTimeout" value="2000"/>
-               <property orgAppName="maxAttempts" value="10"/>
-       </bean>  -->
-
     <bean id="injector"
                class="org.apache.usergrid.corepersistence.GuiceFactory">
     </bean>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/AbstractZooKeeperTest.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/AbstractZooKeeperTest.java
 
b/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/AbstractZooKeeperTest.java
deleted file mode 100644
index 9ff1a33..0000000
--- 
a/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/AbstractZooKeeperTest.java
+++ /dev/null
@@ -1,127 +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.zookeeper;
-
-
-import java.io.File;
-import java.net.InetSocketAddress;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.zookeeper.server.ServerConfig;
-import org.apache.zookeeper.server.ZooKeeperServerMain;
-
-
-/** Base test class for ZooKeeper tests. */
-public abstract class AbstractZooKeeperTest {
-
-    public static final String ZOO_KEEPER_HOST = "localhost:20181/";
-
-    private static final  Logger logger = LoggerFactory.getLogger( 
AbstractZooKeeperTest.class );
-
-
-    static class ZKServerMain extends ZooKeeperServerMain {
-        @Override
-        public void shutdown() {
-            super.shutdown();
-        }
-    }
-
-
-    protected static ZKServerMain zkServer = new ZKServerMain();
-
-    protected static File tmpDir = new File( "./zk_tmp" );
-
-    protected int clientPort;
-
-
-    @BeforeClass
-    public static void before() throws Exception {
-        // we don't call super.setUp
-        System.setProperty( "zkHost", ZOO_KEEPER_HOST );
-        Thread zooThread = new Thread() {
-            @Override
-            public void run() {
-                ServerConfig config = null;
-
-                config = new ServerConfig() {
-                    {
-                        clientPortAddress = new InetSocketAddress( 
"localhost", 20181 );
-                        dataDir = tmpDir.getAbsolutePath() + File.separator + 
"zookeeper/server1/data";
-                        dataLogDir = dataDir;
-                        // this.maxClientCnxns = 50;
-                        // this.tickTime = 2000;
-                    }
-                };
-
-                try {
-                    zkServer.runFromConfig( config );
-                    logger.info( "ZOOKEEPER EXIT" );
-                }
-                catch ( Throwable e ) {
-                    logger.error("Error on zkServer.runFromConfig", e);
-                    throw new RuntimeException( e );
-                }
-            }
-        };
-
-        zooThread.setDaemon( true );
-        zooThread.start();
-        Thread.sleep( 500 ); // pause for ZooKeeper to start
-
-        buildZooKeeper();
-
-        logger.info( "Zookeeper initialized." );
-    }
-
-
-    public static void buildZooKeeper() throws Exception {
-        ZooPut zooPut = new ZooPut( ZOO_KEEPER_HOST.substring( 0, 
ZOO_KEEPER_HOST.indexOf( '/' ) ) );
-        // TODO read a system property to get the app root path if
-        // needed.
-        // zooPut.makePath("/somepath");
-        zooPut.close();
-    }
-
-
-    @AfterClass
-    public static void after() throws Exception {
-        zkServer.shutdown();
-
-        // Remove test data.
-        boolean deletedData = recurseDelete( tmpDir );
-        if ( !deletedData ) {
-            logger.warn( "Zk testing data was not removed properly. You need 
to" + "manually remove:" + tmpDir
-                    .getAbsolutePath() );
-        }
-    }
-
-
-    public static boolean recurseDelete( File f ) {
-        if ( f.isDirectory() ) {
-            for ( File sub : f.listFiles() ) {
-                if ( !recurseDelete( sub ) ) {
-                    return false;
-                }
-            }
-        }
-        return f.delete();
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZooPut.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZooPut.java 
b/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZooPut.java
deleted file mode 100644
index 5ef3b05..0000000
--- a/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZooPut.java
+++ /dev/null
@@ -1,114 +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.zookeeper;
-
-
-import java.io.IOException;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.ZooKeeper;
-
-
-/** Util for uploading and updating files in ZooKeeper. */
-public class ZooPut implements Watcher {
-
-    private ZooKeeper keeper;
-
-    private boolean closeKeeper = true;
-
-    private boolean connected = false;
-
-
-    public ZooPut( String host ) throws IOException {
-        keeper = new ZooKeeper( host, 10000, this );
-        // TODO: nocommit: this is asynchronous - think about how to deal with
-        // connection
-        // lost, and other failures
-        synchronized ( this ) {
-            while ( !connected ) {
-                try {
-                    this.wait();
-                }
-                catch ( InterruptedException e ) {
-                    // nocommit
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-
-
-    public ZooPut( ZooKeeper keeper ) throws IOException {
-        this.closeKeeper = false;
-        this.keeper = keeper;
-    }
-
-
-    public void close() throws InterruptedException {
-        if ( closeKeeper ) {
-            keeper.close();
-        }
-    }
-
-
-    public void makePath( String path ) throws KeeperException, 
InterruptedException {
-        makePath( path, CreateMode.PERSISTENT );
-    }
-
-
-    public void makePath( String path, CreateMode createMode ) throws 
KeeperException, InterruptedException {
-        // nocommit
-        System.out.println( "make:" + path );
-
-        if ( path.startsWith( "/" ) ) {
-            path = path.substring( 1, path.length() );
-        }
-        String[] paths = path.split( "/" );
-        StringBuilder sbPath = new StringBuilder();
-        for ( int i = 0; i < paths.length; i++ ) {
-            String pathPiece = paths[i];
-            sbPath.append("/").append(pathPiece);
-            String currentPath = sbPath.toString();
-            Object exists = keeper.exists( currentPath, null );
-            if ( exists == null ) {
-                CreateMode mode = CreateMode.PERSISTENT;
-                if ( i == paths.length - 1 ) {
-                    mode = createMode;
-                }
-                keeper.create( currentPath, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, 
mode );
-            }
-        }
-    }
-
-
-    @Override
-    public void process( WatchedEvent event ) {
-        // nocommit: consider how we want to accomplish this
-        if ( event.getState() == KeeperState.SyncConnected ) {
-            synchronized ( this ) {
-                connected = true;
-                this.notify();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockManagerTest.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockManagerTest.java
 
b/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockManagerTest.java
deleted file mode 100644
index c74f6f8..0000000
--- 
a/stack/core/src/test/java/org/apache/usergrid/locking/zookeeper/ZookeeperLockManagerTest.java
+++ /dev/null
@@ -1,186 +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.zookeeper;
-
-
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-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.exception.UGLockException;
-
-import net.jcip.annotations.NotThreadSafe;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-@NotThreadSafe
-public class ZookeeperLockManagerTest extends AbstractZooKeeperTest {
-
-    private static final Logger logger = LoggerFactory.getLogger( 
ZookeeperLockManagerTest.class );
-
-    private static LockManager manager;
-
-    private static ExecutorService pool;
-
-
-    @BeforeClass
-    public static void setup() throws Exception {
-
-        //    AbstractZooKeeperTest.before();
-
-        ZooKeeperLockManagerImpl lockImpl = new ZooKeeperLockManagerImpl();
-        lockImpl.setHostPort( "localhost:20181" );
-        lockImpl.setMaxAttempts( 1000 );
-        lockImpl.setSessionTimeout( 2 );
-
-        lockImpl.init();
-
-        manager = lockImpl;
-    }
-
-
-    @Before
-    public void start() {
-        // 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 );
-        assertFalse( 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/8849d8eb/stack/launcher/src/main/resources/usergrid-standalone.properties
----------------------------------------------------------------------
diff --git a/stack/launcher/src/main/resources/usergrid-standalone.properties 
b/stack/launcher/src/main/resources/usergrid-standalone.properties
index c81437a..86c183c 100644
--- a/stack/launcher/src/main/resources/usergrid-standalone.properties
+++ b/stack/launcher/src/main/resources/usergrid-standalone.properties
@@ -101,10 +101,6 @@ usergrid.sysadmin.approve.organizations=false
 # Where to store temporary files
 usergrid.temp.files=/tmp/usergrid
 
-# Zookeeper instances
-zookeeper.hosts=localhost:2180
-zookeeper.sessionTimeout = 3000
-zookeeper.maxAttempts = 3
 
 #AWS_ACCESS_KEY_ID=
 #AWS_ACCESS_KEY_SECRET=

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index e086295..802f7b5 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -551,38 +551,6 @@
             </dependency>
 
             <dependency>
-                <groupId>org.apache.zookeeper</groupId>
-                <artifactId>zookeeper</artifactId>
-                <version>3.4.5</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>jline</groupId>
-                        <artifactId>jline</artifactId>
-                    </exclusion>
-
-                    <exclusion>
-                        <groupId>org.jboss.netty</groupId>
-                        <artifactId>netty</artifactId>
-                    </exclusion>
-
-                    <exclusion>
-                        <groupId>org.slf4j</groupId>
-                        <artifactId>slf4j-api</artifactId>
-                    </exclusion>
-
-                    <exclusion>
-                        <groupId>org.slf4j</groupId>
-                        <artifactId>slf4j-log4j12</artifactId>
-                    </exclusion>
-
-                    <exclusion>
-                        <groupId>log4j</groupId>
-                        <artifactId>log4j</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-
-            <dependency>
                 <groupId>com.sun.mail</groupId>
                 <artifactId>javax.mail</artifactId>
                 <version>1.4.4</version>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/8849d8eb/stack/websocket/src/test/resources/testApplicationContext.xml
----------------------------------------------------------------------
diff --git a/stack/websocket/src/test/resources/testApplicationContext.xml 
b/stack/websocket/src/test/resources/testApplicationContext.xml
index eef74b4..8eccb74 100644
--- a/stack/websocket/src/test/resources/testApplicationContext.xml
+++ b/stack/websocket/src/test/resources/testApplicationContext.xml
@@ -1,136 +1,135 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans";
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:util="http://www.springframework.org/schema/util";
-       xmlns:context="http://www.springframework.org/schema/context";
-       xmlns:amq="http://activemq.apache.org/schema/core"; 
xmlns:jms="http://www.springframework.org/schema/jms";
-       xmlns:p="http://www.springframework.org/schema/p";
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
-       http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.1.xsd
-       http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.1.xsd
-       http://www.springframework.org/schema/jms 
http://www.springframework.org/schema/jms/spring-jms-3.1.xsd
-       http://activemq.apache.org/schema/core 
http://activemq.apache.org/schema/core/activemq-core.xsd";>
-
-       <context:component-scan base-package="org.apache.usergrid.persistence" 
/>
-       <context:annotation-config />
-
-       <bean id="properties"
-               
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
-               <property name="singleton" value="true" />
-               <property name="ignoreResourceNotFound" value="true" />
-               <property name="locations">
-                       <list>
-                               
<value>classpath:/usergrid-default.properties</value>
-                               
<value>classpath:/usergrid-test.properties</value>
-                               
<value>${usergrid-custom-spring-test-properties}</value>
-                       </list>
-               </property>
-       </bean>
-
-       <bean id="propertyPlaceholderConfigurer"
-               
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-               <property name="properties" ref="properties" />
-               <property name="systemPropertiesModeName">
-                       <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
-               </property>
-       </bean>
-
-       <bean id="cassandraUseRemote" class="java.lang.Boolean">
-               <constructor-arg value="${cassandra.use_remote}" />
-       </bean>
-       <bean id="cassandraLocalUrl" class="java.lang.String">
-               <constructor-arg value="${cassandra.local.url}" />
-       </bean>
-       <bean id="cassandraRemoteUrl" class="java.lang.String">
-               <constructor-arg value="${cassandra.remote.url}" />
-       </bean>
-       <bean id="cassandraUrl" class="java.lang.String">
-               <constructor-arg
-                       value="#{cassandraUseRemote ? cassandraRemoteUrl : 
cassandraLocalUrl}" />
-       </bean>
-       <util:map id="cassandraCredentials" map-class="java.util.HashMap">
-               <entry key="username" value="${cassandra.username}" />
-               <entry key="password" value="${cassandra.password}" />
-       </util:map>
-
-       <bean id="realm" class="org.apache.usergrid.security.shiro.Realm">
-               <property name="name" value="realm" />
-       </bean>
-
-       <bean id="securityManager" 
class="org.apache.shiro.mgt.DefaultSecurityManager">
-               <property name="realm" ref="realm" />
-       </bean>
-
-       <bean id="lifecycleBeanPostProcessor" 
class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
-
-       <bean
-               
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
-               <property name="staticMethod"
-                       
value="org.apache.shiro.SecurityUtils.setSecurityManager" />
-               <property name="arguments" ref="securityManager" />
-       </bean>
-
-       <!-- The Time Resolution used for the cluster -->
-       <bean id="microsecondsTimeResolution"
-               
class="me.prettyprint.cassandra.service.clock.MicrosecondsClockResolution" />
-
-       <bean id="cassandraHostConfigurator"
-               
class="me.prettyprint.cassandra.service.CassandraHostConfigurator">
-               <constructor-arg ref="cassandraUrl" />
-               <property name="clockResolution" 
ref="microsecondsTimeResolution" />
-       </bean>
-
-       <bean id="cassandraCluster" 
class="me.prettyprint.cassandra.service.ThriftCluster">
-               <constructor-arg value="${cassandra.cluster}" />
-               <constructor-arg ref="cassandraHostConfigurator" />
-               <constructor-arg ref="cassandraCredentials" />
-       </bean>
-
-       <!-- bean name="lockManager" 
class="org.apache.usergrid.locking.zookeeper.ZooKeeperLockManagerImpl" /> -->
-       <bean name="lockManager" 
class="org.apache.usergrid.locking.zookeeper.NoOpLockManagerImpl" />
-
-       <bean id="cassandraService"
-               
class="org.apache.usergrid.persistence.cassandra.CassandraService" 
init-method="init">
-               <constructor-arg ref="properties" />
-               <constructor-arg ref="cassandraCluster" />
-               <constructor-arg ref="cassandraHostConfigurator" />
-               <constructor-arg ref="lockManager" />
-       </bean>
-
-       <bean id="entityManagerFactory"
-               
class="org.apache.usergrid.persistence.cassandra.EntityManagerFactoryImpl">
-               <constructor-arg ref="cassandraService" />
-       </bean>
-
-       <bean id="queueManagerFactory"
-               
class="org.apache.usergrid.mq.cassandra.QueueManagerFactoryImpl">
-               <constructor-arg ref="cassandraService" />
-       </bean>
-
-       <bean id="serviceManagerFactory" 
class="org.apache.usergrid.services.ServiceManagerFactory">
-               <constructor-arg>
-                       <ref bean="entityManagerFactory" />
-               </constructor-arg>
-       </bean>
-
-       <bean id="tokenService" 
class="org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl"/>
-
-       <bean id="managementService" 
class="org.apache.usergrid.management.cassandra.ManagementServiceImpl" />
-
-</beans>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:util="http://www.springframework.org/schema/util";
+       xmlns:context="http://www.springframework.org/schema/context";
+       xmlns:amq="http://activemq.apache.org/schema/core"; 
xmlns:jms="http://www.springframework.org/schema/jms";
+       xmlns:p="http://www.springframework.org/schema/p";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+       http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.1.xsd
+       http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.1.xsd
+       http://www.springframework.org/schema/jms 
http://www.springframework.org/schema/jms/spring-jms-3.1.xsd
+       http://activemq.apache.org/schema/core 
http://activemq.apache.org/schema/core/activemq-core.xsd";>
+
+       <context:component-scan base-package="org.apache.usergrid.persistence" 
/>
+       <context:annotation-config />
+
+       <bean id="properties"
+               
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+               <property name="singleton" value="true" />
+               <property name="ignoreResourceNotFound" value="true" />
+               <property name="locations">
+                       <list>
+                               
<value>classpath:/usergrid-default.properties</value>
+                               
<value>classpath:/usergrid-test.properties</value>
+                               
<value>${usergrid-custom-spring-test-properties}</value>
+                       </list>
+               </property>
+       </bean>
+
+       <bean id="propertyPlaceholderConfigurer"
+               
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+               <property name="properties" ref="properties" />
+               <property name="systemPropertiesModeName">
+                       <value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
+               </property>
+       </bean>
+
+       <bean id="cassandraUseRemote" class="java.lang.Boolean">
+               <constructor-arg value="${cassandra.use_remote}" />
+       </bean>
+       <bean id="cassandraLocalUrl" class="java.lang.String">
+               <constructor-arg value="${cassandra.local.url}" />
+       </bean>
+       <bean id="cassandraRemoteUrl" class="java.lang.String">
+               <constructor-arg value="${cassandra.remote.url}" />
+       </bean>
+       <bean id="cassandraUrl" class="java.lang.String">
+               <constructor-arg
+                       value="#{cassandraUseRemote ? cassandraRemoteUrl : 
cassandraLocalUrl}" />
+       </bean>
+       <util:map id="cassandraCredentials" map-class="java.util.HashMap">
+               <entry key="username" value="${cassandra.username}" />
+               <entry key="password" value="${cassandra.password}" />
+       </util:map>
+
+       <bean id="realm" class="org.apache.usergrid.security.shiro.Realm">
+               <property name="name" value="realm" />
+       </bean>
+
+       <bean id="securityManager" 
class="org.apache.shiro.mgt.DefaultSecurityManager">
+               <property name="realm" ref="realm" />
+       </bean>
+
+       <bean id="lifecycleBeanPostProcessor" 
class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
+
+       <bean
+               
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+               <property name="staticMethod"
+                       
value="org.apache.shiro.SecurityUtils.setSecurityManager" />
+               <property name="arguments" ref="securityManager" />
+       </bean>
+
+       <!-- The Time Resolution used for the cluster -->
+       <bean id="microsecondsTimeResolution"
+               
class="me.prettyprint.cassandra.service.clock.MicrosecondsClockResolution" />
+
+       <bean id="cassandraHostConfigurator"
+               
class="me.prettyprint.cassandra.service.CassandraHostConfigurator">
+               <constructor-arg ref="cassandraUrl" />
+               <property name="clockResolution" 
ref="microsecondsTimeResolution" />
+       </bean>
+
+       <bean id="cassandraCluster" 
class="me.prettyprint.cassandra.service.ThriftCluster">
+               <constructor-arg value="${cassandra.cluster}" />
+               <constructor-arg ref="cassandraHostConfigurator" />
+               <constructor-arg ref="cassandraCredentials" />
+       </bean>
+
+       <bean name="lockManager" 
class="org.apache.usergrid.locking.cassandra.HectorLockManagerImpl" />
+
+       <bean id="cassandraService"
+               
class="org.apache.usergrid.persistence.cassandra.CassandraService" 
init-method="init">
+               <constructor-arg ref="properties" />
+               <constructor-arg ref="cassandraCluster" />
+               <constructor-arg ref="cassandraHostConfigurator" />
+               <constructor-arg ref="lockManager" />
+       </bean>
+
+       <bean id="entityManagerFactory"
+               
class="org.apache.usergrid.persistence.cassandra.EntityManagerFactoryImpl">
+               <constructor-arg ref="cassandraService" />
+       </bean>
+
+       <bean id="queueManagerFactory"
+               
class="org.apache.usergrid.mq.cassandra.QueueManagerFactoryImpl">
+               <constructor-arg ref="cassandraService" />
+       </bean>
+
+       <bean id="serviceManagerFactory" 
class="org.apache.usergrid.services.ServiceManagerFactory">
+               <constructor-arg>
+                       <ref bean="entityManagerFactory" />
+               </constructor-arg>
+       </bean>
+
+       <bean id="tokenService" 
class="org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl"/>
+
+       <bean id="managementService" 
class="org.apache.usergrid.management.cassandra.ManagementServiceImpl" />
+
+</beans>

Reply via email to