當前位置: 首頁>>代碼示例>>Java>>正文


Java HColumnDescriptor.setBlocksize方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HColumnDescriptor.setBlocksize方法的典型用法代碼示例。如果您正苦於以下問題:Java HColumnDescriptor.setBlocksize方法的具體用法?Java HColumnDescriptor.setBlocksize怎麽用?Java HColumnDescriptor.setBlocksize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HColumnDescriptor的用法示例。


在下文中一共展示了HColumnDescriptor.setBlocksize方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCacheBlocks

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test
public void testCacheBlocks() throws IOException {
  // Set index block size to be the same as normal block size.
  TEST_UTIL.getConfiguration().setInt(HFileBlockIndex.MAX_CHUNK_SIZE_KEY, BLOCK_SIZE);
  HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toBytes(CF)).setMaxVersions(MAX_VERSIONS).
    setCompressionType(COMPRESSION_ALGORITHM).
    setBloomFilterType(BLOOM_TYPE);
  hcd.setBlocksize(BLOCK_SIZE);
  hcd.setBlockCacheEnabled(cfCacheEnabled);
  Region region = TEST_UTIL.createTestRegion(TABLE, hcd);
  BlockCache cache = region.getStore(hcd.getName()).getCacheConfig().getBlockCache();
  CacheStats stats = cache.getStats();
  writeTestData(region);
  assertEquals(0, stats.getHitCount());
  assertEquals(0, HFile.dataBlockReadCnt.get());
  // Do a single get, take count of caches.  If we are NOT caching DATA blocks, the miss
  // count should go up.  Otherwise, all should be cached and the miss count should not rise.
  region.get(new Get(Bytes.toBytes("row" + 0)));
  assertTrue(stats.getHitCount() > 0);
  assertTrue(HFile.dataBlockReadCnt.get() > 0);
  long missCount = stats.getMissCount();
  region.get(new Get(Bytes.toBytes("row" + 0)));
  if (this.cfCacheEnabled) assertEquals(missCount, stats.getMissCount());
  else assertTrue(stats.getMissCount() > missCount);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:TestForceCacheImportantBlocks.java

示例2: createTableWithNonDefaultProperties

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
private void createTableWithNonDefaultProperties() throws Exception {
  final long startTime = System.currentTimeMillis();
  final String sourceTableNameAsString = STRING_TABLE_NAME + startTime;
  originalTableName = TableName.valueOf(sourceTableNameAsString);

  // enable replication on a column family
  HColumnDescriptor maxVersionsColumn = new HColumnDescriptor(MAX_VERSIONS_FAM);
  HColumnDescriptor bloomFilterColumn = new HColumnDescriptor(BLOOMFILTER_FAM);
  HColumnDescriptor dataBlockColumn = new HColumnDescriptor(COMPRESSED_FAM);
  HColumnDescriptor blockSizeColumn = new HColumnDescriptor(BLOCKSIZE_FAM);

  maxVersionsColumn.setMaxVersions(MAX_VERSIONS);
  bloomFilterColumn.setBloomFilterType(BLOOM_TYPE);
  dataBlockColumn.setDataBlockEncoding(DATA_BLOCK_ENCODING_TYPE);
  blockSizeColumn.setBlocksize(BLOCK_SIZE);

  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(sourceTableNameAsString));
  htd.addFamily(maxVersionsColumn);
  htd.addFamily(bloomFilterColumn);
  htd.addFamily(dataBlockColumn);
  htd.addFamily(blockSizeColumn);
  htd.setValue(TEST_CUSTOM_VALUE, TEST_CUSTOM_VALUE);
  htd.setConfiguration(TEST_CONF_CUSTOM_VALUE, TEST_CONF_CUSTOM_VALUE);
  assertTrue(htd.getConfiguration().size() > 0);

  admin.createTable(htd);
  Table original = new HTable(UTIL.getConfiguration(), originalTableName);
  originalTableName = TableName.valueOf(sourceTableNameAsString);
  originalTableDescriptor = admin.getTableDescriptor(originalTableName);
  originalTableDescription = originalTableDescriptor.toStringCustomizedValues();

  original.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:34,代碼來源:TestSnapshotMetadata.java

示例3: testModifyColumnFamily

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test
public void testModifyColumnFamily() throws IOException {
  Admin admin = TEST_UTIL.getHBaseAdmin();

  HColumnDescriptor cfDescriptor = new HColumnDescriptor(FAMILY_0);
  int blockSize = cfDescriptor.getBlocksize();
  // Create a table with one families
  HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
  baseHtd.addFamily(cfDescriptor);
  admin.createTable(baseHtd);
  admin.disableTable(TABLE_NAME);
  try {
    // Verify the table descriptor
    verifyTableDescriptor(TABLE_NAME, FAMILY_0);

    int newBlockSize = 2 * blockSize;
    cfDescriptor.setBlocksize(newBlockSize);

    // Modify colymn family
    admin.modifyColumn(TABLE_NAME, cfDescriptor);

    HTableDescriptor htd = admin.getTableDescriptor(TABLE_NAME);
    HColumnDescriptor hcfd = htd.getFamily(FAMILY_0);
    assertTrue(hcfd.getBlocksize() == newBlockSize);
  } finally {
    admin.deleteTable(TABLE_NAME);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:29,代碼來源:TestTableDescriptorModification.java

示例4: testModifyNonExistingColumnFamily

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test
public void testModifyNonExistingColumnFamily() throws IOException {
  Admin admin = TEST_UTIL.getHBaseAdmin();

  HColumnDescriptor cfDescriptor = new HColumnDescriptor(FAMILY_1);
  int blockSize = cfDescriptor.getBlocksize();
  // Create a table with one families
  HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
  baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
  admin.createTable(baseHtd);
  admin.disableTable(TABLE_NAME);
  try {
    // Verify the table descriptor
    verifyTableDescriptor(TABLE_NAME, FAMILY_0);

    int newBlockSize = 2 * blockSize;
    cfDescriptor.setBlocksize(newBlockSize);

    // Modify a column family that is not in the table.
    try {
      admin.modifyColumn(TABLE_NAME, cfDescriptor);
      Assert.fail("Modify a non-exist column family should fail");
    } catch (InvalidFamilyOperationException e) {
      // Expected.
    }

  } finally {
    admin.deleteTable(TABLE_NAME);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:31,代碼來源:TestTableDescriptorModification.java

示例5: testModifyColumnFamily

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testModifyColumnFamily() throws Exception {
  final TableName tableName = TableName.valueOf("testModifyColumnFamily");
  final String cf1 = "cf1";
  final HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf1);
  int oldBlockSize = columnDescriptor.getBlocksize();
  int newBlockSize = 3 * oldBlockSize;

  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  MasterProcedureTestingUtility.createTable(procExec, tableName, null, cf1, "f2");

  // Test 1: modify the column family online
  columnDescriptor.setBlocksize(newBlockSize);
  long procId1 = procExec.submitProcedure(
    new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor),
    nonceGroup,
    nonce);
  // Wait the completion
  ProcedureTestingUtility.waitProcedure(procExec, procId1);
  ProcedureTestingUtility.assertProcNotFailed(procExec, procId1);
  MasterProcedureTestingUtility.validateColumnFamilyModification(UTIL.getHBaseCluster()
      .getMaster(), tableName, cf1, columnDescriptor);

  // Test 2: modify the column family offline
  UTIL.getHBaseAdmin().disableTable(tableName);
  columnDescriptor.setBlocksize(newBlockSize * 2);
  long procId2 = procExec.submitProcedure(
    new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor),
    nonceGroup + 1,
    nonce + 1);
  // Wait the completion
  ProcedureTestingUtility.waitProcedure(procExec, procId2);
  ProcedureTestingUtility.assertProcNotFailed(procExec, procId2);
  MasterProcedureTestingUtility.validateColumnFamilyModification(UTIL.getHBaseCluster()
      .getMaster(), tableName, cf1, columnDescriptor);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:38,代碼來源:TestModifyColumnFamilyProcedure.java

示例6: testModifyNonExistingColumnFamily

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test(timeout=60000)
public void testModifyNonExistingColumnFamily() throws Exception {
  final TableName tableName = TableName.valueOf("testModifyExistingColumnFamily");
  final String cf2 = "cf2";
  final HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf2);
  int oldBlockSize = columnDescriptor.getBlocksize();
  int newBlockSize = 2 * oldBlockSize;

  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1");

  // Modify the column family that does not exist
  columnDescriptor.setBlocksize(newBlockSize);
  long procId1 = procExec.submitProcedure(
    new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor),
    nonceGroup,
    nonce);
  // Wait the completion
  ProcedureTestingUtility.waitProcedure(procExec, procId1);

  ProcedureInfo result = procExec.getResult(procId1);
  assertTrue(result.isFailed());
  LOG.debug("Modify failed with exception: " + result.getExceptionFullMessage());
  assertTrue(
    ProcedureTestingUtility.getExceptionCause(result) instanceof InvalidFamilyOperationException);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:TestModifyColumnFamilyProcedure.java

示例7: testRecoveryAndDoubleExecutionOffline

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test(timeout=60000)
public void testRecoveryAndDoubleExecutionOffline() throws Exception {
  final TableName tableName = TableName.valueOf("testRecoveryAndDoubleExecutionOffline");
  final String cf3 = "cf3";
  final HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf3);
  int oldBlockSize = columnDescriptor.getBlocksize();
  int newBlockSize = 4 * oldBlockSize;

  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  // create the table
  MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1", "f2", cf3);
  UTIL.getHBaseAdmin().disableTable(tableName);
  ProcedureTestingUtility.waitNoProcedureRunning(procExec);
  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  // Start the Modify procedure && kill the executor
  columnDescriptor.setBlocksize(newBlockSize);
  long procId = procExec.submitProcedure(
    new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor),
    nonceGroup,
    nonce);

  // Restart the executor and execute the step twice
  int numberOfSteps = ModifyColumnFamilyState.values().length;
  MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(
    procExec,
    procId,
    numberOfSteps,
    ModifyColumnFamilyState.values());

  MasterProcedureTestingUtility.validateColumnFamilyModification(UTIL.getHBaseCluster()
      .getMaster(), tableName, cf3, columnDescriptor);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:TestModifyColumnFamilyProcedure.java

示例8: testRecoveryAndDoubleExecutionOnline

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testRecoveryAndDoubleExecutionOnline() throws Exception {
  final TableName tableName = TableName.valueOf("testRecoveryAndDoubleExecutionOnline");
  final String cf4 = "cf4";
  final HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf4);
  int oldBlockSize = columnDescriptor.getBlocksize();
  int newBlockSize = 4 * oldBlockSize;

  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  // create the table
  MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1", "f2", cf4);
  ProcedureTestingUtility.waitNoProcedureRunning(procExec);
  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  // Start the Modify procedure && kill the executor
  columnDescriptor.setBlocksize(newBlockSize);
  long procId = procExec.submitProcedure(
    new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor),
    nonceGroup,
    nonce);

  // Restart the executor and execute the step twice
  int numberOfSteps = ModifyColumnFamilyState.values().length;
  MasterProcedureTestingUtility.testRecoveryAndDoubleExecution(procExec, procId, numberOfSteps,
    ModifyColumnFamilyState.values());

  MasterProcedureTestingUtility.validateColumnFamilyModification(UTIL.getHBaseCluster()
      .getMaster(), tableName, cf4, columnDescriptor);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:31,代碼來源:TestModifyColumnFamilyProcedure.java

示例9: testRollbackAndDoubleExecution

import org.apache.hadoop.hbase.HColumnDescriptor; //導入方法依賴的package包/類
@Test(timeout = 60000)
public void testRollbackAndDoubleExecution() throws Exception {
  final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecution");
  final String cf3 = "cf3";
  final HColumnDescriptor columnDescriptor = new HColumnDescriptor(cf3);
  int oldBlockSize = columnDescriptor.getBlocksize();
  int newBlockSize = 4 * oldBlockSize;

  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();

  // create the table
  MasterProcedureTestingUtility.createTable(procExec, tableName, null, "f1", "f2", cf3);
  ProcedureTestingUtility.waitNoProcedureRunning(procExec);
  ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true);

  // Start the Modify procedure && kill the executor
  columnDescriptor.setBlocksize(newBlockSize);
  long procId = procExec.submitProcedure(
    new ModifyColumnFamilyProcedure(procExec.getEnvironment(), tableName, columnDescriptor),
    nonceGroup,
    nonce);

  // Failing in the middle of proc
  int numberOfSteps = ModifyColumnFamilyState.values().length - 2;
  MasterProcedureTestingUtility.testRollbackAndDoubleExecution(
    procExec,
    procId,
    numberOfSteps,
    ModifyColumnFamilyState.values());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:31,代碼來源:TestModifyColumnFamilyProcedure.java


注:本文中的org.apache.hadoop.hbase.HColumnDescriptor.setBlocksize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。