use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class HbaseSchemaServiceImplTest method getSchemaStatus_noSchemaChangeLogs.
@Test
public void getSchemaStatus_noSchemaChangeLogs() {
final String namespace = "namespace";
final List<ChangeSet> changeSets = Arrays.asList(newChangeSet("id1", "value1"));
when(schemaChangeLogService.isAvailable(namespace)).thenReturn(true);
when(schemaChangeLogService.getSchemaChangeLogs(namespace)).thenReturn(Collections.emptyList());
HbaseSchemaStatus schemaStatus = hbaseSchemaService.getSchemaStatus(namespace, changeSets);
MatcherAssert.assertThat(schemaStatus, is(HbaseSchemaStatus.NONE));
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class XmlParseContext method addChangeSets.
void addChangeSets(Collection<ChangeSet> changeSets) {
if (CollectionUtils.isEmpty(changeSets)) {
return;
}
for (ChangeSet changeSet : changeSets) {
String changeSetId = changeSet.getId();
ChangeSet previous = changeSetMap.put(changeSetId, changeSet);
if (previous != null) {
throw new IllegalStateException("Duplicate changeSet found. Id: " + changeSetId);
}
}
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.
the class HbaseSchemaMapper method mapChangeSets.
private Collection<ChangeSet> mapChangeSets(List<com.navercorp.pinpoint.hbase.schema.definition.xml.ChangeSet> schemaChangeSets) {
if (CollectionUtils.isEmpty(schemaChangeSets)) {
return Collections.emptySet();
}
Map<String, ChangeSet> changeSets = new LinkedHashMap<>();
for (com.navercorp.pinpoint.hbase.schema.definition.xml.ChangeSet schemaChangeSet : schemaChangeSets) {
String changeSetId = schemaChangeSet.getId();
if (changeSets.containsKey(changeSetId)) {
throw new InvalidHbaseSchemaException("Duplicate changeSet id : " + changeSetId);
}
ChangeSet changeSet = changeSetMapper.mapChangeSet(schemaChangeSet);
changeSets.put(changeSetId, changeSet);
}
return changeSets.values();
}
use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet 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.ChangeSet in project pinpoint by naver.
the class ChangeSetManagerTest method filterExecutedChangeSets_largerSchemaChangeLogs.
@Test
public void filterExecutedChangeSets_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> unexecutedChangeSets = changeSetManager.filterExecutedChangeSets(schemaChangeLogs);
assertThat(unexecutedChangeSets, is(empty()));
}
Aggregations