Search in sources :

Example 1 with InvalidHbaseSchemaException

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

the class HbaseSchemaCommandManager method applyChangeSet.

public void applyChangeSet(ChangeSet changeSet) {
    Objects.requireNonNull(changeSet, "changeSet");
    List<TableChange> tableChanges = changeSet.getTableChanges();
    try {
        for (TableChange tableChange : tableChanges) {
            applyTableChange(tableChange);
        }
    } catch (Exception e) {
        throw new InvalidHbaseSchemaException("Error applying changeSet : " + changeSet.getId(), e);
    }
}
Also used : InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException) InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException) TableChange(com.navercorp.pinpoint.hbase.schema.reader.core.TableChange)

Example 2 with InvalidHbaseSchemaException

use of com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException 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)

Example 3 with InvalidHbaseSchemaException

use of com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException 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);
}
Also used : CreateColumnFamilyChange(com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange) InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException) ColumnFamilyConfiguration(com.navercorp.pinpoint.hbase.schema.reader.core.ColumnFamilyConfiguration)

Example 4 with InvalidHbaseSchemaException

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

the class HbaseSchemaManagerRunner method run.

@Override
public void run(ApplicationArguments args) throws Exception {
    logger.info("Launched with arguments : {}", Arrays.asList(args.getSourceArgs()));
    ProgramCommand programCommand = ProgramCommand.parseArgs(args);
    ProgramOptions programOptions = ProgramOptions.parseArgs(args);
    HbaseSchemaManagerTask task = taskFactory.create(programCommand, programOptions);
    try {
        task.run(programCommand.getCommandArgs());
    } catch (HbaseSchemaParseException | InvalidHbaseSchemaException e) {
        logger.error(Markers.TERMINAL, "{}, cause : {}", e.getMessage(), e.getCause().getMessage());
        logger.error(Markers.APP_LOG, "Hbase schema error.", e);
    } catch (HbaseSystemException e) {
        logger.error(Markers.TERMINAL, "Error accessing hbase : {}", e.getMessage());
        logger.error(Markers.APP_LOG, "Hbase error.", e);
    } catch (Exception e) {
        logger.error(Markers.TERMINAL, "Error running '{}' : {}", programCommand.getCommand(), e.getMessage());
        logger.error(Markers.APP_LOG, "Error running '" + programCommand.getCommand() + "'.", e);
    }
}
Also used : InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException) HbaseSystemException(com.navercorp.pinpoint.common.hbase.HbaseSystemException) HbaseSchemaManagerTask(com.navercorp.pinpoint.hbase.manager.task.HbaseSchemaManagerTask) HbaseSchemaParseException(com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException) HbaseSchemaParseException(com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException) HbaseSystemException(com.navercorp.pinpoint.common.hbase.HbaseSystemException) InvalidHbaseSchemaException(com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException)

Example 5 with InvalidHbaseSchemaException

use of com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException 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)

Aggregations

InvalidHbaseSchemaException (com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException)7 ColumnFamilyChange (com.navercorp.pinpoint.hbase.schema.reader.core.ColumnFamilyChange)3 ChangeSet (com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet)2 CreateColumnFamilyChange (com.navercorp.pinpoint.hbase.schema.reader.core.CreateColumnFamilyChange)2 CreateTableChange (com.navercorp.pinpoint.hbase.schema.reader.core.CreateTableChange)2 TableChange (com.navercorp.pinpoint.hbase.schema.reader.core.TableChange)2 LinkedHashMap (java.util.LinkedHashMap)2 HbaseSystemException (com.navercorp.pinpoint.common.hbase.HbaseSystemException)1 HbaseSchemaManagerTask (com.navercorp.pinpoint.hbase.manager.task.HbaseSchemaManagerTask)1 Table (com.navercorp.pinpoint.hbase.schema.definition.xml.Table)1 HbaseSchemaParseException (com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException)1 ColumnFamilyConfiguration (com.navercorp.pinpoint.hbase.schema.reader.core.ColumnFamilyConfiguration)1 ModifyTableChange (com.navercorp.pinpoint.hbase.schema.reader.core.ModifyTableChange)1 TableConfiguration (com.navercorp.pinpoint.hbase.schema.reader.core.TableConfiguration)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 Test (org.junit.Test)1