当前位置: 首页>>代码示例>>Java>>正文


Java JavaUtils类代码示例

本文整理汇总了Java中org.apache.hadoop.hive.common.JavaUtils的典型用法代码示例。如果您正苦于以下问题:Java JavaUtils类的具体用法?Java JavaUtils怎么用?Java JavaUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaUtils类属于org.apache.hadoop.hive.common包,在下文中一共展示了JavaUtils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSessionSpecifiedClassLoader

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
/**
 * get session specified class loader and get current class loader if fall
 *
 * @return
 */
public static ClassLoader getSessionSpecifiedClassLoader() {
  SessionState state = SessionState.get();
  if (state == null || state.getConf() == null) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Hive Conf not found or Session not initiated, use thread based class loader instead");
    }
    return JavaUtils.getClassLoader();
  }
  ClassLoader sessionCL = state.getConf().getClassLoader();
  if (sessionCL != null) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Use session specified class loader");  //it's normal case
    }
    return sessionCL;
  }
  if (LOG.isDebugEnabled()) {
    LOG.debug("Session specified class loader not found, use thread based class loader");
  }
  return JavaUtils.getClassLoader();
}
 
开发者ID:mini666,项目名称:hive-phoenix-handler,代码行数:26,代码来源:Utilities.java

示例2: removeFromClassPath

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
/**
   * remove elements from the classpath.
   *
   * @param pathsToRemove
   *          Array of classpath elements
   */
  public static void removeFromClassPath(String[] pathsToRemove) throws Exception {
    Thread curThread = Thread.currentThread();
    URLClassLoader loader = (URLClassLoader) curThread.getContextClassLoader();
    Set<URL> newPath = new HashSet<URL>(Arrays.asList(loader.getURLs()));

    for (String onestr : pathsToRemove) {
      URL oneurl = urlFromPathString(onestr);
      if (oneurl != null) {
        newPath.remove(oneurl);
      }
    }
    JavaUtils.closeClassLoader(loader);
//this loader is closed, remove it from cached registry loaders to avoid remove it again.
    Registry reg = SessionState.getRegistry();
    if(reg != null) {
      reg.removeFromUDFLoaders(loader);
    }

    loader = new URLClassLoader(newPath.toArray(new URL[0]));
    curThread.setContextClassLoader(loader);
    SessionState.get().getConf().setClassLoader(loader);
  }
 
开发者ID:mini666,项目名称:hive-phoenix-handler,代码行数:29,代码来源:Utilities.java

示例3: close

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
@Override
public void close() throws HiveSQLException {
  ClassLoader nonDBClassLoader = getSessionState().getConf().getClassLoader();
  super.close();
  // Release class loader resources
  JavaUtils.closeClassLoadersTo(nonDBClassLoader, getClass().getClassLoader());
  synchronized (sessionDbClassLoaders) {
    for (Map.Entry<String, SessionClassLoader> entry : sessionDbClassLoaders.entrySet()) {
      try {
        // Closing session level classloaders up untill the db class loader if present, or null.
        // When db class loader is null, the class loader in the session is a single class loader
        // which stays as it is on database switch -- provided the new db doesn't have db jars.
        // The following line will close class loaders made on top of db class loaders and will close
        // only one classloader without closing the parents. In case of no db class loader, the session
        // classloader will already have been closed by either super.close() or before this for loop.
        JavaUtils.closeClassLoadersTo(entry.getValue(), getDbResService().getClassLoader(entry.getKey()));
      } catch (Exception e) {
        log.error("Error closing session classloader for session: {}", getSessionHandle().getSessionId(), e);
      }
    }
    sessionDbClassLoaders.clear();
  }
  // reset classloader in close
  Thread.currentThread().setContextClassLoader(LensSessionImpl.class.getClassLoader());
}
 
开发者ID:apache,项目名称:lens,代码行数:26,代码来源:LensSessionImpl.java

示例4: getHooks

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
/**
 * Returns the hooks specified in a configuration variable.  The hooks are returned in a list in
 * the order they were specified in the configuration variable.
 *
 * @param hookConfVar The configuration variable specifying a comma separated list of the hook
 *                    class names.
 * @return            A list of the hooks, in the order they are listed in the value of hookConfVar
 * @throws Exception
 */
private static <T extends Hook> List<T> getHooks(String csHooks) throws Exception {

  List<T> hooks = new ArrayList<T>();
  if (csHooks.isEmpty()) {
    return hooks;
  }
  for (String hookClass : Splitter.on(",").omitEmptyStrings().trimResults().split(csHooks)) {
    try {
      @SuppressWarnings("unchecked")
      T hook =
          (T) Class.forName(hookClass, true, JavaUtils.getClassLoader()).newInstance();
      hooks.add(hook);
    } catch (ClassNotFoundException e) {
      LOG.error(hookClass + " Class not found:" + e.getMessage());
      throw e;
    }
  }

  return hooks;
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:30,代码来源:HiveAuthzBindingHook.java

示例5: getHooks

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
/**
 * Returns the hooks specified in a configuration variable. The hooks are returned in a list in
 * the order they were specified in the configuration variable.
 *
 * @param hookConfVar The configuration variable specifying a comma separated list of the hook
 *        class names.
 * @param clazz The super type of the hooks.
 * @return A list of the hooks cast as the type specified in clazz, in the order they are listed
 *         in the value of hookConfVar
 * @throws Exception
 */
public static <T extends Hook> List<T> getHooks(String csHooks, Class<T> clazz) throws Exception {

  List<T> hooks = new ArrayList<T>();
  if (csHooks.isEmpty()) {
    return hooks;
  }
  for (String hookClass : Splitter.on(",").omitEmptyStrings().trimResults().split(csHooks)) {
    try {
      @SuppressWarnings("unchecked")
      T hook = (T) Class.forName(hookClass, true, JavaUtils.getClassLoader()).newInstance();
      hooks.add(hook);
    } catch (ClassNotFoundException e) {
      LOG.error(hookClass + " Class not found:" + e.getMessage());
      throw e;
    }
  }

  return hooks;
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:31,代码来源:SentryAuthorizerUtil.java

示例6: getMetaStoreFsHandler

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
private MetaStoreFS getMetaStoreFsHandler(Configuration conf)
    throws MetaException {
  String handlerClassStr = HiveConf.getVar(conf,
      HiveConf.ConfVars.HIVE_METASTORE_FS_HANDLER_CLS);
  try {
    @SuppressWarnings("unchecked")
  Class<? extends MetaStoreFS> handlerClass = (Class<? extends MetaStoreFS>) Class
        .forName(handlerClassStr, true, JavaUtils.getClassLoader());
    MetaStoreFS handler = (MetaStoreFS) ReflectionUtils.newInstance(
        handlerClass, conf);
    return handler;
  } catch (ClassNotFoundException e) {
    throw new MetaException("Error in loading MetaStoreFS handler."
        + e.getMessage());
  }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:17,代码来源:Warehouse.java

示例7: restoreSessionSpecifiedClassLoader

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
public static void restoreSessionSpecifiedClassLoader(ClassLoader prev) {
  SessionState state = SessionState.get();
  if (state != null && state.getConf() != null) {
    ClassLoader current = state.getConf().getClassLoader();
    if (current != prev && JavaUtils.closeClassLoadersTo(current, prev)) {
      Thread.currentThread().setContextClassLoader(prev);
      state.getConf().setClassLoader(prev);
    }
  }
}
 
开发者ID:mini666,项目名称:hive-phoenix-handler,代码行数:11,代码来源:Utilities.java

示例8: getMetaStoreListeners

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
/**
 * create listener instances as per the configuration.
 *
 * @param clazz
 * @param conf
 * @param listenerImplList
 * @return
 * @throws MetaException
 */
static <T> List<T> getMetaStoreListeners(Class<T> clazz,
    HiveConf conf, String listenerImplList) throws MetaException {

  List<T> listeners = new ArrayList<T>();
  listenerImplList = listenerImplList.trim();
  if (listenerImplList.equals("")) {
    return listeners;
  }

  String[] listenerImpls = listenerImplList.split(",");
  for (String listenerImpl : listenerImpls) {
    try {
      @SuppressWarnings("unchecked")
      T listener = (T) Class.forName(
          listenerImpl.trim(), true, JavaUtils.getClassLoader()).getConstructor(
              Configuration.class).newInstance(conf);
      listeners.add(listener);
    } catch (InvocationTargetException ie) {
      throw new MetaException("Failed to instantiate listener named: "+
          listenerImpl + ", reason: " + ie.getCause());
    } catch (Exception e) {
      throw new MetaException("Failed to instantiate listener named: "+
          listenerImpl + ", reason: " + e);
    }
  }

  return listeners;
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:38,代码来源:MetaStoreUtils.java

示例9: getClass

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
public static Class<?> getClass(String rawStoreClassName)
    throws MetaException {
  try {
    return Class.forName(rawStoreClassName, true, JavaUtils.getClassLoader());
  } catch (ClassNotFoundException e) {
    throw new MetaException(rawStoreClassName + " class not found");
  }
}
 
开发者ID:facebookarchive,项目名称:swift-hive-metastore,代码行数:9,代码来源:MetaStoreUtils.java

示例10: configureJobProperties

import org.apache.hadoop.hive.common.JavaUtils; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void configureJobProperties(TableDesc tableDesc, Map<String, String> jobProperties) {
	Properties tableProperties = tableDesc.getProperties();

	String inputFormatClassName = tableProperties.getProperty(PhoenixStorageHandlerConstants.HBASE_INPUT_FORMAT_CLASS);

	if (LOG.isDebugEnabled()) {
		LOG.debug(PhoenixStorageHandlerConstants.HBASE_INPUT_FORMAT_CLASS + " is " + inputFormatClassName);
	}

	Class<?> inputFormatClass = null;
	try {
		if (inputFormatClassName != null) {
			inputFormatClass = JavaUtils.loadClass(inputFormatClassName);
		} else {
			inputFormatClass = PhoenixInputFormat.class;
		}
	} catch (Exception e) {
		LOG.error(e.getMessage(), e);
		throw new RuntimeException(e);
	}

	if (inputFormatClass != null) {
		tableDesc.setInputFileFormatClass((Class<? extends InputFormat>) inputFormatClass);
	}

	String tableName = tableProperties.getProperty(PhoenixStorageHandlerConstants.PHOENIX_TABLE_NAME);
	if (tableName == null) {
		tableName = tableDesc.getTableName();
		tableProperties.setProperty(PhoenixStorageHandlerConstants.PHOENIX_TABLE_NAME, tableName);
	}
	
	jobProperties.put(PhoenixConfigurationUtil.INPUT_TABLE_NAME, tableName);
	jobProperties.put(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM, tableProperties.getProperty(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM, PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_QUORUM));
	jobProperties.put(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT, tableProperties.getProperty(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT, String.valueOf(PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_PORT)));
	jobProperties.put(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT, tableProperties.getProperty(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT, PhoenixStorageHandlerConstants.DEFAULT_ZOOKEEPER_PARENT));
	
	jobProperties.put(hive_metastoreConstants.META_TABLE_STORAGE, this.getClass().getName());
	
	// set configuration when direct work with HBase.
	jobProperties.put(HConstants.ZOOKEEPER_QUORUM, jobProperties.get(PhoenixStorageHandlerConstants.ZOOKEEPER_QUORUM));
	jobProperties.put(HConstants.ZOOKEEPER_CLIENT_PORT, jobProperties.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PORT));
	jobProperties.put(HConstants.ZOOKEEPER_ZNODE_PARENT, jobProperties.get(PhoenixStorageHandlerConstants.ZOOKEEPER_PARENT));
}
 
开发者ID:mini666,项目名称:hive-phoenix-handler,代码行数:45,代码来源:PhoenixStorageHandler.java


注:本文中的org.apache.hadoop.hive.common.JavaUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。