You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by rb...@apache.org on 2012/11/26 20:50:20 UTC

svn commit: r1413803 - in /shindig/trunk/java: common/src/main/java/org/apache/shindig/common/logging/i18n/ common/src/main/resources/org/apache/shindig/common/logging/i18n/ gadgets/src/main/java/org/apache/shindig/gadgets/http/

Author: rbaxter85
Date: Mon Nov 26 19:50:20 2012
New Revision: 1413803

URL: http://svn.apache.org/viewvc?rev=1413803&view=rev
Log:
Some additional logging around the request pipeline

Modified:
    shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java
    shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java

Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java?rev=1413803&r1=1413802&r2=1413803&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java Mon Nov 26 19:50:20 2012
@@ -146,5 +146,8 @@ public interface MessageKeys {
 	public static final String NO_LOCKED_DOMAIN_CONFIG="noLockedDomainConfig";
 	//Bootstrap
 	public static final String STARTING_CONN_MANAGER_WITH="startingConnManagerWith";
+	//DefaultRequestPipeline
+	public static final String CACHED_RESPONSE="cachedResponse";
+	public static final String STALE_RESPONSE="staleResponse";
 
 }

Modified: shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties?rev=1413803&r1=1413802&r2=1413803&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties (original)
+++ shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties Mon Nov 26 19:50:20 2012
@@ -174,3 +174,7 @@ startingConnManagerWith=Connection manag
 ##XSDValidator
 resolveResource=The following resources are being resolved: {0}, {1}, {2}, {3}.
 failedToValidate=An error occurred when validating {0}.
+
+##DefaultRequestPipeline
+cachedResponse=Returning cached response for the request to {0}.
+staleResponse="There was an error requesting the resource at {0} but we have a prior response in the cache.  Returning a possibly stale response from the cache.

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java?rev=1413803&r1=1413802&r2=1413803&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java Mon Nov 26 19:50:20 2012
@@ -24,6 +24,7 @@ import com.google.inject.Singleton;
 import com.google.inject.name.Named;
 
 import org.apache.shindig.common.Nullable;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
 import org.apache.shindig.common.servlet.HttpUtil;
 import org.apache.shindig.common.util.DateUtil;
 import org.apache.shindig.common.util.Utf8UrlCoder;
@@ -37,6 +38,8 @@ import org.apache.shindig.gadgets.rewrit
 
 import java.util.Collection;
 import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * A standard implementation of a request pipeline. Performs request caching and
@@ -58,6 +61,10 @@ public class DefaultRequestPipeline impl
 
   @Inject(optional = true) @Named("shindig.http.date-drift-limit-ms")
   private static long responseDateDriftLimit = DEFAULT_DRIFT_LIMIT_MS;
+  
+  //class name for logging purpose
+  private static final String classname = DefaultRequestPipeline.class.getName();
+  private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
 
   @Inject
   public DefaultRequestPipeline(HttpFetcher httpFetcher,
@@ -78,6 +85,7 @@ public class DefaultRequestPipeline impl
   }
 
   public HttpResponse execute(HttpRequest request) throws GadgetException {
+    final String method = "execute";
     normalizeProtocol(request);
 
     HttpResponse cachedResponse = checkCachedResponse(request);
@@ -91,6 +99,10 @@ public class DefaultRequestPipeline impl
     if (cachedResponse != null && !cachedResponse.isStrictNoCache()) {
       if (!cachedResponse.isStale()) {
         if (invalidationService.isValid(request, cachedResponse)) {
+          if(LOG.isLoggable(Level.FINEST)) {
+            LOG.logp(Level.FINEST, classname, method, MessageKeys.CACHED_RESPONSE, 
+                    new Object[]{request.getUri().toString()});
+          }
           return cachedResponse;
         } else {
           invalidatedResponse = cachedResponse;
@@ -186,6 +198,7 @@ public class DefaultRequestPipeline impl
    */
   protected HttpResponse fixFetchedResponse(HttpRequest request, HttpResponse fetchedResponse,
       @Nullable HttpResponse invalidatedResponse, @Nullable HttpResponse staleResponse) throws GadgetException {
+    final String method = "fixFetchedResponse";
     if (fetchedResponse.isError() && invalidatedResponse != null) {
       // Use the invalidated cached response if it is not stale. We don't update its
       // mark so it remains invalidated
@@ -195,6 +208,9 @@ public class DefaultRequestPipeline impl
     if (fetchedResponse.getHttpStatusCode() >= 500 && staleResponse != null) {
       // If we have trouble accessing the remote server,
       // Lets try the latest good but staled result
+      if(LOG.isLoggable(Level.FINEST)) {
+        LOG.logp(Level.FINEST, classname, method, MessageKeys.STALE_RESPONSE, new Object[]{request.getUri().toString()});
+      }
       return staleResponse;
     }