Package org.voltdb.compiler.deploymentfile

Examples of org.voltdb.compiler.deploymentfile.DeploymentType


        org.voltdb.compiler.deploymentfile.ObjectFactory factory =
            new org.voltdb.compiler.deploymentfile.ObjectFactory();

        // <deployment>
        DeploymentType deployment = factory.createDeploymentType();
        JAXBElement<DeploymentType> doc = factory.createDeployment(deployment);

        // <cluster>
        ClusterType cluster = factory.createClusterType();
        deployment.setCluster(cluster);
        cluster.setHostcount(m_hostCount);
        cluster.setSitesperhost(m_sitesPerHost);
        cluster.setKfactor(m_replication);
        cluster.setSchema(m_useDDLSchema ? SchemaType.DDL : SchemaType.CATALOG);

        // <paths>
        PathsType paths = factory.createPathsType();
        deployment.setPaths(paths);
        Voltdbroot voltdbroot = factory.createPathsTypeVoltdbroot();
        paths.setVoltdbroot(voltdbroot);
        voltdbroot.setPath(m_voltRootPath);

        if (m_snapshotPath != null) {
            PathEntry snapshotPathElement = factory.createPathEntry();
            snapshotPathElement.setPath(m_snapshotPath);
            paths.setSnapshots(snapshotPathElement);
        }

        if (m_commandLogPath != null) {
            PathEntry commandLogPathElement = factory.createPathEntry();
            commandLogPathElement.setPath(m_commandLogPath);
            paths.setCommandlog(commandLogPathElement);
        }

        if (m_internalSnapshotPath != null) {
            PathEntry commandLogSnapshotPathElement = factory.createPathEntry();
            commandLogSnapshotPathElement.setPath(m_internalSnapshotPath);
            paths.setCommandlogsnapshot(commandLogSnapshotPathElement);
        }

        if (m_snapshotPrefix != null) {
            SnapshotType snapshot = factory.createSnapshotType();
            deployment.setSnapshot(snapshot);
            snapshot.setFrequency(m_snapshotFrequency);
            snapshot.setPrefix(m_snapshotPrefix);
            snapshot.setRetain(m_snapshotRetain);
        }

        SecurityType security = factory.createSecurityType();
        deployment.setSecurity(security);
        security.setEnabled(m_securityEnabled);
        SecurityProviderString provider = SecurityProviderString.HASH;
        if (m_securityEnabled) try {
            provider = SecurityProviderString.fromValue(m_securityProvider);
        } catch (IllegalArgumentException shouldNotHappenSeeSetter) {
        }
        security.setProvider(provider);

        if (m_commandLogSync != null || m_commandLogEnabled != null ||
                m_commandLogFsyncInterval != null || m_commandLogMaxTxnsBeforeFsync != null ||
                m_commandLogSize != null) {
            CommandLogType commandLogType = factory.createCommandLogType();
            if (m_commandLogSync != null) {
                commandLogType.setSynchronous(m_commandLogSync.booleanValue());
            }
            if (m_commandLogEnabled != null) {
                commandLogType.setEnabled(m_commandLogEnabled);
            }
            if (m_commandLogSize != null) {
                commandLogType.setLogsize(m_commandLogSize);
            }
            if (m_commandLogFsyncInterval != null || m_commandLogMaxTxnsBeforeFsync != null) {
                CommandLogType.Frequency frequency = factory.createCommandLogTypeFrequency();
                if (m_commandLogFsyncInterval != null) {
                    frequency.setTime(m_commandLogFsyncInterval);
                }
                if (m_commandLogMaxTxnsBeforeFsync != null) {
                    frequency.setTransactions(m_commandLogMaxTxnsBeforeFsync);
                }
                commandLogType.setFrequency(frequency);
            }
            deployment.setCommandlog(commandLogType);
        }

        // <partition-detection>/<snapshot>
        PartitionDetectionType ppd = factory.createPartitionDetectionType();
        deployment.setPartitionDetection(ppd);
        ppd.setEnabled(m_ppdEnabled);
        Snapshot ppdsnapshot = factory.createPartitionDetectionTypeSnapshot();
        ppd.setSnapshot(ppdsnapshot);
        ppdsnapshot.setPrefix(m_ppdPrefix);

        // <admin-mode>
        // can't be disabled, but only write out the non-default config if
        // requested by a test. otherwise, take the implied defaults (or
        // whatever local cluster overrides on the command line).
        if (m_useCustomAdmin) {
            AdminModeType admin = factory.createAdminModeType();
            deployment.setAdminMode(admin);
            admin.setPort(m_adminPort);
            admin.setAdminstartup(m_adminOnStartup);
        }

        // <systemsettings>
        SystemSettingsType systemSettingType = factory.createSystemSettingsType();
        Temptables temptables = factory.createSystemSettingsTypeTemptables();
        temptables.setMaxsize(m_maxTempTableMemory);
        systemSettingType.setTemptables(temptables);
        if (m_snapshotPriority != null) {
            SystemSettingsType.Snapshot snapshot = factory.createSystemSettingsTypeSnapshot();
            snapshot.setPriority(m_snapshotPriority);
            systemSettingType.setSnapshot(snapshot);
        }
        deployment.setSystemsettings(systemSettingType);

        // <users>
        if (m_users.size() > 0) {
            UsersType users = factory.createUsersType();
            deployment.setUsers(users);

            // <user>
            for (final UserInfo info : m_users) {
                User user = factory.createUsersTypeUser();
                users.getUser().add(user);
                user.setName(info.name);
                user.setPassword(info.password);

                // build up user/@groups.
                if (info.groups.length > 0) {
                    final StringBuilder groups = new StringBuilder();
                    for (final String group : info.groups) {
                        if (groups.length() > 0)
                            groups.append(",");
                        groups.append(group.toLowerCase());
                    }
                    user.setGroups(groups.toString());
                }
            }
        }

        // <httpd>. Disabled unless port # is configured by a testcase
        HttpdType httpd = factory.createHttpdType();
        deployment.setHttpd(httpd);
        httpd.setEnabled(m_httpdPortNo != -1);
        httpd.setPort(m_httpdPortNo);
        Jsonapi json = factory.createHttpdTypeJsonapi();
        httpd.setJsonapi(json);
        json.setEnabled(m_jsonApiEnabled);

        // <export>
        ExportType export = factory.createExportType();
        deployment.setExport(export);
        export.setEnabled(m_elenabled);

        // Have some yummy boilerplate!
        String xml = null;
        try {
View Full Code Here


            {
        org.voltdb.compiler.deploymentfile.ObjectFactory factory =
            new org.voltdb.compiler.deploymentfile.ObjectFactory();

        // <deployment>
        DeploymentType deployment = factory.createDeploymentType();
        JAXBElement<DeploymentType> doc = factory.createDeployment(deployment);

        // <cluster>
        ClusterType cluster = factory.createClusterType();
        deployment.setCluster(cluster);
        cluster.setHostcount(dinfo.hostCount);
        cluster.setSitesperhost(dinfo.sitesPerHost);
        cluster.setKfactor(dinfo.replication);
        cluster.setSchema(m_useDDLSchema ? SchemaType.DDL : SchemaType.CATALOG);

        // <paths>
        PathsType paths = factory.createPathsType();
        deployment.setPaths(paths);
        Voltdbroot voltdbroot = factory.createPathsTypeVoltdbroot();
        paths.setVoltdbroot(voltdbroot);
        voltdbroot.setPath(voltRoot);

        if (m_snapshotPath != null) {
            PathEntry snapshotPathElement = factory.createPathEntry();
            snapshotPathElement.setPath(m_snapshotPath);
            paths.setSnapshots(snapshotPathElement);
        }

        if (m_deadHostTimeout != null) {
            HeartbeatType heartbeat = factory.createHeartbeatType();
            heartbeat.setTimeout(m_deadHostTimeout);
            deployment.setHeartbeat(heartbeat);
        }

        if (m_commandLogPath != null) {
            PathEntry commandLogPathElement = factory.createPathEntry();
            commandLogPathElement.setPath(m_commandLogPath);
            paths.setCommandlog(commandLogPathElement);
        }

        if (m_internalSnapshotPath != null) {
            PathEntry commandLogSnapshotPathElement = factory.createPathEntry();
            commandLogSnapshotPathElement.setPath(m_internalSnapshotPath);
            paths.setCommandlogsnapshot(commandLogSnapshotPathElement);
        }

        if (m_snapshotPrefix != null) {
            SnapshotType snapshot = factory.createSnapshotType();
            deployment.setSnapshot(snapshot);
            snapshot.setFrequency(m_snapshotFrequency);
            snapshot.setPrefix(m_snapshotPrefix);
            snapshot.setRetain(m_snapshotRetain);
        }

        SecurityType security = factory.createSecurityType();
        deployment.setSecurity(security);
        security.setEnabled(m_securityEnabled);
        SecurityProviderString provider = SecurityProviderString.HASH;
        if (m_securityEnabled) try {
            provider = SecurityProviderString.fromValue(m_securityProvider);
        } catch (IllegalArgumentException shouldNotHappenSeeSetter) {
        }
        security.setProvider(provider);

        // set the command log (which defaults to off)
        CommandLogType commandLogType = factory.createCommandLogType();
        commandLogType.setEnabled(m_commandLogEnabled);
        if (m_commandLogSync != null) {
            commandLogType.setSynchronous(m_commandLogSync.booleanValue());
        }
        if (m_commandLogSize != null) {
            commandLogType.setLogsize(m_commandLogSize);
        }
        if (m_commandLogFsyncInterval != null || m_commandLogMaxTxnsBeforeFsync != null) {
            CommandLogType.Frequency frequency = factory.createCommandLogTypeFrequency();
            if (m_commandLogFsyncInterval != null) {
                frequency.setTime(m_commandLogFsyncInterval);
            }
            if (m_commandLogMaxTxnsBeforeFsync != null) {
                frequency.setTransactions(m_commandLogMaxTxnsBeforeFsync);
            }
            commandLogType.setFrequency(frequency);
        }
        deployment.setCommandlog(commandLogType);

        // <partition-detection>/<snapshot>
        PartitionDetectionType ppd = factory.createPartitionDetectionType();
        deployment.setPartitionDetection(ppd);
        ppd.setEnabled(m_ppdEnabled);
        Snapshot ppdsnapshot = factory.createPartitionDetectionTypeSnapshot();
        ppd.setSnapshot(ppdsnapshot);
        ppdsnapshot.setPrefix(m_ppdPrefix);

        // <admin-mode>
        // can't be disabled, but only write out the non-default config if
        // requested by a test. otherwise, take the implied defaults (or
        // whatever local cluster overrides on the command line).
        if (dinfo.useCustomAdmin) {
            AdminModeType admin = factory.createAdminModeType();
            deployment.setAdminMode(admin);
            admin.setPort(dinfo.adminPort);
            admin.setAdminstartup(dinfo.adminOnStartup);
        }

        // <systemsettings>
        SystemSettingsType systemSettingType = factory.createSystemSettingsType();
        Temptables temptables = factory.createSystemSettingsTypeTemptables();
        temptables.setMaxsize(m_maxTempTableMemory);
        systemSettingType.setTemptables(temptables);
        if (m_snapshotPriority != null) {
            SystemSettingsType.Snapshot snapshot = factory.createSystemSettingsTypeSnapshot();
            snapshot.setPriority(m_snapshotPriority);
            systemSettingType.setSnapshot(snapshot);
        }
        if (m_elasticThroughput != null || m_elasticDuration != null) {
            SystemSettingsType.Elastic elastic = factory.createSystemSettingsTypeElastic();
            if (m_elasticThroughput != null) elastic.setThroughput(m_elasticThroughput);
            if (m_elasticDuration != null) elastic.setDuration(m_elasticDuration);
            systemSettingType.setElastic(elastic);
        }
        if (m_queryTimeout != null) {
            SystemSettingsType.Query query = factory.createSystemSettingsTypeQuery();
            query.setTimeout(m_queryTimeout);
            systemSettingType.setQuery(query);
        }

        deployment.setSystemsettings(systemSettingType);

        // <users>
        if (m_users.size() > 0) {
            UsersType users = factory.createUsersType();
            deployment.setUsers(users);

            // <user>
            for (final UserInfo info : m_users) {
                User user = factory.createUsersTypeUser();
                users.getUser().add(user);
                user.setName(info.name);
                user.setPassword(info.password);

                // build up user/@groups.
                if (info.groups.length > 0) {
                    final StringBuilder groups = new StringBuilder();
                    for (final String group : info.groups) {
                        if (groups.length() > 0)
                            groups.append(",");
                        groups.append(group);
                    }
                    user.setGroups(groups.toString());
                }
            }
        }

        // <httpd>. Disabled unless port # is configured by a testcase
        HttpdType httpd = factory.createHttpdType();
        deployment.setHttpd(httpd);
        httpd.setEnabled(m_httpdPortNo != -1);
        httpd.setPort(m_httpdPortNo);
        Jsonapi json = factory.createHttpdTypeJsonapi();
        httpd.setJsonapi(json);
        json.setEnabled(m_jsonApiEnabled);

        // <export>
        ExportType export = factory.createExportType();
        deployment.setExport(export);

        // this is for old generation export test suite backward compatibility
        export.setEnabled(m_elenabled && m_elloader != null && !m_elloader.trim().isEmpty());

        ServerExportEnum exportTarget = ServerExportEnum.fromValue(m_elExportTarget.toLowerCase());
View Full Code Here

        // the default deployment file includes an http server on port 8080.
        // do some verification without starting VoltDB, since that port
        // number conflicts with jenkins on some test servers.
        String absolutePath = RealVoltDB.setupDefaultDeployment();

        DeploymentType dflt = CatalogUtil.parseDeployment(absolutePath);
        assertTrue(dflt != null);

        assertTrue(dflt.getCluster().getHostcount() == 1);
        assertTrue(dflt.getCluster().getSitesperhost() == 8);
    }
View Full Code Here

        final File tmpDdl = VoltProjectBuilder.writeStringToTempFile(ddl);

        //Custom deployment with bad class export will be disabled.
        final File tmpBad = VoltProjectBuilder.writeStringToTempFile(withBadCustomExport);
        DeploymentType bad_deployment = CatalogUtil.getDeployment(new FileInputStream(tmpBad));

        VoltCompiler compiler = new VoltCompiler();
        String x[] = {tmpDdl.getAbsolutePath()};
        Catalog cat = compiler.compileCatalogFromDDL(x);

        long crc = CatalogUtil.compileDeployment(cat, bad_deployment, true, false);
        assertTrue("Deployment file failed to parse", crc != -1);

        Database db = cat.getClusters().get("cluster").getDatabases().get("database");
        org.voltdb.catalog.Connector catconn = db.getConnectors().get("0");
        assertNotNull(catconn);

        assertFalse(bad_deployment.getExport().isEnabled());

        //This is a good deployment with custom class that can be found
        final File tmpGood = VoltProjectBuilder.writeStringToTempFile(withGoodCustomExport);
        DeploymentType good_deployment = CatalogUtil.getDeployment(new FileInputStream(tmpGood));

        Catalog cat2 = compiler.compileCatalogFromDDL(x);
        crc = CatalogUtil.compileDeployment(cat2, good_deployment, true, false);
        assertTrue("Deployment file failed to parse", crc != -1);

        db = cat2.getClusters().get("cluster").getDatabases().get("database");
        catconn = db.getConnectors().get("0");
        assertNotNull(catconn);

        assertTrue(good_deployment.getExport().isEnabled());
        assertEquals(good_deployment.getExport().getTarget(), ServerExportEnum.CUSTOM);
        assertEquals(good_deployment.getExport().getExportconnectorclass(),
                "org.voltdb.exportclient.NoOpTestExportClient");
        ConnectorProperty prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
        assertEquals(prop.getValue(), "org.voltdb.exportclient.NoOpTestExportClient");

        // This is to test previous deployment with builtin export functionality.
        final File tmpBuiltin = VoltProjectBuilder.writeStringToTempFile(withBuiltinFileExport);
        DeploymentType builtin_deployment = CatalogUtil.getDeployment(new FileInputStream(tmpBuiltin));

        Catalog cat3 = compiler.compileCatalogFromDDL(x);
        crc = CatalogUtil.compileDeployment(cat3, builtin_deployment, true, false);
        assertTrue("Deployment file failed to parse", crc != -1);

        db = cat3.getClusters().get("cluster").getDatabases().get("database");
        catconn = db.getConnectors().get("0");
        assertNotNull(catconn);

        assertTrue(builtin_deployment.getExport().isEnabled());
        assertEquals(builtin_deployment.getExport().getTarget(), ServerExportEnum.FILE);
        prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
        assertEquals(prop.getValue(), "org.voltdb.exportclient.ExportToFileClient");

        //Check kafka option.
        final File tmpKafkaBuiltin = VoltProjectBuilder.writeStringToTempFile(withBuiltinKafkaExport);
        DeploymentType builtin_kafkadeployment = CatalogUtil.getDeployment(new FileInputStream(tmpKafkaBuiltin));

        Catalog cat4 = compiler.compileCatalogFromDDL(x);
        crc = CatalogUtil.compileDeployment(cat4, builtin_kafkadeployment, true, false);
        assertTrue("Deployment file failed to parse", crc != -1);

        db = cat4.getClusters().get("cluster").getDatabases().get("database");
        catconn = db.getConnectors().get("0");
        assertNotNull(catconn);

        assertTrue(builtin_kafkadeployment.getExport().isEnabled());
        assertEquals(builtin_kafkadeployment.getExport().getTarget(), ServerExportEnum.KAFKA);
        prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
        assertEquals(prop.getValue(), "org.voltdb.exportclient.KafkaExportClient");

        // Check RabbitMQ option
        final File tmpRabbitMQBuiltin = VoltProjectBuilder.writeStringToTempFile(withBuiltinRabbitMQExport);
        DeploymentType builtin_rabbitmqdeployment = CatalogUtil.getDeployment(new FileInputStream(tmpRabbitMQBuiltin));
        Catalog cat5 = compiler.compileCatalogFromDDL(x);
        crc = CatalogUtil.compileDeployment(cat5, builtin_rabbitmqdeployment, true, false);
        assertTrue("Deployment file failed to parse", crc != -1);
        db = cat5.getClusters().get("cluster").getDatabases().get("database");
        catconn = db.getConnectors().get("0");
        assertNotNull(catconn);
        assertTrue(builtin_rabbitmqdeployment.getExport().isEnabled());
        assertEquals(ServerExportEnum.RABBITMQ, builtin_rabbitmqdeployment.getExport().getTarget());
        prop = catconn.getConfig().get(ExportDataProcessor.EXPORT_TO_TYPE);
        assertEquals("org.voltdb.exportclient.RabbitMQExportClient", prop.getValue());
    }
View Full Code Here

        return true;
    }

    public static long compileDeployment(Catalog catalog, String deploymentURL,
            boolean crashOnFailedValidation, boolean isPlaceHolderCatalog) {
        DeploymentType deployment = CatalogUtil.parseDeployment(deploymentURL);
        if (deployment == null) {
            return -1;
        }
        return compileDeployment(catalog, deployment, crashOnFailedValidation, isPlaceHolderCatalog);
    }
View Full Code Here

        return compileDeployment(catalog, deployment, crashOnFailedValidation, isPlaceHolderCatalog);
    }

    public static long compileDeploymentString(Catalog catalog, String deploymentString,
            boolean crashOnFailedValidation, boolean isPlaceHolderCatalog) {
        DeploymentType deployment = CatalogUtil.parseDeploymentFromString(deploymentString);
        if (deployment == null) {
            return -1;
        }
        return compileDeployment(catalog, deployment, crashOnFailedValidation, isPlaceHolderCatalog);
    }
View Full Code Here

            Schema schema = sf.newSchema(VoltDB.class.getResource("compiler/DeploymentFileSchema.xsd"));
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            unmarshaller.setSchema(schema);
            JAXBElement<DeploymentType> result =
                (JAXBElement<DeploymentType>) unmarshaller.unmarshal(deployIS);
            DeploymentType deployment = result.getValue();
            return deployment;
        } catch (JAXBException e) {
            // Convert some linked exceptions to more friendly errors.
            if (e.getLinkedException() instanceof java.io.FileNotFoundException) {
                hostLog.error(e.getLinkedException().getMessage());
View Full Code Here

            Unmarshaller unmarshaller = jc.createUnmarshaller();
            unmarshaller.setSchema(schema);
            @SuppressWarnings("unchecked")
            JAXBElement<DeploymentType> result =
                (JAXBElement<DeploymentType>) unmarshaller.unmarshal(sourceFH);
            DeploymentType deployment = result.getValue();
            return deployment;

        } catch (JAXBException e) {
            // Convert some linked exceptions to more friendly errors.
            if (e.getLinkedException() instanceof java.io.FileNotFoundException) {
View Full Code Here

        } catch (IOException e) {
            System.err.println("could not stat specified files: " + e.getMessage());
            return;
        }

        DeploymentType depl = getDeployment(deployFH);
        if (depl == null) return;

        try {
            scramblePasswords(depl);
        } catch (UnsupportedOperationException e) {
View Full Code Here

TOP

Related Classes of org.voltdb.compiler.deploymentfile.DeploymentType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.