Search in sources :

Example 1 with ClusterType

use of org.voltdb.compiler.deploymentfile.ClusterType in project voltdb by VoltDB.

the class DeploymentBuilder method getXML.

/**
     * Writes deployment.xml file to a temporary file. It is constructed from the passed parameters and the m_users
     * field.
     *
     * @param voltRoot
     * @param dinfo an instance {@link DeploymentInfo}
     * @return deployment path
     * @throws IOException
     * @throws JAXBException
     */
public String getXML() {
    // make sure voltroot exists
    new File(m_voltRootPath).mkdirs();
    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) {
        PathsType.Snapshots snapshotPathElement = factory.createPathsTypeSnapshots();
        snapshotPathElement.setPath(m_snapshotPath);
        paths.setSnapshots(snapshotPathElement);
    }
    if (m_commandLogPath != null) {
        PathsType.Commandlog commandLogPathElement = factory.createPathsTypeCommandlog();
        commandLogPathElement.setPath(m_commandLogPath);
        paths.setCommandlog(commandLogPathElement);
    }
    if (m_internalSnapshotPath != null) {
        PathsType.Commandlogsnapshot commandLogSnapshotPathElement = factory.createPathsTypeCommandlogsnapshot();
        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);
    // <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/roles.
            if (info.roles.length > 0) {
                final StringBuilder roles = new StringBuilder();
                for (final String role : info.roles) {
                    if (roles.length() > 0)
                        roles.append(",");
                    roles.append(role.toLowerCase());
                }
                user.setRoles(roles.toString());
            }
        }
    }
    SslType ssl = factory.createSslType();
    deployment.setSsl(ssl);
    ssl.setEnabled(false);
    // <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);
    // <dr>
    if (m_drRole != DrRoleType.NONE) {
        final DrType drType = factory.createDrType();
        deployment.setDr(drType);
        drType.setRole(m_drRole);
        drType.setId(1);
    }
    // Have some yummy boilerplate!
    String xml = null;
    try {
        JAXBContext context = JAXBContext.newInstance(DeploymentType.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        StringWriter writer = new StringWriter();
        marshaller.marshal(doc, writer);
        xml = writer.toString();
    } catch (Exception e) {
        e.printStackTrace();
        assert (false);
    }
    return xml;
}
Also used : SecurityType(org.voltdb.compiler.deploymentfile.SecurityType) User(org.voltdb.compiler.deploymentfile.UsersType.User) SecurityProviderString(org.voltdb.compiler.deploymentfile.SecurityProviderString) Jsonapi(org.voltdb.compiler.deploymentfile.HttpdType.Jsonapi) JAXBContext(javax.xml.bind.JAXBContext) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) SecurityProviderString(org.voltdb.compiler.deploymentfile.SecurityProviderString) PathsType(org.voltdb.compiler.deploymentfile.PathsType) CommandLogType(org.voltdb.compiler.deploymentfile.CommandLogType) SystemSettingsType(org.voltdb.compiler.deploymentfile.SystemSettingsType) StringWriter(java.io.StringWriter) PartitionDetectionType(org.voltdb.compiler.deploymentfile.PartitionDetectionType) Marshaller(javax.xml.bind.Marshaller) ExportType(org.voltdb.compiler.deploymentfile.ExportType) Voltdbroot(org.voltdb.compiler.deploymentfile.PathsType.Voltdbroot) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) DrType(org.voltdb.compiler.deploymentfile.DrType) Temptables(org.voltdb.compiler.deploymentfile.SystemSettingsType.Temptables) HttpdType(org.voltdb.compiler.deploymentfile.HttpdType) UsersType(org.voltdb.compiler.deploymentfile.UsersType) SslType(org.voltdb.compiler.deploymentfile.SslType) SnapshotType(org.voltdb.compiler.deploymentfile.SnapshotType) File(java.io.File)

Example 2 with ClusterType

use of org.voltdb.compiler.deploymentfile.ClusterType in project voltdb by VoltDB.

the class CatalogUtil method setClusterInfo.

/**
     * Set cluster info in the catalog.
     * @param leader The leader hostname
     * @param catalog The catalog to be updated.
     * @param printLog Whether or not to print cluster configuration.
     */
private static void setClusterInfo(Catalog catalog, DeploymentType deployment) {
    ClusterType cluster = deployment.getCluster();
    int kFactor = cluster.getKfactor();
    Cluster catCluster = catalog.getClusters().get("cluster");
    // copy the deployment info that is currently not recorded anywhere else
    Deployment catDeploy = catCluster.getDeployment().get("deployment");
    catDeploy.setKfactor(kFactor);
    if (deployment.getPartitionDetection().isEnabled()) {
        catCluster.setNetworkpartition(true);
    } else {
        catCluster.setNetworkpartition(false);
    }
    setSystemSettings(deployment, catDeploy);
    catCluster.setHeartbeattimeout(deployment.getHeartbeat().getTimeout());
    // copy schema modification behavior from xml to catalog
    if (cluster.getSchema() != null) {
        catCluster.setUseddlschema(cluster.getSchema() == SchemaType.DDL);
    } else {
        // Don't think we can get here, deployment schema guarantees a default value
        hostLog.warn("Schema modification setting not found. " + "Forcing default behavior of UpdateCatalog to modify database schema.");
        catCluster.setUseddlschema(false);
    }
}
Also used : Cluster(org.voltdb.catalog.Cluster) Deployment(org.voltdb.catalog.Deployment) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType) Constraint(org.voltdb.catalog.Constraint)

Example 3 with ClusterType

use of org.voltdb.compiler.deploymentfile.ClusterType in project voltdb by VoltDB.

the class VoltProjectBuilder method writeDeploymentFile.

/**
     * Writes deployment.xml file to a temporary file. It is constructed from the passed parameters and the m_users
     * field.
     *
     * @param voltRoot
     * @param dinfo an instance {@link DeploymentInfo}
     * @return deployment path
     * @throws IOException
     * @throws JAXBException
     */
private String writeDeploymentFile(String voltRoot, DeploymentInfo dinfo) throws IOException, JAXBException {
    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.setId(dinfo.clusterId);
    cluster.setSchema(m_useDDLSchema ? SchemaType.DDL : SchemaType.CATALOG);
    // <paths>
    PathsType paths = factory.createPathsType();
    deployment.setPaths(paths);
    if ((voltRoot != null) && !voltRoot.trim().isEmpty()) {
        Voltdbroot voltdbroot = factory.createPathsTypeVoltdbroot();
        paths.setVoltdbroot(voltdbroot);
        voltdbroot.setPath(voltRoot);
    }
    if (m_snapshotPath != null) {
        PathsType.Snapshots snapshotPathElement = factory.createPathsTypeSnapshots();
        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) {
        PathsType.Commandlog commandLogPathElement = factory.createPathsTypeCommandlog();
        commandLogPathElement.setPath(m_commandLogPath);
        paths.setCommandlog(commandLogPathElement);
    }
    if (m_internalSnapshotPath != null) {
        PathsType.Commandlogsnapshot commandLogSnapshotPathElement = factory.createPathsTypeCommandlogsnapshot();
        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);
    // don't include this element if not explicitly set
    if (m_heartbeatTimeout != null) {
        HeartbeatType hb = factory.createHeartbeatType();
        deployment.setHeartbeat(hb);
        hb.setTimeout((int) m_heartbeatTimeout);
    }
    // don't include this element if not explicitly set
    if (m_consistencyReadLevel != null) {
        ConsistencyType ct = factory.createConsistencyType();
        deployment.setConsistency(ct);
        ct.setReadlevel(m_consistencyReadLevel.toReadLevelType());
    }
    deployment.setSystemsettings(createSystemSettingsType(factory));
    // <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);
            user.setPlaintext(info.plaintext);
            // build up user/roles.
            if (info.roles.length > 0) {
                final StringBuilder roles = new StringBuilder();
                for (final String role : info.roles) {
                    if (roles.length() > 0)
                        roles.append(",");
                    roles.append(role);
                }
                user.setRoles(roles.toString());
            }
        }
    }
    SslType ssl = factory.createSslType();
    deployment.setSsl(ssl);
    ssl.setEnabled(m_sslEnabled);
    ssl.setExternal(m_sslExternal);
    if (m_keystore != null) {
        KeyOrTrustStoreType store = factory.createKeyOrTrustStoreType();
        store.setPath(m_keystore);
        store.setPassword(m_keystorePassword);
        ssl.setKeystore(store);
    }
    if (m_certstore != null) {
        KeyOrTrustStoreType store = factory.createKeyOrTrustStoreType();
        store.setPath(m_certstore);
        store.setPassword(m_certstorePassword);
        ssl.setTruststore(store);
    }
    // <httpd>. Disabled unless port # is configured by a testcase
    // Omit element(s) when null.
    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);
    //SNMP
    SnmpType snmpType = factory.createSnmpType();
    if (m_snmpEnabled) {
        snmpType.setEnabled(true);
        snmpType.setTarget(m_snmpTarget);
        deployment.setSnmp(snmpType);
    }
    // <export>
    ExportType export = factory.createExportType();
    deployment.setExport(export);
    for (HashMap<String, Object> exportConnector : m_elExportConnectors) {
        ExportConfigurationType exportConfig = factory.createExportConfigurationType();
        exportConfig.setEnabled((boolean) exportConnector.get("elEnabled") && exportConnector.get("elLoader") != null && !((String) exportConnector.get("elLoader")).trim().isEmpty());
        ServerExportEnum exportTarget = ServerExportEnum.fromValue(((String) exportConnector.get("elExportTarget")).toLowerCase());
        exportConfig.setType(exportTarget);
        if (exportTarget.equals(ServerExportEnum.CUSTOM)) {
            exportConfig.setExportconnectorclass(System.getProperty(ExportDataProcessor.EXPORT_TO_TYPE));
        }
        exportConfig.setTarget((String) exportConnector.get("elGroup"));
        Properties config = (Properties) exportConnector.get("elConfig");
        if ((config != null) && (config.size() > 0)) {
            List<PropertyType> configProperties = exportConfig.getProperty();
            for (Object nameObj : config.keySet()) {
                String name = String.class.cast(nameObj);
                PropertyType prop = factory.createPropertyType();
                prop.setName(name);
                prop.setValue(config.getProperty(name));
                configProperties.add(prop);
            }
        }
        export.getConfiguration().add(exportConfig);
    }
    // <import>
    ImportType importt = factory.createImportType();
    deployment.setImport(importt);
    for (HashMap<String, Object> importConnector : m_ilImportConnectors) {
        ImportConfigurationType importConfig = factory.createImportConfigurationType();
        importConfig.setEnabled((boolean) importConnector.get("ilEnabled"));
        ServerImportEnum importType = ServerImportEnum.fromValue(((String) importConnector.get("ilImportType")).toLowerCase());
        importConfig.setType(importType);
        importConfig.setModule((String) importConnector.get("ilModule"));
        String formatter = (String) importConnector.get("ilFormatter");
        if (formatter != null) {
            importConfig.setFormat(formatter);
        }
        Properties config = (Properties) importConnector.get("ilConfig");
        if ((config != null) && (config.size() > 0)) {
            List<PropertyType> configProperties = importConfig.getProperty();
            for (Object nameObj : config.keySet()) {
                String name = String.class.cast(nameObj);
                PropertyType prop = factory.createPropertyType();
                prop.setName(name);
                prop.setValue(config.getProperty(name));
                configProperties.add(prop);
            }
        }
        Properties formatConfig = (Properties) importConnector.get("ilFormatterConfig");
        if ((formatConfig != null) && (formatConfig.size() > 0)) {
            List<PropertyType> configProperties = importConfig.getFormatProperty();
            for (Object nameObj : formatConfig.keySet()) {
                String name = String.class.cast(nameObj);
                PropertyType prop = factory.createPropertyType();
                prop.setName(name);
                prop.setValue(formatConfig.getProperty(name));
                configProperties.add(prop);
            }
        }
        importt.getConfiguration().add(importConfig);
    }
    DrType dr = factory.createDrType();
    deployment.setDr(dr);
    dr.setListen(m_drProducerEnabled);
    dr.setRole(m_drRole);
    if (m_drMasterHost != null && !m_drMasterHost.isEmpty()) {
        ConnectionType conn = factory.createConnectionType();
        dr.setConnection(conn);
        conn.setSource(m_drMasterHost);
        conn.setPreferredSource(m_preferredSource);
        conn.setEnabled(m_drConsumerConnectionEnabled);
    }
    // Have some yummy boilerplate!
    File file = File.createTempFile("myAppDeployment", ".tmp");
    JAXBContext context = JAXBContext.newInstance(DeploymentType.class);
    Marshaller marshaller = context.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.marshal(doc, file);
    final String deploymentPath = file.getPath();
    return deploymentPath;
}
Also used : Jsonapi(org.voltdb.compiler.deploymentfile.HttpdType.Jsonapi) SecurityProviderString(org.voltdb.compiler.deploymentfile.SecurityProviderString) PropertyType(org.voltdb.compiler.deploymentfile.PropertyType) PartitionDetectionType(org.voltdb.compiler.deploymentfile.PartitionDetectionType) ConnectionType(org.voltdb.compiler.deploymentfile.ConnectionType) Voltdbroot(org.voltdb.compiler.deploymentfile.PathsType.Voltdbroot) ServerExportEnum(org.voltdb.compiler.deploymentfile.ServerExportEnum) ExportConfigurationType(org.voltdb.compiler.deploymentfile.ExportConfigurationType) SslType(org.voltdb.compiler.deploymentfile.SslType) File(java.io.File) SecurityType(org.voltdb.compiler.deploymentfile.SecurityType) User(org.voltdb.compiler.deploymentfile.UsersType.User) SecurityProviderString(org.voltdb.compiler.deploymentfile.SecurityProviderString) JAXBContext(javax.xml.bind.JAXBContext) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) Properties(java.util.Properties) HeartbeatType(org.voltdb.compiler.deploymentfile.HeartbeatType) ConsistencyType(org.voltdb.compiler.deploymentfile.ConsistencyType) PathsType(org.voltdb.compiler.deploymentfile.PathsType) CommandLogType(org.voltdb.compiler.deploymentfile.CommandLogType) ImportType(org.voltdb.compiler.deploymentfile.ImportType) Marshaller(javax.xml.bind.Marshaller) ServerImportEnum(org.voltdb.compiler.deploymentfile.ServerImportEnum) ExportType(org.voltdb.compiler.deploymentfile.ExportType) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType) DrType(org.voltdb.compiler.deploymentfile.DrType) HttpdType(org.voltdb.compiler.deploymentfile.HttpdType) UsersType(org.voltdb.compiler.deploymentfile.UsersType) SnmpType(org.voltdb.compiler.deploymentfile.SnmpType) SnapshotType(org.voltdb.compiler.deploymentfile.SnapshotType) ImportConfigurationType(org.voltdb.compiler.deploymentfile.ImportConfigurationType) KeyOrTrustStoreType(org.voltdb.compiler.deploymentfile.KeyOrTrustStoreType)

Example 4 with ClusterType

use of org.voltdb.compiler.deploymentfile.ClusterType in project voltdb by VoltDB.

the class RealVoltDB method buildClusterMesh.

/**
     * Start the voltcore HostMessenger. This joins the node
     * to the existing cluster. In the non rejoin case, this
     * function will return when the mesh is complete. If
     * rejoining, it will return when the node and agreement
     * site are synched to the existing cluster.
     */
MeshProber.Determination buildClusterMesh(ReadDeploymentResults readDepl) {
    final boolean bareAtStartup = m_config.m_forceVoltdbCreate || pathsWithRecoverableArtifacts(readDepl.deployment).isEmpty();
    setBare(bareAtStartup);
    final Supplier<Integer> hostCountSupplier = new Supplier<Integer>() {

        @Override
        public Integer get() {
            return m_clusterSettings.get().hostcount();
        }
    };
    ClusterType clusterType = readDepl.deployment.getCluster();
    MeshProber criteria = MeshProber.builder().coordinators(m_config.m_coordinators).versionChecker(m_versionChecker).enterprise(m_config.m_isEnterprise).startAction(m_config.m_startAction).bare(bareAtStartup).configHash(CatalogUtil.makeDeploymentHashForConfig(readDepl.deploymentBytes)).hostCountSupplier(hostCountSupplier).kfactor(clusterType.getKfactor()).paused(m_config.m_isPaused).nodeStateSupplier(m_statusTracker.getNodeStateSupplier()).addAllowed(m_config.m_enableAdd).safeMode(m_config.m_safeMode).terminusNonce(getTerminusNonce()).missingHostCount(m_config.m_missingHostCount).build();
    HostAndPort hostAndPort = criteria.getLeader();
    String hostname = hostAndPort.getHostText();
    int port = hostAndPort.getPort();
    org.voltcore.messaging.HostMessenger.Config hmconfig;
    hmconfig = new org.voltcore.messaging.HostMessenger.Config(hostname, port);
    if (m_config.m_placementGroup != null) {
        hmconfig.group = m_config.m_placementGroup;
    }
    hmconfig.internalPort = m_config.m_internalPort;
    hmconfig.internalInterface = m_config.m_internalInterface;
    hmconfig.zkInterface = m_config.m_zkInterface;
    hmconfig.deadHostTimeout = m_config.m_deadHostTimeoutMS;
    hmconfig.factory = new VoltDbMessageFactory();
    hmconfig.coreBindIds = m_config.m_networkCoreBindings;
    hmconfig.acceptor = criteria;
    hmconfig.localSitesCount = m_config.m_sitesperhost;
    m_messenger = new org.voltcore.messaging.HostMessenger(hmconfig, this);
    hostLog.info(String.format("Beginning inter-node communication on port %d.", m_config.m_internalPort));
    try {
        m_messenger.start();
    } catch (Exception e) {
        VoltDB.crashLocalVoltDB(e.getMessage(), true, e);
    }
    VoltZK.createPersistentZKNodes(m_messenger.getZK());
    // Use the host messenger's hostId.
    m_myHostId = m_messenger.getHostId();
    hostLog.info(String.format("Host id of this node is: %d", m_myHostId));
    consoleLog.info(String.format("Host id of this node is: %d", m_myHostId));
    MeshProber.Determination determination = criteria.waitForDetermination();
    // paused is determined in the mesh formation exchanged
    if (determination.paused) {
        m_messenger.pause();
    } else {
        m_messenger.unpause();
    }
    // leader and we're rejoining, this is clearly bad.
    if (m_myHostId == 0 && determination.startAction.doesJoin()) {
        VoltDB.crashLocalVoltDB("Unable to rejoin a node to itself.  " + "Please check your command line and start action and try again.", false, null);
    }
    // load or store settings form/to zookeeper
    if (determination.startAction.doesJoin()) {
        m_clusterSettings.load(m_messenger.getZK());
        m_clusterSettings.get().store();
    } else if (m_myHostId == 0) {
        m_clusterSettings.store(m_messenger.getZK());
    }
    m_clusterCreateTime = m_messenger.getInstanceId().getTimestamp();
    return determination;
}
Also used : VoltDbMessageFactory(org.voltdb.messaging.VoltDbMessageFactory) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType) MeshProber(org.voltdb.probe.MeshProber) SocketException(java.net.SocketException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) JSONException(org.json_voltpatches.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) KeeperException(org.apache.zookeeper_voltpatches.KeeperException) SettingsException(org.voltdb.settings.SettingsException) HostAndPort(com.google_voltpatches.common.net.HostAndPort) HostMessenger(org.voltcore.messaging.HostMessenger) HostMessenger(org.voltcore.messaging.HostMessenger) Supplier(com.google_voltpatches.common.base.Supplier)

Example 5 with ClusterType

use of org.voltdb.compiler.deploymentfile.ClusterType in project voltdb by VoltDB.

the class CatalogUtil method shallowClusterAndPathsClone.

/**
     * Creates a shallow clone of {@link DeploymentType} where all its
     * children references are copied except for {@link ClusterType}, and
     * {@link PathsType} which are newly instantiated
     * @param o
     * @return a shallow clone of {@link DeploymentType}
     */
public static DeploymentType shallowClusterAndPathsClone(DeploymentType o) {
    DeploymentType clone = new DeploymentType();
    clone.setPartitionDetection(o.getPartitionDetection());
    clone.setHeartbeat(o.getHeartbeat());
    clone.setHttpd(o.getHttpd());
    clone.setSnapshot(o.getSnapshot());
    clone.setExport(o.getExport());
    clone.setUsers(o.getUsers());
    clone.setCommandlog(o.getCommandlog());
    clone.setSystemsettings(o.getSystemsettings());
    clone.setSecurity(o.getSecurity());
    clone.setDr(o.getDr());
    clone.setImport(o.getImport());
    clone.setConsistency(o.getConsistency());
    ClusterType other = o.getCluster();
    ClusterType cluster = new ClusterType();
    cluster.setHostcount(other.getHostcount());
    cluster.setSitesperhost(other.getSitesperhost());
    cluster.setKfactor(other.getKfactor());
    cluster.setId(other.getId());
    cluster.setElastic(other.getElastic());
    cluster.setSchema(other.getSchema());
    clone.setCluster(cluster);
    PathsType prev = o.getPaths();
    PathsType paths = new PathsType();
    paths.setVoltdbroot(prev.getVoltdbroot());
    paths.setSnapshots(prev.getSnapshots());
    paths.setExportoverflow(prev.getExportoverflow());
    paths.setDroverflow(prev.getDroverflow());
    paths.setCommandlog(prev.getCommandlog());
    paths.setCommandlogsnapshot(prev.getCommandlogsnapshot());
    clone.setPaths(paths);
    clone.setSsl(o.getSsl());
    clone.setSnmp(o.getSnmp());
    return clone;
}
Also used : PathsType(org.voltdb.compiler.deploymentfile.PathsType) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType)

Aggregations

ClusterType (org.voltdb.compiler.deploymentfile.ClusterType)5 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)3 PathsType (org.voltdb.compiler.deploymentfile.PathsType)3 File (java.io.File)2 IOException (java.io.IOException)2 JAXBContext (javax.xml.bind.JAXBContext)2 Marshaller (javax.xml.bind.Marshaller)2 CommandLogType (org.voltdb.compiler.deploymentfile.CommandLogType)2 DrType (org.voltdb.compiler.deploymentfile.DrType)2 ExportType (org.voltdb.compiler.deploymentfile.ExportType)2 HttpdType (org.voltdb.compiler.deploymentfile.HttpdType)2 Jsonapi (org.voltdb.compiler.deploymentfile.HttpdType.Jsonapi)2 PartitionDetectionType (org.voltdb.compiler.deploymentfile.PartitionDetectionType)2 Voltdbroot (org.voltdb.compiler.deploymentfile.PathsType.Voltdbroot)2 SecurityProviderString (org.voltdb.compiler.deploymentfile.SecurityProviderString)2 SecurityType (org.voltdb.compiler.deploymentfile.SecurityType)2 SnapshotType (org.voltdb.compiler.deploymentfile.SnapshotType)2 SslType (org.voltdb.compiler.deploymentfile.SslType)2 UsersType (org.voltdb.compiler.deploymentfile.UsersType)2 User (org.voltdb.compiler.deploymentfile.UsersType.User)2