Search in sources :

Example 1 with HbaseSchemaParseException

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

the class XmlHbaseSchemaReader method loadChangeSets.

/**
 * Loads change sets from the hbase schema xml file at the given path.
 *
 * @param path path to hbase schema xml file
 * @return list of change sets loaded
 * @throws HbaseSchemaParseException if there was a problem reading or parsing from the schema xml file
 */
@Override
public List<ChangeSet> loadChangeSets(String path) {
    Resource resource = resourceLoader.getResource(path);
    XmlParseContext xmlParseContext = new XmlParseContext(resource);
    try {
        loadChangeSets(xmlParseContext);
    } catch (HbaseSchemaParseException e) {
        logger.error("Error loading change sets from {}", xmlParseContext.getResource(), e);
        throw e;
    } catch (Exception e) {
        logger.error("Error loading change sets from {}", xmlParseContext.getResource(), e);
        throw new HbaseSchemaParseException("Error loading change sets from " + xmlParseContext.getResource(), e);
    }
    return xmlParseContext.getChangeSets();
}
Also used : HbaseSchemaParseException(com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException) Resource(org.springframework.core.io.Resource) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) HbaseSchemaParseException(com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException)

Example 2 with HbaseSchemaParseException

use of com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException 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 3 with HbaseSchemaParseException

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

the class XmlHbaseSchemaParser method parseSchema.

XmlHbaseSchemaParseResult parseSchema(InputSource inputSource) {
    try {
        Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
        unmarshaller.setSchema(SCHEMA);
        HbaseSchema hbaseSchema = (HbaseSchema) unmarshaller.unmarshal(inputSource);
        return mapper.map(hbaseSchema);
    } catch (JAXBException e) {
        Throwable linkedException = e.getLinkedException();
        if (linkedException == null) {
            throw new IllegalStateException("JAXB error", e);
        }
        throw new HbaseSchemaParseException(linkedException.getMessage(), linkedException);
    }
}
Also used : HbaseSchemaParseException(com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException) JAXBException(javax.xml.bind.JAXBException) HbaseSchema(com.navercorp.pinpoint.hbase.schema.definition.xml.HbaseSchema) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 4 with HbaseSchemaParseException

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

Aggregations

HbaseSchemaParseException (com.navercorp.pinpoint.hbase.schema.reader.HbaseSchemaParseException)4 JAXBException (javax.xml.bind.JAXBException)2 HbaseSystemException (com.navercorp.pinpoint.common.hbase.HbaseSystemException)1 HbaseSchemaManagerTask (com.navercorp.pinpoint.hbase.manager.task.HbaseSchemaManagerTask)1 HbaseSchema (com.navercorp.pinpoint.hbase.schema.definition.xml.HbaseSchema)1 InvalidHbaseSchemaException (com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException)1 ChangeSet (com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet)1 TableChange (com.navercorp.pinpoint.hbase.schema.reader.core.TableChange)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 URISyntaxException (java.net.URISyntaxException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Resource (org.springframework.core.io.Resource)1