From af11cc50293f483c26415ddec6691157783be3fd Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Thu, 12 Aug 2010 05:19:21 +0000 Subject: [PATCH] CSPACE-2587: Add a separate log file for service profiling information. Also adding Laramie's filter class that we're using to profile requests to the service layer. --- .../src/main/webapp/WEB-INF/web.xml | 205 +++++++++--------- .../schemas/collectionobjects_common.xsd | 1 + .../test/CollectionObjectServiceTest.java | 6 + .../resources/collectionobjects_common.xsd | 1 + .../CollectionObjectResource.java | 21 +- .../src/main/config/log/jboss-log4j.xml | 2 +- .../services/common/profile/CSpaceFilter.java | 84 +++++++ .../services/common/profile/Profiler.java | 23 +- .../common/security/SecurityInterceptor.java | 4 + .../client/java/DocumentModelHandler.java | 5 + .../client/java/RepositoryJavaClientImpl.java | 2 +- 11 files changed, 239 insertions(+), 115 deletions(-) create mode 100644 services/common/src/main/java/org/collectionspace/services/common/profile/CSpaceFilter.java diff --git a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml index 3ed461b9a..c1395cf26 100644 --- a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml +++ b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml @@ -1,98 +1,107 @@ - - - - - CollectionSpace Services - - Sets the logging context for the Tiger web-app - cspace-logging-context - CSpaceLoggingContext - java.lang.String - - - - javax.ws.rs.Application - org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication - - - - resteasy.servlet.mapping.prefix - / - - - - - contextConfigLocation - - /WEB-INF/applicationContext-security.xml - - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - - springSecurityFilterChain - /* - - - - - - - org.springframework.web.context.ContextLoaderListener - - - - - org.springframework.security.web.session.HttpSessionEventPublisher - - - - - - - org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap - - - - - - org.collectionspace.services.common.CollectionSpaceServiceContextListener - - - - - Resteasy - - org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher - - - - - Resteasy - /* - - - + + + + + CollectionSpace Services + + Sets the logging context for the Tiger web-app + cspace-logging-context + CSpaceLoggingContext + java.lang.String + + + + javax.ws.rs.Application + org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication + + + + resteasy.servlet.mapping.prefix + / + + + + + contextConfigLocation + + /WEB-INF/applicationContext-security.xml + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + CSpaceFilter + org.collectionspace.services.common.profile.CSpaceFilter + + + CSpaceFilter + /* + + + + springSecurityFilterChain + /* + + + + + + + org.springframework.web.context.ContextLoaderListener + + + + + org.springframework.security.web.session.HttpSessionEventPublisher + + + + + + + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap + + + + + + org.collectionspace.services.common.CollectionSpaceServiceContextListener + + + + + Resteasy + + org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher + + + + + Resteasy + /* + + + diff --git a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd index 3c3319578..bd3efb565 100644 --- a/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd +++ b/services/collectionobject/3rdparty/nuxeo-platform-cs-collectionobject/src/main/resources/schemas/collectionobjects_common.xsd @@ -17,6 +17,7 @@ xmlns="http://collectionspace.org/collectionobject/" targetNamespace="http://collectionspace.org/collectionobject/" version="0.1"> + diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index 30beb96ca..392eed3cd 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -1122,6 +1122,12 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl { String objectNumber, String objectName) { CollectionobjectsCommon collectionObject = new CollectionobjectsCommon(); + //REM + OtherNumber remNumber = new OtherNumber(); + remNumber.setNumberType("remNumber"); + remNumber.setNumberValue("2271966-" + System.currentTimeMillis()); + collectionObject.setRemNumber(remNumber); + BriefDescriptionList descriptionList = new BriefDescriptionList(); List descriptions = descriptionList.getBriefDescription(); descriptions.add("Papier mache bird cow mask with horns, " diff --git a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd index 306361991..9ebf9ba1d 100644 --- a/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd +++ b/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd @@ -32,6 +32,7 @@ + diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java index 5b9b31bf8..553449cab 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java @@ -69,10 +69,14 @@ import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler; import org.collectionspace.services.relation.NewRelationResource; import org.collectionspace.services.relation.RelationsCommonList; import org.collectionspace.services.relation.RelationshipType; +import org.collectionspace.services.common.profile.Profiler; + import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; import org.jboss.resteasy.util.HttpResponseCodes; + import org.nuxeo.ecm.core.api.DocumentModel; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -254,6 +258,9 @@ public class CollectionObjectResource */ private CollectionobjectsCommonList getCollectionObjectList(MultivaluedMap queryParams) { CollectionobjectsCommonList collectionObjectList; + Profiler profiler = new Profiler(this, 1); + profiler.start(); + try { ServiceContext ctx = createServiceContext(queryParams); DocumentHandler handler = createDocumentHandler(ctx); @@ -271,6 +278,8 @@ public class CollectionObjectResource Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build(); throw new WebApplicationException(response); } + + profiler.stop(); return collectionObjectList; } @@ -475,21 +484,17 @@ public class CollectionObjectResource * * This is an intentionally empty method used for getting a rough time estimate * of the overhead required for a client->server request/response cycle. + * @param ms - milliseconds to delay * * @return the response */ @GET - @Path("/roundtrip") + @Path("/{ms}/roundtrip") @Produces("application/xml") - public Response roundtrip() { + public Response roundtrip( + @PathParam("ms") String ms) { Response result = null; - if (logger.isDebugEnabled()) { - logger.debug("------------------------------------------------------------------------------"); - logger.debug("Client to server roundtrip called."); - logger.debug("------------------------------------------------------------------------------"); - logger.debug(""); - } result = Response.status(HttpResponseCodes.SC_OK).build(); return result; diff --git a/services/common/src/main/config/log/jboss-log4j.xml b/services/common/src/main/config/log/jboss-log4j.xml index 46e979dfe..c765e2831 100644 --- a/services/common/src/main/config/log/jboss-log4j.xml +++ b/services/common/src/main/config/log/jboss-log4j.xml @@ -158,7 +158,7 @@ - +