Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jgambarios committed Jan 25, 2018
1 parent 6f2f7cc commit 83a907a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 54 deletions.
9 changes: 4 additions & 5 deletions dotCMS/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand All @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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<String> 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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -230,7 +230,7 @@ private void updateAuditStatus() throws DotPublisherException, DotDataException
List<PublishAuditStatus> 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();
Expand All @@ -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);
}
}
}
Expand All @@ -267,7 +267,7 @@ private Map<String, Map<String, EndpointDetail>> 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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())))
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand All @@ -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();
Expand Down

0 comments on commit 83a907a

Please sign in to comment.