use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class XmlHbaseSchemaParserTest method parseSchema.
@Test
public void parseSchema() {
final String schemaFile = "hbase-schema/test-hbase-schema.xml";
TableConfiguration expectedChangeSet1_tableConfiguration = new TableConfiguration.Builder().durability(TableConfiguration.Durability.ASYNC_WAL).build();
List<ColumnFamilyChange> expectedChangeSet1_columnFamilies = Arrays.asList(new CreateColumnFamilyChange("CF1", new ColumnFamilyConfiguration.Builder().timeToLive(86400).dataBlockEncoding(ColumnFamilyConfiguration.DataBlockEncoding.NONE).build()), new CreateColumnFamilyChange("CF2", ColumnFamilyConfiguration.EMPTY_CONFIGURATION));
CreateTableChange.SplitOption expectedChangeSet1_tableSplitOption = new CreateTableChange.SplitOption.Auto(16);
TableChange expectedChangeSet1_tableChange = new CreateTableChange("Table1", expectedChangeSet1_tableConfiguration, expectedChangeSet1_columnFamilies, expectedChangeSet1_tableSplitOption);
List<ColumnFamilyChange> expectedChangeSet2_columnFamilies = Arrays.asList(new CreateColumnFamilyChange("CF3", ColumnFamilyConfiguration.EMPTY_CONFIGURATION));
TableChange expectedChangeSet2_tableChange = new ModifyTableChange("Table1", TableConfiguration.EMPTY_CONFIGURATION, expectedChangeSet2_columnFamilies);
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(schemaFile);
XmlHbaseSchemaParseResult parseResult = parser.parseSchema(new InputSource(inputStream));
List<String> includeFiles = new ArrayList<>(parseResult.getIncludeFiles());
assertThat(includeFiles.size(), is(1));
String includeFile = includeFiles.get(0);
assertThat(includeFile, is("test-hbase-schema-include.xml"));
List<ChangeSet> changeSets = new ArrayList<>(parseResult.getChangeSets());
assertThat(changeSets.size(), is(2));
ChangeSet changeSet1 = changeSets.get(0);
assertThat(changeSet1.getId(), is("id-1"));
assertThat(changeSet1.getTableChanges(), is(Arrays.asList(expectedChangeSet1_tableChange)));
ChangeSet changeSet2 = changeSets.get(1);
assertThat(changeSet2.getId(), is("id-2"));
assertThat(changeSet2.getTableChanges(), is(Arrays.asList(expectedChangeSet2_tableChange)));
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method getExecutedChangeSets.
@Test
public void getExecutedChangeSets() {
ChangeSet changeSet1 = newChangeSet("id1", "value1");
ChangeSet changeSet2 = newChangeSet("id2", "value2");
ChangeSet changeSet3 = newChangeSet("id3", "value3");
ChangeSet changeSet4 = newChangeSet("id4", "value4");
List<ChangeSet> changeSets = Arrays.asList(changeSet1, changeSet2, changeSet3, changeSet4);
List<SchemaChangeLog> schemaChangeLogs = newSchemaChangeLogs(changeSet1, changeSet2);
ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
List<ChangeSet> executedChangeSets = changeSetManager.getExecutedChangeSets(schemaChangeLogs);
assertThat(executedChangeSets, contains(changeSet1, changeSet2));
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method getExecutedChangeSets_largerSchemaChangeLogs.
@Test
public void getExecutedChangeSets_largerSchemaChangeLogs() {
ChangeSet changeSet = newChangeSet("id1", "value1");
ChangeSetManager changeSetManager = new ChangeSetManager(Arrays.asList(changeSet));
List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id1", "value1", 1), newSchemaChangeLog("id2", "value2", 2));
List<ChangeSet> executedChangeSets = changeSetManager.getExecutedChangeSets(schemaChangeLogs);
assertThat(executedChangeSets, hasSize(1));
assertThat(executedChangeSets, contains(changeSet));
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method filterExecutedChangeSets_invalidCheckSum.
@Test(expected = IllegalArgumentException.class)
public void filterExecutedChangeSets_invalidCheckSum() {
ChangeSet changeSet = newChangeSet("id1", "value1");
List<ChangeSet> changeSets = Arrays.asList(changeSet);
CheckSum invalidCheckSum = CheckSum.compute(CheckSum.getCurrentVersion(), "value2");
List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id1", "value1", invalidCheckSum, 1));
ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
changeSetManager.filterExecutedChangeSets(schemaChangeLogs);
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method newSchemaChangeLogs.
private List<SchemaChangeLog> newSchemaChangeLogs(ChangeSet... changeSets) {
List<SchemaChangeLog> schemaChangeLogs = new ArrayList<>();
int execOrder = 1;
for (ChangeSet changeSet : changeSets) {
schemaChangeLogs.add(new SchemaChangeLog.Builder().id(changeSet.getId()).value(changeSet.getValue()).checkSum(CheckSum.compute(CheckSum.getCurrentVersion(), changeSet.getValue())).execOrder(execOrder++).build());
}
return schemaChangeLogs;
}
Aggregations