[강운덕] [PINPOINT-241] trace의 region 쪼개는 정책변경 32기준으로 변경하였음. real용 hbase reset도 만듬.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-server/trunk@3012 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2013-12-10 09:06:06 +00:00
parent 9ab6962af1
commit dfb773397c
@@ -3,36 +3,65 @@ package com.nhn.pinpoint.collector.regionsplit;
import java.util.ArrayList;
import java.util.List;
import com.sematext.hbase.wd.AbstractRowKeyDistributor;
import org.junit.Test;
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix.OneByteSimpleHash;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext-test.xml")
public class PreSplitRegionsTest {
int traceRegionNumber = 64;
int traceRegionNumber = 32;
int traceIndexRegionNumber = 32;
int agentStatRegionNumber = 32;
String tracesFormat = "create 'Traces', { NAME => 'S', TTL => 604800 }, { NAME => 'A', TTL => 604800 }, { NAME => 'T', TTL => 604800 }, %s";
String traceIndexFormat = "create 'ApplicationTraceIndex', { NAME => 'I', TTL => 604800 }, %s";
String agentStatFormat = "create 'AgentStat', { NAME => 'S', TTL => 604800 }, %s";
@Autowired
@Qualifier("rowKeyDistributor")
private AbstractRowKeyDistributor rowKeyDistributor;
@Test
public void traceRegions() {
List<String> regions = new ArrayList<String>();
int width = 256 / traceRegionNumber;
for (int onebyte=width; onebyte<256; onebyte+=width) {
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
for (int i = 0; i < 15; i++) {
region += "\\x00";
}
System.out.println(region);
regions.add(region);
}
printCommand(tracesFormat, regions);
List<String> regions = new ArrayList<String>();
OneByteSimpleHash hash = new OneByteSimpleHash(traceRegionNumber);
for (byte[] each : hash.getAllPossiblePrefixes()) {
byte onebyte = each[0];
if (onebyte == 0) {
continue;
}
String region = "\\x" + Integer.toString((onebyte & 0xff) + 0x100, 16).substring(1);
for (int i = 0; i < 15; i++) {
region += "\\x00";
}
regions.add(region);
}
printCommand(tracesFormat, regions);
}
@Test
public void range() {
System.out.println("------------------------");
for (int i =0 ; i< 255; i++) {
byte[] bytes = new byte[1];
bytes[0] = (byte) i;
byte[] distributedKey = rowKeyDistributor.getDistributedKey(bytes);
System.out.println("distributedKey:" + distributedKey[0]);
}
System.out.println("------------------------");
}
@Test
public void applicationTraceIndexRegions() {