Search in sources :

Example 1 with MergeToolConfiguration

use of org.apache.rya.export.MergeToolConfiguration in project incubator-rya by apache.

the class MergeConfigurationCLITest method testCreate1ConfigurationFromFile.

@Test
public void testCreate1ConfigurationFromFile() throws MergeConfigurationException, JAXBException {
    final MergeToolConfiguration conf = MergeConfigurationCLI.createConfigurationFromFile(new File("conf/config.xml"));
    assertEquals("10.10.10.100", conf.getParentHostname());
    assertEquals("accumuloUsername", conf.getParentUsername());
    assertEquals("accumuloPassword", conf.getParentPassword());
    assertEquals("accumuloInstance", conf.getParentRyaInstanceName());
    assertEquals("rya_demo_export_", conf.getParentTablePrefix());
    assertEquals("http://10.10.10.100:8080", conf.getParentTomcatUrl());
    assertEquals(DBType.ACCUMULO, conf.getParentDBType());
    assertEquals(1111, conf.getParentPort());
    assertEquals("10.10.10.101", conf.getChildHostname());
    assertEquals("rya_demo_child", conf.getChildRyaInstanceName());
    assertEquals("rya_demo_export_", conf.getChildTablePrefix());
    assertEquals("http://10.10.10.101:8080", conf.getChildTomcatUrl());
    assertEquals(DBType.MONGO, conf.getChildDBType());
    assertEquals(27017, conf.getChildPort());
    assertEquals(MergePolicy.TIMESTAMP, conf.getMergePolicy());
    assertEquals(Boolean.FALSE, conf.isUseNtpServer());
    assertEquals(null, conf.getNtpServerHost());
}
Also used : MergeToolConfiguration(org.apache.rya.export.MergeToolConfiguration) File(java.io.File) Test(org.junit.Test)

Example 2 with MergeToolConfiguration

use of org.apache.rya.export.MergeToolConfiguration in project incubator-rya by apache.

the class MergeConfigurationCLI method createConfigurationFromFile.

public static MergeToolConfiguration createConfigurationFromFile(final File configFile) throws MergeConfigurationException {
    try {
        final JAXBContext context = JAXBContext.newInstance(DBType.class, MergeToolConfiguration.class, AccumuloMergeToolConfiguration.class, TimestampMergePolicyConfiguration.class, MergePolicy.class, InstanceType.class);
        final Unmarshaller unmarshaller = context.createUnmarshaller();
        final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        XmlFactoryConfiguration.harden(dbf);
        final DocumentBuilder db = dbf.newDocumentBuilder();
        return unmarshaller.unmarshal(db.parse(configFile), MergeToolConfiguration.class).getValue();
    } catch (final JAXBException | IllegalArgumentException | ParserConfigurationException | SAXException | IOException JAXBe) {
        throw new MergeConfigurationException("Failed to create a config based on the provided configuration.", JAXBe);
    }
}
Also used : MergeConfigurationException(org.apache.rya.export.api.conf.MergeConfigurationException) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MergeToolConfiguration(org.apache.rya.export.MergeToolConfiguration) AccumuloMergeToolConfiguration(org.apache.rya.export.AccumuloMergeToolConfiguration) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Unmarshaller(javax.xml.bind.Unmarshaller) SAXException(org.xml.sax.SAXException)

Aggregations

MergeToolConfiguration (org.apache.rya.export.MergeToolConfiguration)2 File (java.io.File)1 IOException (java.io.IOException)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 AccumuloMergeToolConfiguration (org.apache.rya.export.AccumuloMergeToolConfiguration)1 MergeConfigurationException (org.apache.rya.export.api.conf.MergeConfigurationException)1 Test (org.junit.Test)1 SAXException (org.xml.sax.SAXException)1