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


Java CoprocessorClassLoader类代码示例

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


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

示例1: testTableCoprocessorAttrs

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
/**
 * Sanity check the table coprocessor attributes of the supplied schema. Will
 * throw an exception if there is a problem.
 * @param conf
 * @param htd
 * @throws IOException
 */
public static void testTableCoprocessorAttrs(final Configuration conf,
    final HTableDescriptor htd) throws IOException {
  String pathPrefix = UUID.randomUUID().toString();
  for (TableCoprocessorAttribute attr: getTableCoprocessorAttrsFromSchema(conf, htd)) {
    if (attr.getPriority() < 0) {
      throw new IOException("Priority for coprocessor " + attr.getClassName() +
        " cannot be less than 0");
    }
    ClassLoader old = Thread.currentThread().getContextClassLoader();
    try {
      ClassLoader cl;
      if (attr.getPath() != null) {
        cl = CoprocessorClassLoader.getClassLoader(attr.getPath(),
          CoprocessorHost.class.getClassLoader(), pathPrefix, conf);
      } else {
        cl = CoprocessorHost.class.getClassLoader();
      }
      Thread.currentThread().setContextClassLoader(cl);
      cl.loadClass(attr.getClassName());
    } catch (ClassNotFoundException e) {
      throw new IOException("Class " + attr.getClassName() + " cannot be loaded", e);
    } finally {
      Thread.currentThread().setContextClassLoader(old);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:RegionCoprocessorHost.java

示例2: testPrivateClassLoader

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
@Test
// HBASE-6308: Test CP classloader is the CoprocessorClassLoader
public void testPrivateClassLoader() throws Exception {
  File jarFile = buildCoprocessorJar(cpName4);

  // create a table that references the jar
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(cpName4));
  htd.addFamily(new HColumnDescriptor("test"));
  htd.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName4 + "|" +
    Coprocessor.PRIORITY_USER);
  Admin admin = TEST_UTIL.getHBaseAdmin();
  admin.createTable(htd);
  waitForTable(htd.getTableName());

  // verify that the coprocessor was loaded correctly
  boolean found = false;
  MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
  for (Region region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
    if (region.getRegionInfo().getRegionNameAsString().startsWith(cpName4)) {
      Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4);
      if (cp != null) {
        found = true;
        assertEquals("Class " + cpName4 + " was not loaded by CoprocessorClassLoader",
          cp.getClass().getClassLoader().getClass(), CoprocessorClassLoader.class);
      }
    }
  }
  assertTrue("Class " + cpName4 + " was missing on a region", found);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:TestClassLoading.java

示例3: testPrivateClassLoader

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
@Test
// HBASE-6308: Test CP classloader is the CoprocessorClassLoader
public void testPrivateClassLoader() throws Exception {
  File jarFile = buildCoprocessorJar(cpName4);

  // create a table that references the jar
  HTableDescriptor htd = new HTableDescriptor(cpName4);
  htd.addFamily(new HColumnDescriptor("test"));
  htd.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName4 + "|" +
    Coprocessor.PRIORITY_USER);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  admin.createTable(htd);
  waitForTable(htd.getName());

  // verify that the coprocessor was loaded correctly
  boolean found = false;
  MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
  for (HRegion region:
      hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
    if (region.getRegionNameAsString().startsWith(cpName4)) {
      Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4);
      if (cp != null) {
        found = true;
        assertEquals("Class " + cpName4 + " was not loaded by CoprocessorClassLoader",
          cp.getClass().getClassLoader().getClass(), CoprocessorClassLoader.class);
      }
    }
  }
  assertTrue("Class " + cpName4 + " was missing on a region", found);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:31,代码来源:TestClassLoading.java

示例4: testPrivateClassLoader

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
@Test
// HBASE-6308: Test CP classloader is the CoprocessorClassLoader
public void testPrivateClassLoader() throws Exception {
  File jarFile = buildCoprocessorJar(cpName4);

  // create a table that references the jar
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(cpName4));
  htd.addFamily(new HColumnDescriptor("test"));
  htd.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName4 + "|" +
    Coprocessor.PRIORITY_USER);
  Admin admin = TEST_UTIL.getHBaseAdmin();
  admin.createTable(htd);
  waitForTable(htd.getTableName());

  // verify that the coprocessor was loaded correctly
  boolean found = false;
  MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
  for (HRegion region:
      hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
    if (region.getRegionNameAsString().startsWith(cpName4)) {
      Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4);
      if (cp != null) {
        found = true;
        assertEquals("Class " + cpName4 + " was not loaded by CoprocessorClassLoader",
          cp.getClass().getClassLoader().getClass(), CoprocessorClassLoader.class);
      }
    }
  }
  assertTrue("Class " + cpName4 + " was missing on a region", found);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:31,代码来源:TestClassLoading.java

示例5: testPrivateClassLoader

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
@Test
// HBASE-6308: Test CP classloader is the CoprocessorClassLoader
public void testPrivateClassLoader() throws Exception {
  File jarFile = buildCoprocessorJar(cpName4);

  // create a table that references the jar
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(cpName4));
  htd.addFamily(new HColumnDescriptor("test"));
  htd.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName4 + "|" +
    Coprocessor.PRIORITY_USER);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  admin.createTable(htd);
  waitForTable(htd.getTableName());

  // verify that the coprocessor was loaded correctly
  boolean found = false;
  MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
  for (HRegion region:
      hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
    if (region.getRegionNameAsString().startsWith(cpName4)) {
      Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4);
      if (cp != null) {
        found = true;
        assertEquals("Class " + cpName4 + " was not loaded by CoprocessorClassLoader",
          cp.getClass().getClassLoader().getClass(), CoprocessorClassLoader.class);
      }
    }
  }
  assertTrue("Class " + cpName4 + " was missing on a region", found);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:31,代码来源:TestClassLoading.java

示例6: testPrivateClassLoader

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
@Test
// HBASE-6308: Test CP classloader is the CoprocessorClassLoader
public void testPrivateClassLoader() throws Exception {
  File jarFile = buildCoprocessorJar(cpName4);

  // create a table that references the jar
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(cpName4));
  htd.addFamily(new HColumnDescriptor("test"));
  htd.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName4 + "|" +
    Coprocessor.PRIORITY_USER);
  Admin admin = TEST_UTIL.getAdmin();
  admin.createTable(htd);
  waitForTable(htd.getTableName());

  // verify that the coprocessor was loaded correctly
  boolean found = false;
  MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster();
  for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) {
    if (region.getRegionInfo().getRegionNameAsString().startsWith(cpName4)) {
      Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4);
      if (cp != null) {
        found = true;
        assertEquals("Class " + cpName4 + " was not loaded by CoprocessorClassLoader",
          cp.getClass().getClassLoader().getClass(), CoprocessorClassLoader.class);
      }
    }
  }
  assertTrue("Class " + cpName4 + " was missing on a region", found);
}
 
开发者ID:apache,项目名称:hbase,代码行数:30,代码来源:TestClassLoading.java

示例7: testTableCoprocessorAttrs

import org.apache.hadoop.hbase.util.CoprocessorClassLoader; //导入依赖的package包/类
/**
 * Sanity check the table coprocessor attributes of the supplied schema. Will
 * throw an exception if there is a problem.
 * @param conf
 * @param htd
 * @throws IOException
 */
public static void testTableCoprocessorAttrs(final Configuration conf,
    final TableDescriptor htd) throws IOException {
  String pathPrefix = UUID.randomUUID().toString();
  for (TableCoprocessorAttribute attr: getTableCoprocessorAttrsFromSchema(conf, htd)) {
    if (attr.getPriority() < 0) {
      throw new IOException("Priority for coprocessor " + attr.getClassName() +
        " cannot be less than 0");
    }
    ClassLoader old = Thread.currentThread().getContextClassLoader();
    try {
      ClassLoader cl;
      if (attr.getPath() != null) {
        cl = CoprocessorClassLoader.getClassLoader(attr.getPath(),
          CoprocessorHost.class.getClassLoader(), pathPrefix, conf);
      } else {
        cl = CoprocessorHost.class.getClassLoader();
      }
      Thread.currentThread().setContextClassLoader(cl);
      cl.loadClass(attr.getClassName());
    } catch (ClassNotFoundException e) {
      throw new IOException("Class " + attr.getClassName() + " cannot be loaded", e);
    } finally {
      Thread.currentThread().setContextClassLoader(old);
    }
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:RegionCoprocessorHost.java


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