Author: olamy
Date: Tue Feb 28 21:03:07 2012
New Revision: 1294829
URL: http://svn.apache.org/viewvc?rev=1294829&view=rev
Log:
add a http header in put response X-DirectMemory-SerializeSize to give
information on byte numbers stored on server side.
Modified:
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
incubator/directmemory/trunk/server/directmemory-server-commons/src/main/java/org/apache/directmemory/server/commons/DirectMemoryHttpConstants.java
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
Modified:
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js?rev=1294829&r1=1294828&r2=1294829&view=diff
==============================================================================
---
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
(original)
+++
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
Tue Feb 28 21:03:07 2012
@@ -55,8 +55,10 @@ $(function() {
204: function() {
displayWarning("not put in cache");
},
- 200:function( data ) {
- displayInfo('put in cache with key:'+wine.name);
+ 200:function( data, textStatus, jqXHR ) {
+ var size = jqXHR.getResponseHeader('X-DirectMemory-SerializeSize');
+ displayInfo('put in cache with key:'+wine.name+ " bytes
stored:"+size);
+
},
500:function(data){
displayError("error put in cache");
Modified:
incubator/directmemory/trunk/server/directmemory-server-commons/src/main/java/org/apache/directmemory/server/commons/DirectMemoryHttpConstants.java
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server-commons/src/main/java/org/apache/directmemory/server/commons/DirectMemoryHttpConstants.java?rev=1294829&r1=1294828&r2=1294829&view=diff
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server-commons/src/main/java/org/apache/directmemory/server/commons/DirectMemoryHttpConstants.java
(original)
+++
incubator/directmemory/trunk/server/directmemory-server-commons/src/main/java/org/apache/directmemory/server/commons/DirectMemoryHttpConstants.java
Tue Feb 28 21:03:07 2012
@@ -29,6 +29,7 @@ public class DirectMemoryHttpConstants
public static final String EXPIRES_IN_HTTP_HEADER =
"X-DirectMemory-ExpiresIn";
+ public static final String EXPIRES_SERIALIZE_SIZE =
"X-DirectMemory-SerializeSize";
private DirectMemoryHttpConstants()
{
Modified:
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
URL:
http://svn.apache.org/viewvc/incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java?rev=1294829&r1=1294828&r2=1294829&view=diff
==============================================================================
---
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
(original)
+++
incubator/directmemory/trunk/server/directmemory-server/src/main/java/org/apache/directmemory/server/services/DirectMemoryServlet.java
Tue Feb 28 21:03:07 2012
@@ -131,12 +131,15 @@ public class DirectMemoryServlet
//if exists free first ?
//if ( cacheService.retrieveByteArray( key ) == null )
- Pointer p = cacheService.putByteArray( key, request.getCacheContent(),
request.getExpiresIn() );
+ byte[] bytes = request.getCacheContent();
+ Pointer p = cacheService.putByteArray( key, bytes,
request.getExpiresIn() );
if ( p == null )
{
resp.sendError( HttpServletResponse.SC_NO_CONTENT, "Content not
put in cache for key: " + key );
return;
}
+ log.debug( "put content for key {} size {}", key, bytes.length );
+ resp.addHeader( DirectMemoryHttpConstants.EXPIRES_SERIALIZE_SIZE,
Integer.toString( bytes.length ) );
}
protected ContentTypeHandler findPutCacheContentTypeHandler(
HttpServletRequest req, HttpServletResponse response )
@@ -171,6 +174,7 @@ public class DirectMemoryServlet
return;
}
cacheService.free( pointer );
+ log.debug( "free content of key: {}", key );
}
@Override
@@ -210,7 +214,7 @@ public class DirectMemoryServlet
byte[] bytes = cacheService.retrieveByteArray( key );
- log.debug( "content size {} for key {}", ( bytes == null ? "null" :
bytes.length ), key );
+ log.debug( "return content size {} for key {}", ( bytes == null ?
"null" : bytes.length ), key );
if ( bytes == null || bytes.length == 0 )
{