usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject usergrid git commit: Don't cache Optionals or nulls in app id cache.
Date Fri, 08 Apr 2016 22:51:20 GMT
Repository: usergrid
Updated Branches:
  refs/heads/dont-cache-optionals [created] 177e06375
Updated Tags:  refs/tags/1.0.0 [created] 1c090d37a
  refs/tags/1.0.1 [created] eee11aab9
  refs/tags/1.0.2 [created] c2a6dccac
  refs/tags/e2e [created] c5afe3ebf


Don't cache Optionals or nulls in app id cache.


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

Branch: refs/heads/dont-cache-optionals
Commit: 177e06375351dbcff7f14e158814b47c53413d56
Parents: 74de4bc
Author: Dave Johnson <snoopdave@apache.org>
Authored: Fri Apr 8 18:51:14 2016 -0400
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Fri Apr 8 18:51:14 2016 -0400

----------------------------------------------------------------------
 .../corepersistence/ApplicationIdCache.java     |  6 +-
 .../corepersistence/ApplicationIdCacheImpl.java | 64 ++++++++------------
 .../corepersistence/CpEntityManagerFactory.java |  9 ++-
 .../persistence/EntityManagerFactory.java       |  4 +-
 .../index/AsyncEventServiceImplTest.java        | 23 +++----
 .../cassandra/EntityManagerFactoryImplIT.java   |  8 +--
 .../apache/usergrid/mongo/BasicMongoTest.java   |  8 +--
 .../apache/usergrid/mongo/MongoQueryTest.java   | 18 +++---
 .../organizations/OrganizationResource.java     |  8 +--
 .../cassandra/ManagementServiceImpl.java        |  8 +--
 .../migration/AppInfoMigrationPluginTest.java   |  8 +--
 11 files changed, 70 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCache.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCache.java
index a7d1c4e..83c2144 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCache.java
@@ -35,17 +35,17 @@ public interface ApplicationIdCache {
     /**
      * Evict the application by name
      */
-    public Optional<UUID> getApplicationId(final String applicationName);
+    UUID getApplicationId( final String applicationName );
 
 
     /**
      * Evict the app id by the name
      */
-    public void evictAppId(final String applicationName);
+    void evictAppId( final String applicationName );
 
 
     /**
      * Evict all caches
      */
-    public void evictAll();
+    void evictAll();
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
index 95171a8..7745359 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ApplicationIdCacheImpl.java
@@ -16,74 +16,64 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.usergrid.corepersistence;
 
 
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
-
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.Query;
 import org.apache.usergrid.persistence.Schema;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.utils.UUIDUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import rx.Observable;
 
-import com.google.common.base.Optional;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 
-
 /**
- * Implements the org app cache for faster runtime lookups.  These values are immutable,
so this LRU cache can stay
- * full for the duration of the execution
+ * Implements the org app cache for faster runtime lookups.
+ * These values are immutable, so this LRU cache can stay full for the duration of the execution.
  */
 public class ApplicationIdCacheImpl implements ApplicationIdCache {
     private static final Logger logger = LoggerFactory.getLogger(ApplicationIdCacheImpl.class);
 
+    // cache the pointer to our root entity manager for reference
+    private final LoadingCache<String, UUID> appCache;
 
-    /**
-     * Cache the pointer to our root entity manager for reference
-     */
-
-    private final LoadingCache<String, Optional<UUID>> appCache;
     private final EntityManager managementEnityManager;
+
     private final ManagerCache managerCache;
 
 
-    public ApplicationIdCacheImpl(final EntityManager managementEnityManager, ManagerCache
managerCache, ApplicationIdCacheFig fig) {
+    public ApplicationIdCacheImpl(
+        final EntityManager managementEnityManager, ManagerCache managerCache, ApplicationIdCacheFig
fig) {
+
         this.managementEnityManager = managementEnityManager;
         this.managerCache = managerCache;
+
         appCache = CacheBuilder.newBuilder()
             .maximumSize(fig.getCacheSize())
             .expireAfterWrite(fig.getCacheTimeout(), TimeUnit.MILLISECONDS)
-            .build(new CacheLoader<String, Optional<UUID>>() {
+            .build(new CacheLoader<String, UUID>() {
                 @Override
-                public Optional<UUID> load(final String key) throws Exception {
-                    return Optional.fromNullable(fetchApplicationId(key));
+                public UUID load(final String key) throws Exception {
+                    return fetchApplicationId(key);
                 }
             });
     }
 
     @Override
-    public  Optional<UUID> getApplicationId( final String applicationName ) {
+    public UUID getApplicationId( final String applicationName ) {
         try {
-            Optional<UUID> optionalUuid = appCache.get( applicationName.toLowerCase()
);
-            if(!optionalUuid.isPresent()){
-                appCache.invalidate(applicationName.toLowerCase());
-                return Optional.absent();
-            }
-            return optionalUuid;
+            return appCache.get( applicationName.toLowerCase() );
         } catch (Exception e) {
             if (logger.isDebugEnabled()) {
                 logger.debug("Returning for key {} value null", applicationName);
@@ -112,25 +102,21 @@ public class ApplicationIdCacheImpl implements ApplicationIdCache {
             logger.error("Error looking up management app", e);
         }
 
-        try {
+        // look up application_info ID for application using unique "name" field
+        final Observable<Id> idObs = ecm.getIdField(
+            CpNamingUtils.APPLICATION_INFO, new StringField(Schema.PROPERTY_NAME, applicationName));
+        Id id = idObs.toBlocking().lastOrDefault(null);
 
-            // look up application_info ID for application using unique "name" field
-            final Observable<Id> idObs = ecm.getIdField(
-                CpNamingUtils.APPLICATION_INFO, new StringField(Schema.PROPERTY_NAME, applicationName));
+        if ( id != null ) {
+            value = id.getUuid();
 
-            Id id = idObs.toBlocking().lastOrDefault(null);
-            if(id != null) {
-                value = id.getUuid();
-            }else{
-                if(logger.isDebugEnabled()) {
-                    logger.debug("Could not load value for key {} ", applicationName);
-                }
+        } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug( "Could not load value for key {} ", applicationName );
             }
-            return value;
-        }
-        catch ( Exception e ) {
-            throw new RuntimeException( "Unable to retrieve application id", e );
         }
+
+        return value;
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index a2054d9..a88bf7b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -31,7 +31,6 @@ import org.springframework.context.ApplicationContextAware;
 import org.apache.commons.lang.StringUtils;
 
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
-import org.apache.usergrid.corepersistence.index.IndexSchemaCache;
 import org.apache.usergrid.corepersistence.index.IndexSchemaCacheFactory;
 import org.apache.usergrid.corepersistence.index.ReIndexRequestBuilder;
 import org.apache.usergrid.corepersistence.index.ReIndexService;
@@ -220,9 +219,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
         String appName = buildAppName( orgName, name );
 
-        final Optional<UUID> appId = applicationIdCache.getApplicationId( appName );
+        final UUID appId = applicationIdCache.getApplicationId( appName );
 
-        if ( appId.isPresent()) {
+        if ( appId == null ) {
             throw new ApplicationAlreadyExistsException( name );
         }
 
@@ -260,7 +259,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
         // check for pre-existing application
 
-        if ( lookupApplication( appName ).isPresent()) {
+        if ( lookupApplication( appName ) == null ) {
             throw new ApplicationAlreadyExistsException( appName );
         }
 
@@ -451,7 +450,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     }
 
 
-    public Optional<UUID> lookupApplication( String orgAppName ) throws Exception {
+    public UUID lookupApplication(String orgAppName ) throws Exception {
         return applicationIdCache.getApplicationId(orgAppName);
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 96bd3b2..eedde17 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -20,8 +20,6 @@ package org.apache.usergrid.persistence;
 import java.util.Map;
 import java.util.UUID;
 
-import com.google.common.base.Optional;
-
 import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.index.EntityIndex;
 
@@ -121,7 +119,7 @@ public interface EntityManagerFactory {
      *
      * @throws Exception the exception
      */
-    Optional<UUID> lookupApplication( String name ) throws Exception;
+    UUID lookupApplication(String name ) throws Exception;
 
     /**
      * Returns all the applications in the system.

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
index c915464..4c0058b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
@@ -20,31 +20,24 @@
 package org.apache.usergrid.corepersistence.index;
 
 
-import org.apache.usergrid.corepersistence.asyncevents.EventBuilder;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.impl.IndexProducer;
-import org.apache.usergrid.persistence.queue.QueueFig;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-
+import com.google.inject.Inject;
+import net.jcip.annotations.NotThreadSafe;
 import org.apache.usergrid.corepersistence.TestIndexModule;
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
 import org.apache.usergrid.corepersistence.asyncevents.AsyncEventServiceImpl;
+import org.apache.usergrid.corepersistence.asyncevents.EventBuilder;
 import org.apache.usergrid.persistence.core.aws.NoAWSCredsRule;
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.rx.RxTaskScheduler;
 import org.apache.usergrid.persistence.core.test.UseModules;
+import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.index.impl.EsRunner;
+import org.apache.usergrid.persistence.index.impl.IndexProducer;
 import org.apache.usergrid.persistence.map.MapManagerFactory;
+import org.apache.usergrid.persistence.queue.QueueFig;
 import org.apache.usergrid.persistence.queue.QueueManagerFactory;
-
-import com.google.inject.Inject;
-
-import net.jcip.annotations.NotThreadSafe;
-
-import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.Rule;
+import org.junit.runner.RunWith;
 
 
 @RunWith( EsRunner.class )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index abd55ea..d287d7e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -134,7 +134,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
         Entity film2 = em.create( "film", properties2 );
 
         for ( int j=0; j<maxRetries; j++ ) {
-            if ( setup.getEmf().lookupApplication( orgName + "/" + appName ).isPresent())
{
+            if ( setup.getEmf().lookupApplication( orgName + "/" + appName ) != null ) {
                 break;
             }
             Thread.sleep( 500 );
@@ -171,7 +171,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
         assertTrue("Deleted app must be found in in deleted apps collection", found);
 
         // attempt to get entities in application's collections in various ways should all
fail
-        found =  setup.getEmf().lookupApplication( orgName + "/" + appName ).isPresent()
;
+        found =  setup.getEmf().lookupApplication( orgName + "/" + appName ) != null;
 
         assertFalse("Lookup of deleted app must fail", found);
 
@@ -211,7 +211,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
         assertTrue("Restored app not found in apps collection", found);
 
         // TODO: this assertion should work!
-        assertTrue(setup.getEmf().lookupApplication( orgName + "/" + appName ).isPresent());
+        assertTrue(setup.getEmf().lookupApplication( orgName + "/" + appName ) != null );
     }
 
 
@@ -307,7 +307,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
 
         UUID appId = setup.createApplication(orgName, appName);
 
-        UUID lookedUpId = setup.getEmf().lookupApplication( orgAppName ).get();
+        UUID lookedUpId = setup.getEmf().lookupApplication( orgAppName );
 
         Assert.assertEquals(appId, lookedUpId);
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/BasicMongoTest.java
----------------------------------------------------------------------
diff --git a/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/BasicMongoTest.java
b/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/BasicMongoTest.java
index 17e4449..bcd4d2b 100644
--- a/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/BasicMongoTest.java
+++ b/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/BasicMongoTest.java
@@ -110,7 +110,7 @@ public class BasicMongoTest extends AbstractMongoTest {
 
         // check we can find it when using the native entity manager
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Entity entity = em.get( new SimpleEntityRef( (String)returnedObject.get("type"),
id ));
@@ -228,7 +228,7 @@ public class BasicMongoTest extends AbstractMongoTest {
 
         Thread.sleep( 5000 );
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Entity entity = em.get( new SimpleEntityRef( (String)returnedObject.get("type"),
id ) );
@@ -290,7 +290,7 @@ public class BasicMongoTest extends AbstractMongoTest {
 
         // check it has been deleted
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Entity entity = em.get( new SimpleEntityRef( (String)returnedObject.get("type"),
id ) );
@@ -345,7 +345,7 @@ public class BasicMongoTest extends AbstractMongoTest {
         assertFalse( cursor.hasNext() );
 
         // check it has been deleted
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Results results =

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/MongoQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/MongoQueryTest.java
b/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/MongoQueryTest.java
index 6bd1df9..98bc7ba 100644
--- a/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/MongoQueryTest.java
+++ b/stack/mongo-emulator/src/test/java/org/apache/usergrid/mongo/MongoQueryTest.java
@@ -45,7 +45,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void stringEqual() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -105,7 +105,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void greaterThan() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -156,7 +156,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void greaterThanEqual() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -211,7 +211,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void lessThan() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -262,7 +262,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void lessThanEqual() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -317,7 +317,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void in() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -372,7 +372,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void or() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -427,7 +427,7 @@ public class MongoQueryTest extends AbstractMongoTest {
     @Test
     public void and() throws Exception {
 
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
@@ -476,7 +476,7 @@ public class MongoQueryTest extends AbstractMongoTest {
 
     @Test
     public void withFieldSelector() throws Exception {
-        UUID appId = emf.lookupApplication( "test-organization/test-app" ).get();
+        UUID appId = emf.lookupApplication( "test-organization/test-app" );
         EntityManager em = emf.getEntityManager( appId );
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
index 43867e3..dea727f 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/organizations/OrganizationResource.java
@@ -138,9 +138,9 @@ public class OrganizationResource extends AbstractContextResource {
         }
 
         String orgAppName = PathingUtils.assembleAppName( organizationName, applicationName
);
-        Optional<UUID> optionalAppId = emf.lookupApplication( orgAppName );
+        UUID optionalAppId = emf.lookupApplication( orgAppName );
 
-        if ( !optionalAppId.isPresent()) {
+        if ( optionalAppId == null ) {
 
             // TODO: fix this hacky work-around for apparent Jersey issue
             UUID applicationId = UUIDUtils.tryExtractUUID( applicationName );
@@ -148,11 +148,11 @@ public class OrganizationResource extends AbstractContextResource {
             if ( applicationId == null ) {
                 throw new OrganizationApplicationNotFoundException( orgAppName, uriInfo,
properties, management );
             }else{
-                optionalAppId = Optional.fromNullable(applicationId);
+                optionalAppId = applicationId;
             }
         }
 
-        return appResourceFor( optionalAppId.get() );
+        return appResourceFor( optionalAppId );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 7b55c84..a586c26 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -1796,7 +1796,7 @@ public class ManagementServiceImpl implements ManagementService {
             throw new EntityNotFoundException("Deleted application ID " + applicationId +
" not found");
         }
 
-        if ( emf.lookupApplication( app.getName() ).isPresent()) {
+        if ( emf.lookupApplication( app.getName() ) != null ) {
             throw new ConflictException("Cannot restore application, one with that name already
exists.");
         }
 
@@ -1990,11 +1990,11 @@ public class ManagementServiceImpl implements ManagementService {
         if ( applicationName == null ) {
             return null;
         }
-        Optional<UUID> applicationId = emf.lookupApplication(applicationName);
-        if ( !applicationId.isPresent() ) {
+        UUID applicationId = emf.lookupApplication(applicationName);
+        if ( applicationId == null ) {
             return null;
         }
-        return new ApplicationInfo( applicationId.get(), applicationName.toLowerCase() );
+        return new ApplicationInfo( applicationId, applicationName.toLowerCase() );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/177e0637/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
index 8fe50de..b697f12 100644
--- a/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
+++ b/stack/services/src/test/java/org/apache/usergrid/corepersistence/migration/AppInfoMigrationPluginTest.java
@@ -202,7 +202,7 @@ public class AppInfoMigrationPluginTest {
         for ( Entity applicationInfo : deletedApps ) {
 
             String appName = applicationInfo.getName();
-            boolean isPresent = setup.getEmf().lookupApplication( appName ).isPresent();
+            boolean isPresent = setup.getEmf().lookupApplication( appName ) != null;
 
             // missing application_info does not completely break applications, but we...
             assertFalse("Should not be able to lookup deleted application by name" + appName,
isPresent);
@@ -219,11 +219,11 @@ public class AppInfoMigrationPluginTest {
 
             String appName = orgName + "/application" + i;
 
-            Optional<UUID> uuid = setup.getEmf().lookupApplication(appName);
+            UUID uuid = setup.getEmf().lookupApplication(appName);
 
-            assertTrue ("Should be able to get application", uuid.isPresent() );
+            assertTrue ("Should be able to get application", uuid != null );
 
-            EntityManager em = setup.getEmf().getEntityManager( uuid.get() );
+            EntityManager em = setup.getEmf().getEntityManager( uuid );
 
             Application app = em.getApplication();
             assertEquals( appName, app.getName() );


Mime
View raw message