use of com.navercorp.pinpoint.hbase.schema.reader.core.TableChange in project pinpoint by naver.
the class ChangeSetMapper method mapChangeSet.
public ChangeSet mapChangeSet(com.navercorp.pinpoint.hbase.schema.definition.xml.ChangeSet changeSet) {
try {
// no need to close StringWriter
StringWriter stringWriter = new StringWriter();
createMarshaller().marshal(changeSet, stringWriter);
String value = stringWriter.toString();
List<TableChange> tableChangeList = mapTableChanges(changeSet.getModifyTable(), changeSet.getCreateTable());
return new ChangeSet(changeSet.getId(), value, tableChangeList);
} catch (JAXBException e) {
Throwable linkedException = e.getLinkedException();
if (linkedException == null) {
throw new IllegalStateException("JAXB error", e);
}
throw new HbaseSchemaParseException("Error computing md5 for change set id : " + changeSet.getId(), linkedException);
}
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.TableChange in project pinpoint by naver.
the class HbaseSchemaCommandManagerTest method modifyingNonExistingTableShouldFail.
@Test(expected = InvalidHbaseSchemaException.class)
public void modifyingNonExistingTableShouldFail() {
String namespace = "namespace";
String tableName = "table";
String nonExistingTableName = "anotherTable";
HTableDescriptor existingTable = createHtd(namespace, tableName, "CF");
HbaseSchemaCommandManager manager = new HbaseSchemaCommandManager(namespace, null, Arrays.asList(existingTable));
TableChange modifyTableChange = newTableChange(ChangeType.MODIFY, nonExistingTableName);
ChangeSet modifyTableChangeSet = newChangeSet(modifyTableChange);
manager.applyChangeSet(modifyTableChangeSet);
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.TableChange 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