示例#1
0
  private ResourceMonitorType initializeResourceMonitorType(
      SystemSettingsType systemSettingType,
      org.voltdb.compiler.deploymentfile.ObjectFactory factory) {
    ResourceMonitorType monitorType = systemSettingType.getResourcemonitor();
    if (monitorType == null) {
      monitorType = factory.createResourceMonitorType();
      systemSettingType.setResourcemonitor(monitorType);
    }

    return monitorType;
  }
示例#2
0
  private void setupDiskLimitType(
      SystemSettingsType systemSettingsType,
      org.voltdb.compiler.deploymentfile.ObjectFactory factory) {

    if (m_featureDiskLimits == null || m_featureDiskLimits.isEmpty()) {
      return;
    }

    DiskLimitType diskLimit = factory.createDiskLimitType();
    if (m_featureDiskLimits != null && !m_featureDiskLimits.isEmpty()) {
      for (FeatureNameType featureName : m_featureDiskLimits.keySet()) {
        DiskLimitType.Feature feature = factory.createDiskLimitTypeFeature();
        feature.setName(featureName);
        feature.setSize(m_featureDiskLimits.get(featureName));
        diskLimit.getFeature().add(feature);
      }
    }

    ResourceMonitorType monitorType = initializeResourceMonitorType(systemSettingsType, factory);
    monitorType.setDisklimit(diskLimit);
  }
示例#3
0
  private SystemSettingsType createSystemSettingsType(
      org.voltdb.compiler.deploymentfile.ObjectFactory factory) {
    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);
    }
    if (m_rssLimit != null) {
      ResourceMonitorType monitorType = initializeResourceMonitorType(systemSettingType, factory);
      Memorylimit memoryLimit = factory.createResourceMonitorTypeMemorylimit();
      memoryLimit.setSize(m_rssLimit);
      monitorType.setMemorylimit(memoryLimit);
    }

    if (m_resourceCheckInterval != null) {
      ResourceMonitorType monitorType = initializeResourceMonitorType(systemSettingType, factory);
      monitorType.setFrequency(m_resourceCheckInterval);
    }

    setupDiskLimitType(systemSettingType, factory);

    return systemSettingType;
  }
示例#4
0
  /**
   * 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.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) {
      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);
    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);
    }

    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());
        }
      }
    }

    // <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);

    // <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.setStream((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);
        }
      }
      importt.getConfiguration().add(importConfig);
    }

    if (m_drProducerClusterId != null || (m_drMasterHost != null && !m_drMasterHost.isEmpty())) {
      DrType dr = factory.createDrType();
      deployment.setDr(dr);
      if (m_drProducerClusterId != null) {
        dr.setListen(m_drProducerEnabled);
        dr.setId(m_drProducerClusterId);
      }
      if (m_drMasterHost != null && !m_drMasterHost.isEmpty()) {
        ConnectionType conn = factory.createConnectionType();
        dr.setConnection(conn);
        conn.setSource(m_drMasterHost);
      }
    }

    // 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;
  }