diff --git service/src/java/org/apache/hive/service/AbstractService.java service/src/java/org/apache/hive/service/AbstractService.java index 37a9f4cf42..2ddb06921c 100644 --- service/src/java/org/apache/hive/service/AbstractService.java +++ service/src/java/org/apache/hive/service/AbstractService.java @@ -50,7 +50,7 @@ /** * The configuration. Will be null until the service is initialized. */ - protected HiveConf hiveConf; + private HiveConf hiveConf; /** * List of state change listeners; it is final to ensure @@ -69,6 +69,7 @@ public AbstractService(String name) { this.name = name; } + // This probably doesn't need to be sync, but nobody calls this, so it doesn't matter. @Override public synchronized STATE getServiceState() { return state; @@ -84,11 +85,15 @@ public synchronized STATE getServiceState() { @Override public synchronized void init(HiveConf hiveConf) { ensureCurrentState(STATE.NOTINITED); - this.hiveConf = hiveConf; + setHiveConf(hiveConf); changeState(STATE.INITED); LOG.info("Service:" + getName() + " is inited."); } + protected final void setHiveConf(HiveConf hiveConf) { + this.hiveConf = hiveConf; + } + /** * {@inheritDoc} * @@ -126,13 +131,17 @@ public synchronized void stop() { } @Override - public synchronized void register(ServiceStateChangeListener l) { - listeners.add(l); + public void register(ServiceStateChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } } @Override - public synchronized void unregister(ServiceStateChangeListener l) { - listeners.remove(l); + public void unregister(ServiceStateChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } } @Override @@ -141,7 +150,7 @@ public String getName() { } @Override - public synchronized HiveConf getHiveConf() { + public HiveConf getHiveConf() { return hiveConf; } diff --git service/src/java/org/apache/hive/service/cli/CLIService.java service/src/java/org/apache/hive/service/cli/CLIService.java index c9914ba9bf..3e261972fa 100644 --- service/src/java/org/apache/hive/service/cli/CLIService.java +++ service/src/java/org/apache/hive/service/cli/CLIService.java @@ -80,7 +80,7 @@ public CLIService(HiveServer2 hiveServer2) { @Override public synchronized void init(HiveConf hiveConf) { - this.hiveConf = hiveConf; + setHiveConf(hiveConf); sessionManager = new SessionManager(hiveServer2); defaultFetchRows = hiveConf.getIntVar(ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE); addService(sessionManager); @@ -132,6 +132,7 @@ private void applyAuthorizationConfigPolicy(HiveConf newHiveConf) throws HiveExc } private void setupBlockedUdfs() { + HiveConf hiveConf = getHiveConf(); FunctionRegistry.setupPermissionsForBuiltinUDFs( hiveConf.getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_WHITELIST), hiveConf.getVar(ConfVars.HIVE_SERVER2_BUILTIN_UDF_BLACKLIST)); @@ -563,8 +564,10 @@ public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientatio } // obtain delegation token for the give user from metastore + // TODO: why is this synchronized? public synchronized String getDelegationTokenFromMetaStore(String owner) throws HiveSQLException, UnsupportedOperationException, LoginException, IOException { + HiveConf hiveConf = getHiveConf(); if (!hiveConf.getBoolVar(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL) || !hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS)) { throw new UnsupportedOperationException( diff --git service/src/java/org/apache/hive/service/server/HiveServer2.java service/src/java/org/apache/hive/service/server/HiveServer2.java index 661beb54e4..0197b66c00 100644 --- service/src/java/org/apache/hive/service/server/HiveServer2.java +++ service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -772,7 +772,7 @@ public void isLeader() { LOG.info("Started/Reconnected tez sessions."); // resolve futures used for testing - if (HiveConf.getBoolVar(hiveServer2.hiveConf, ConfVars.HIVE_IN_TEST)) { + if (HiveConf.getBoolVar(hiveServer2.getHiveConf(), ConfVars.HIVE_IN_TEST)) { hiveServer2.isLeaderTestFuture.set(true); hiveServer2.resetNotLeaderTestFuture(); } @@ -787,7 +787,7 @@ public void notLeader() { LOG.info("Stopped/Disconnected tez sessions."); // resolve futures used for testing - if (HiveConf.getBoolVar(hiveServer2.hiveConf, ConfVars.HIVE_IN_TEST)) { + if (HiveConf.getBoolVar(hiveServer2.getHiveConf(), ConfVars.HIVE_IN_TEST)) { hiveServer2.notLeaderTestFuture.set(true); hiveServer2.resetIsLeaderTestFuture(); } @@ -802,14 +802,15 @@ private void startOrReconnectTezSessions() { try { resourcePlan = sessionHive.getActiveResourcePlan(); } catch (HiveException e) { - if (!HiveConf.getBoolVar(hiveConf, ConfVars.HIVE_IN_TEST_SSL)) { + if (!HiveConf.getBoolVar(getHiveConf(), ConfVars.HIVE_IN_TEST_SSL)) { throw new RuntimeException(e); } else { resourcePlan = null; // Ignore errors in SSL tests where the connection is misconfigured. } } - if (resourcePlan == null && HiveConf.getBoolVar(hiveConf, ConfVars.HIVE_IN_TEST)) { + if (resourcePlan == null && HiveConf.getBoolVar( + getHiveConf(), ConfVars.HIVE_IN_TEST)) { LOG.info("Creating a default resource plan for test"); resourcePlan = createTestResourcePlan(); } @@ -825,6 +826,7 @@ private void initAndStartTezSessionPoolManager(final WMFullResourcePlan resource // will be invoked anyway in TezTask. Doing it early to initialize triggers for non-pool tez session. LOG.info("Initializing tez session pool manager"); tezSessionPoolManager = TezSessionPoolManager.getInstance(); + HiveConf hiveConf = getHiveConf(); if (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_TEZ_INITIALIZE_DEFAULT_SESSIONS)) { tezSessionPoolManager.setupPool(hiveConf); } else { @@ -842,7 +844,7 @@ private void initAndStartWorkloadManager(final WMFullResourcePlan resourcePlan) // Initialize workload management. LOG.info("Initializing workload management"); try { - wm = WorkloadManager.create(wmQueue, hiveConf, resourcePlan); + wm = WorkloadManager.create(wmQueue, getHiveConf(), resourcePlan); wm.start(); LOG.info("Workload manager initialized."); } catch (Exception e) {