There is now a new option on the /status end-point. If you specify 
"ignore_errors=false" the the /status end-point will return an HTTP 500 error 
if there is a problem connecting to Cassandra or of the query index is status 
RED for the management app.

This change removes the HealthCheckFilter that was added last week to allow us 
to fail fast when there is an error connecting to Cassandra or ElasticSearch.

This change adds some new methods at the Core module level:
1) EntityManagerFactory.getEntityStoreHealth(), which returns GREEN if the 
Cassandra connection is OK, or RED if it is not.
2) EntityManager.getIndexHealth(), which returns GREEN, YELLOW or RED depending 
on the status of the EntityManager's application index.


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

Branch: refs/heads/two-dot-o
Commit: 1dd6739cf044998aa592a20bafbefa7701d612ac
Parents: 63fb7df
Author: Dave Johnson <[email protected]>
Authored: Mon Nov 3 17:42:32 2014 -0500
Committer: Dave Johnson <[email protected]>
Committed: Mon Nov 3 17:42:32 2014 -0500

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |  12 +-
 .../corepersistence/CpEntityManagerFactory.java |  30 ++---
 .../HybridEntityManagerFactory.java             |  10 +-
 .../usergrid/persistence/EntityManager.java     |   6 +
 .../persistence/EntityManagerFactory.java       |  25 ++--
 .../cassandra/EntityManagerFactoryImpl.java     |  10 +-
 .../cassandra/EntityManagerImpl.java            |   6 +
 .../collection/EntityCollectionManager.java     |   6 +-
 .../impl/EntityCollectionManagerImpl.java       |   7 +-
 .../collection/EntityCollectionManagerIT.java   |   3 +-
 .../usergrid/persistence/core/util/Health.java  |  23 ++++
 .../usergrid/persistence/index/EntityIndex.java |  13 +-
 .../index/impl/EsEntityIndexImpl.java           |  42 ++++--
 .../impl/EntityConnectionIndexImplTest.java     |  14 --
 .../persistence/index/impl/EntityIndexTest.java |  36 +++--
 .../org/apache/usergrid/rest/RootResource.java  |  34 ++++-
 .../rest/filters/HealthCheckFilter.java         |  66 ----------
 .../applications/ApplicationResource.java       | 130 ++++++++++++-------
 stack/rest/src/main/webapp/WEB-INF/web.xml      |  10 --
 19 files changed, 271 insertions(+), 212 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 78c9433..daa046c 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -118,6 +118,7 @@ import 
org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerif
 import 
org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
 import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.persistence.entities.Event;
 import org.apache.usergrid.persistence.entities.Group;
@@ -222,15 +223,22 @@ public class CpEntityManager implements EntityManager {
             .maximumSize( entityCacheSize )
             .expireAfterWrite( entityCacheTimeout, TimeUnit.MILLISECONDS )
             .build( new CacheLoader<EntityScope, 
org.apache.usergrid.persistence.model.entity.Entity>() {
-                public org.apache.usergrid.persistence.model.entity.Entity 
load( EntityScope entityScope ) { 
+                public org.apache.usergrid.persistence.model.entity.Entity 
load( EntityScope es) { 
                     return managerCache.getEntityCollectionManager( 
-                        entityScope.scope ).load( entityScope.entityId 
).toBlocking().lastOrDefault(null);
+                        es.scope ).load( es.entityId 
).toBlocking().lastOrDefault(null);
                 }
             }
         );
     }
 
 
+    @Override
+    public Health getIndexHealth() {
+        EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+        return ei.getIndexHealth();
+    }
+
+
     /** Needed to support short-term Entity cache. */ 
     public static class EntityScope {
         CollectionScope scope;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/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 cf9207a..515eb09 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
@@ -55,6 +55,7 @@ import 
org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory
 import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.entities.Application;
 import 
org.apache.usergrid.persistence.exceptions.ApplicationAlreadyExistsException;
 import org.apache.usergrid.persistence.graph.Edge;
@@ -722,21 +723,16 @@ public class CpEntityManagerFactory implements 
EntityManagerFactory, Application
     }
 
     @Override
-    public boolean verifyCollectionsModuleHealthy() {
-
-        CollectionScope collScope = new CollectionScopeImpl(
-            getApplicationScope(SYSTEM_APP_ID).getApplication(),
-            getApplicationScope(SYSTEM_APP_ID).getApplication(),
-            CpNamingUtils.getCollectionScopeNameFromCollectionName( "appinfos" 
));
-
-        EntityCollectionManager ecm = managerCache.getEntityCollectionManager( 
collScope );
-        return ecm.isHealthy();
-    }
-
-    @Override
-    public boolean verifyQueryIndexModuleHealthy() {
-
-        EntityIndex ei = managerCache.getEntityIndex( getApplicationScope( 
SYSTEM_APP_ID ));
-        return ei.isHealthy();
-    }
+    public Health getEntityStoreHealth() {
+
+        // could use any collection scope here, does not matter
+        EntityCollectionManager ecm = 
getManagerCache().getEntityCollectionManager( 
+            new CollectionScopeImpl( 
+                new SimpleId( SYSTEM_APP_ID, "application"), 
+                new SimpleId( SYSTEM_APP_ID, "application"), 
+                "dummy"
+        ));
+                 
+        return ecm.getHealth();
+    } 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
index 79c3d7d..f4454f2 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/HybridEntityManagerFactory.java
@@ -23,6 +23,7 @@ import org.apache.usergrid.persistence.EntityManagerFactory;
 import org.apache.usergrid.persistence.cassandra.CassandraService;
 import org.apache.usergrid.persistence.cassandra.CounterUtils;
 import org.apache.usergrid.persistence.cassandra.EntityManagerFactoryImpl;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
@@ -165,12 +166,7 @@ public class HybridEntityManagerFactory implements 
EntityManagerFactory, Applica
     }
 
     @Override
-    public boolean verifyCollectionsModuleHealthy() {
-        return factory.verifyCollectionsModuleHealthy();
-    }
-
-    @Override
-    public boolean verifyQueryIndexModuleHealthy() {
-        return factory.verifyQueryIndexModuleHealthy();
+    public Health getEntityStoreHealth() {
+        return factory.getEntityStoreHealth();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java 
b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index cd92729..a8bd363 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -28,6 +28,7 @@ import me.prettyprint.hector.api.mutation.Mutator;
 
 import org.apache.usergrid.persistence.cassandra.CassandraService;
 import org.apache.usergrid.persistence.cassandra.GeoIndexManager;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.persistence.entities.Role;
 import org.apache.usergrid.persistence.index.query.CounterResolution;
@@ -695,4 +696,9 @@ public interface EntityManager {
     public void flushManagerCaches();
 
     public void reindex( final EntityManagerFactory.ProgressObserver po ) 
throws Exception;
+
+    /**
+     * Get health status of application's index.
+     */
+    public Health getIndexHealth();
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/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 e1a22c8..4ebe731 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
@@ -19,17 +19,16 @@ package org.apache.usergrid.persistence;
 
 import java.util.Map;
 import java.util.UUID;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.springframework.context.ApplicationContext;
 
 
-// TODO: Auto-generated Javadoc
-
-
 /**
- * The interface class that specifies the operations that can be performed on 
the Usergrid Datastore. This interface is
- * designed to be implemented by different backends. Although these operations 
are meant to take advantage of the
- * capabilities of Cassandra, they should be implementable using other 
relational databases such as MySql or NoSQL
- * databases such as GAE or MongoDB.
+ * The interface that specifies the operations that can be performed on the 
Usergrid Datastore. 
+ * This interface is designed to be implemented by different backends. 
Although these 
+ * operations are meant to take advantage of the capabilities of Cassandra, 
they should be 
+ * implementable using other relational databases such as MySql or NoSQL 
databases such as GAE or 
+ * MongoDB.
  */
 public interface EntityManagerFactory {
 
@@ -63,7 +62,8 @@ public interface EntityManagerFactory {
     public abstract UUID createApplication( String organizationName, String 
name ) throws Exception;
 
     /**
-     * Creates a Application entity. All entities except for applications must 
be attached to a Application.
+     * Creates a Application entity. All entities except for applications must 
be attached to a 
+     * Application.
      *
      * @param name the name of the application to create.
      * @param properties property values to create in the new entity or null.
@@ -72,8 +72,8 @@ public interface EntityManagerFactory {
      *
      * @throws Exception the exception
      */
-    public abstract UUID createApplication( String organizationName, String 
name, Map<String, Object> properties )
-            throws Exception;
+    public abstract UUID createApplication( 
+            String organizationName, String name, Map<String, Object> 
properties ) throws Exception;
 
     public abstract UUID importApplication( String organization, UUID 
applicationId, String name,
                                             Map<String, Object> properties ) 
throws Exception;
@@ -130,11 +130,10 @@ public interface EntityManagerFactory {
 
     public void rebuildCollectionIndex(UUID appId, String collection, 
ProgressObserver object);
 
-    public boolean verifyCollectionsModuleHealthy();
-
-    public boolean verifyQueryIndexModuleHealthy();
+    public Health getEntityStoreHealth();
 
     public interface ProgressObserver {
+
         public void onProgress( EntityRef entity);
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 2654d29..dd3704c 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -67,6 +67,7 @@ import static 
org.apache.usergrid.persistence.cassandra.CassandraService.PROPERT
 import static 
org.apache.usergrid.persistence.cassandra.CassandraService.RETRY_COUNT;
 import static org.apache.usergrid.utils.ConversionUtils.uuid;
 import static org.apache.usergrid.persistence.cassandra.Serializers.*;
+import org.apache.usergrid.persistence.core.util.Health;
 
 
 /**
@@ -440,12 +441,7 @@ public class EntityManagerFactoryImpl implements 
EntityManagerFactory, Applicati
     }
 
     @Override
-    public boolean verifyCollectionsModuleHealthy() {
-        return true;
-    }
-
-    @Override
-    public boolean verifyQueryIndexModuleHealthy() {
-        return true;
+    public Health getEntityStoreHealth() {
+        throw new UnsupportedOperationException("Not supported yet."); 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 7437c7a..a0c4c5b 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -162,6 +162,7 @@ import static 
org.apache.usergrid.persistence.cassandra.Serializers.be;
 import static org.apache.usergrid.persistence.cassandra.Serializers.le;
 import static org.apache.usergrid.persistence.cassandra.Serializers.se;
 import static org.apache.usergrid.persistence.cassandra.Serializers.ue;
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.hector.CountingMutator;
 import static org.apache.usergrid.persistence.index.query.Query.Level.REFS;
 import static org.apache.usergrid.utils.ClassUtils.cast;
@@ -2929,4 +2930,9 @@ public class EntityManagerImpl implements EntityManager {
         throw new UnsupportedOperationException("Not supported."); 
     }
 
+
+    @Override
+    public Health getIndexHealth() {
+        return Health.GREEN; // no good way to assess index status using 
old-school entity manager
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
 
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
index 360d8e0..534d7a6 100644
--- 
a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
+++ 
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.persistence.collection;
 
 
 import java.util.Collection;
+import org.apache.usergrid.persistence.core.util.Health;
 
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
@@ -70,7 +71,6 @@ public interface EntityCollectionManager {
      */
     public Observable<EntitySet> load(Collection<Id> entityIds);
 
-
     /**
      * Takes the change and reloads an entity with all changes applied in this 
entity applied.
      * The resulting entity from calling load will be the previous version of 
this entity + the entity
@@ -81,8 +81,8 @@ public interface EntityCollectionManager {
     public Observable<Entity> update ( Entity entity );
 
     /** 
-     * Return true if connection query index system (Cassandra) is healthy.
+     * Returns health of entity data store.
      */
-    public boolean isHealthy();
+    public Health getHealth();
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
 
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index f24334e..bb75cc9 100644
--- 
a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ 
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -63,6 +63,7 @@ import com.netflix.astyanax.model.ColumnFamily;
 import com.netflix.astyanax.model.CqlResult;
 import com.netflix.astyanax.serializers.StringSerializer;
 import 
org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.core.util.Health;
 
 import rx.Observable;
 import rx.Subscriber;
@@ -348,7 +349,7 @@ public class EntityCollectionManagerImpl implements 
EntityCollectionManager {
 
 
     @Override
-    public boolean isHealthy() {
+    public Health getHealth() {
 
         try {
             ColumnFamily<String, String> CF_SYSTEM_LOCAL = new 
ColumnFamily<String, String>(
@@ -362,14 +363,14 @@ public class EntityCollectionManagerImpl implements 
EntityCollectionManager {
                 .execute();
 
             if ( result.getResult().getRows().size() == 1 ) {
-                return true;
+                return Health.GREEN;
             }
 
         } catch ( ConnectionException ex ) {
             logger.error("Error connecting to Cassandra", ex);
         }
 
-        return false;
+        return Health.RED;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
 
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index 763d00a..6cd7098 100644
--- 
a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ 
b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -45,6 +45,7 @@ import 
org.apache.usergrid.persistence.model.field.StringField;
 
 import com.fasterxml.uuid.UUIDComparator;
 import com.google.inject.Inject;
+import org.apache.usergrid.persistence.core.util.Health;
 
 import rx.Observable;
 
@@ -704,6 +705,6 @@ public class EntityCollectionManagerIT {
 
         final EntityCollectionManager manager = 
factory.createCollectionManager( context );
 
-        assertTrue( manager.isHealthy() );
+        assertEquals( Health.GREEN, manager.getHealth() );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/Health.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/Health.java
 
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/Health.java
new file mode 100644
index 0000000..00966be
--- /dev/null
+++ 
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/util/Health.java
@@ -0,0 +1,23 @@
+/*
+ * 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.persistence.core.util;
+
+
+public enum Health {
+    GREEN, YELLOW, RED;     
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
 
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index fda3a53..8ded788 100644
--- 
a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ 
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -19,6 +19,7 @@
 
 package org.apache.usergrid.persistence.index;
 
+import org.apache.usergrid.persistence.core.util.Health;
 import org.apache.usergrid.persistence.index.query.Query;
 import org.apache.usergrid.persistence.index.query.CandidateResults;
 import org.apache.usergrid.persistence.model.entity.Id;
@@ -55,8 +56,14 @@ public interface EntityIndex {
      */
     public void refresh();
 
-    /** 
-     * Return true if connection query index system (ElasticSearch) is healthy.
+    /**
+     * Check health of cluster.
+     */
+    public Health getClusterHealth();
+    
+    /**
+     * Check health of this specific index.
      */
-    public boolean isHealthy();
+    public Health getIndexHealth();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
 
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 23accdd..154bcbe 100644
--- 
a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ 
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -65,6 +65,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 import java.util.HashMap;
+import org.apache.usergrid.persistence.core.util.Health;
 
 import static 
org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
 import static 
org.apache.usergrid.persistence.index.impl.IndexingUtils.DOC_ID_SEPARATOR_SPLITTER;
@@ -401,32 +402,53 @@ public class EsEntityIndexImpl implements EntityIndex {
     }
 
 
+    /**
+     * Check health of cluster.
+     */
     @Override
-    public boolean isHealthy() {
+    public Health getClusterHealth() {
 
         try {
-            ClusterHealthResponse health =
-                    client.admin().cluster().health( new 
ClusterHealthRequest() ).get();
-            
-            if ( health.getStatus().equals( ClusterHealthStatus.GREEN ) ) {
-                return true;
-            }
+            ClusterHealthResponse chr = client.admin().cluster()
+                .health( new ClusterHealthRequest() ).get();
+            return Health.valueOf( chr.getStatus().name() );
+        } 
+        catch (Exception ex) {
+            logger.error("Error connecting to ElasticSearch", ex);
+        } 
+
+        // this is bad, red alert!
+        return Health.RED;
+    }
+
+
+    /**
+     * Check health of this specific index.
+     */
+    @Override
+    public Health getIndexHealth() {
+        
+        try {
+            ClusterHealthResponse chr = client.admin().cluster()
+                .health( new ClusterHealthRequest( new String[] { indexName } 
) ).get();
+            return Health.valueOf( chr.getStatus().name() );
         } 
         catch (Exception ex) {
             logger.error("Error connecting to ElasticSearch", ex);
         } 
 
-        return false ;
+        // this is bad, red alert!
+        return Health.RED;
     }
 
 
     /**
-     * Interface for operations
+     * Interface for operations.
      */
     private static interface RetryOperation {
 
         /**
-         * Return true if done, false if there should be a retry
+         * Return true if done, false if there should be a retry.
          */
         public boolean doOp();
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
 
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
index 28b3bfb..78afc10 100644
--- 
a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
+++ 
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
@@ -50,7 +50,6 @@ import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 
 import com.google.inject.Inject;
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -126,17 +125,4 @@ public class EntityConnectionIndexImplTest extends BaseIT {
 
     }
 
-    
-
-    @Test
-    public void healthTest() {
-
-        Id appId = new SimpleId( "application" );
-        ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
-        EntityIndex ei = ecif.createEntityIndex( applicationScope ); 
-
-        assertTrue( ei.isHealthy() );
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
 
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 6a82c65..43364e8 100644
--- 
a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ 
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -35,9 +35,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.commons.lang3.time.StopWatch;
 
-import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.guice.MigrationManagerRule;
-import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
 import org.apache.usergrid.persistence.collection.util.EntityUtils;
 import org.apache.usergrid.persistence.core.cassandra.CassandraRule;
 import org.apache.usergrid.persistence.core.cassandra.ITRunner;
@@ -61,10 +59,11 @@ import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.Maps;
 import com.google.inject.Inject;
-import java.util.ArrayList;
+import org.apache.usergrid.persistence.core.util.Health;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 
 
 @RunWith(ITRunner.class)
@@ -84,7 +83,7 @@ public class EntityIndexTest extends BaseIT {
     public MigrationManagerRule migrationManagerRule;
 
     @Inject
-    public EntityIndexFactory cif;
+    public EntityIndexFactory eif;
 
 
 
@@ -100,7 +99,7 @@ public class EntityIndexTest extends BaseIT {
         IndexScope indexScope = new IndexScopeImpl( appId, "things" );
 
 
-        EntityIndex entityIndex = cif.createEntityIndex( applicationScope );
+        EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
         entityIndex.initializeIndex();
 
         InputStream is = this.getClass().getResourceAsStream( 
"/sample-large.json" );
@@ -155,7 +154,7 @@ public class EntityIndexTest extends BaseIT {
 
         IndexScope indexScope = new IndexScopeImpl( appId, "fastcars" );
 
-        EntityIndex entityIndex = cif.createEntityIndex( applicationScope );
+        EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
         entityIndex.initializeIndex();
 
         Map entityMap = new HashMap() {{
@@ -284,7 +283,7 @@ public class EntityIndexTest extends BaseIT {
 
 
 
-        EntityIndex entityIndex = cif.createEntityIndex( applicationScope );
+        EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
         entityIndex.initializeIndex();
 
         final String middleName = "middleName" + UUIDUtils.newTimeUUID();
@@ -334,7 +333,7 @@ public class EntityIndexTest extends BaseIT {
 
         IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
 
-        EntityIndex ei = cif.createEntityIndex( applicationScope );
+        EntityIndex ei = eif.createEntityIndex( applicationScope );
         ei.initializeIndex();
 
         final String middleName = "middleName" + UUIDUtils.newTimeUUID();
@@ -378,7 +377,7 @@ public class EntityIndexTest extends BaseIT {
 
         IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
 
-        EntityIndex ei = cif.createEntityIndex( applicationScope );
+        EntityIndex ei = eif.createEntityIndex( applicationScope );
         ei.createBatch();
 
         // Bill has favorites as string, age as string and retirement goal as 
number
@@ -439,6 +438,25 @@ public class EntityIndexTest extends BaseIT {
         r = ei.search(  appScope, query );
         assertEquals( bill.getId(), r.get( 0 ).getId() );
     }
+
+    
+    @Test
+    public void healthTest() {
+
+        Id appId = new SimpleId( "application" );
+        ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+
+        EntityIndex ei = eif.createEntityIndex( applicationScope ); 
+
+        assertNotEquals( "cluster should be ok", Health.RED, 
ei.getClusterHealth() );
+        assertEquals( "index not be ready yet", Health.RED, 
ei.getIndexHealth() );
+
+        ei.initializeIndex();
+        ei.refresh();
+
+        assertNotEquals( "cluster should be fine", Health.RED, 
ei.getIndexHealth() );
+        assertNotEquals( "cluster should be ready now", Health.RED, 
ei.getClusterHealth() );
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
----------------------------------------------------------------------
diff --git 
a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java 
b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
index 621c342..5351389 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/RootResource.java
@@ -19,7 +19,6 @@ package org.apache.usergrid.rest;
 
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Map;
@@ -70,6 +69,9 @@ import com.yammer.metrics.core.Sampling;
 import com.yammer.metrics.core.Summarizable;
 import com.yammer.metrics.core.Timer;
 import com.yammer.metrics.stats.Snapshot;
+import java.io.IOException;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.core.util.Health;
 
 
 /** @author [email protected] */
@@ -160,14 +162,40 @@ public class RootResource extends AbstractContextResource 
implements MetricProce
 
     @GET
     @Path("status")
-    public JSONWithPadding getStatus( @QueryParam("callback") 
@DefaultValue("callback") String callback ) {
+    public JSONWithPadding getStatus( 
+            @QueryParam("ignore_errors") @DefaultValue("true") Boolean 
ignoreErrors,
+            @QueryParam("callback") @DefaultValue("callback") String callback 
) {
+
         ApiResponse response = createApiResponse();
 
+        if ( !ignoreErrors ) {
+
+            if ( !emf.getEntityStoreHealth().equals( Health.GREEN )) {
+                throw new RuntimeException("Error connecting to datastore");
+            }
+
+            EntityManager em = emf.getEntityManager( emf.getManagementAppId() 
);
+            if ( em.getIndexHealth().equals( Health.RED) ) {
+                throw new RuntimeException("Management app index is status 
RED");
+            }
+
+        }
+
         ObjectNode node = JsonNodeFactory.instance.objectNode();
         node.put( "started", started );
         node.put( "uptime", System.currentTimeMillis() - started );
         node.put( "version", usergridSystemMonitor.getBuildNumber() );
-        node.put( "cassandraAvailable", 
usergridSystemMonitor.getIsCassandraAlive() );
+
+        // Hector status, for backwards compatibility
+        node.put( "cassandraAvailable", 
usergridSystemMonitor.getIsCassandraAlive() ); 
+
+        // Core Persistence Collections module status
+        node.put( "cassandraStatus", emf.getEntityStoreHealth().toString() ); 
+
+        // Core Persistence Query Index module status for Management App Index
+        EntityManager em = emf.getEntityManager( emf.getManagementAppId() );
+        node.put( "managementAppIndexStatus", em.getIndexHealth().toString() );
+
         dumpMetrics( node );
         response.setProperty( "status", node );
         return new JSONWithPadding( response, callback );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/rest/src/main/java/org/apache/usergrid/rest/filters/HealthCheckFilter.java
----------------------------------------------------------------------
diff --git 
a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/HealthCheckFilter.java
 
b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/HealthCheckFilter.java
deleted file mode 100644
index be09ef1..0000000
--- 
a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/HealthCheckFilter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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.rest.filters;
-
-import java.io.IOException;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-
-
-/**
- * Fail fast if connection to database or query index not healthy.
- */
-public class HealthCheckFilter implements Filter {
-
-    ServletContext sc;
-
-    @Override
-    public void init(FilterConfig fc) throws ServletException {
-        if ( sc == null ) {
-            sc = fc.getServletContext();
-        }
-    }
-
-    @Override
-    public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain 
fc) 
-            throws IOException, ServletException {
-
-
-        WebApplicationContext ctx = 
WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
-        EntityManagerFactory emf = 
(EntityManagerFactory)ctx.getBean("entityManagerFactory");
-
-        if ( !emf.verifyCollectionsModuleHealthy() ) {
-            throw new RuntimeException("Error connecting to datastore");
-        }
-        if ( !emf.verifyQueryIndexModuleHealthy() ) {
-            throw new RuntimeException("Error connecting to query index");
-        }
-    }
-
-    @Override
-    public void destroy() {
-        // no op
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git 
a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
 
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index a5fffdc..32d44f8 100644
--- 
a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ 
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -62,14 +62,21 @@ import com.sun.jersey.api.json.JSONWithPadding;
 import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
 import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
 import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
+import static javax.servlet.http.HttpServletResponse.SC_OK;
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import org.apache.usergrid.persistence.EntityManager;
 
 
 
@Component("org.apache.usergrid.rest.management.organizations.applications.ApplicationResource")
 @Scope("prototype")
 @Produces({
-        MediaType.APPLICATION_JSON, "application/javascript", 
"application/x-javascript", "text/ecmascript",
-        "application/ecmascript", "text/jscript"
+    MediaType.APPLICATION_JSON, 
+    "application/javascript", 
+    "application/x-javascript", 
+    "text/ecmascript",
+    "application/ecmascript", 
+    "text/jscript"
 })
 public class ApplicationResource extends AbstractContextResource {
 
@@ -104,10 +111,9 @@ public class ApplicationResource extends 
AbstractContextResource {
 
     @RequireOrganizationAccess
     @DELETE
-    public JSONWithPadding deleteApplicationFromOrganizationByApplicationId( 
@Context UriInfo ui,
-                                                                             
@QueryParam("callback")
-                                                                             
@DefaultValue("callback") String callback )
-            throws Exception {
+    public JSONWithPadding deleteApplicationFromOrganizationByApplicationId( 
+            @Context UriInfo ui, @QueryParam("callback") 
@DefaultValue("callback") String callback )
+        throws Exception {
 
         ApiResponse response = createApiResponse();
         response.setAction( "delete application from organization" );
@@ -120,9 +126,9 @@ public class ApplicationResource extends 
AbstractContextResource {
 
     @RequireOrganizationAccess
     @GET
-    public JSONWithPadding getApplication( @Context UriInfo ui,
-                                           @QueryParam("callback") 
@DefaultValue("callback") String callback )
-            throws Exception {
+    public JSONWithPadding getApplication( 
+            @Context UriInfo ui, @QueryParam("callback") 
@DefaultValue("callback") String callback )
+        throws Exception {
 
         ApiResponse response = createApiResponse();
         ServiceManager sm = smf.getServiceManager( applicationId );
@@ -137,9 +143,9 @@ public class ApplicationResource extends 
AbstractContextResource {
     @RequireOrganizationAccess
     @GET
     @Path("credentials")
-    public JSONWithPadding getCredentials( @Context UriInfo ui,
-                                           @QueryParam("callback") 
@DefaultValue("callback") String callback )
-            throws Exception {
+    public JSONWithPadding getCredentials( 
+            @Context UriInfo ui, @QueryParam("callback") 
@DefaultValue("callback") String callback )
+        throws Exception {
 
         ApiResponse response = createApiResponse();
         response.setAction( "get application client credentials" );
@@ -156,9 +162,9 @@ public class ApplicationResource extends 
AbstractContextResource {
     @RequireOrganizationAccess
     @POST
     @Path("credentials")
-    public JSONWithPadding generateCredentials( @Context UriInfo ui,
-                                                @QueryParam("callback") 
@DefaultValue("callback") String callback )
-            throws Exception {
+    public JSONWithPadding generateCredentials( @Context UriInfo ui, 
+            @QueryParam("callback") @DefaultValue("callback") String callback )
+        throws Exception {
 
         ApiResponse response = createApiResponse();
         response.setAction( "generate application client credentials" );
@@ -176,10 +182,13 @@ public class ApplicationResource extends 
AbstractContextResource {
     @Path("sia-provider")
     @Consumes(APPLICATION_JSON)
     @RequireOrganizationAccess
-    public JSONWithPadding configureProvider( @Context UriInfo ui, 
@QueryParam("provider_key") String siaProvider,
-                                              Map<String, Object> json,
-                                              @QueryParam("callback") 
@DefaultValue("") String callback )
-            throws Exception {
+    public JSONWithPadding configureProvider( 
+            @Context UriInfo ui, 
+            @QueryParam("provider_key") String siaProvider,
+            Map<String, Object> json, 
+            @QueryParam("callback") 
+            @DefaultValue("") String callback )
+        throws Exception {
 
         ApiResponse response = createApiResponse();
         response.setAction( "post signin provider configuration" );
@@ -188,20 +197,20 @@ public class ApplicationResource extends 
AbstractContextResource {
 
         SignInAsProvider signInAsProvider = null;
         if ( StringUtils.equalsIgnoreCase( siaProvider, "facebook" ) ) {
-            signInAsProvider =
-                    signInProviderFactory.facebook( smf.getServiceManager( 
applicationId ).getApplication() );
+            signInAsProvider = signInProviderFactory.facebook( 
+                    smf.getServiceManager( applicationId ).getApplication() );
         }
         else if ( StringUtils.equalsIgnoreCase( siaProvider, "pingident" ) ) {
-            signInAsProvider =
-                    signInProviderFactory.pingident( smf.getServiceManager( 
applicationId ).getApplication() );
+            signInAsProvider = signInProviderFactory.pingident( 
+                    smf.getServiceManager( applicationId ).getApplication() );
         }
         else if ( StringUtils.equalsIgnoreCase( siaProvider, "foursquare" ) ) {
-            signInAsProvider =
-                    signInProviderFactory.foursquare( smf.getServiceManager( 
applicationId ).getApplication() );
+            signInAsProvider = signInProviderFactory.foursquare( 
+                    smf.getServiceManager( applicationId ).getApplication() );
         }
 
-        Preconditions
-                .checkArgument( signInAsProvider != null, "No signin provider 
found by that name: " + siaProvider );
+        Preconditions.checkArgument( signInAsProvider != null, 
+                "No signin provider found by that name: " + siaProvider );
 
         signInAsProvider.saveToConfiguration( json );
 
@@ -261,14 +270,17 @@ public class ApplicationResource extends 
AbstractContextResource {
             uuidRet.put( "Export Entity", jobUUID.toString() );
         }
         catch ( NullPointerException e ) {
-            return Response.status( SC_BAD_REQUEST ).type( 
JSONPUtils.jsonMediaType( callback ) )
-                           .entity( ServiceResource.wrapWithCallback( 
e.getMessage(), callback ) ).build();
+            return Response.status( SC_BAD_REQUEST )
+                .type( JSONPUtils.jsonMediaType( callback ) )
+                .entity( ServiceResource.wrapWithCallback( e.getMessage(), 
callback ) ).build();
         }
         catch ( Exception e ) {
-            //TODO:throw descriptive error message and or include on in the 
response
-            //TODO:fix below, it doesn't work if there is an exception. Make 
it look like the OauthResponse.
-            return Response.status( SC_INTERNAL_SERVER_ERROR ).type( 
JSONPUtils.jsonMediaType( callback ) )
-                                       .entity( 
ServiceResource.wrapWithCallback( e.getMessage(), callback ) ).build();
+            // TODO: throw descriptive error message and or include on in the 
response
+            // TODO: fix below, it doesn't work if there is an exception. 
+            // Make it look like the OauthResponse.
+            return Response.status( SC_INTERNAL_SERVER_ERROR )
+                .type( JSONPUtils.jsonMediaType( callback ) )
+                .entity( ServiceResource.wrapWithCallback( e.getMessage(), 
callback ) ).build();
         }
 
         return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
@@ -278,8 +290,9 @@ public class ApplicationResource extends 
AbstractContextResource {
     @Path("collection/{collection_name}/export")
     @Consumes(APPLICATION_JSON)
     @RequireOrganizationAccess
-    public Response exportPostJson( @Context UriInfo ui,@PathParam( 
"collection_name" ) String collection_name ,Map<String, Object> json,
-                                    @QueryParam("callback") @DefaultValue("") 
String callback )
+    public Response exportPostJson( @Context UriInfo ui,
+            @PathParam( "collection_name" ) String collection_name 
,Map<String, Object> json,
+            @QueryParam("callback") @DefaultValue("") String callback )
             throws OAuthSystemException {
 
 
@@ -327,19 +340,48 @@ public class ApplicationResource extends 
AbstractContextResource {
             uuidRet.put( "Export Entity", jobUUID.toString() );
         }
         catch ( NullPointerException e ) {
-            return Response.status( SC_BAD_REQUEST ).type( 
JSONPUtils.jsonMediaType( callback ) )
-                           .entity( ServiceResource.wrapWithCallback( 
e.getMessage(), callback ) ).build();
+            return Response.status( SC_BAD_REQUEST )
+                .type( JSONPUtils.jsonMediaType( callback ) )
+                .entity( ServiceResource.wrapWithCallback( e.getMessage(), 
callback ) )
+                .build();
         }
         catch ( Exception e ) {
-            //TODO:throw descriptive error message and or include on in the 
response
-            //TODO:fix below, it doesn't work if there is an exception. Make 
it look like the OauthResponse.
-            OAuthResponse errorMsg =
-                    OAuthResponse.errorResponse( SC_INTERNAL_SERVER_ERROR 
).setErrorDescription( e.getMessage() )
-                                 .buildJSONMessage();
-            return Response.status( errorMsg.getResponseStatus() ).type( 
JSONPUtils.jsonMediaType( callback ) )
-                           .entity( ServiceResource.wrapWithCallback( 
errorMsg.getBody(), callback ) ).build();
+
+            // TODO: throw descriptive error message and or include on in the 
response
+            // TODO: fix below, it doesn't work if there is an exception.  
+            // Make it look like the OauthResponse.
+
+            OAuthResponse errorMsg = OAuthResponse.errorResponse( 
SC_INTERNAL_SERVER_ERROR )
+                .setErrorDescription( e.getMessage() )
+                .buildJSONMessage();
+
+            return Response.status( errorMsg.getResponseStatus() )
+                .type( JSONPUtils.jsonMediaType( callback ) )
+                .entity( ServiceResource.wrapWithCallback( errorMsg.getBody(), 
callback ) )
+                .build();
         }
 
         return Response.status( SC_ACCEPTED ).entity( uuidRet ).build();
     }
+
+    @GET
+    @Path("/status")
+    public Response getStatus() {
+
+        Map<String, Object> statusMap = new HashMap<String, Object>();
+
+        EntityManager em = emf.getEntityManager( applicationId );
+        try {
+            if ( em.getApplication() == null ) {
+                statusMap.put("message", "Appliction " + applicationId + " not 
found");
+                return Response.status( SC_NOT_FOUND ).entity( statusMap 
).build();
+            }
+
+        } catch (Exception ex) {
+            statusMap.put("message", "Error looking up appliction " + 
applicationId );
+            return Response.status( SC_INTERNAL_SERVER_ERROR ).entity( 
statusMap ).build();
+        }
+            
+        return Response.status( SC_OK ).entity( null ).build();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6739c/stack/rest/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/web.xml 
b/stack/rest/src/main/webapp/WEB-INF/web.xml
index c50251b..24a82ca 100644
--- a/stack/rest/src/main/webapp/WEB-INF/web.xml
+++ b/stack/rest/src/main/webapp/WEB-INF/web.xml
@@ -33,16 +33,6 @@
     </listener>
 
     <filter>
-        <filter-name>healthCheckFilter</filter-name>
-        
<filter-class>org.apache.usergrid.rest.filters.HealthCheckFilter</filter-class>
-    </filter>
-
-    <filter-mapping>
-        <filter-name>healthCheckFilter</filter-name>
-        <url-pattern>/*</url-pattern>
-    </filter-mapping>
-
-    <filter>
         <filter-name>swaggerFilter</filter-name>
         <filter-class>org.apache.usergrid.rest.SwaggerServlet</filter-class>
     </filter>

Reply via email to