usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [2/5] git commit: Add new ignore_error argument to /status end-point, which defaults to true and, also added Index health check to the /org/app/status end-point.
Date Wed, 05 Nov 2014 22:48:22 GMT
Add new ignore_error argument to /status end-point, which defaults to true and, also added
Index health check to the /org/app/status end-point.


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

Branch: refs/heads/key-row-sharding
Commit: 5285f3d595f571c1adfbfc252cec773f463a7c2c
Parents: 1dd6739
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Tue Nov 4 10:16:28 2014 -0500
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Tue Nov 4 10:16:28 2014 -0500

----------------------------------------------------------------------
 .../usergrid/rest/JacksonCustomMapperProvider.java    |  7 +++----
 .../java/org/apache/usergrid/rest/RootResource.java   | 14 +++++++++++---
 .../applications/ApplicationResource.java             |  6 ++++++
 3 files changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5285f3d5/stack/rest/src/main/java/org/apache/usergrid/rest/JacksonCustomMapperProvider.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/JacksonCustomMapperProvider.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/JacksonCustomMapperProvider.java
index ba0e44a..a0d7948 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/JacksonCustomMapperProvider.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/JacksonCustomMapperProvider.java
@@ -17,8 +17,8 @@
 package org.apache.usergrid.rest;
 
 
-import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.ContextResolver;
@@ -39,12 +39,11 @@ public class JacksonCustomMapperProvider implements ContextResolver<ObjectMapper
     private static final Logger logger = LoggerFactory.getLogger( JacksonCustomMapperProvider.class
);
 
     ObjectMapper mapper = new ObjectMapper();
+    
 
     public JacksonCustomMapperProvider() {
         logger.info( "JacksonCustomMapperProvider installed" );
-
-        // Should not be necessary
-        //mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        mapper.configure( SerializationFeature.INDENT_OUTPUT, true); // pretty print 
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5285f3d5/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 5351389..f324d28 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
@@ -160,15 +160,24 @@ public class RootResource extends AbstractContextResource implements
MetricProce
     }
 
 
+    /**
+     * Return status of this Usergrid instance in JSON format.
+     * 
+     * By Default this end-point will ignore errors but if you call it with ignore_status=false
+     * then it will return HTTP 500 if either the Entity store or the Index for the management
+     * application are in a bad state.
+     * 
+     * @param ignoreError Ignore any errors and return status no matter what.
+     */
     @GET
     @Path("status")
     public JSONWithPadding getStatus( 
-            @QueryParam("ignore_errors") @DefaultValue("true") Boolean ignoreErrors,
+            @QueryParam("ignore_error") @DefaultValue("true") Boolean ignoreError,
             @QueryParam("callback") @DefaultValue("callback") String callback ) {
 
         ApiResponse response = createApiResponse();
 
-        if ( !ignoreErrors ) {
+        if ( !ignoreError ) {
 
             if ( !emf.getEntityStoreHealth().equals( Health.GREEN )) {
                 throw new RuntimeException("Error connecting to datastore");
@@ -178,7 +187,6 @@ public class RootResource extends AbstractContextResource implements MetricProce
             if ( em.getIndexHealth().equals( Health.RED) ) {
                 throw new RuntimeException("Management app index is status RED");
             }
-
         }
 
         ObjectNode node = JsonNodeFactory.instance.objectNode();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5285f3d5/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 32d44f8..7bfd895 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
@@ -66,6 +66,7 @@ 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;
+import org.apache.usergrid.persistence.core.util.Health;
 
 
 @Component("org.apache.usergrid.rest.management.organizations.applications.ApplicationResource")
@@ -371,6 +372,11 @@ public class ApplicationResource extends AbstractContextResource {
         Map<String, Object> statusMap = new HashMap<String, Object>();
 
         EntityManager em = emf.getEntityManager( applicationId );
+        if ( !em.getIndexHealth().equals( Health.RED ) ) {
+            statusMap.put("message", "Index Health Status RED for application " + applicationId
);
+            return Response.status( SC_INTERNAL_SERVER_ERROR ).entity( statusMap ).build();
+        }
+
         try {
             if ( em.getApplication() == null ) {
                 statusMap.put("message", "Appliction " + applicationId + " not found");


Mime
View raw message