aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-04-10 12:11:55 -0700
committerGary Wu <gary.i.wu@huawei.com>2017-04-10 12:14:07 -0700
commit19340cad94eeaa1b580f7c0c99531de499e8ca14 (patch)
treeaf4989c384f5d8c54d01b2fa160e2d53ac71a6f5 /mso-api-handlers
parentd60f3ad34b20c16d31da8f8a09ed2d9adb10f493 (diff)
Remove unnecessary use of Calendar.getInstance()
Calendar.getInstance() is expensive and unnecessary when we only need the system time. This change replaces the uses of Calendar.getInstance() with System.currentTimeMillis(). Change-Id: I476f8850f5eb88d20cf7249cca5bb2e9b671b45a Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java9
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java9
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java9
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java10
5 files changed, 16 insertions, 33 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
index e976419399..64bdc3f269 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
@@ -25,7 +25,6 @@ import java.io.StringWriter;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -116,16 +115,14 @@ public class MsoRequest {
MsoRequest (String requestId) {
this.requestId = requestId;
- Calendar startTimeCalendar = Calendar.getInstance ();
- this.startTime = startTimeCalendar.getTimeInMillis ();
+ this.startTime = System.currentTimeMillis();
MsoLogger.setLogContext (requestId, null);
}
MsoRequest () {
- Calendar startTimeCalendar = Calendar.getInstance ();
- this.startTime = startTimeCalendar.getTimeInMillis ();
+ this.startTime = System.currentTimeMillis();
MsoLogger.setLogContext (requestId, null);
}
@@ -522,7 +519,7 @@ public class MsoRequest {
aq.setRequestAction(action.name());
aq.setAction(action.name());
- Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ());
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setStartTime (startTimeStamp);
@@ -625,8 +622,7 @@ public class MsoRequest {
aq.setResponseBody (this.responseBody);
aq.setProgress(new Long(100));
- Calendar endTime = Calendar.getInstance ();
- Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setEndTime (endTimeStamp);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
index f35ddfbda8..61f4b9f7cd 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
@@ -24,7 +24,6 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
import java.util.Date;
import javax.ws.rs.core.Response;
@@ -82,8 +81,7 @@ public class NetworkMsoInfraRequest {
NetworkMsoInfraRequest (String requestId) {
this.requestId = requestId;
- Calendar startTimeCalendar = Calendar.getInstance ();
- this.startTime = startTimeCalendar.getTimeInMillis ();
+ this.startTime = System.currentTimeMillis();
MsoLogger.setLogContext (requestId, null);
}
@@ -260,7 +258,7 @@ public class NetworkMsoInfraRequest {
InfraActiveRequests aq = new InfraActiveRequests ();
aq.setRequestId (requestId);
- Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ());
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
if (rinfo != null) {
if (rinfo.getAction () != null) {
aq.setAction (rinfo.getAction ().value ());
@@ -320,8 +318,7 @@ public class NetworkMsoInfraRequest {
aq.setStatusMessage (this.errorMessage);
aq.setResponseBody (this.responseBody);
- Calendar endTime = Calendar.getInstance ();
- Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setEndTime (endTimeStamp);
}
aq.setProgress (this.progress);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
index e22d182086..162e4f799a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
@@ -25,7 +25,6 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -86,8 +85,7 @@ public class VnfMsoInfraRequest {
VnfMsoInfraRequest (String requestId) {
this.requestId = requestId;
- Calendar startTimeCalendar = Calendar.getInstance ();
- this.startTime = startTimeCalendar.getTimeInMillis ();
+ this.startTime = System.currentTimeMillis();
MsoLogger.setLogContext (requestId, null);
}
@@ -285,7 +283,7 @@ public class VnfMsoInfraRequest {
aq.setRequestId (requestId);
aq.setClientRequestId(rinfo.getRequestId());
- Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ());
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
if (rinfo != null) {
if (rinfo.getAction () != null) {
aq.setAction (rinfo.getAction ().value ());
@@ -372,8 +370,7 @@ public class VnfMsoInfraRequest {
aq.setStatusMessage (this.errorMessage);
aq.setResponseBody (this.responseBody);
- Calendar endTime = Calendar.getInstance ();
- Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setEndTime (endTimeStamp);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
index 42ef60bfaf..eb7d1874cd 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
@@ -24,7 +24,6 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
import java.util.Date;
import javax.ws.rs.core.Response;
@@ -83,8 +82,7 @@ public class VolumeMsoInfraRequest {
VolumeMsoInfraRequest (String requestId) {
this.requestId = requestId;
- Calendar startTimeCalendar = Calendar.getInstance ();
- this.startTime = startTimeCalendar.getTimeInMillis ();
+ this.startTime = System.currentTimeMillis();
MsoLogger.setLogContext (requestId, null);
}
@@ -287,7 +285,7 @@ public class VolumeMsoInfraRequest {
InfraActiveRequests aq = new InfraActiveRequests ();
aq.setRequestId (requestId);
- Timestamp startTimeStamp = new Timestamp (Calendar.getInstance ().getTimeInMillis ());
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
if (rinfo != null) {
if (rinfo.getAction () != null) {
aq.setAction (rinfo.getAction ().value ());
@@ -350,8 +348,7 @@ public class VolumeMsoInfraRequest {
aq.setStatusMessage (this.errorMessage);
aq.setResponseBody (this.responseBody);
- Calendar endTime = Calendar.getInstance ();
- Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
aq.setEndTime (endTimeStamp);
}
aq.setProgress (this.progress);
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
index 9abd871b5f..fda4461840 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/openecomp/mso/requestsdb/RequestsDatabase.java
@@ -22,7 +22,6 @@ package org.openecomp.mso.requestsdb;
import java.sql.Timestamp;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -98,8 +97,7 @@ public class RequestsDatabase {
query.setParameter ("requestStatus", requestStatus);
query.setParameter (REQUEST_ID, requestId);
query.setParameter ("lastModifiedBy", lastModifiedBy);
- Calendar modifyTime = Calendar.getInstance ();
- Timestamp modifyTimeStamp = new Timestamp (modifyTime.getTimeInMillis ());
+ Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
query.setParameter ("modifyTime", modifyTimeStamp);
result = query.executeUpdate ();
session.getTransaction ().commit ();
@@ -125,8 +123,7 @@ public class RequestsDatabase {
query.setParameter (REQUEST_ID, requestId);
query.setParameter ("progress", progress);
query.setParameter ("lastModifiedBy", lastModifiedBy);
- Calendar modifyTime = Calendar.getInstance ();
- Timestamp modifyTimeStamp = new Timestamp (modifyTime.getTimeInMillis ());
+ Timestamp modifyTimeStamp = new Timestamp (System.currentTimeMillis());
query.setParameter ("modifyTime", modifyTimeStamp);
result = query.executeUpdate ();
session.getTransaction ().commit ();
@@ -150,8 +147,7 @@ public class RequestsDatabase {
Query query = session.createQuery ("update InfraActiveRequests set requestStatus = :requestStatus, statusMessage = :statusMessage, progress = :progress, endTime = :endTime, responseBody = :responseBody, lastModifiedBy = :lastModifiedBy where id.requestId = :requestId ");
query.setParameter ("requestStatus", requestStatus);
query.setParameter ("requestId", requestId);
- Calendar endTime = Calendar.getInstance ();
- Timestamp endTimeStamp = new Timestamp (endTime.getTimeInMillis ());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
query.setParameter ("endTime", endTimeStamp);
query.setParameter ("statusMessage", statusMessage);
query.setParameter ("progress", progress);