コード例 #1
0
  /**
   * Updates the stored base list with a new one based on the config.
   *
   * @param config
   */
  public void updateStoredBaseList(Config config) {
    List<String> bucketServers = config.getServers();
    if (bucketServers.size() > 0) {
      List<URI> newList = new ArrayList<URI>();
      for (String bucketServer : bucketServers) {
        String hostname = bucketServer.split(":")[0];
        try {
          newList.add(new URI("http://" + hostname + ":8091/pools"));
        } catch (URISyntaxException ex) {
          getLogger()
              .warn(
                  "Could not add node to updated bucket list because " + "of a parsing exception.");
          getLogger().debug("Could not parse list because: " + ex);
        }
      }

      if (nodeListsAreDifferent(storedBaseList, newList)) {
        getLogger()
            .info("Replacing current streaming node list " + storedBaseList + " with " + newList);
        potentiallyRandomizeNodeList(newList);
        storedBaseList = newList;
        getConfigurationProvider().updateBaseListFromConfig(newList);
      }
    }
  }
コード例 #2
0
  private void initialize(List<URI> baseList, String bucket, String password) {
    potentiallyRandomizeNodeList(baseList);

    storedBaseList = new ArrayList<URI>();
    for (URI bu : baseList) {
      if (!bu.isAbsolute()) {
        throw new IllegalArgumentException("The base URI must be absolute");
      }
      storedBaseList.add(bu);
    }

    if (bucket == null || bucket.isEmpty()) {
      throw new IllegalArgumentException("The bucket name must not be null " + "or empty.");
    }
    if (password == null) {
      throw new IllegalArgumentException("The bucket password must not be " + " null.");
    }

    this.bucket = bucket;
    pass = password;
    configurationProvider = new ConfigurationProviderHTTP(baseList, bucket, password);
  }