コード例 #1
0
  void configureInternal(Map<String, ?> conf) throws Exception {
    configuration = configurer.configure(conf, this);

    if (Strings.isNullOrBlank(runtimeId)) {
      throw new IllegalArgumentException("Runtime id must not be null or empty.");
    }

    if (Strings.isNullOrBlank(localResolver)) {
      localResolver = globalResolver;
    }

    String decodedZookeeperPassword = null;

    Properties userProps = new Properties();
    try {
      userProps.load(new File(confDir, "users.properties"));
    } catch (IOException e) {
      LOGGER.warn("Failed to load users from etc/users.properties. No users will be imported.", e);
    }

    if (Strings.isNotBlank(zookeeperPassword)) {
      decodedZookeeperPassword = PasswordEncoder.decode(zookeeperPassword);
    } else if (userProps.containsKey(DEFAULT_ADMIN_USER)) {
      String passwordAndRole = userProps.getProperty(DEFAULT_ADMIN_USER).trim();
      decodedZookeeperPassword =
          passwordAndRole.substring(0, passwordAndRole.indexOf(ROLE_DELIMITER));
    } else {
      decodedZookeeperPassword = PasswordEncoder.encode(CreateEnsembleOptions.generatePassword());
    }

    if (userProps.isEmpty()) {
      userProps.put(
          DEFAULT_ADMIN_USER, decodedZookeeperPassword + ROLE_DELIMITER + DEFAULT_ADMIN_ROLE);
    }

    options =
        CreateEnsembleOptions.builder()
            .bindAddress(bindAddress)
            .agentEnabled(agentAutoStart)
            .ensembleStart(ensembleAutoStart)
            .zookeeperPassword(decodedZookeeperPassword)
            .zooKeeperServerPort(zookeeperServerPort)
            .zooKeeperServerConnectionPort(zookeeperServerConnectionPort)
            .autoImportEnabled(profilesAutoImport)
            .importPath(profilesAutoImportPath)
            .resolver(localResolver)
            .globalResolver(globalResolver)
            .users(userProps)
            .profiles(profiles)
            .version(version)
            .build();
  }
コード例 #2
0
 private boolean checkCreated(BundleContext bundleContext) throws IOException {
   org.apache.felix.utils.properties.Properties props =
       new org.apache.felix.utils.properties.Properties(new File(dataDir, ENSEMBLE_MARKER));
   return props.containsKey("created");
 }