diff --git a/dotCMS/dependencies.gradle b/dotCMS/dependencies.gradle index a5d799f45144..c7f715e65039 100644 --- a/dotCMS/dependencies.gradle +++ b/dotCMS/dependencies.gradle @@ -116,11 +116,10 @@ dependencies { compile group: 'com.dotcms.lib', name: 'dot.jython', version:'2.2.1_2' compile group: 'com.dotcms.lib', name: 'dot.ldap', version:'ukv_2' compile group: 'com.dotcms.lib', name: 'dot.lesscss', version:'1.5.1-SNAPSHOT_3' - compile group: 'com.dotcms.lib', name: 'dot.log4j-1.2-api', version:'2.3_1' - compile group: 'com.dotcms.lib', name: 'dot.log4j-api', version:'2.3_1' - compile group: 'com.dotcms.lib', name: 'dot.log4j-core', version:'2.3_2' - compile group: 'com.dotcms.lib', name: 'dot.log4j-jcl', version:'2.3_1' - compile group: 'com.dotcms.lib', name: 'dot.log4j-web', version:'2.3_2' + compile group: 'com.dotcms.lib', name: 'dot.log4j-api', version:'2.3_2' + compile group: 'com.dotcms.lib', name: 'dot.log4j-core', version:'2.3_3' + compile group: 'com.dotcms.lib', name: 'dot.log4j-jcl', version:'2.3_2' + compile group: 'com.dotcms.lib', name: 'dot.log4j-web', version:'2.3_3' compile group: 'com.dotcms.lib', name: 'dot.lucene-analyzers-common', version:'4.10.4_1' compile group: 'com.dotcms.lib', name: 'dot.lucene-core', version:'4.10.4_1' compile group: 'com.dotcms.lib', name: 'dot.lucene-expressions', version:'4.10.4_1' diff --git a/dotCMS/src/integration-test/java/com/dotmarketing/business/cache/provider/guava/CachePerformanceTest.java b/dotCMS/src/integration-test/java/com/dotmarketing/business/cache/provider/guava/CachePerformanceTest.java index 7724811d6f13..9c07877c08b9 100644 --- a/dotCMS/src/integration-test/java/com/dotmarketing/business/cache/provider/guava/CachePerformanceTest.java +++ b/dotCMS/src/integration-test/java/com/dotmarketing/business/cache/provider/guava/CachePerformanceTest.java @@ -2,26 +2,22 @@ import static org.hamcrest.MatcherAssert.assertThat; +import com.dotcms.repackage.org.apache.commons.lang.RandomStringUtils; +import com.dotmarketing.business.cache.provider.CacheProvider; +import com.dotmarketing.business.cache.provider.CacheProviderStats; +import com.dotmarketing.business.cache.provider.CacheStats; +import com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded; +import com.dotmarketing.util.Logger; +import com.dotmarketing.util.UtilMethods; +import com.hazelcast.nio.serialization.HazelcastSerializationException; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - -import com.dotmarketing.business.cache.provider.CacheProviderStats; -import com.dotmarketing.business.cache.provider.CacheStats; -import com.dotmarketing.util.UtilMethods; import org.junit.Test; -import com.dotcms.repackage.org.apache.commons.lang.RandomStringUtils; -import com.dotcms.repackage.org.apache.log4j.Logger; -import com.dotmarketing.business.cache.provider.CacheProvider; -import com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderClient; -import com.dotmarketing.business.cache.provider.hazelcast.HazelcastCacheProviderEmbedded; -import com.hazelcast.nio.serialization.HazelcastSerializationException; - - public class CachePerformanceTest { final String[] GROUPNAMES = {"testGroup", "testGroup2", "myBigGroup"}; @@ -35,7 +31,6 @@ public class CachePerformanceTest { final int numberOfThreads = 20; final int numberOfGroups = 10; final int maxCharOfObjects = 50000; - private static final Logger LOGGER = Logger.getLogger("ROOT"); private final long startTime = System.currentTimeMillis(); // Class provider = GuavaCache.class; @@ -44,10 +39,6 @@ public class CachePerformanceTest { @Test public void testInit() throws Exception { - LOGGER.info("INFO TEST"); - LOGGER.debug("DEBUG TEST"); - LOGGER.error("ERROR TEST"); - CacheProvider cache =(CacheProvider) provider.newInstance(); cache.init(); @@ -102,23 +93,31 @@ public void testInit() throws Exception { // test causing an error and recovering - LOGGER.info("Total Memory Available : " + UtilMethods.prettyByteify( Runtime.getRuntime().maxMemory())); - LOGGER.info("Memory Allocated : " + UtilMethods.prettyByteify( Runtime.getRuntime().totalMemory())); - LOGGER.info("Filled Memory : " + UtilMethods.prettyByteify( Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() )); - LOGGER.info("Free Memory : " + UtilMethods.prettyByteify( Runtime.getRuntime().freeMemory() )); + Logger.info(this.getClass(), "Total Memory Available : " + UtilMethods + .prettyByteify(Runtime.getRuntime().maxMemory())); + Logger.info(this.getClass(), + "Memory Allocated : " + UtilMethods.prettyByteify(Runtime.getRuntime().totalMemory())); + Logger.info(this.getClass(), "Filled Memory : " + UtilMethods + .prettyByteify(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())); + Logger.info(this.getClass(), + "Free Memory : " + UtilMethods.prettyByteify(Runtime.getRuntime().freeMemory())); testMultithreaded(cache, numberOfThreads, false, true, false); - LOGGER.info("Total Memory Available : " + UtilMethods.prettyByteify( Runtime.getRuntime().maxMemory())); - LOGGER.info("Memory Allocated : " + UtilMethods.prettyByteify( Runtime.getRuntime().totalMemory())); - LOGGER.info("Filled Memory : " + UtilMethods.prettyByteify( Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() )); - LOGGER.info("Free Memory : " + UtilMethods.prettyByteify( Runtime.getRuntime().freeMemory() )); + Logger.info(this.getClass(), "Total Memory Available : " + UtilMethods + .prettyByteify(Runtime.getRuntime().maxMemory())); + Logger.info(this.getClass(), + "Memory Allocated : " + UtilMethods.prettyByteify(Runtime.getRuntime().totalMemory())); + Logger.info(this.getClass(), "Filled Memory : " + UtilMethods + .prettyByteify(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())); + Logger.info(this.getClass(), + "Free Memory : " + UtilMethods.prettyByteify(Runtime.getRuntime().freeMemory())); CacheProviderStats pStats = cache.getStats(); Set columns = pStats.getStatColumns(); for (CacheStats cs :pStats.getStats()) { for(String col : columns){ - LOGGER.info(col + " : " + cs.getStatValue(col)); + Logger.info(this.getClass(), col + " : " + cs.getStatValue(col)); } } diff --git a/dotCMS/src/main/java/com/dotcms/publisher/business/PublisherQueueJob.java b/dotCMS/src/main/java/com/dotcms/publisher/business/PublisherQueueJob.java index 43282ef4c440..d31860770b9a 100644 --- a/dotCMS/src/main/java/com/dotcms/publisher/business/PublisherQueueJob.java +++ b/dotCMS/src/main/java/com/dotcms/publisher/business/PublisherQueueJob.java @@ -22,7 +22,7 @@ import com.dotcms.repackage.com.google.common.collect.Sets; import com.dotcms.repackage.javax.ws.rs.client.Client; import com.dotcms.repackage.javax.ws.rs.client.WebTarget; -import com.dotcms.repackage.org.apache.log4j.MDC; +import com.dotcms.repackage.org.apache.logging.log4j.ThreadContext; import com.dotcms.rest.RestClientBuilder; import com.dotmarketing.business.APILocator; import com.dotmarketing.db.DbConnectionFactory; @@ -134,7 +134,7 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution + ". Publish Date: " + publishDate); tempBundleId = (String) bundle.get("bundle_id"); - MDC.put(BUNDLE_ID, BUNDLE_ID + "=" + tempBundleId); + ThreadContext.put(BUNDLE_ID, BUNDLE_ID + "=" + tempBundleId); try { PushPublishLogger.log(this.getClass(), "Pre-publish work started."); @@ -195,7 +195,7 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution pubAPI.deleteElementsFromPublishQueueTable(pconf.getId()); } } finally { - MDC.remove(BUNDLE_ID); + ThreadContext.remove(BUNDLE_ID); } } Logger.debug(PublisherQueueJob.class, "Finished PublishQueue Job"); @@ -230,7 +230,7 @@ private void updateAuditStatus() throws DotPublisherException, DotDataException List pendingBundleAudits = pubAuditAPI.getPendingPublishAuditStatus(); // For each bundle audit for ( PublishAuditStatus bundleAudit : pendingBundleAudits ) { - MDC.put(BUNDLE_ID, BUNDLE_ID + "=" + bundleAudit.getBundleId()); + ThreadContext.put(BUNDLE_ID, BUNDLE_ID + "=" + bundleAudit.getBundleId()); try { PublishAuditHistory localHistory = bundleAudit.getStatusPojo(); @@ -248,8 +248,8 @@ private void updateAuditStatus() throws DotPublisherException, DotDataException pubAPI.deleteElementsFromPublishQueueTable(bundleAudit.getBundleId()); } } finally { - MDC.remove(BUNDLE_ID); - MDC.remove(ENDPOINT_NAME); + ThreadContext.remove(BUNDLE_ID); + ThreadContext.remove(ENDPOINT_NAME); } } } @@ -267,7 +267,7 @@ private Map> collectEndpointInfoFromRemote(f PublishingEndPoint targetEndpoint = endpointAPI.findEndPointById(endpointID); if ( targetEndpoint != null && !targetEndpoint.isSending() ) { - MDC.put(ENDPOINT_NAME, ENDPOINT_NAME + "=" + targetEndpoint.getServerName()); + ThreadContext.put(ENDPOINT_NAME, ENDPOINT_NAME + "=" + targetEndpoint.getServerName()); // Don't poll status for static publishing if (!AWSS3Publisher.PROTOCOL_AWS_S3.equalsIgnoreCase(targetEndpoint.getProtocol()) && !StaticPublisher.PROTOCOL_STATIC.equalsIgnoreCase(targetEndpoint.getProtocol())) { diff --git a/dotCMS/src/main/java/com/dotcms/publisher/pusher/PushPublisher.java b/dotCMS/src/main/java/com/dotcms/publisher/pusher/PushPublisher.java index 00ad32a7d09d..0ac2320a3bf7 100644 --- a/dotCMS/src/main/java/com/dotcms/publisher/pusher/PushPublisher.java +++ b/dotCMS/src/main/java/com/dotcms/publisher/pusher/PushPublisher.java @@ -46,7 +46,7 @@ import com.dotcms.repackage.javax.ws.rs.core.Response; import com.dotcms.repackage.org.apache.commons.httpclient.HttpStatus; import com.dotcms.repackage.org.apache.commons.io.FileUtils; -import com.dotcms.repackage.org.apache.log4j.MDC; +import com.dotcms.repackage.org.apache.logging.log4j.ThreadContext; import com.dotcms.repackage.org.glassfish.jersey.client.ClientProperties; import com.dotcms.rest.RestClientBuilder; import com.dotcms.system.event.local.business.LocalSystemEventsAPI; @@ -223,8 +223,8 @@ public PublisherConfig process ( final PublishStatus status ) throws DotPublishi Bundle b=APILocator.getBundleAPI().getBundleById(this.config.getId()); //For logging purpose - MDC.put(ENDPOINT_NAME, ENDPOINT_NAME + "=" + endpoint.getServerName()); - MDC.put(BUNDLE_ID, BUNDLE_ID + "=" + b.getName()); + ThreadContext.put(ENDPOINT_NAME, ENDPOINT_NAME + "=" + endpoint.getServerName()); + ThreadContext.put(BUNDLE_ID, BUNDLE_ID + "=" + b.getName()); PushPublishLogger.log(this.getClass(), "Status Update: Sending Bundle"); WebTarget webTarget = client.target(endpoint.toURL()+"/api/bundlePublisher/publish") .queryParam("AUTH_TOKEN", retriveKeyString(PublicEncryptionFactory.decryptString(endpoint.getAuthKey().toString()))) @@ -276,8 +276,8 @@ public PublisherConfig process ( final PublishStatus status ) throws DotPublishi PushPublishLogger.log(this.getClass(), "Status Update: Failed to send bundle. Exception: " + e.getMessage()); } finally { CloseUtils.closeQuietly(bundleStream); - MDC.remove(ENDPOINT_NAME); - MDC.remove(BUNDLE_ID); + ThreadContext.remove(ENDPOINT_NAME); + ThreadContext.remove(BUNDLE_ID); } if (isHistoryEmpty || failedEnvironment) { currentStatusHistory.addOrUpdateEndpoint(environment.getId(), endpoint.getId(), detail); diff --git a/dotCMS/src/test/java/com/dotmarketing/business/cache/provider/h22/H22CacheTest.java b/dotCMS/src/test/java/com/dotmarketing/business/cache/provider/h22/H22CacheTest.java index c8e887077352..d622483616e1 100644 --- a/dotCMS/src/test/java/com/dotmarketing/business/cache/provider/h22/H22CacheTest.java +++ b/dotCMS/src/test/java/com/dotmarketing/business/cache/provider/h22/H22CacheTest.java @@ -1,10 +1,9 @@ package com.dotmarketing.business.cache.provider.h22; +import static org.hamcrest.MatcherAssert.assertThat; + import com.dotcms.repackage.org.apache.commons.lang.RandomStringUtils; -import com.dotcms.repackage.org.apache.log4j.Logger; import com.liferay.util.FileUtil; -import org.junit.Test; - import java.io.File; import java.sql.Connection; import java.sql.SQLException; @@ -15,8 +14,7 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - -import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.Test; public class H22CacheTest { @@ -36,15 +34,10 @@ public class H22CacheTest { final int numberOfThreads = 40; final int numberOfGroups = 100; final int maxCharOfObjects = 100; - private static final Logger LOGGER = Logger.getLogger(H22CacheTest.class); - - @Test public void testInit() throws Exception { - LOGGER.info("INFO TEST"); - LOGGER.debug("DEBUG TEST"); - LOGGER.error("ERROR TEST"); + // File dir = Files.createTempDir(); File dir = new File("/tmp/h2cachetest"); dir.delete();