use of com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange 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.CreateColumnFamilyChange in project pinpoint by naver.
the class HbaseSchemaCommandManagerTest method shouldFilterTablesFromDifferentNamespace.
@Test
public void shouldFilterTablesFromDifferentNamespace() {
String namespace = "namespace";
String differentNamespace = "differentNamespace";
String tableName = "table1";
HTableDescriptor sameNamespaceHtd = createHtd(namespace, tableName, "CF1");
HTableDescriptor differentNamespaceHtd = createHtd(differentNamespace, tableName, "CF1");
List<HTableDescriptor> htds = Arrays.asList(sameNamespaceHtd, differentNamespaceHtd);
HbaseSchemaCommandManager manager = new HbaseSchemaCommandManager(namespace, null, htds);
ColumnFamilyChange createColumnFamilyChange = newColumnFamilyChange("CF2");
TableChange modifyTableChange = newTableChange(ChangeType.MODIFY, tableName, createColumnFamilyChange);
ChangeSet modifyTableChangeSet = newChangeSet(modifyTableChange);
manager.applyChangeSet(modifyTableChangeSet);
List<HTableDescriptor> schemaSnapshot = manager.getSchemaSnapshot();
assertThat(schemaSnapshot, contains(sameNamespaceHtd));
assertThat(schemaSnapshot, not(contains(differentNamespaceHtd)));
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange in project pinpoint by naver.
the class ColumnFamilyChangeMapper method mapCreate.
public ColumnFamilyChange mapCreate(Table.CreateColumnFamily createColumnFamily) {
String name = createColumnFamily.getName();
if (StringUtils.isEmpty(name)) {
throw new InvalidHbaseSchemaException("ColumnFamily name must not be empty");
}
ColumnFamilyConfiguration columnFamilyConfiguration = columnFamilyConfigurationMapper.mapConfiguration(createColumnFamily.getConfiguration());
return new CreateColumnFamilyChange(name, columnFamilyConfiguration);
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange in project pinpoint by naver.
the class XmlHbaseSchemaReaderTest method loadChangeSets.
@Test
public void loadChangeSets() {
final String schemaFilePath = "classpath:hbase-schema/test-hbase-schema.xml";
String expectedIncludeChangeSetId = "include-1";
List<TableChange> expectedIncludeChangeSetTableChanges = Arrays.asList(new CreateTableChange("IncludeTable1", TableConfiguration.EMPTY_CONFIGURATION, Arrays.asList(new CreateColumnFamilyChange("CF1", new ColumnFamilyConfiguration.Builder().timeToLive(5184000).build())), new CreateTableChange.SplitOption.Manual(Arrays.asList("\\x01", "\\x02", "\\x03"))));
String expectedChangeSetId1 = "id-1";
List<TableChange> expectedChangeSet1TableChanges = Arrays.asList(new CreateTableChange("Table1", new TableConfiguration.Builder().durability(TableConfiguration.Durability.ASYNC_WAL).build(), Arrays.asList(new CreateColumnFamilyChange("CF1", new ColumnFamilyConfiguration.Builder().timeToLive(86400).dataBlockEncoding(ColumnFamilyConfiguration.DataBlockEncoding.NONE).build()), new CreateColumnFamilyChange("CF2", ColumnFamilyConfiguration.EMPTY_CONFIGURATION)), new CreateTableChange.SplitOption.Auto(16)));
String expectedChangeSetId2 = "id-2";
List<TableChange> expectedChangeSet2TableChanges = Arrays.asList(new ModifyTableChange("Table1", TableConfiguration.EMPTY_CONFIGURATION, Arrays.asList(new CreateColumnFamilyChange("CF3", ColumnFamilyConfiguration.EMPTY_CONFIGURATION))));
List<ChangeSet> changeSets = reader.loadChangeSets(schemaFilePath);
assertThat(changeSets.size(), is(3));
ChangeSet includeChangeSet = changeSets.get(0);
assertThat(includeChangeSet, matches(expectedIncludeChangeSetId, expectedIncludeChangeSetTableChanges));
ChangeSet changeSet1 = changeSets.get(1);
assertThat(changeSet1, matches(expectedChangeSetId1, expectedChangeSet1TableChanges));
ChangeSet changeSet2 = changeSets.get(2);
assertThat(changeSet2, matches(expectedChangeSetId2, expectedChangeSet2TableChanges));
}
Aggregations