Package com.couchbase.client.vbucket.config

Examples of com.couchbase.client.vbucket.config.Config


  }

  @Override
  public MemcachedConnection createConnection(List<InetSocketAddress> addrs)
    throws IOException {
    Config config = getVBucketConfig();
    if (config.getConfigType() == ConfigType.MEMCACHE) {
      return new CouchbaseMemcachedConnection(getReadBufSize(), this, addrs,
        getInitialObservers(), getFailureMode(), getOperationFactory());
    } else if (config.getConfigType() == ConfigType.COUCHBASE) {
      return new CouchbaseConnection(getReadBufSize(), this, addrs,
        getInitialObservers(), getFailureMode(), getOperationFactory());
    }
    throw new IOException("No ConnectionFactory for bucket type "
      + config.getConfigType());
  }
View Full Code Here


    return new ViewConnection(this, addrs, getInitialObservers());
  }

  @Override
  public NodeLocator createLocator(List<MemcachedNode> nodes) {
    Config config = getVBucketConfig();

    if (config == null) {
      throw new IllegalStateException("Couldn't get config");
    }

    if (config.getConfigType() == ConfigType.MEMCACHE) {
      return new KetamaNodeLocator(nodes, DefaultHashAlgorithm.KETAMA_HASH);
    } else if (config.getConfigType() == ConfigType.COUCHBASE) {
      return new VBucketNodeLocator(nodes, getVBucketConfig());
    } else {
      throw new IllegalStateException("Unhandled locator type: "
          + config.getConfigType());
    }
  }
View Full Code Here

    return cas(key, cas, exp, value, PersistTo.ZERO, rep);
  }

  private Map<MemcachedNode, ObserveResponse> observe(final String key,
    final long cas, final boolean toMaster, final boolean toReplica) {
    Config cfg = ((CouchbaseConnectionFactory) connFactory).getVBucketConfig();
    VBucketNodeLocator locator = (VBucketNodeLocator) mconn.getLocator();

    final int vb = locator.getVBucketIndex(key);
    List<MemcachedNode> bcastNodes = new ArrayList<MemcachedNode>();

    if (toMaster) {
      MemcachedNode primary = locator.getPrimary(key);
      if (primary != null) {
        bcastNodes.add(primary);
      }
    }

    if (toReplica) {
      for (int i = 0; i < cfg.getReplicasCount(); i++) {
        MemcachedNode replica = locator.getReplica(key, i);
        if (replica != null) {
          bcastNodes.add(replica);
        }
      }
View Full Code Here

    }
    return shutdownResult;
  }

  private void checkObserveReplica(String key, int numPersist, int numReplica) {
    Config cfg = ((CouchbaseConnectionFactory) connFactory).getVBucketConfig();
    VBucketNodeLocator locator = (VBucketNodeLocator) mconn.getLocator();

    if(numReplica > 0) {
      int vBucketIndex = locator.getVBucketIndex(key);
      int currentReplicaNum = cfg.getReplica(vBucketIndex, numReplica-1);
      if (currentReplicaNum < 0) {
        throw new ObservedException("Currently, there is no replica node "
          + "available for the given replication index (" + numReplica + ").");
      }
    }

    int replicaCount = Math.min(locator.getAll().size() - 1, cfg.getReplicasCount());
    if (numReplica > replicaCount) {
      throw new ObservedException("Requested replication to " + numReplica
          + " node(s), but only " + replicaCount + " are available.");
    } else if (numPersist > replicaCount + 1) {
      throw new ObservedException("Requested persistence to " + (numPersist + 1)
View Full Code Here

  /**
   * Updates the current list of seed nodes with a current one from the stored
   * configuration.
   */
  private void updateSeedNodes() {
    Config config = this.config.get().getConfig();

    List<String> clusterNodes = config.getRestEndpoints();
    if (!clusterNodes.isEmpty()) {
      List<URI> newNodes = new ArrayList<URI>();
      for (String clusterNode : clusterNodes) {
        try {
          newNodes.add(new URI(clusterNode));
View Full Code Here

    return observeFuture;
  }

  private Map<MemcachedNode, ObserveResponse> observe(final String key,
    final long cas, final boolean toMaster, final boolean toReplica) {
    Config cfg = ((CouchbaseConnectionFactory) connFactory).getVBucketConfig();
    VBucketNodeLocator locator = (VBucketNodeLocator) mconn.getLocator();

    final int vb = locator.getVBucketIndex(key);
    List<MemcachedNode> bcastNodes = new ArrayList<MemcachedNode>();

    if (toMaster) {
      MemcachedNode primary = locator.getPrimary(key);
      if (primary != null) {
        bcastNodes.add(primary);
      }
    }

    if (toReplica) {
      for (int i = 0; i < cfg.getReplicasCount(); i++) {
        MemcachedNode replica = locator.getReplica(key, i);
        if (replica != null) {
          bcastNodes.add(replica);
        }
      }
View Full Code Here

    }
    return shutdownResult;
  }

  private void checkObserveReplica(String key, int numPersist, int numReplica) {
    Config cfg = ((CouchbaseConnectionFactory) connFactory).getVBucketConfig();
    VBucketNodeLocator locator = (VBucketNodeLocator) mconn.getLocator();

    if(numReplica > 0) {
      int vBucketIndex = locator.getVBucketIndex(key);
      int currentReplicaNum = cfg.getReplica(vBucketIndex, numReplica-1);
      if (currentReplicaNum < 0) {
        throw new ObservedException("Currently, there is no replica node "
          + "available for the given replication index (" + numReplica + ").");
      }
    }

    int replicaCount = Math.min(locator.getAll().size() - 1, cfg.getReplicasCount());
    if (numReplica > replicaCount) {
      throw new ObservedException("Requested replication to " + numReplica
          + " node(s), but only " + replicaCount + " are available.");
    } else if (numPersist > replicaCount + 1) {
      throw new ObservedException("Requested persistence to " + (numPersist + 1)
View Full Code Here

      boolean warmedUp = false;
      int maxBackoffRetries = 5;
      int retryCount = 1;
      while(!warmedUp) {
        readPools(bucketname);
        Config config = this.buckets.get(bucketname).getConfig();
        if(config.getConfigType().equals(ConfigType.MEMCACHE)) {
          warmedUp = true;
          continue;
        }
        if(config.getVbucketsCount() == 0) {
          if(retryCount > maxBackoffRetries) {
            throw new ConfigurationException("Cluster is not in a warmed up "
              + "state after " + maxBackoffRetries + " exponential retries.");
          }
          int backoffSeconds = new Double(
View Full Code Here

    return observeFuture;
  }

  private Map<MemcachedNode, ObserveResponse> observe(final String key,
    final long cas, final boolean toMaster, final boolean toReplica) {
    Config cfg = ((CouchbaseConnectionFactory) connFactory).getVBucketConfig();
    VBucketNodeLocator locator = (VBucketNodeLocator) mconn.getLocator();

    final int vb = locator.getVBucketIndex(key);
    List<MemcachedNode> bcastNodes = new ArrayList<MemcachedNode>();

    if (toMaster) {
      MemcachedNode primary = locator.getPrimary(key);
      if (primary != null) {
        bcastNodes.add(primary);
      }
    }

    if (toReplica) {
      for (int i = 0; i < cfg.getReplicasCount(); i++) {
        MemcachedNode replica = locator.getReplica(key, i);
        if (replica != null) {
          bcastNodes.add(replica);
        }
      }
View Full Code Here

    }
    return shutdownResult;
  }

  private void checkObserveReplica(String key, int numPersist, int numReplica) {
    Config cfg = ((CouchbaseConnectionFactory) connFactory).getVBucketConfig();
    VBucketNodeLocator locator = (VBucketNodeLocator) mconn.getLocator();

    if(numReplica > 0) {
      int vBucketIndex = locator.getVBucketIndex(key);
      int currentReplicaNum = cfg.getReplica(vBucketIndex, numReplica-1);
      if (currentReplicaNum < 0) {
        throw new ObservedException("Currently, there is no replica node "
          + "available for the given replication index (" + numReplica + ").");
      }
    }

    int replicaCount = Math.min(locator.getAll().size() - 1, cfg.getReplicasCount());
    if (numReplica > replicaCount) {
      throw new ObservedException("Requested replication to " + numReplica
          + " node(s), but only " + replicaCount + " are available.");
    } else if (numPersist > replicaCount + 1) {
      throw new ObservedException("Requested persistence to " + (numPersist + 1)
View Full Code Here

TOP

Related Classes of com.couchbase.client.vbucket.config.Config

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.