due to HIVE-17155, we make a workaround, put the three hive xml files in resources, waiting for hive 3 release to fix this bug
Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/a09f70e0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/a09f70e0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/a09f70e0 Branch: refs/heads/griffin-0.2.0-incubating-rc4 Commit: a09f70e0ff44f4659cce0407d070b0d92af64201 Parents: a682d5d Author: Lionel Liu <[email protected]> Authored: Tue Apr 24 10:17:09 2018 +0800 Committer: Lionel Liu <[email protected]> Committed: Tue Apr 24 10:17:09 2018 +0800 ---------------------------------------------------------------------- service/pom.xml | 105 +------- .../core/metastore/hive/HiveMetaStoreProxy.java | 90 +------ .../hive/HiveMetaStoreServiceImpl.java | 32 +-- .../metastore/hive/ThriftMetastoreClient.java | 250 ------------------- service/src/main/resources/hive-site.xml | 22 ++ .../src/main/resources/hivemetastore-site.xml | 22 ++ service/src/main/resources/hiveserver2-site.xml | 22 ++ 7 files changed, 78 insertions(+), 465 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/pom.xml ---------------------------------------------------------------------- diff --git a/service/pom.xml b/service/pom.xml index 901d739..e58e6f8 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -70,38 +70,16 @@ under the License. </dependencyManagement> <dependencies> - <!--<dependency>--> - <!--<groupId>javax.servlet</groupId>--> - <!--<artifactId>javax.servlet-api</artifactId>--> - <!--<version>3.1.0</version>--> - <!--</dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> - <!--<exclusion>--> - <!--<groupId>org.springframework.boot</groupId>--> - <!--<artifactId>spring-boot-starter-tomcat</artifactId>--> - <!--</exclusion>--> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> - <!--<exclusion>--> - <!--<groupId>ch.qos.logback</groupId>--> - <!--<artifactId>logback-classic</artifactId>--> - <!--</exclusion>--> - <!--<exclusion>--> - <!--<groupId>org.slf4j</groupId>--> - <!--<artifactId>log4j-over-slf4j</artifactId>--> - <!--</exclusion>--> </exclusions> </dependency> - <!--<dependency>--> - <!--<groupId>org.springframework.boot</groupId>--> - <!--<artifactId>spring-boot-starter-tomcat</artifactId>--> - <!--<version>1.1.2.RELEASE</version>--> - <!--</dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> @@ -121,11 +99,6 @@ under the License. <artifactId>spring-aspects</artifactId> </dependency> <!--eclipse link--> - <!--<dependency>--> - <!--<groupId>javax.persistence</groupId>--> - <!--<artifactId>javax.persistence-api</artifactId>--> - <!--<version>2.2</version>--> - <!--</dependency>--> <dependency> <groupId>org.eclipse.persistence</groupId> <artifactId>org.eclipse.persistence.jpa</artifactId> @@ -167,55 +140,10 @@ under the License. </dependency> <dependency> <groupId>org.apache.hive</groupId> - <artifactId>hive-common</artifactId> - <version>${hive.version}</version> - <scope>provided</scope> - <exclusions> - <exclusion> - <groupId>org.eclipse.jetty.aggregate</groupId> - <artifactId>jetty-all</artifactId> - </exclusion> - <exclusion> - <groupId>org.eclipse.jetty.orbit</groupId> - <artifactId>javax.servlet</artifactId> - </exclusion> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.hive</groupId> <artifactId>hive-metastore</artifactId> <version>${hive.version}</version> <exclusions> <exclusion> - <groupId>org.apache.hive</groupId> - <artifactId>hive-common</artifactId> - </exclusion> - <exclusion> - <artifactId>log4j-web</artifactId> - <groupId>org.apache.logging.log4j</groupId> - </exclusion> - <exclusion> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - - <exclusion> <groupId>org.eclipse.jetty.aggregate</groupId> <artifactId>jetty-all</artifactId> </exclusion> @@ -227,30 +155,6 @@ under the License. <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> </exclusion> - <!--<!–<exclusion>–>--> - <!--<!–<groupId>org.apache.hive</groupId>–>--> - <!--<!–<artifactId>hive-shims</artifactId>–>--> - <!--<!–</exclusion>–>--> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - </exclusion> - <!--<exclusion>--> - <!--<groupId>tomcat</groupId>--> - <!--<artifactId>jasper-compiler</artifactId>--> - <!--</exclusion>--> - <!--<exclusion>--> - <!--<groupId>tomcat</groupId>--> - <!--<artifactId>jasper-runtime</artifactId>--> - <!--</exclusion>--> - <!--<exclusion>--> - <!--<groupId>javax.servlet</groupId>--> - <!--<artifactId>servlet-api</artifactId>--> - <!--</exclusion>--> </exclusions> </dependency> @@ -259,12 +163,6 @@ under the License. <groupId>io.confluent</groupId> <artifactId>kafka-schema-registry-client</artifactId> <version>${confluent.version}</version> - <!--<exclusions>--> - <!--<exclusion>--> - <!--<groupId>org.slf4j</groupId>--> - <!--<artifactId>slf4j-log4j12</artifactId>--> - <!--</exclusion>--> - <!--</exclusions>--> </dependency> <!--schedule--> @@ -363,7 +261,7 @@ under the License. </executions> <configuration> <fork>true</fork> - <layout>ZIP</layout> + <layout>JAR</layout> <mainClass>org.apache.griffin.core.GriffinWebApplication</mainClass> </configuration> </plugin> @@ -377,7 +275,6 @@ under the License. </configuration> </plugin> - </plugins> </build> </project> http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreProxy.java ---------------------------------------------------------------------- diff --git a/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreProxy.java b/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreProxy.java index 8291f82..63fbc00 100644 --- a/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreProxy.java +++ b/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreProxy.java @@ -53,100 +53,18 @@ public class HiveMetaStoreProxy { @Value("${hive.hmshandler.retry.interval}") private String interval; -// private HiveMetaStoreClient client = null; - private ThriftMetastoreClient client = null; - - private static final Logger l4j = LoggerFactory.getLogger(HiveConf.class); - - private static URL checkConfigFile(File f) { - try { - return (f.exists() && f.isFile()) ? f.toURI().toURL() : null; - } catch (Throwable e) { - if (l4j.isInfoEnabled()) { - l4j.info("Error looking for config " + f, e); - } - System.err.println("Error looking for config " + f + ": " + e.getMessage()); - return null; - } - } - - private static URL findConfigFile(ClassLoader classLoader, String name, boolean doLog) { - URL result = classLoader.getResource(name); - LOGGER.warn("result: {}", result); - if (result == null) { - String confPath = System.getenv("HIVE_CONF_DIR"); - LOGGER.warn("confPath: {}", confPath); - result = checkConfigFile(new File(confPath, name)); - LOGGER.warn("result: {}", result); - if (result == null) { - String homePath = System.getenv("HIVE_HOME"); - LOGGER.warn("homePath: {}", homePath); - String nameInConf = "conf" + File.pathSeparator + name; - LOGGER.warn("nameInConf: {}", nameInConf); - result = checkConfigFile(new File(homePath, nameInConf)); - LOGGER.warn("result: {}", result); - if (result == null) { - URI jarUri = null; - try { - java.security.ProtectionDomain domain = HiveConf.class.getProtectionDomain(); - LOGGER.warn("domain: {}", domain); - CodeSource codeSource = domain.getCodeSource(); - LOGGER.warn("codeSource: {}", codeSource); - URL location = codeSource.getLocation(); - LOGGER.warn("location: {}", location); - jarUri = location.toURI(); - -// jarUri = HiveConf.class.getProtectionDomain().getCodeSource().getLocation().toURI(); - LOGGER.warn("jarUri: {}", jarUri); - } catch (Throwable e) { - if (l4j.isInfoEnabled()) { - l4j.info("Cannot get jar URI", e); - } - System.err.println("Cannot get jar URI: " + e.getMessage()); - } - File f1 = new File(jarUri); - LOGGER.warn("f1: {}", f1); - File f2 = f1.getParentFile(); - LOGGER.warn("f2: {}", f2); - File f3 = new File(f2, nameInConf); - LOGGER.warn("f3: {}", f3); - result = checkConfigFile(f3); - } - } - } - if (doLog && l4j.isInfoEnabled()) { - l4j.info("Found configuration file " + result); - } - return result; - } - -// @Bean - public ThriftMetastoreClient initHiveMetastoreClient() { - LOGGER.warn("begin client"); - LOGGER.warn(File.pathSeparator); - LOGGER.warn(uris); - -// ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - ClassLoader classLoader = HiveConf.class.getClassLoader(); - LOGGER.warn("classLoader: {}", classLoader); - if (classLoader == null) { - classLoader = HiveConf.class.getClassLoader(); - LOGGER.warn("classLoader: {}", classLoader); - } - URL url = findConfigFile(classLoader, "hive-site.xml", true); - LOGGER.warn("url: {}", url); + private HiveMetaStoreClient client = null; + @Bean + public HiveMetaStoreClient initHiveMetastoreClient() { HiveConf hiveConf = new HiveConf(); - LOGGER.warn("hive conf success"); hiveConf.set("hive.metastore.local", "false"); hiveConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3); hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, uris); hiveConf.setIntVar(HiveConf.ConfVars.HMSHANDLERATTEMPTS, attempts); hiveConf.setVar(HiveConf.ConfVars.HMSHANDLERINTERVAL, interval); try { - LOGGER.warn("begin hive ms client"); - client = new ThriftMetastoreClient(hiveConf); - LOGGER.warn("hive ms client success"); + client = new HiveMetaStoreClient(hiveConf); } catch (Exception e) { LOGGER.error("Failed to connect hive metastore. {}", e.getMessage()); client = null; http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java ---------------------------------------------------------------------- diff --git a/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java b/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java index 674defd..b4d1a8c 100644 --- a/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java +++ b/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java @@ -48,19 +48,12 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { private static final Logger LOGGER = LoggerFactory.getLogger(HiveMetaStoreService.class); -// @Autowired -// private HiveMetaStoreClient client = null; - private ThriftMetastoreClient client = null; + @Autowired + private HiveMetaStoreClient client = null; @Autowired private HiveMetaStoreProxy proxy; - public void initClient() { - if (client == null) { - client = proxy.initHiveMetastoreClient(); - } - } - @Value("${hive.metastore.dbname}") private String defaultDbName; @@ -74,15 +67,13 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Override @Cacheable public Iterable<String> getAllDatabases() { - initClient(); Iterable<String> results = null; try { if (client == null) { LOGGER.warn("Hive client is null. Please check your hive config."); return new ArrayList<>(); } - results = client.getClient().get_all_databases(); -// results = client.getAllDatabases(); + results = client.getAllDatabases(); } catch (Exception e) { reconnect(); LOGGER.error("Can not get databases : {}", e.getMessage()); @@ -94,15 +85,13 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Override @Cacheable public Iterable<String> getAllTableNames(String dbName) { - initClient(); Iterable<String> results = null; try { if (client == null) { LOGGER.warn("Hive client is null. Please check your hive config."); return new ArrayList<>(); } - results = client.getClient().get_all_tables(dbName); -// results = client.getAllTables(getUseDbName(dbName)); + results = client.getAllTables(getUseDbName(dbName)); } catch (Exception e) { reconnect(); LOGGER.error("Exception fetching tables info: {}", e.getMessage()); @@ -121,7 +110,6 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Override @Cacheable public Map<String, List<Table>> getAllTable() { - initClient(); Map<String, List<Table>> results = new HashMap<>(); Iterable<String> dbs; // if hive.metastore.uris in application.properties configs wrong, client will be injected failure and will be null. @@ -143,15 +131,13 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { @Override @Cacheable public Table getTable(String dbName, String tableName) { - initClient(); Table result = null; try { if (client == null) { LOGGER.warn("Hive client is null. Please check your hive config."); return null; } - result = client.getClient().get_table(getUseDbName(dbName), tableName); -// result = client.getTable(getUseDbName(dbName), tableName); + result = client.getTable(getUseDbName(dbName), tableName); } catch (Exception e) { reconnect(); LOGGER.error("Exception fetching table info : {}. {}", tableName, e.getMessage()); @@ -169,7 +155,6 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { private List<Table> getTables(String db) { - initClient(); String useDbName = getUseDbName(db); List<Table> allTables = new ArrayList<>(); try { @@ -177,11 +162,9 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { LOGGER.warn("Hive client is null. Please check your hive config."); return allTables; } - Iterable<String> tables = client.getClient().get_all_tables(useDbName); -// Iterable<String> tables = client.getAllTables(useDbName); + Iterable<String> tables = client.getAllTables(useDbName); for (String table : tables) { - Table tmp = client.getClient().get_table(db, table); -// Table tmp = client.getTable(db, table); + Table tmp = client.getTable(db, table); allTables.add(tmp); } } catch (Exception e) { @@ -200,7 +183,6 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { } private void reconnect() { - initClient(); if (singleThreadExecutor.getActiveCount() == 0) { System.out.println("execute create thread."); singleThreadExecutor.execute(() -> { http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/src/main/java/org/apache/griffin/core/metastore/hive/ThriftMetastoreClient.java ---------------------------------------------------------------------- diff --git a/service/src/main/java/org/apache/griffin/core/metastore/hive/ThriftMetastoreClient.java b/service/src/main/java/org/apache/griffin/core/metastore/hive/ThriftMetastoreClient.java deleted file mode 100644 index 90f4739..0000000 --- a/service/src/main/java/org/apache/griffin/core/metastore/hive/ThriftMetastoreClient.java +++ /dev/null @@ -1,250 +0,0 @@ - -/** - * Copyright (C) 2015-2017 The Apache Software Foundation and Expedia Inc. - * - * This code is based on Hive's HiveMetaStoreClient: - * - * https://github.com/apache/hive/blob/rel/release-2.1.0/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.griffin.core.metastore.hive; - - import java.io.Closeable; - import java.io.IOException; - import java.net.URI; - import java.util.Random; - import java.util.concurrent.TimeUnit; - import java.util.concurrent.atomic.AtomicInteger; - - import org.apache.hadoop.hive.conf.HiveConf; - import org.apache.hadoop.hive.conf.HiveConf.ConfVars; - import org.apache.hadoop.hive.conf.HiveConfUtil; - import org.apache.hadoop.hive.metastore.MetaStoreUtils; - import org.apache.hadoop.hive.metastore.api.MetaException; - import org.apache.hadoop.hive.metastore.api.ThriftHiveMetastore; - import org.apache.hadoop.hive.shims.ShimLoader; - import org.apache.hadoop.hive.shims.Utils; - import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge; - import org.apache.hadoop.util.StringUtils; - import org.apache.thrift.TException; - import org.apache.thrift.protocol.TBinaryProtocol; - import org.apache.thrift.protocol.TCompactProtocol; - import org.apache.thrift.protocol.TProtocol; - import org.apache.thrift.transport.TFramedTransport; - import org.apache.thrift.transport.TSocket; - import org.apache.thrift.transport.TTransport; - import org.apache.thrift.transport.TTransportException; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; - -class ThriftMetastoreClient implements Closeable { - - private static final Logger LOG = LoggerFactory.getLogger(ThriftMetastoreClient.class); - - private static final AtomicInteger CONN_COUNT = new AtomicInteger(0); - - private ThriftHiveMetastore.Iface client = null; - private TTransport transport = null; - private boolean isConnected = false; - private URI metastoreUris[]; - private String tokenStrForm; - protected final HiveConf conf; - - // for thrift connects - private int retries = 5; - private long retryDelaySeconds = 0; - - public ThriftMetastoreClient(HiveConf conf) { - this.conf = conf; - String msUri = conf.getVar(ConfVars.METASTOREURIS); - - if (HiveConfUtil.isEmbeddedMetaStore(msUri)) { - throw new RuntimeException("You can't waggle an embedded metastore"); - } - - // get the number retries - retries = HiveConf.getIntVar(conf, HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES); - retryDelaySeconds = conf.getTimeVar(ConfVars.METASTORE_CLIENT_CONNECT_RETRY_DELAY, TimeUnit.SECONDS); - - // user wants file store based configuration - if (msUri != null) { - String metastoreUrisString[] = msUri.split(","); - metastoreUris = new URI[metastoreUrisString.length]; - try { - int i = 0; - for (String s : metastoreUrisString) { - URI tmpUri = new URI(s); - if (tmpUri.getScheme() == null) { - throw new IllegalArgumentException("URI: " + s + " does not have a scheme"); - } - metastoreUris[i++] = tmpUri; - } - } catch (IllegalArgumentException e) { - throw (e); - } catch (Exception e) { - String exInfo = "Got exception: " + e.getClass().getName() + " " + e.getMessage(); - LOG.error(exInfo, e); - throw new RuntimeException(exInfo, e); - } - } else { - LOG.error("NOT getting uris from conf"); - throw new RuntimeException("MetaStoreURIs not found in conf file"); - } - } - - public void open() { - if (isConnected) { - return; - } - TTransportException tte = null; - boolean useSasl = conf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_SASL); - boolean useFramedTransport = conf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_FRAMED_TRANSPORT); - boolean useCompactProtocol = conf.getBoolVar(ConfVars.METASTORE_USE_THRIFT_COMPACT_PROTOCOL); - int clientSocketTimeout = (int) conf.getTimeVar(ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT, TimeUnit.MILLISECONDS); - - for (int attempt = 0; !isConnected && attempt < retries; ++attempt) { - for (URI store : metastoreUris) { - LOG.info("Trying to connect to metastore with URI " + store); - try { - transport = new TSocket(store.getHost(), store.getPort(), clientSocketTimeout); - if (useSasl) { - // Wrap thrift connection with SASL for secure connection. - try { - HadoopThriftAuthBridge.Client authBridge = ShimLoader.getHadoopThriftAuthBridge().createClient(); - - // check if we should use delegation tokens to authenticate - // the call below gets hold of the tokens if they are set up by hadoop - // this should happen on the map/reduce tasks if the client added the - // tokens into hadoop's credential store in the front end during job - // submission. - String tokenSig = conf.getVar(ConfVars.METASTORE_TOKEN_SIGNATURE); - // tokenSig could be null - tokenStrForm = Utils.getTokenStrForm(tokenSig); - if (tokenStrForm != null) { - // authenticate using delegation tokens via the "DIGEST" mechanism - transport = authBridge.createClientTransport(null, store.getHost(), "DIGEST", tokenStrForm, transport, - MetaStoreUtils.getMetaStoreSaslProperties(conf)); - } else { - String principalConfig = conf.getVar(HiveConf.ConfVars.METASTORE_KERBEROS_PRINCIPAL); - transport = authBridge.createClientTransport(principalConfig, store.getHost(), "KERBEROS", null, - transport, MetaStoreUtils.getMetaStoreSaslProperties(conf)); - } - } catch (IOException ioe) { - LOG.error("Couldn't create client transport", ioe); - throw new MetaException(ioe.toString()); - } - } else if (useFramedTransport) { - transport = new TFramedTransport(transport); - } - final TProtocol protocol; - if (useCompactProtocol) { - protocol = new TCompactProtocol(transport); - } else { - protocol = new TBinaryProtocol(transport); - } - client = new ThriftHiveMetastore.Client(protocol); - try { - transport.open(); - LOG.info("Opened a connection to metastore '" - + store - + "', total current connections to all metastores: " - + CONN_COUNT.incrementAndGet()); - - isConnected = true; - } catch (TTransportException e) { - tte = e; - if (LOG.isDebugEnabled()) { - LOG.warn("Failed to connect to the MetaStore Server...", e); - } else { - // Don't print full exception trace if DEBUG is not on. - LOG.warn("Failed to connect to the MetaStore Server..."); - } - } - } catch (MetaException e) { - LOG.error("Unable to connect to metastore with URI " + store + " in attempt " + attempt, e); - } - if (isConnected) { - break; - } - } - // Wait before launching the next round of connection retries. - if (!isConnected && retryDelaySeconds > 0) { - try { - LOG.info("Waiting " + retryDelaySeconds + " seconds before next connection attempt."); - Thread.sleep(retryDelaySeconds * 1000); - } catch (InterruptedException ignore) {} - } - } - - if (!isConnected) { - throw new RuntimeException("Could not connect to meta store using any of the URIs provided. Most recent failure: " - + StringUtils.stringifyException(tte)); - } - LOG.info("Connected to metastore."); - } - - public void reconnect() { - close(); - // Swap the first element of the metastoreUris[] with a random element from the rest - // of the array. Rationale being that this method will generally be called when the default - // connection has died and the default connection is likely to be the first array element. - promoteRandomMetaStoreURI(); - open(); - } - - @Override - public void close() { - if (!isConnected) { - return; - } - isConnected = false; - try { - if (client != null) { - client.shutdown(); - } - } catch (TException e) { - LOG.debug("Unable to shutdown metastore client. Will try closing transport directly.", e); - } - // Transport would have got closed via client.shutdown(), so we don't need this, but - // just in case, we make this call. - if (isOpen()) { - transport.close(); - transport = null; - } - LOG.info("Closed a connection to metastore, current connections: " + CONN_COUNT.decrementAndGet()); - } - - public boolean isOpen() { - return transport != null && transport.isOpen(); - } - - protected ThriftHiveMetastore.Iface getClient() { - return client; - } - - /** - * Swaps the first element of the metastoreUris array with a random element from the remainder of the array. - */ - private void promoteRandomMetaStoreURI() { - if (metastoreUris.length <= 1) { - return; - } - Random rng = new Random(); - int index = rng.nextInt(metastoreUris.length - 1) + 1; - URI tmp = metastoreUris[0]; - metastoreUris[0] = metastoreUris[index]; - metastoreUris[index] = tmp; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/src/main/resources/hive-site.xml ---------------------------------------------------------------------- diff --git a/service/src/main/resources/hive-site.xml b/service/src/main/resources/hive-site.xml new file mode 100644 index 0000000..1b0d65d --- /dev/null +++ b/service/src/main/resources/hive-site.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--><configuration> + <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! --> + <!-- WARNING!!! Any changes you make to this file will be ignored by Hive. --> + <!-- WARNING!!! You must make your changes in hive-site.xml instead. --> + <!-- Hive Execution Parameters --> + </configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/src/main/resources/hivemetastore-site.xml ---------------------------------------------------------------------- diff --git a/service/src/main/resources/hivemetastore-site.xml b/service/src/main/resources/hivemetastore-site.xml new file mode 100644 index 0000000..a992e83 --- /dev/null +++ b/service/src/main/resources/hivemetastore-site.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--><configuration> + <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! --> + <!-- WARNING!!! Any changes you make to this file will be ignored by Hive. --> + <!-- WARNING!!! You must make your changes in hive-site.xml instead. --> + <!-- Hive Execution Parameters --> +</configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a09f70e0/service/src/main/resources/hiveserver2-site.xml ---------------------------------------------------------------------- diff --git a/service/src/main/resources/hiveserver2-site.xml b/service/src/main/resources/hiveserver2-site.xml new file mode 100644 index 0000000..a992e83 --- /dev/null +++ b/service/src/main/resources/hiveserver2-site.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--><configuration> + <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! --> + <!-- WARNING!!! Any changes you make to this file will be ignored by Hive. --> + <!-- WARNING!!! You must make your changes in hive-site.xml instead. --> + <!-- Hive Execution Parameters --> +</configuration> \ No newline at end of file
