Package net.spy.memcached.vbucket.config

Examples of net.spy.memcached.vbucket.config.Bucket


        HttpRequest request = prepareRequest(cometStreamURI, host);
        channel.write(request);
        try {
            String response = this.handler.getLastResponse();
            logFiner("Getting server list returns this last chunked response:\n" + response);
            Bucket bucketToMonitor = this.configParser.parseBucket(response);
            setBucket(bucketToMonitor);
        } catch (ParseException ex) {
            Logger.getLogger(BucketMonitor.class.getName()).log(Level.WARNING,
                    "Invalid client configuration received from server.  Staying with existing configuration.", ex);
            Logger.getLogger(BucketMonitor.class.getName()).log(Level.FINE,
View Full Code Here


    }

    protected void invalidate() {
        try {
            String response = handler.getLastResponse();
            Bucket updatedBucket = this.configParser.parseBucket(response);
            setBucket(updatedBucket);
        } catch (ParseException e) {
            Logger.getLogger(BucketMonitor.class.getName()).log(Level.SEVERE,
                    "Invalid client configuration received from server.  Staying with existing configuration.", e);
        }
View Full Code Here

     */
    public Bucket getBucketConfiguration(final String bucketname) throws ConfigurationException {
        if (bucketname == null || bucketname.isEmpty()) {
            throw new IllegalArgumentException("Bucket name can not be blank.");
        }
        Bucket bucket = this.buckets.get(bucketname);
        if (bucket == null) {
            readPools(bucketname);
        }
        return this.buckets.get(bucketname);
    }
View Full Code Here

            throw new ConfigurationException("Configuration for bucket " + bucketToFind + " was not found.");
        }
    }

    public List<InetSocketAddress> getServerList(final String bucketname) throws ConfigurationException {
        Bucket bucket = getBucketConfiguration(bucketname);
        List<String> servers = bucket.getConfig().getServers();
        StringBuilder serversString = new StringBuilder();
        for (String server : servers) {
            serversString.append(server).append(' ');
        }
        return AddrUtil.getAddresses(serversString.toString());
View Full Code Here

     * @param bucketName bucket name to receive configuration for
     * @param rec reconfigurable that will receive updates
     * @throws ConfigurationException
     */
    public void subscribe(String bucketName, Reconfigurable rec) throws ConfigurationException {
        Bucket bucket = getBucketConfiguration(bucketName);

        ReconfigurableObserver obs = new ReconfigurableObserver(rec);
        BucketMonitor monitor = this.monitors.get(bucketName);
        if (monitor == null) {
            URI streamingURI = bucket.getStreamingURI();
            monitor = new BucketMonitor(this.loadedBaseUri.resolve(streamingURI), bucketName, this.restUsr, this.restPwd, configurationParser);
            this.monitors.put(bucketName, monitor);
            monitor.addObserver(obs);
            monitor.startMonitor();
        } else {
View Full Code Here

            monitor.deleteObserver(new ReconfigurableObserver(rec));
        }
    }

    public Config getLatestConfig(String bucketname) throws ConfigurationException {
        Bucket bucket = getBucketConfiguration(bucketname);
        return bucket.getConfig();
    }
View Full Code Here

      if (!bu.isAbsolute()) {
        throw new IllegalArgumentException("The base URI must be absolute");
      }
    }
    this.configurationProvider = new ConfigurationProviderHTTP(baseList, usr, pwd);
    Bucket bucket = this.configurationProvider.getBucketConfiguration(bucketName);
    Config config = bucket.getConfig();
    ConnectionFactoryBuilder cfb = new ConnectionFactoryBuilder();
    if (config.getConfigType() == ConfigType.MEMBASE) {
      cfb.setFailureMode(FailureMode.Retry)
        .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
        .setHashAlg(HashAlgorithm.KETAMA_HASH)
        .setLocatorType(ConnectionFactoryBuilder.Locator.VBUCKET)
        .setVBucketConfig(bucket.getConfig());
    } else if (config.getConfigType() == ConfigType.MEMCACHE) {
      cfb.setFailureMode(FailureMode.Retry)
        .setProtocol(ConnectionFactoryBuilder.Protocol.BINARY)
        .setHashAlg(HashAlgorithm.KETAMA_HASH)
        .setLocatorType(ConnectionFactoryBuilder.Locator.CONSISTENT);
    } else {
      throw new ConfigurationException("Bucket type not supported or JSON response unexpected");
    }
    if (!this.configurationProvider.getAnonymousAuthBucket().equals(bucketName) && usr != null) {
      AuthDescriptor ad = new AuthDescriptor(new String[]{"PLAIN"},
        new PlainCallbackHandler(usr, pwd));
      cfb.setAuthDescriptor(ad);
    }
    ConnectionFactory cf = cfb.build();
    List<InetSocketAddress> addrs = AddrUtil.getAddresses(bucket.getConfig().getServers());
    if(cf == null) {
      throw new NullPointerException("Connection factory required");
    }
    if(addrs == null) {
      throw new NullPointerException("Server list required");
View Full Code Here

TOP

Related Classes of net.spy.memcached.vbucket.config.Bucket

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.