diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2017-04-10 12:11:55 -0700 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2017-04-10 12:14:07 -0700 |
commit | 19340cad94eeaa1b580f7c0c99531de499e8ca14 (patch) | |
tree | af4989c384f5d8c54d01b2fa160e2d53ac71a6f5 /mso-api-handlers/mso-api-handler-infra/src/main/java | |
parent | d60f3ad34b20c16d31da8f8a09ed2d9adb10f493 (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/mso-api-handler-infra/src/main/java')
4 files changed, 13 insertions, 26 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); |