]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA: Adding profiling aop/aspects for blob creation.
authorRichard Millet <remillet@yahoo.com>
Tue, 11 Dec 2018 17:47:06 +0000 (09:47 -0800)
committerRichard Millet <remillet@yahoo.com>
Tue, 11 Dec 2018 17:47:06 +0000 (09:47 -0800)
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/aspect/BlobProfileAspect.java [new file with mode: 0644]
services/JaxRsServiceProvider/src/main/resources/META-INF/aop.xml
services/JaxRsServiceProvider/src/main/resources/log4j.properties
services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java

diff --git a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/aspect/BlobProfileAspect.java b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/aspect/BlobProfileAspect.java
new file mode 100644 (file)
index 0000000..a55b797
--- /dev/null
@@ -0,0 +1,73 @@
+package org.collectionspace.services.aspect;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+import org.collectionspace.services.client.Profiler;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Aspect
+public class BlobProfileAspect {
+       private static final Logger logger = LoggerFactory.getLogger(BlobProfileAspect.class);
+       private static int indent = 0;
+       
+       private int pushIndent() {
+               return indent++;
+       }
+       
+       private int popIndent() {
+               return --indent;
+       }
+
+
+       @Around("blobResourceCreateMethods()")
+    public Object profile(ProceedingJoinPoint pjp) throws Throwable {
+               Object result = null;
+               
+               // Start profiler
+        Profiler profiler = new Profiler(pjp.getSignature().toShortString(), pushIndent());
+        profiler.start();
+
+        try {
+                       Object[] args = pjp.getArgs(); // gets us a read-only copy of the argument(s)
+            result = pjp.proceed();    // finish the call
+        } finally {
+            // No cleanup needed.
+        }
+        
+        profiler.stop();
+        popIndent();
+        
+        return result;
+    }
+
+       /**
+        * Setup a pointcut for all the Blob methods related to creating a new blob
+        */
+       @Pointcut("execution(* org.nuxeo.ecm.platform.filemanager.service.extension.AbstractFileImporter.create(..))")
+    public void nuxeoImagePluginCutPoint() {}
+       
+       @Pointcut("execution(* org.collectionspace.services.common.imaging.nuxeo.NuxeoBlobUtils.createDocumentFromBlob(..))")
+    public void createDocumentFromBlobCutPoint() {}
+       
+    @Pointcut("execution(* org.collectionspace.services.blob.BlobResource.create(..))")
+    public void blobResourceCreateCutPoint() {}
+    
+    @Pointcut("execution(* org.collectionspace.services.blob.BlobResource.createBlob(..))")
+    public void blobResourceCreatBlobCutPoint() {}
+    
+    @Pointcut("execution(void org.collectionspace.services.common.blob.BlobInput.createBlobFile(..))")
+    public void blobUtilCreatBlobFile() {}
+    
+    @Pointcut("createDocumentFromBlobCutPoint()"
+               + " || blobResourceCreateCutPoint()"
+               + " || blobResourceCreatBlobCutPoint()"
+               + " || blobUtilCreatBlobFile()"
+               + " || nuxeoImagePluginCutPoint()")
+    public void blobResourceCreateMethods() {}
+
+}
index 2ef53fb0cd010286b1f3e2626b97487f9c7b06f0..9e8ae06a12fc4350c35860b9f307d55c26d20885 100644 (file)
@@ -3,6 +3,7 @@
 <aspectj>
     <weaver>
         <!-- only weave classes in our application-specific packages -->
+        <include within="org.nuxeo..*"/>
         <include within="org.collectionspace.services..*"/>
         <include within="org.collectionspace.services.aspect.*"/>
     </weaver>
@@ -10,5 +11,6 @@
     <aspects>        
         <!-- weave in just this aspect --> 
         <aspect name="org.collectionspace.services.aspect.JaxbXMLGregorianCalendarMarshal"/>
+        <aspect name="org.collectionspace.services.aspect.BlobProfileAspect"/>
     </aspects>
 </aspectj>
\ No newline at end of file
index deebd4a439212b7831c25944d0021fd76700b1b6..d303420f9d296b52d2b4ef5faddfd858d327b5bc 100644 (file)
@@ -45,7 +45,7 @@ log4j.appender.cspace_perf_appender.layout.ConversionPattern=%d %-5p [%t] [%c:%L
 #
 # This logger uses the "cspace_perf_appender" appender to log performance profiling information.
 #
-log4j.logger.perf.collectionspace=WARN, cspace_perf_appender, stdout
+log4j.logger.perf.collectionspace=TRACE, cspace_perf_appender, stdout
 # send the logs only to our appender -no inheritence.
 log4j.additivity.perf.collectionspace=false
 
index 6a7d3e8be871c0f905cc5a8745c1ef02bac3c595..b5f49624184cd82cd56e2e65dfd2fa74b0cf865d 100644 (file)
@@ -178,6 +178,7 @@ public class BlobInput {
        // FIXME: REM - The callers of this method are sending us a multipart form-data post, so why
        // are we also receiving the blobUri?
        //
+       @YourAnnotation
        public void createBlobFile(HttpServletRequest req, String blobUri) throws Exception {
        File tmpFile = org.collectionspace.services.common.FileUtilities.createTmpFile(req);
        this.setIsTemporaryFile(true);