org.apache.hadoop.hbase.regionserver.HStore.getSize()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(17.7k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.apache.hadoop.hbase.regionserver.HStore.getSize()方法的一些代码示例,展示了HStore.getSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HStore.getSize()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.regionserver.HStore
类名称:HStore
方法名:getSize

HStore.getSize介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

/**
 * @return the key at which the region should be split, or null
 * if it cannot be split. This will only be called if shouldSplit
 * previously returned true.
 */
protected byte[] getSplitPoint() {
 byte[] explicitSplitPoint = this.region.getExplicitSplitPoint();
 if (explicitSplitPoint != null) {
  return explicitSplitPoint;
 }
 List<HStore> stores = region.getStores();
 byte[] splitPointFromLargestStore = null;
 long largestStoreSize = 0;
 for (HStore s : stores) {
  Optional<byte[]> splitPoint = s.getSplitPoint();
  // Store also returns null if it has references as way of indicating it is not splittable
  long storeSize = s.getSize();
  if (splitPoint.isPresent() && largestStoreSize < storeSize) {
   splitPointFromLargestStore = splitPoint.get();
   largestStoreSize = storeSize;
  }
 }
 return splitPointFromLargestStore;
}

代码示例来源:origin: apache/hbase

@Override
protected boolean shouldSplit() {
 boolean force = region.shouldForceSplit();
 boolean foundABigStore = false;
 for (HStore store : region.getStores()) {
  // If any of the stores are unable to split (eg they contain reference files)
  // then don't split
  if ((!store.canSplit())) {
   return false;
  }
  // Mark if any store is big enough
  if (store.getSize() > desiredMaxFileSize) {
   foundABigStore = true;
  }
 }
 return foundABigStore || force;
}

代码示例来源:origin: apache/hbase

@Test
public void testGetSplitPoint() throws IOException {
 ConstantSizeRegionSplitPolicy policy =
  (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
 // For no stores, should not split
 assertFalse(policy.shouldSplit());
 assertNull(policy.getSplitPoint());
 // Add a store above the requisite size. Should split.
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("store 1 split"))).when(mockStore).getSplitPoint();
 stores.add(mockStore);
 assertEquals("store 1 split",
   Bytes.toString(policy.getSplitPoint()));
 // Add a bigger store. The split point should come from that one
 HStore mockStore2 = Mockito.mock(HStore.class);
 Mockito.doReturn(4000L).when(mockStore2).getSize();
 Mockito.doReturn(true).when(mockStore2).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("store 2 split"))).when(mockStore2).getSplitPoint();
 stores.add(mockStore2);
 assertEquals("store 2 split",
   Bytes.toString(policy.getSplitPoint()));
}

代码示例来源:origin: apache/hbase

@Test
public void testConstantSizePolicyWithJitter() throws IOException {
 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
  ConstantSizeRegionSplitPolicy.class.getName());
 htd.setMaxFileSize(Long.MAX_VALUE);
 boolean positiveJitter = false;
 ConstantSizeRegionSplitPolicy policy = null;
 while (!positiveJitter) {
  policy = (ConstantSizeRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
  positiveJitter = policy.positiveJitterRate();
 }
 // add a store
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 stores.add(mockStore);
 // Jitter shouldn't cause overflow when HTableDescriptor.MAX_FILESIZE set to Long.MAX_VALUE
 assertFalse(policy.shouldSplit());
}

代码示例来源:origin: apache/hbase

/**
 * Test setting up a customized split policy
 */
@Test
public void testCustomPolicy() throws IOException {
 HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
   KeyPrefixRegionSplitPolicy.class.getName());
 myHtd.setValue(KeyPrefixRegionSplitPolicy.PREFIX_LENGTH_KEY, String.valueOf(2));
 HRegion myMockRegion = Mockito.mock(HRegion.class);
 Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
 Mockito.doReturn(stores).when(myMockRegion).getStores();
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("abcd"))).when(mockStore).getSplitPoint();
 stores.add(mockStore);
 KeyPrefixRegionSplitPolicy policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
 Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
 Mockito.doReturn(Bytes.toBytes("efgh")).when(myMockRegion)
   .getExplicitSplitPoint();
 policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("ef", Bytes.toString(policy.getSplitPoint()));
}

代码示例来源:origin: apache/hbase

@Test
public void testDelimitedKeyPrefixRegionSplitPolicy() throws IOException {
 HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
   DelimitedKeyPrefixRegionSplitPolicy.class.getName());
 myHtd.setValue(DelimitedKeyPrefixRegionSplitPolicy.DELIMITER_KEY, ",");
 HRegion myMockRegion = Mockito.mock(HRegion.class);
 Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
 Mockito.doReturn(stores).when(myMockRegion).getStores();
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("ab,cd"))).when(mockStore).getSplitPoint();
 stores.add(mockStore);
 DelimitedKeyPrefixRegionSplitPolicy policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
 Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
 Mockito.doReturn(Bytes.toBytes("efg,h")).when(myMockRegion)
   .getExplicitSplitPoint();
 policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("efg", Bytes.toString(policy.getSplitPoint()));
 Mockito.doReturn(Bytes.toBytes("ijk")).when(myMockRegion)
 .getExplicitSplitPoint();
 assertEquals("ijk", Bytes.toString(policy.getSplitPoint()));
}

代码示例来源:origin: apache/hbase

@Override
protected boolean shouldSplit() {
 boolean force = region.shouldForceSplit();
 boolean foundABigStore = false;
 // Get count of regions that have the same common table as this.region
 int tableRegionsCount = getCountOfCommonTableRegions();
 // Get size to check
 long sizeToCheck = getSizeToCheck(tableRegionsCount);
 for (HStore store : region.getStores()) {
  // If any of the stores is unable to split (eg they contain reference files)
  // then don't split
  if (!store.canSplit()) {
   return false;
  }
  // Mark if any store is big enough
  long size = store.getSize();
  if (size > sizeToCheck) {
   LOG.debug("ShouldSplit because " + store.getColumnFamilyName() +
    " size=" + StringUtils.humanSize(size) +
    ", sizeToCheck=" + StringUtils.humanSize(sizeToCheck) +
    ", regionsWithCommonTable=" + tableRegionsCount);
   foundABigStore = true;
  }
 }
 return foundABigStore || force;
}

代码示例来源:origin: apache/hbase

/**
 * Run through tests for a ConstantSizeRegionSplitPolicy
 * @param policy
 */
private void doConstantSizePolicyTests(final ConstantSizeRegionSplitPolicy policy) {
 // For no stores, should not split
 assertFalse(policy.shouldSplit());
 // Add a store above the requisite size. Should split.
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 stores.add(mockStore);
 assertTrue(policy.shouldSplit());
 // Act as if there's a reference file or some other reason it can't split.
 // This should prevent splitting even though it's big enough.
 Mockito.doReturn(false).when(mockStore).canSplit();
 assertFalse(policy.shouldSplit());
 // Reset splittability after above
 Mockito.doReturn(true).when(mockStore).canSplit();
 // Set to a small size but turn on forceSplit. Should result in a split.
 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
 Mockito.doReturn(100L).when(mockStore).getSize();
 assertTrue(policy.shouldSplit());
 // Turn off forceSplit, should not split
 Mockito.doReturn(false).when(mockRegion).shouldForceSplit();
 assertFalse(policy.shouldSplit());
 // Clear families we added above
 stores.clear();
}

代码示例来源:origin: apache/hbase

@Test
public void testForceSplitRegionWithReference() throws IOException {
 htd.setMaxFileSize(1024L);
 // Add a store above the requisite size. Should split.
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 // Act as if there's a reference file or some other reason it can't split.
 // This should prevent splitting even though it's big enough.
 Mockito.doReturn(false).when(mockStore).canSplit();
 stores.add(mockStore);
 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
  ConstantSizeRegionSplitPolicy.class.getName());
 ConstantSizeRegionSplitPolicy policy =
   (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
 assertFalse(policy.shouldSplit());
 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
 assertFalse(policy.shouldSplit());
 Mockito.doReturn(false).when(mockRegion).shouldForceSplit();
 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
  IncreasingToUpperBoundRegionSplitPolicy.class.getName());
 policy = (IncreasingToUpperBoundRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
 assertFalse(policy.shouldSplit());
 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
 assertFalse(policy.shouldSplit());
}

代码示例来源:origin: apache/hbase

Mockito.doReturn(2000L).when(mockStore).getSize();
Mockito.doReturn(true).when(mockStore).canSplit();
stores.add(mockStore);
Mockito.doReturn(flushSize).when(mockStore).getSize();
Mockito.doReturn(flushSize*2 + 1).when(mockStore).getSize();
assertTrue(policy.shouldSplit());
assertFalse(policy.shouldSplit());
Mockito.doReturn((long)(maxSplitSize * 1.25 + 1)).when(mockStore).getSize();
assertTrue(policy.shouldSplit());

代码示例来源:origin: apache/hbase

long expectedStoreFilesSize = store.getStorefilesSize();
Assert.assertNotNull(store);
Assert.assertEquals(expectedStoreFilesSize, store.getSize());
 Assert.assertEquals(expectedStoreFilesSize, store.getSize());

代码示例来源:origin: apache/hbase

long regionMemstoreSize = secondaryRegion.getMemStoreDataSize();
MemStoreSize mss = store.getFlushableSize();
long storeSize = store.getSize();
long storeSizeUncompressed = store.getStoreSizeUncompressed();
if (flushDesc.getAction() == FlushAction.START_FLUSH) {
 assertTrue(store.getSize() > storeSize);
 assertTrue(store.getStoreSizeUncompressed() > storeSizeUncompressed);
 assertEquals(store.getSize(), store.getStorefilesSize());

代码示例来源:origin: apache/phoenix

.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
long storeSize = s.getSize();
if (splitPoint.isPresent() && largestStoreSize < storeSize) {
  splitPointFromLargestStore = splitPoint.get();

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

.startsWith(QueryConstants.LOCAL_INDEX_COLUMN_FAMILY_PREFIX)) {
Optional<byte[]> splitPoint = s.getSplitPoint();
long storeSize = s.getSize();
if (splitPoint.isPresent() && largestStoreSize < storeSize) {
  splitPointFromLargestStore = splitPoint.get();

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testGetSplitPoint() throws IOException {
 ConstantSizeRegionSplitPolicy policy =
  (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
 // For no stores, should not split
 assertFalse(policy.shouldSplit());
 assertNull(policy.getSplitPoint());
 // Add a store above the requisite size. Should split.
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("store 1 split"))).when(mockStore).getSplitPoint();
 stores.add(mockStore);
 assertEquals("store 1 split",
   Bytes.toString(policy.getSplitPoint()));
 // Add a bigger store. The split point should come from that one
 HStore mockStore2 = Mockito.mock(HStore.class);
 Mockito.doReturn(4000L).when(mockStore2).getSize();
 Mockito.doReturn(true).when(mockStore2).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("store 2 split"))).when(mockStore2).getSplitPoint();
 stores.add(mockStore2);
 assertEquals("store 2 split",
   Bytes.toString(policy.getSplitPoint()));
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testConstantSizePolicyWithJitter() throws IOException {
 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
  ConstantSizeRegionSplitPolicy.class.getName());
 htd.setMaxFileSize(Long.MAX_VALUE);
 boolean positiveJitter = false;
 ConstantSizeRegionSplitPolicy policy = null;
 while (!positiveJitter) {
  policy = (ConstantSizeRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
  positiveJitter = policy.positiveJitterRate();
 }
 // add a store
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 stores.add(mockStore);
 // Jitter shouldn't cause overflow when HTableDescriptor.MAX_FILESIZE set to Long.MAX_VALUE
 assertFalse(policy.shouldSplit());
}

代码示例来源:origin: org.apache.hbase/hbase-server

/**
 * Test setting up a customized split policy
 */
@Test
public void testCustomPolicy() throws IOException {
 HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
   KeyPrefixRegionSplitPolicy.class.getName());
 myHtd.setValue(KeyPrefixRegionSplitPolicy.PREFIX_LENGTH_KEY, String.valueOf(2));
 HRegion myMockRegion = Mockito.mock(HRegion.class);
 Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
 Mockito.doReturn(stores).when(myMockRegion).getStores();
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("abcd"))).when(mockStore).getSplitPoint();
 stores.add(mockStore);
 KeyPrefixRegionSplitPolicy policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
 Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
 Mockito.doReturn(Bytes.toBytes("efgh")).when(myMockRegion)
   .getExplicitSplitPoint();
 policy = (KeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("ef", Bytes.toString(policy.getSplitPoint()));
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testDelimitedKeyPrefixRegionSplitPolicy() throws IOException {
 HTableDescriptor myHtd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
 myHtd.setValue(HTableDescriptor.SPLIT_POLICY,
   DelimitedKeyPrefixRegionSplitPolicy.class.getName());
 myHtd.setValue(DelimitedKeyPrefixRegionSplitPolicy.DELIMITER_KEY, ",");
 HRegion myMockRegion = Mockito.mock(HRegion.class);
 Mockito.doReturn(myHtd).when(myMockRegion).getTableDescriptor();
 Mockito.doReturn(stores).when(myMockRegion).getStores();
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 Mockito.doReturn(Optional.of(Bytes.toBytes("ab,cd"))).when(mockStore).getSplitPoint();
 stores.add(mockStore);
 DelimitedKeyPrefixRegionSplitPolicy policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("ab", Bytes.toString(policy.getSplitPoint()));
 Mockito.doReturn(true).when(myMockRegion).shouldForceSplit();
 Mockito.doReturn(Bytes.toBytes("efg,h")).when(myMockRegion)
   .getExplicitSplitPoint();
 policy = (DelimitedKeyPrefixRegionSplitPolicy) RegionSplitPolicy
   .create(myMockRegion, conf);
 assertEquals("efg", Bytes.toString(policy.getSplitPoint()));
 Mockito.doReturn(Bytes.toBytes("ijk")).when(myMockRegion)
 .getExplicitSplitPoint();
 assertEquals("ijk", Bytes.toString(policy.getSplitPoint()));
}

代码示例来源:origin: org.apache.hbase/hbase-server

/**
 * Run through tests for a ConstantSizeRegionSplitPolicy
 * @param policy
 */
private void doConstantSizePolicyTests(final ConstantSizeRegionSplitPolicy policy) {
 // For no stores, should not split
 assertFalse(policy.shouldSplit());
 // Add a store above the requisite size. Should split.
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 Mockito.doReturn(true).when(mockStore).canSplit();
 stores.add(mockStore);
 assertTrue(policy.shouldSplit());
 // Act as if there's a reference file or some other reason it can't split.
 // This should prevent splitting even though it's big enough.
 Mockito.doReturn(false).when(mockStore).canSplit();
 assertFalse(policy.shouldSplit());
 // Reset splittability after above
 Mockito.doReturn(true).when(mockStore).canSplit();
 // Set to a small size but turn on forceSplit. Should result in a split.
 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
 Mockito.doReturn(100L).when(mockStore).getSize();
 assertTrue(policy.shouldSplit());
 // Turn off forceSplit, should not split
 Mockito.doReturn(false).when(mockRegion).shouldForceSplit();
 assertFalse(policy.shouldSplit());
 // Clear families we added above
 stores.clear();
}

代码示例来源:origin: org.apache.hbase/hbase-server

@Test
public void testForceSplitRegionWithReference() throws IOException {
 htd.setMaxFileSize(1024L);
 // Add a store above the requisite size. Should split.
 HStore mockStore = Mockito.mock(HStore.class);
 Mockito.doReturn(2000L).when(mockStore).getSize();
 // Act as if there's a reference file or some other reason it can't split.
 // This should prevent splitting even though it's big enough.
 Mockito.doReturn(false).when(mockStore).canSplit();
 stores.add(mockStore);
 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
  ConstantSizeRegionSplitPolicy.class.getName());
 ConstantSizeRegionSplitPolicy policy =
   (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
 assertFalse(policy.shouldSplit());
 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
 assertFalse(policy.shouldSplit());
 Mockito.doReturn(false).when(mockRegion).shouldForceSplit();
 conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
  IncreasingToUpperBoundRegionSplitPolicy.class.getName());
 policy = (IncreasingToUpperBoundRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
 assertFalse(policy.shouldSplit());
 Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
 assertFalse(policy.shouldSplit());
}

相关文章

HStore类方法