Search in sources :

Example 26 with ChangeSet

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));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) HbaseSchemaStatus(com.navercorp.pinpoint.hbase.schema.core.HbaseSchemaStatus) Test(org.junit.Test)

Example 27 with ChangeSet

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);
        }
    }
}
Also used : ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet)

Example 28 with ChangeSet

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();
}
Also used : InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException) ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) LinkedHashMap(java.util.LinkedHashMap)

Example 29 with ChangeSet

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);
    }
}
Also used : StringWriter(java.io.StringWriter) HbaseSchemaParseException(com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException) JAXBException(javax.xml.bind.JAXBException) ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) TableChange(com.navercorp.pinpoint.hbase.schema.reader.core.TableChange)

Example 30 with ChangeSet

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()));
}
Also used : ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) SchemaChangeLog(com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog) Test(org.junit.Test)

Aggregations

ChangeSet (com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet)39 Test (org.junit.Test)28 SchemaChangeLog (com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog)23 ArrayList (java.util.ArrayList)8 TableChange (com.navercorp.pinpoint.hbase.schema.reader.core.TableChange)7 CreateTableChange (com.navercorp.pinpoint.hbase.schema.reader.core.CreateTableChange)6 ModifyTableChange (com.navercorp.pinpoint.hbase.schema.reader.core.ModifyTableChange)6 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)6 HbaseSchemaStatus (com.navercorp.pinpoint.hbase.schema.core.HbaseSchemaStatus)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 CreateColumnFamilyChange (com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange)4 ColumnFamilyChange (com.navercorp.pinpoint.hbase.schema.reader.core.ColumnFamilyChange)3 HbaseAdminOperation (com.navercorp.pinpoint.common.hbase.HbaseAdminOperation)2 ChangeSetManager (com.navercorp.pinpoint.hbase.schema.core.ChangeSetManager)2 HbaseSchemaCommandManager (com.navercorp.pinpoint.hbase.schema.core.command.HbaseSchemaCommandManager)2 InvalidHbaseSchemaException (com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException)2 ColumnFamilyConfiguration (com.navercorp.pinpoint.hbase.schema.reader.core.ColumnFamilyConfiguration)2 TableCommand (com.navercorp.pinpoint.hbase.schema.core.command.TableCommand)1 HbaseSchemaParseException (com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException)1 TableConfiguration (com.navercorp.pinpoint.hbase.schema.reader.core.TableConfiguration)1