Skip to content

Commit

Permalink
Merge pull request #22 from LeeKyoungIl/feature/separate_illuminati_e…
Browse files Browse the repository at this point in the history
…xecutor_from_main

Improving the performance of illuminati processor.
  • Loading branch information
LeeKyoungIl authored Dec 2, 2017
2 parents 62d4a2b + 9c87534 commit 7a2553e
Show file tree
Hide file tree
Showing 32 changed files with 909 additions and 402 deletions.
4 changes: 2 additions & 2 deletions ApiServerSample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>com.leekyoungil.illuminati</groupId>
<artifactId>illuminati-client-processor</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
<scope>compile</scope>
</dependency>

Expand All @@ -96,7 +96,7 @@
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.2.2</version>
<version>4.3.0</version>
<scope>compile</scope>
</dependency>

Expand Down
8 changes: 4 additions & 4 deletions illuminati-client/illuminati-client-annotation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.leekyoungil.illuminati</groupId>
<artifactId>illuminati-client-processor</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</dependency>
```

Expand All @@ -29,7 +29,7 @@

```java
compile 'com.leekyoungil.illuminati:illuminati-client-annotation:1.1.1'
compile 'com.leekyoungil.illuminati:illuminati-client-processor:0.9.6'
compile 'com.leekyoungil.illuminati:illuminati-client-processor:0.9.7'
```

## add @Illuminati to Class
Expand Down Expand Up @@ -121,7 +121,7 @@ public class ApiSampleController {
<dependency>
<groupId>com.leekyoungil.illuminati</groupId>
<artifactId>illuminati-client-processor</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</dependency>
```

Expand All @@ -130,7 +130,7 @@ public class ApiSampleController {

```java
compile 'com.leekyoungil.illuminati:illuminati-client-annotation:1.1.1'
compile 'com.leekyoungil.illuminati:illuminati-client-processor:0.9.6'
compile 'com.leekyoungil.illuminati:illuminati-client-processor:0.9.7'
```


Expand Down
2 changes: 1 addition & 1 deletion illuminati-client/illuminati-client-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.leekyoungil.illuminati</groupId>
<artifactId>illuminati-client-common</artifactId>
<version>1.1.4</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.leekyoungil.illuminati.common.dto;

import com.leekyoungil.illuminati.common.constant.IlluminatiConstant;
import com.leekyoungil.illuminati.common.dto.enums.IlluminatiTransactionIdType;
import com.leekyoungil.illuminati.common.util.ConvertUtil;
import com.leekyoungil.illuminati.common.util.SystemUtil;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.Map;

public class IlluminatiDataInterfaceModel {

private static final Logger ILLUMINATI_DATA_INTERFACE_MODEL_LOGGER = LoggerFactory.getLogger(IlluminatiDataInterfaceModel.class);

private final static String ILLUMINATI_UNIQUE_USER_ID_KEY_NAME = "illuminatiUniqueUserId";

private final MethodSignature signature;
private final Object[] args;
private long elapsedTime = 0L;
private final Object output;

private String illuminatiUniqueUserId;
private RequestHeaderModel requestHeaderModel;
private Map<String, String> clientInfoMap;
private Map<String, Object> staticInfo;
private boolean isActiveChaosBomber;

public IlluminatiDataInterfaceModel (final HttpServletRequest request, final MethodSignature signature, final Object[] args, long elapsedTime, final Object output) {
this.signature = signature;
this.args = args;
this.elapsedTime = elapsedTime;
this.output = output;

this.initDataFromHttpRequest(request);
}

private void initDataFromHttpRequest (final HttpServletRequest request) {
this.requestHeaderModel = new RequestHeaderModel(request);
this.requestHeaderModel.setSessionTransactionId(SystemUtil.generateTransactionIdByRequest(request, IlluminatiTransactionIdType.ILLUMINATI_S_PROC_ID));
this.requestHeaderModel.setGlobalTransactionId(SystemUtil.generateTransactionIdByRequest(request, IlluminatiTransactionIdType.ILLUMINATI_G_PROC_ID));
this.requestHeaderModel.setTransactionId(SystemUtil.generateTransactionIdByRequest(request, IlluminatiTransactionIdType.ILLUMINATI_PROC_ID));
this.illuminatiUniqueUserId = SystemUtil.getValueFromHeaderByKey(request, ILLUMINATI_UNIQUE_USER_ID_KEY_NAME);
this.clientInfoMap = ConvertUtil.getClientInfoFromHttpRequest(request);
this.staticInfo = ConvertUtil.getStaticInfoFromHttpRequest(request);
this.isActiveChaosBomber = ConvertUtil.getChaosBomberFromHttpRequest(request);
}

public boolean isValid () {
if (this.requestHeaderModel == null) {
ILLUMINATI_DATA_INTERFACE_MODEL_LOGGER.warn("request is must not null");
return false;
}
if (signature == null) {
ILLUMINATI_DATA_INTERFACE_MODEL_LOGGER.warn("signature is must not null");
return false;
}

return true;
}

public long getElapsedTime () {
return this.elapsedTime;
}
public Object getOutput () {
return this.output;
}
public Object[] getParamValues () {
return this.args;
}
public MethodSignature getSignature () {
return this.signature;
}
public RequestHeaderModel getRequestHeaderModel () {
return this.requestHeaderModel;
}
public String getIlluminatiUniqueUserId() {
return this.illuminatiUniqueUserId;
}
public Map<String, String> getClientInfoMap() {
return this.clientInfoMap;
}
public Map<String, Object> getStaticInfo() {
return this.staticInfo;
}
public boolean isActiveChaosBomber() {
return this.isActiveChaosBomber;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Created by leekyoungil (leekyoungil@gmail.com) on 10/07/2017.
*/
public class IlluminatiModel implements Serializable {
public class IlluminatiTemplateInterfaceModel implements Serializable {

private static final long serialVersionUID = 7526472295622776147L;

Expand All @@ -40,25 +40,31 @@ public class IlluminatiModel implements Serializable {
private Date localTime;
private Object[] paramValues;

public IlluminatiModel () {}
public IlluminatiTemplateInterfaceModel() {}

public IlluminatiModel (final Date localTime, final long elapsedTime, final MethodSignature signature, final Object output, final Object[] paramValues) {
this.localTime = localTime;
public IlluminatiTemplateInterfaceModel(final IlluminatiDataInterfaceModel illuminatiDataInterfaceModel) {
this.localTime = new Date();
this.generateAggregateId();

this.elapsedTime = elapsedTime;
this.output = output;
this.elapsedTime = illuminatiDataInterfaceModel.getElapsedTime();
this.output = illuminatiDataInterfaceModel.getOutput();

this.timestamp = localTime.getTime();
this.logTime = DATE_FORMAT_EVENT.format(localTime);
this.paramValues = paramValues;
this.paramValues = illuminatiDataInterfaceModel.getParamValues();

this.setMethod(signature.getMethod(), signature.getParameterNames());
this.setMethod(illuminatiDataInterfaceModel.getSignature());
this.initReqHeaderInfo(illuminatiDataInterfaceModel.getRequestHeaderModel());
this.checkAndSetTransactionIdFromPostBody(this.header.getPostContentBody());
this.initUniqueUserId(illuminatiDataInterfaceModel.getIlluminatiUniqueUserId());
this.loadClientInfo(illuminatiDataInterfaceModel.getClientInfoMap());
this.staticInfo(illuminatiDataInterfaceModel.getStaticInfo());
this.isActiveChaosBomber(illuminatiDataInterfaceModel.isActiveChaosBomber());
}

public void initReqHeaderInfo (final RequestHeaderModel requestHeaderModel) {
this.header = requestHeaderModel;
}
// ################################################################################################################
// ### public methods ###
// ################################################################################################################

public void initBasicJvmInfo (final Map<String, Object> jvmInfo) {
this.jvmInfo = jvmInfo;
Expand All @@ -79,28 +85,6 @@ public void addBasicJvmMemoryInfo (final Map<String, Object> jvmMemoryInfo) {
}
}

public void loadClientInfo (final Map<String, String> clientInfoMap) {
if (clientInfoMap == null) {
return;
}

if (this.general == null) {
this.general = new RequestGeneralModel();
}

this.general.initClientInfo(clientInfoMap);
}

public void staticInfo (final Map<String, Object> staticInfo) {
if (this.serverInfo != null && !this.serverInfo.isAreadySetServerDomainAndPort()) {
this.serverInfo.setStaticInfoFromRequest(staticInfo);
}
}

public void isActiveChaosBomber (boolean isActiveChaosBomber) {
this.isActiveChaosBomber = isActiveChaosBomber;
}

public String getJsonString () {
return IlluminatiConstant.ILLUMINATI_GSON_OBJ.toJson(this);
}
Expand All @@ -124,11 +108,53 @@ public void setJavascriptUserAction () {
}
}

public void initUniqueUserId (String illuminatiUniqueUserId) {
// ################################################################################################################
// ### protected methods ###
// ################################################################################################################

protected String getId () {
return this.id;
}

protected String getParentModuleName () {
return this.parentModuleName;
}

// ################################################################################################################
// ### private methods ###
// ################################################################################################################

private void initReqHeaderInfo (final RequestHeaderModel requestHeaderModel) {
this.header = requestHeaderModel;
}

private void loadClientInfo (final Map<String, String> clientInfoMap) {
if (clientInfoMap == null) {
return;
}

if (this.general == null) {
this.general = new RequestGeneralModel();
}

this.general.initClientInfo(clientInfoMap);
}

private void staticInfo (final Map<String, Object> staticInfo) {
if (this.serverInfo != null && !this.serverInfo.isAreadySetServerDomainAndPort()) {
this.serverInfo.setStaticInfoFromRequest(staticInfo);
}
}

private void isActiveChaosBomber (boolean isActiveChaosBomber) {
this.isActiveChaosBomber = isActiveChaosBomber;
}

private void initUniqueUserId (String illuminatiUniqueUserId) {
this.illuminatiUniqueUserId = illuminatiUniqueUserId;
}

public void checkAndSetTransactionIdFromPostBody (String postBody) {
private void checkAndSetTransactionIdFromPostBody (String postBody) {
if (StringObjectUtils.isValid(postBody) == false) {
return;
}
Expand Down Expand Up @@ -164,18 +190,10 @@ private void generateAggregateId () {
this.id = StringObjectUtils.generateId(this.localTime.getTime(), null);
}

protected String getId () {
return this.id;
}

protected String getParentModuleName () {
return this.parentModuleName;
}

private void setMethod (final Method method, final String[] paramNames) {
private void setMethod (final MethodSignature methodSignature) {
if (this.general == null) {
this.general = new RequestGeneralModel();
}
this.general.setMethod(method, paramNames, this.paramValues);
this.general.setMethod(methodSignature.getMethod(), methodSignature.getParameterNames(), this.paramValues);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ public RequestHeaderModel (final HttpServletRequest request) {
if (request != null) {
this.init(request);
//this.getIlluminatiProcId(request);

if ("post".equals(request.getMethod().toLowerCase())) {
if ("post".equalsIgnoreCase(request.getMethod())) {
try {
this.postContentBody = StringObjectUtils.getPostBodyString(request);
} catch (IOException ex) {
Expand Down Expand Up @@ -418,18 +417,21 @@ private void init (HttpServletRequest request) {
field.setAccessible(true);
field.set(this, value);
} catch (Exception ex) {
if (this.anotherHeader == null) {
this.anotherHeader = new HashMap<String, String>();
}
try {
if (this.anotherHeader == null) {
this.anotherHeader = new HashMap<String, String>();
}

final String key = (String) headerNames.nextElement();
final String value = request.getHeader(key);
this.anotherHeader.put(key, value);
final String key = (String) headerNames.nextElement();
final String value = request.getHeader(key);
this.anotherHeader.put(key, value);
} catch (Exception ex1) {
// ignore
}

REQUEST_HEADER_MODEL_LOGGER.debug("Sorry. check your header (There Exception is no problem in operation). ("+ex.toString()+")");
}
}

}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ public void run() {
}

try {
Thread.sleep(1000);
Thread.sleep(10000);
} catch (InterruptedException e) {
// ignore
}
}
}
};

SystemUtil.createSystemThread(threadCheckRunnable, "debug");
SystemUtil.createSystemThread(threadCheckRunnable, "ILLUMINATI_DEBUG_THREAD");
}
}
}
Loading

0 comments on commit 7a2553e

Please sign in to comment.