Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HColumnDescriptor


    HRegionInfo info = null;
    try {
      FileSystem fs = Mockito.mock(FileSystem.class);
      Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
      HTableDescriptor htd = new HTableDescriptor(tableName);
      htd.addFamily(new HColumnDescriptor("cf"));
      info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
          HConstants.EMPTY_BYTE_ARRAY, false);
      Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
      region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
      // region initialization throws IOException and set task state to ABORTED.
View Full Code Here


  @Test
  public void testRegionInfoFileCreation() throws IOException {
    Path rootDir = new Path(DIR + "testRegionInfoFileCreation");

    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("testtb"));
    htd.addFamily(new HColumnDescriptor("cf"));

    HRegionInfo hri = new HRegionInfo(htd.getTableName());

    // Create a region and skip the initialization (like CreateTableHandler)
    HRegion region = HRegion.createHRegion(hri, rootDir, conf, htd, null, false, true);
View Full Code Here

    HTable table = new HTable(TEST_UTIL.getConfiguration(), tableName);

    // Add one column family and put some data in it
    admin.disableTable(tableName);
    admin.addColumn(tableName, new HColumnDescriptor(TEST_FAMILY2));
    admin.enableTable(tableName);
    assertEquals(2, table.getTableDescriptor().getFamilies().size());
    HTableDescriptor htd = admin.getTableDescriptor(tableName);
    assertEquals(2, htd.getFamilies().size());
    SnapshotTestingUtils.loadData(TEST_UTIL, table, 500, TEST_FAMILY2);
View Full Code Here

      server, regionName, FAMILY).size();
    assertTrue(sfCount > 1);

    // change an individual CF's config option to 2 & online schema update
    LOG.info("hbase.hstore.compaction.min should now be 2");
    HColumnDescriptor hcd = new HColumnDescriptor(htd.getFamily(FAMILY));
    hcd.setValue("hbase.hstore.compaction.min", String.valueOf(2));
    htd.addFamily(hcd);
    admin.modifyTable(TABLE, htd);
    while (null != (st = admin.getAlterStatus(TABLE)) && st.getFirst() > 0) {
      LOG.debug(st.getFirst() + " regions left to update");
      Thread.sleep(40);
    }
    LOG.info("alter status finished");

    // Issue a compaction request
    admin.compact(TABLE.getName());

    // poll wait for the compactions to happen
    for (int i = 0; i < 10 * 1000 / 40; ++i) {
      loc = hTable.getRegionLocation(row, true);
      regionName = loc.getRegionInfo().getRegionName();
      try {
        server = connection.getAdmin(loc.getServerName());
        if (ProtobufUtil.getStoreFiles(
            server, regionName, FAMILY).size() < sfCount) {
          break;
        }
      } catch (Exception e) {
        LOG.debug("Waiting for region to come online: " + regionName);
      }
      Thread.sleep(40);
    }
    // verify the compaction took place and that we didn't just time out
    assertTrue(ProtobufUtil.getStoreFiles(
      server, regionName, FAMILY).size() < sfCount);

    // Finally, ensure that we can remove a custom config value after we made it
    LOG.info("Removing CF config value");
    LOG.info("hbase.hstore.compaction.min should now be 5");
    hcd = new HColumnDescriptor(htd.getFamily(FAMILY));
    hcd.setValue("hbase.hstore.compaction.min", null);
    htd.addFamily(hcd);
    admin.modifyTable(TABLE, htd);
    while (null != (st = admin.getAlterStatus(TABLE)) && st.getFirst() > 0) {
      LOG.debug(st.getFirst() + " regions left to update");
      Thread.sleep(40);
View Full Code Here

  @Test
  public void testGetEmptyRow() throws Exception {
    //Create a table and put in 1 row
    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(Bytes.toBytes("test")));
    desc.addFamily(new HColumnDescriptor(FAMILY));
    admin.createTable(desc);
    HTable table = new HTable(TEST_UTIL.getConfiguration(), "test");

    Put put = new Put(ROW_BYTES);
    put.add(FAMILY, COL_QUAL, VAL_BYTES);
View Full Code Here

    }
    LruBlockCache cache =
      (LruBlockCache)new CacheConfig(testUtil.getConfiguration()).getBlockCache();
    cache.clearCache();
    // Need to disable default row bloom filter for this test to pass.
    HColumnDescriptor hcd = (new HColumnDescriptor(CF_NAME)).setMaxVersions(MAX_VERSIONS).
        setDataBlockEncoding(encoding).
        setBlocksize(BLOCK_SIZE).
        setBloomFilterType(BloomType.NONE).
        setCompressTags(compressTags);
    HRegion region = testUtil.createTestRegion(TABLE_NAME, hcd);
View Full Code Here

  public void initlize() throws IOException {
    HBaseAdmin admin = new HBaseAdmin(this.conf);
    String tTableName = StorageTableNameBuilder.buildTransactionTableName(egi
        .getEncodedName());
    if (!admin.tableExists(tTableName)) {
      HColumnDescriptor family = new HColumnDescriptor(fEntityValue);
      family.setCompressionType(Algorithm.GZ);
      HTableDescriptor tableDes = new HTableDescriptor(tTableName);
      tableDes.addFamily(family);
      admin.createTable(tableDes);
    }
    admin.close();
View Full Code Here

    
     HTableDescriptor wordcount = new HTableDescriptor(TABLE_NAME);
     hbase.createTable(wordcount);
     // Cannot edit a stucture on an active table.
     hbase.disableTable(TABLE_NAME);
     HColumnDescriptor columnFamily = new HColumnDescriptor(COLUMN_FAMILY);
     hbase.addColumn(TABLE_NAME, columnFamily);
     hbase.enableTable(TABLE_NAME);
    
     hbase.close();
   }
View Full Code Here

  }
 
  private HTableDescriptor createTable(String tableName) {
    HTableDescriptor descriptor = new HTableDescriptor(tableName);
   
    HColumnDescriptor columnDescriptor = new HColumnDescriptor("string:");
    descriptor.addFamily(columnDescriptor);
   
    return descriptor;
  }
View Full Code Here

     
      if (!admin.tableExists(tablenameshard)) {
        HTableDescriptor tableDescripter = new HTableDescriptor(tablenameshard.getBytes());
        tableDescripter.setValue("group",String.valueOf(params.get("realtime.hbase.group")));

        HColumnDescriptor columnDescripter2 = new HColumnDescriptor(DATA_FAMILY);
        columnDescripter2.setBlockCacheEnabled(false);
        columnDescripter2.setBlocksize(262144);
        columnDescripter2.setBloomFilterType(BloomType.NONE);
        columnDescripter2.setCompressionType(Algorithm.GZ);
        columnDescripter2.setMaxVersions(10);
        columnDescripter2.setInMemory(false);
        columnDescripter2.setTimeToLive(Integer.MAX_VALUE);
        tableDescripter.addFamily(columnDescripter2);

        admin.createTable(tableDescripter);
      }
     
     
      String tablenamequeue = this.getQueueTableNme(tablename);
      if (!admin.tableExists(tablenamequeue)) {
        HTableDescriptor tableDescripter = new HTableDescriptor(tablenamequeue.getBytes());
        tableDescripter.setValue("group",String.valueOf(params.get("realtime.hbase.group")));

        HColumnDescriptor columnDescripter2 = new HColumnDescriptor(MdrillQueue.FAMILY);
        columnDescripter2.setBlockCacheEnabled(false);
        columnDescripter2.setBlocksize(262144);
        columnDescripter2.setBloomFilterType(BloomType.NONE);
        columnDescripter2.setCompressionType(Algorithm.NONE);
        columnDescripter2.setMaxVersions(10);
        columnDescripter2.setInMemory(false);
        columnDescripter2.setTimeToLive(2 * 24 * 60 * 60);
        tableDescripter.addFamily(columnDescripter2);
        admin.createTable(tableDescripter);
      }
       
   
 
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.HColumnDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.