Search in sources :

Example 11 with ChangeSet

use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.

the class ChangeSetManagerTest method getExecutedChangeSets_invalidCheckSum.

@Test(expected = IllegalArgumentException.class)
public void getExecutedChangeSets_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.getExecutedChangeSets(schemaChangeLogs);
}
Also used : ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) SchemaChangeLog(com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog) Test(org.junit.Test)

Example 12 with ChangeSet

use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.

the class ChangeSetManagerTest method filterExecutedChangeSets_invalidId.

@Test(expected = IllegalArgumentException.class)
public void filterExecutedChangeSets_invalidId() {
    ChangeSet changeSet = newChangeSet("id1", "value1");
    List<ChangeSet> changeSets = Arrays.asList(changeSet);
    List<SchemaChangeLog> schemaChangeLogs = Arrays.asList(newSchemaChangeLog("id2", "value1", 1));
    ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
    changeSetManager.filterExecutedChangeSets(schemaChangeLogs);
}
Also used : ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) SchemaChangeLog(com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog) Test(org.junit.Test)

Example 13 with ChangeSet

use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.

the class ChangeSetManagerTest method filterExecutedChangeSets_emptySchemaChangeLogs.

@Test
public void filterExecutedChangeSets_emptySchemaChangeLogs() {
    ChangeSet changeSet1 = newChangeSet("id1", "value1");
    ChangeSet changeSet2 = newChangeSet("id2", "value2");
    List<ChangeSet> changeSets = Arrays.asList(changeSet1, changeSet2);
    ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
    assertThat(changeSetManager.filterExecutedChangeSets(Collections.emptyList()), contains(changeSet1, changeSet2));
    assertThat(changeSetManager.filterExecutedChangeSets(null), contains(changeSet1, changeSet2));
}
Also used : ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) Test(org.junit.Test)

Example 14 with ChangeSet

use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.

the class HbaseSchemaCommandManagerTest method creatingExistingTableShouldFail.

@Test(expected = InvalidHbaseSchemaException.class)
public void creatingExistingTableShouldFail() {
    String namespace = "namespace";
    String tableName = "table";
    HTableDescriptor existingTable = createHtd(namespace, tableName, "CF");
    HbaseSchemaCommandManager manager = new HbaseSchemaCommandManager(namespace, null, Arrays.asList(existingTable));
    TableChange createTableChange = newTableChange(ChangeType.CREATE, tableName);
    ChangeSet createTableChangeSet = newChangeSet(createTableChange);
    manager.applyChangeSet(createTableChangeSet);
}
Also used : ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) CreateTableChange(com.navercorp.pinpoint.hbase.schema.reader.core.CreateTableChange) TableChange(com.navercorp.pinpoint.hbase.schema.reader.core.TableChange) ModifyTableChange(com.navercorp.pinpoint.hbase.schema.reader.core.ModifyTableChange) Test(org.junit.Test)

Example 15 with ChangeSet

use of com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet in project pinpoint by naver.

the class HbaseSchemaCommandManagerTest method failedChangesShouldNotAffectTheSchema.

@Test
public void failedChangesShouldNotAffectTheSchema() {
    String namespace = "namespace";
    String tableName = "table";
    String columnFamilyName = "CF";
    HbaseSchemaCommandManager manager = new HbaseSchemaCommandManager(namespace, null);
    // initial create table
    ColumnFamilyChange columnFamilyChange = newColumnFamilyChange(columnFamilyName);
    TableChange createTableChange = newTableChange(ChangeType.CREATE, tableName, columnFamilyChange);
    ChangeSet createTableChangeSet = newChangeSet(createTableChange);
    manager.applyChangeSet(createTableChangeSet);
    List<HTableDescriptor> initialSnapshot = manager.getSchemaSnapshot();
    // modify non-existing table
    TableChange modifyNonExistingTableChange = newTableChange(ChangeType.MODIFY, "nonExistingTable", newColumnFamilyChange("newCF"));
    ChangeSet modifyNonExistingTableChangeSet = newChangeSet(modifyNonExistingTableChange);
    try {
        manager.applyChangeSet(modifyNonExistingTableChangeSet);
        fail("Expected an InvalidHbaseSchemaException to be thrown");
    } catch (InvalidHbaseSchemaException expected) {
        List<HTableDescriptor> currentSnapshot = manager.getSchemaSnapshot();
        assertThat(currentSnapshot, equalTo(initialSnapshot));
    }
    // create existing table
    TableChange createExistingTableChange = newTableChange(ChangeType.CREATE, tableName);
    ChangeSet createExistingTableChangeSet = newChangeSet(createExistingTableChange);
    try {
        manager.applyChangeSet(createExistingTableChangeSet);
        fail("Expected an InvalidHbaseSchemaException to be thrown");
    } catch (InvalidHbaseSchemaException expected) {
        List<HTableDescriptor> currentSnapshot = manager.getSchemaSnapshot();
        assertThat(currentSnapshot, equalTo(initialSnapshot));
    }
    // create existing column family
    ColumnFamilyChange createExistingColumnFamilyChange = newColumnFamilyChange(columnFamilyName);
    TableChange createExistingColumnFamilyTableChange = newTableChange(ChangeType.MODIFY, tableName, createExistingColumnFamilyChange);
    ChangeSet createExistingColumnFamilyChangeSet = newChangeSet(createExistingColumnFamilyTableChange);
    try {
        manager.applyChangeSet(createExistingColumnFamilyChangeSet);
        fail("Expected an InvalidHbaseSchemaException to be thrown");
    } catch (InvalidHbaseSchemaException expected) {
        List<HTableDescriptor> currentSnapshot = manager.getSchemaSnapshot();
        assertThat(currentSnapshot, equalTo(initialSnapshot));
    }
}
Also used : InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException) CreateColumnFamilyChange(com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange) ColumnFamilyChange(com.navercorp.pinpoint.hbase.schema.reader.core.ColumnFamilyChange) List(java.util.List) ChangeSet(com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet) CreateTableChange(com.navercorp.pinpoint.hbase.schema.reader.core.CreateTableChange) TableChange(com.navercorp.pinpoint.hbase.schema.reader.core.TableChange) ModifyTableChange(com.navercorp.pinpoint.hbase.schema.reader.core.ModifyTableChange) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) 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