ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject git commit: ARGUS-133: Moved expensive getTimeZone calls from per-invokation to be static final members
Date Sun, 26 Oct 2014 05:48:30 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 372b98002 -> 26cd9d32f


ARGUS-133: Moved expensive getTimeZone calls from per-invokation to be static final members

Signed-off-by: mneethiraj <mneethiraj@hortonworks.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/26cd9d32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/26cd9d32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/26cd9d32

Branch: refs/heads/master
Commit: 26cd9d32f0512d176ada5c45b4ca9b859465590b
Parents: 372b980
Author: mneethiraj <mneethiraj@hortonworks.com>
Authored: Sat Oct 25 22:48:19 2014 -0700
Committer: mneethiraj <mneethiraj@hortonworks.com>
Committed: Sat Oct 25 22:48:19 2014 -0700

----------------------------------------------------------------------
 .../xasecure/authorization/hadoop/log/HdfsFileAppender.java    | 2 +-
 .../main/java/com/xasecure/authorization/utils/StringUtil.java | 6 ++++--
 .../authorization/hbase/XaSecureAuthorizationCoprocessor.java  | 6 ++++--
 security-admin/src/main/java/com/xasecure/common/DateUtil.java | 6 ++++--
 4 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/26cd9d32/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
index ab4d8a2..973897f 100644
--- a/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
+++ b/agents-common/src/main/java/com/xasecure/authorization/hadoop/log/HdfsFileAppender.java
@@ -150,7 +150,7 @@ public class HdfsFileAppender extends FileAppender {
      /**
      * The gmtTimeZone is used only in computeCheckPeriod() method.
      */
-    private static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT");
+    private static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT+0");
     
 	private static final String DEFAULT_HDFSCHECKINTERVAL = "2min";
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/26cd9d32/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
b/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
index 0c83e98..7e3dccd 100644
--- a/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
+++ b/agents-common/src/main/java/com/xasecure/authorization/utils/StringUtil.java
@@ -28,7 +28,9 @@ import java.util.TimeZone;
 
 public class StringUtil {
 
-	public static boolean equals(String str1, String str2) {
+    private static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT+0");
+
+    public static boolean equals(String str1, String str2) {
 		boolean ret = false;
 
 		if(str1 == null) {
@@ -264,7 +266,7 @@ public class StringUtil {
 	    Calendar local  = Calendar.getInstance();
 	    int      offset = local.getTimeZone().getOffset(local.getTimeInMillis());
 
-	    GregorianCalendar utc = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
+	    GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
 
 	    utc.setTimeInMillis(local.getTimeInMillis());
 	    utc.add(Calendar.MILLISECOND, -offset);

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/26cd9d32/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
----------------------------------------------------------------------
diff --git a/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
b/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
index fe96c95..2353873 100644
--- a/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
+++ b/hbase-agent/src/main/java/com/xasecure/authorization/hbase/XaSecureAuthorizationCoprocessor.java
@@ -132,7 +132,9 @@ public class XaSecureAuthorizationCoprocessor extends XaSecureAuthorizationCopro
 	private static final String WILDCARD = "*";
 	private static final byte[] WILDCARD_MATCH = "*".getBytes();
 	
-	private RegionCoprocessorEnvironment regionEnv;
+    private static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT+0");
+
+    private RegionCoprocessorEnvironment regionEnv;
 	private Map<InternalScanner, String> scannerOwners = new MapMaker().weakKeys().makeMap();
 	
 	private HBaseAccessController accessController = HBaseAccessControllerFactory.getInstance();
@@ -1009,7 +1011,7 @@ public class XaSecureAuthorizationCoprocessor extends XaSecureAuthorizationCopro
 	public static Date getUTCDate() {
 		Calendar local=Calendar.getInstance();
 	    int offset = local.getTimeZone().getOffset(local.getTimeInMillis());
-	    GregorianCalendar utc = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
+	    GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
 	    utc.setTimeInMillis(local.getTimeInMillis());
 	    utc.add(Calendar.MILLISECOND, -offset);
 	    return utc.getTime();

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/26cd9d32/security-admin/src/main/java/com/xasecure/common/DateUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/common/DateUtil.java b/security-admin/src/main/java/com/xasecure/common/DateUtil.java
index c987401..a5ebcaa 100644
--- a/security-admin/src/main/java/com/xasecure/common/DateUtil.java
+++ b/security-admin/src/main/java/com/xasecure/common/DateUtil.java
@@ -32,6 +32,8 @@ import org.springframework.stereotype.Component;
 @Component
 public class DateUtil {    
 
+    private static final TimeZone gmtTimeZone = TimeZone.getTimeZone("GMT+0");
+
     public Date getDateFromNow(int days) {
     	return getDateFromNow(days, 0, 0);
     }   
@@ -78,7 +80,7 @@ public class DateUtil {
 		try{
 			Calendar local=Calendar.getInstance();
 		    int offset = local.getTimeZone().getOffset(local.getTimeInMillis());
-		    GregorianCalendar utc = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
+		    GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
 		    utc.setTimeInMillis(local.getTimeInMillis());
 		    utc.add(Calendar.MILLISECOND, -offset);
 		    return utc.getTime();
@@ -94,7 +96,7 @@ public class DateUtil {
 		try{
 			Calendar local=Calendar.getInstance();
 		    int offset = local.getTimeZone().getOffset(epoh);
-		    GregorianCalendar utc = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"));
+		    GregorianCalendar utc = new GregorianCalendar(gmtTimeZone);
 		    utc.setTimeInMillis(epoh);
 		    utc.add(Calendar.MILLISECOND, -offset);	   
 		    return utc.getTime();


Mime
View raw message