summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByung-Woo Jun <byung-woo.jun@ericsson.com>2018-03-19 13:25:50 -0400
committerByung-Woo Jun <byung-woo.jun@ericsson.com>2018-03-19 13:25:50 -0400
commit5e6179609805dfab1b571d58517cef6d3a169f77 (patch)
tree2118ca8a21a4990c760d55cacea3507dd45e7ff2
parent88a47679a783c620683d283b20b04fcdc97b4c8f (diff)
Fix String concatenation optimzation
Replaced queryString from String to StringBuffer for memory and GC optimization Change-Id: I0e4656d1fdf8ff773704e788a3b59b3f910ae3ba Issue-ID: SO-500 Signed-off-by: byungwoojun<byung-woo.jun@ericsson.com>
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java40
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java40
2 files changed, 40 insertions, 40 deletions
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
index 358fe53ecb..925086a9d3 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -70,59 +70,59 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
long startTime = System.currentTimeMillis ();
try {
session.beginTransaction ();
- String queryString = "update InfraActiveRequests set ";
+ StringBuilder queryString = new StringBuilder("update InfraActiveRequests set ");
if (statusMessage != null) {
- queryString += "statusMessage = :statusMessage, ";
+ queryString.append("statusMessage = :statusMessage, ");
}
if (responseBody != null) {
- queryString += "responseBody = :responseBody, ";
+ queryString.append("responseBody = :responseBody, ");
}
if (requestStatus != null) {
- queryString += "requestStatus = :requestStatus, ";
+ queryString.append("requestStatus = :requestStatus, ");
}
if (progress != null) {
- queryString += "progress = :progress, ";
+ queryString.append("progress = :progress, ");
}
if (vnfOutputs != null) {
- queryString += "vnfOutputs = :vnfOutputs, ";
+ queryString.append("vnfOutputs = :vnfOutputs, ");
}
if (serviceInstanceId != null) {
- queryString += "serviceInstanceId = :serviceInstanceId, ";
+ queryString.append("serviceInstanceId = :serviceInstanceId, ");
}
if (networkId != null) {
- queryString += "networkId = :networkId, ";
+ queryString.append("networkId = :networkId, ");
}
if (vnfId != null) {
- queryString += "vnfId = :vnfId, ";
+ queryString.append("vnfId = :vnfId, ");
}
if (vfModuleId != null) {
- queryString += "vfModuleId = :vfModuleId, ";
+ queryString.append("vfModuleId = :vfModuleId, ");
}
if (volumeGroupId != null) {
- queryString += "volumeGroupId = :volumeGroupId, ";
+ queryString.append("volumeGroupId = :volumeGroupId, ");
}
if (serviceInstanceName != null) {
- queryString += "serviceInstanceName = :serviceInstanceName, ";
+ queryString.append("serviceInstanceName = :serviceInstanceName, ");
}
if (vfModuleName != null) {
- queryString += "vfModuleName = :vfModuleName, ";
+ queryString.append("vfModuleName = :vfModuleName, ");
}
if (configurationId != null) {
- queryString += "configurationId = :configurationId, ";
+ queryString.append("configurationId = :configurationId, ");
}
if (configurationName != null) {
- queryString += "configurationName = :configurationName, ";
+ queryString.append("configurationName = :configurationName, ");
}
if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
- queryString += "endTime = :endTime, ";
+ queryString.append("endTime = :endTime, ");
} else {
- queryString += "modifyTime = :modifyTime, ";
+ queryString.append("modifyTime = :modifyTime, ");
}
- queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId";
+ queryString.append("lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId");
- logger.debug("Executing update: " + queryString);
+ logger.debug("Executing update: " + queryString.toString());
- Query query = session.createQuery (queryString);
+ Query query = session.createQuery (queryString.toString());
query.setParameter ("requestId", requestId);
if (statusMessage != null) {
query.setParameter ("statusMessage", statusMessage);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java
index 109da17ea2..2443169151 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/adapter/requests/db/MsoRequestsDbAdapterClient.java
@@ -51,7 +51,7 @@ public class MsoRequestsDbAdapterClient implements MsoRequestsDbAdapter {
MsoLogger.setLogContext(request.getRequestId(), null);
try {
session.beginTransaction();
- String queryString = "update InfraActiveRequests set ";
+ StringBuilder queryString = new StringBuilder("update InfraActiveRequests set ");
String statusMessage = null;
String responseBody = null;
RequestStatusType requestStatus = null;
@@ -67,72 +67,72 @@ public class MsoRequestsDbAdapterClient implements MsoRequestsDbAdapter {
String configurationId = null;
String configurationName = null;
if (request.getStatusMessage() != null) {
- queryString += "statusMessage = :statusMessage, ";
+ queryString.append("statusMessage = :statusMessage, ");
statusMessage = request.getStatusMessage();
}
if (request.getResponseBody() != null) {
- queryString += "responseBody = :responseBody, ";
+ queryString.append("responseBody = :responseBody, ");
responseBody = request.getResponseBody();
}
if (request.getRequestStatus() != null) {
- queryString += "requestStatus = :requestStatus, ";
+ queryString.append("requestStatus = :requestStatus, ");
requestStatus = request.getRequestStatus();
}
if (request.getProgress() != null) {
- queryString += "progress = :progress, ";
+ queryString.append("progress = :progress, ");
progress = request.getProgress();
}
if (request.getVnfOutputs() != null) {
- queryString += "vnfOutputs = :vnfOutputs, ";
+ queryString.append("vnfOutputs = :vnfOutputs, ");
vnfOutputs = request.getVnfOutputs();
}
if (request.getServiceInstanceId() != null) {
- queryString += "serviceInstanceId = :serviceInstanceId, ";
+ queryString.append("serviceInstanceId = :serviceInstanceId, ");
serviceInstanceId = request.getServiceInstanceId();
}
if (request.getNetworkId() != null) {
- queryString += "networkId = :networkId, ";
+ queryString.append("networkId = :networkId, ");
networkId = request.getNetworkId();
}
if (request.getVnfId() != null) {
- queryString += "vnfId = :vnfId, ";
+ queryString.append("vnfId = :vnfId, ");
vnfId = request.getVnfId();
}
if (request.getVfModuleId() != null) {
- queryString += "vfModuleId = :vfModuleId, ";
+ queryString.append("vfModuleId = :vfModuleId, ");
vfModuleId = request.getVfModuleId();
}
if (request.getVolumeGroupId() != null) {
- queryString += "volumeGroupId = :volumeGroupId, ";
+ queryString.append("volumeGroupId = :volumeGroupId, ");
volumeGroupId = request.getVolumeGroupId();
}
if (request.getServiceInstanceName() != null) {
- queryString += "serviceInstanceName = :serviceInstanceName, ";
+ queryString.append("serviceInstanceName = :serviceInstanceName, ");
serviceInstanceName = request.getServiceInstanceName();
}
if (request.getVfModuleName() != null) {
- queryString += "vfModuleName = :vfModuleName, ";
+ queryString.append("vfModuleName = :vfModuleName, ");
vfModuleName = request.getVfModuleName();
}
if (request.getConfigurationId() != null) {
- queryString += "configurationId = :configurationId, ";
+ queryString.append("configurationId = :configurationId, ");
configurationId = request.getConfigurationId();
}
if (request.getConfigurationName() != null) {
- queryString += "configurationName = :configurationName, ";
+ queryString.append("configurationName = :configurationName, ");
configurationName = request.getConfigurationName();
}
if (request.getRequestStatus() == RequestStatusType.COMPLETE
|| request.getRequestStatus() == RequestStatusType.FAILED) {
- queryString += "endTime = :endTime, ";
+ queryString.append("endTime = :endTime, ");
} else {
- queryString += "modifyTime = :modifyTime, ";
+ queryString.append("modifyTime = :modifyTime, ");
}
- queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId";
+ queryString.append("lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId");
- LOGGER.debug("Executing update: " + queryString);
+ LOGGER.debug("Executing update: " + queryString.toString());
- Query query = session.createQuery(queryString);
+ Query query = session.createQuery(queryString.toString());
query.setParameter("requestId", request.getRequestId());
if (statusMessage != null) {
query.setParameter("statusMessage", statusMessage);