From 2dad926f01d61268f9e32fc7f74f1f601cf57108 Mon Sep 17 00:00:00 2001 From: Akshay Rai Date: Fri, 8 Sep 2017 12:32:51 +0530 Subject: [PATCH] HadoopSecurity should be a Singleton (#284) * HadoopSecurity should be a singleton * Update build to the last recognized successful deployment (Linkedin) --- app/com/linkedin/drelephant/security/HadoopSecurity.java | 7 ++++--- .../drelephant/spark/fetchers/SparkLogClient.scala | 2 +- app/org/apache/spark/deploy/history/SparkFSFetcher.scala | 2 +- build.sbt | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/com/linkedin/drelephant/security/HadoopSecurity.java b/app/com/linkedin/drelephant/security/HadoopSecurity.java index 9c63b2965..652e4e6c2 100644 --- a/app/com/linkedin/drelephant/security/HadoopSecurity.java +++ b/app/com/linkedin/drelephant/security/HadoopSecurity.java @@ -41,13 +41,14 @@ public class HadoopSecurity { private static HadoopSecurity instance = null; public static HadoopSecurity getInstance() throws IOException{ - if(instance==null) { - return new HadoopSecurity(); + if (instance == null) { + instance = new HadoopSecurity(); } + return instance; } - public HadoopSecurity() throws IOException { + private HadoopSecurity() throws IOException { Configuration conf = new Configuration(); UserGroupInformation.setConfiguration(conf); _securityEnabled = UserGroupInformation.isSecurityEnabled(); diff --git a/app/com/linkedin/drelephant/spark/fetchers/SparkLogClient.scala b/app/com/linkedin/drelephant/spark/fetchers/SparkLogClient.scala index fcd05bf04..90a2eb9a2 100644 --- a/app/com/linkedin/drelephant/spark/fetchers/SparkLogClient.scala +++ b/app/com/linkedin/drelephant/spark/fetchers/SparkLogClient.scala @@ -43,7 +43,7 @@ class SparkLogClient(hadoopConfiguration: Configuration, sparkConf: SparkConf, e private val logger: Logger = Logger.getLogger(classOf[SparkLogClient]) - private lazy val security: HadoopSecurity = new HadoopSecurity() + private lazy val security: HadoopSecurity = HadoopSecurity.getInstance() protected lazy val sparkUtils: SparkUtils = SparkUtils diff --git a/app/org/apache/spark/deploy/history/SparkFSFetcher.scala b/app/org/apache/spark/deploy/history/SparkFSFetcher.scala index 6788cccf5..ecac7f608 100644 --- a/app/org/apache/spark/deploy/history/SparkFSFetcher.scala +++ b/app/org/apache/spark/deploy/history/SparkFSFetcher.scala @@ -52,7 +52,7 @@ class SparkFSFetcher(fetcherConfData: FetcherConfigurationData) extends Elephant val eventLogUri = Option(fetcherConfData.getParamMap.get(LOG_LOCATION_URI_XML_FIELD)) logger.info("The event log location of Spark application is set to " + eventLogUri) - private lazy val security = new HadoopSecurity() + private lazy val security = HadoopSecurity.getInstance() protected lazy val hadoopUtils: HadoopUtils = HadoopUtils diff --git a/build.sbt b/build.sbt index 071e15337..5b35af624 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,7 @@ import Dependencies._ name := "dr-elephant" -version := "2.0.6" +version := "2.0.13" organization := "com.linkedin.drelephant"