From: Richard Millet Date: Tue, 11 Dec 2018 17:47:06 +0000 (-0800) Subject: NOJIRA: Adding profiling aop/aspects for blob creation. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=7e8545fe3728e19228a53bbefe38489def3b40a8;p=tmp%2Fjakarta-migration.git NOJIRA: Adding profiling aop/aspects for blob creation. --- 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 index 000000000..a55b797ec --- /dev/null +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/aspect/BlobProfileAspect.java @@ -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() {} + +} diff --git a/services/JaxRsServiceProvider/src/main/resources/META-INF/aop.xml b/services/JaxRsServiceProvider/src/main/resources/META-INF/aop.xml index 2ef53fb0c..9e8ae06a1 100644 --- a/services/JaxRsServiceProvider/src/main/resources/META-INF/aop.xml +++ b/services/JaxRsServiceProvider/src/main/resources/META-INF/aop.xml @@ -3,6 +3,7 @@ + @@ -10,5 +11,6 @@ + \ No newline at end of file diff --git a/services/JaxRsServiceProvider/src/main/resources/log4j.properties b/services/JaxRsServiceProvider/src/main/resources/log4j.properties index deebd4a43..d303420f9 100644 --- a/services/JaxRsServiceProvider/src/main/resources/log4j.properties +++ b/services/JaxRsServiceProvider/src/main/resources/log4j.properties @@ -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 diff --git a/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java b/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java index 6a7d3e8be..b5f496241 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java +++ b/services/common/src/main/java/org/collectionspace/services/common/blob/BlobInput.java @@ -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);