Search in sources :

Example 1 with Configuration

use of org.apache.asterix.installer.schema.conf.Configuration in project asterixdb by apache.

the class AsterixInstallerIntegrationUtil method initZookeeperTestConfiguration.

private static void initZookeeperTestConfiguration(int port) throws JAXBException, FileNotFoundException {
    String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
    JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
    configuration.getZookeeper().setClientPort(new BigInteger("" + port));
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
}
Also used : Marshaller(javax.xml.bind.Marshaller) Configuration(org.apache.asterix.installer.schema.conf.Configuration) FileOutputStream(java.io.FileOutputStream) BigInteger(java.math.BigInteger) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File)

Example 2 with Configuration

use of org.apache.asterix.installer.schema.conf.Configuration in project asterixdb by apache.

the class ConfigureConfig method execCommand.

@Override
protected void execCommand() throws Exception {
    configureCluster("local", "local.xml");
    configureCluster("local", "local_chained_declustering_rep.xml");
    configureCluster("local", "local_metadata_only_rep.xml");
    configureCluster("demo", "demo.xml");
    String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
    JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
    configuration.setConfigured(true);
    configuration.getBackup().setBackupDir(InstallerDriver.getManagixHome() + File.separator + "backup");
    configuration.getZookeeper().setHomeDir(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "zookeeper_home");
    configuration.getZookeeper().getServers().setJavaHome(System.getProperty("java.home"));
    Marshaller marshaller = ctx.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
}
Also used : Marshaller(javax.xml.bind.Marshaller) Configuration(org.apache.asterix.installer.schema.conf.Configuration) FileOutputStream(java.io.FileOutputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File)

Example 3 with Configuration

use of org.apache.asterix.installer.schema.conf.Configuration in project asterixdb by apache.

the class ValidateConfig method validateConfiguration.

public boolean validateConfiguration() throws Exception {
    String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
    File configFile = new File(managixHome + File.separator + InstallerDriver.MANAGIX_CONF_XML);
    JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
    Unmarshaller unmarshaller = configCtx.createUnmarshaller();
    Configuration conf = (Configuration) unmarshaller.unmarshal(configFile);
    return validateZookeeperConfiguration(conf);
}
Also used : Configuration(org.apache.asterix.installer.schema.conf.Configuration) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File)

Example 4 with Configuration

use of org.apache.asterix.installer.schema.conf.Configuration in project asterixdb by apache.

the class InstallerDriver method initConfig.

public static void initConfig(boolean ensureLookupServiceIsRunning) throws Exception {
    File configFile = new File(managixHome + File.separator + MANAGIX_CONF_XML);
    JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
    Unmarshaller unmarshaller = configCtx.createUnmarshaller();
    Configuration conf = (Configuration) unmarshaller.unmarshal(configFile);
    String asterixDir = managixHome + File.separator + ASTERIX_DIR;
    String eventHome = managixHome + File.separator + MANAGIX_INTERNAL_DIR;
    AsterixEventService.initialize(conf, asterixDir, eventHome);
    ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
    if (ensureLookupServiceIsRunning) {
        if (!conf.isConfigured()) {
            try {
                configure();
                /* read back the configuration file updated as part of configure command*/
                conf = (Configuration) unmarshaller.unmarshal(configFile);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (!lookupService.isRunning(conf)) {
            lookupService.startService(conf);
        }
    }
}
Also used : Configuration(org.apache.asterix.installer.schema.conf.Configuration) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File) ILookupService(org.apache.asterix.event.service.ILookupService)

Aggregations

File (java.io.File)4 JAXBContext (javax.xml.bind.JAXBContext)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 Configuration (org.apache.asterix.installer.schema.conf.Configuration)4 FileOutputStream (java.io.FileOutputStream)2 Marshaller (javax.xml.bind.Marshaller)2 BigInteger (java.math.BigInteger)1 ILookupService (org.apache.asterix.event.service.ILookupService)1