Examples of RedisClient


Examples of com.lambdaworks.redis.RedisClient

    }

    public void addSlave(String host, int port) {
        slaveDown(masterEntry.getClient().getAddr().getHostName(), masterEntry.getClient().getAddr().getPort());

        RedisClient client = new RedisClient(group, host, port, config.getTimeout());
        slaveBalancer.add(new SubscribesConnectionEntry(client,
                this.config.getSlaveConnectionPoolSize(),
                this.config.getSlaveSubscriptionConnectionPoolSize()));
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        c.setSlaveSubscriptionConnectionPoolSize(cfg.getSlaveSubscriptionConnectionPoolSize());
        c.setSubscriptionsPerConnection(cfg.getSubscriptionsPerConnection());

        final Set<String> addedSlaves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
        for (URI addr : cfg.getSentinelAddresses()) {
            RedisClient client = new RedisClient(group, addr.getHost(), addr.getPort(), cfg.getTimeout());
            RedisAsyncConnection<String, String> connection = client.connectAsync();

            // TODO async
            List<String> master = connection.getMasterAddrByKey(cfg.getMasterName()).awaitUninterruptibly().getNow();
            String masterHost = master.get(0) + ":" + master.get(1);
            c.setMasterAddress(masterHost);
            log.info("master: {}", masterHost);
//            c.addSlaveAddress(masterHost);

            // TODO async
            List<Map<String, String>> slaves = connection.slaves(cfg.getMasterName()).awaitUninterruptibly().getNow();
            for (Map<String, String> map : slaves) {
                String ip = map.get("ip");
                String port = map.get("port");
                log.info("slave: {}:{}", ip, port);
                c.addSlaveAddress(ip + ":" + port);
                String host = ip + ":" + port;
                addedSlaves.add(host);
            }

            client.shutdown();
            break;
        }

        init(c);
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

    private void monitorMasterChange(final SentinelServersConfig cfg, final Set<String> addedSlaves) {
        final AtomicReference<String> master = new AtomicReference<String>();
        final Set<String> freezeSlaves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());

        for (final URI addr : cfg.getSentinelAddresses()) {
            RedisClient client = new RedisClient(group, addr.getHost(), addr.getPort(), cfg.getTimeout());
            sentinels.add(client);

            RedisPubSubConnection<String, String> pubsub = client.connectPubSub();
            pubsub.addListener(new RedisPubSubAdapter<String>() {
                @Override
                public void subscribed(String channel, long count) {
                    log.info("subscribed to channel: {} from Sentinel {}:{}", channel, addr.getHost(), addr.getPort());
                }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        super(codec, group, config);
    }

    @Override
    public void setupMasterEntry(String host, int port) {
        RedisClient masterClient = new RedisClient(group, host, port, config.getTimeout());
        masterEntry = new SubscribesConnectionEntry(masterClient, config.getMasterConnectionPoolSize(), config.getSlaveSubscriptionConnectionPoolSize());
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        return RedisClient.class;
    }

    @Override
    protected RedisClient createInstance() throws Exception {
        return new RedisClient(getRedisURI());
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        return RedisClient.class;
    }

    @Override
    protected RedisClient createInstance() throws Exception {
        return new RedisClient(getRedisURI());
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

     * @param redisURI
     * @return RedisClient
     */
    @Produces
    public RedisClient create(RedisURI redisURI) {
        return new RedisClient(redisURI);
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

    public RedisClient create(CreationalContext<RedisClient> creationalContext) {

        CreationalContext<RedisURI> uriCreationalContext = beanManager.createCreationalContext(redisURIBean);
        RedisURI redisURI = (RedisURI) beanManager.getReference(redisURIBean, RedisURI.class, uriCreationalContext);

        return new RedisClient(redisURI);
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        return RedisClient.class;
    }

    @Override
    protected RedisClient createInstance() throws Exception {
        return new RedisClient(getRedisURI());
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

  private RedisClient createRedisClient() {
    if (pool != null) {
      return pool.getClient();
    }
    RedisClient client = password != null ? new AuthenticatingRedisClient(hostName, port, password) : new RedisClient(
        hostName, port);
    client.setDefaultTimeout(timeout, TimeUnit.MILLISECONDS);
    return client;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.