Examples of RedisClient


Examples of com.baidu.disconf.ub.common.redis.RedisClient

     * @param authKey
     * @param timeOut
     */
    public ContextMgr(String redisServer, int port, String authKey, int timeOut) {

        client = new RedisClient();
        client.setRedisServerHost(redisServer);
        client.setRedisServerPort(port);
        client.setRedisAuthKey(authKey);
        client.setTimeout(timeOut);

View Full Code Here

Examples of com.baidu.disconf.ub.common.redis.RedisClient

     * @param authKey
     * @param timeOut
     */
    public ContextMgr(String redisServer, int port, String authKey, int timeOut) {

        client = new RedisClient();
        client.setRedisServerHost(redisServer);
        client.setRedisServerPort(port);
        client.setRedisAuthKey(authKey);
        client.setTimeout(timeOut);

View Full Code Here

Examples of com.impetus.client.redis.RedisClient

    public void testCRUD()
    {
        logger.info("On testInsert");
        EntityManager em = emf.createEntityManager();
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        RedisClient client = (RedisClient) clients.get(REDIS_PU);
        onInsert(client);
        onUpdate(client);
        onDelete(client);
        em.close();
    }
View Full Code Here

Examples of com.impetus.client.redis.RedisClient

        Map<String, String> batchProperty = new HashMap<String, String>(1);
        batchProperty.put(PersistenceProperties.KUNDERA_BATCH_SIZE, "5");
        EntityManagerFactory emf = Persistence.createEntityManagerFactory(REDIS_PU, batchProperty);
        EntityManager em = emf.createEntityManager();
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        RedisClient client = (RedisClient) clients.get(REDIS_PU);
        Assert.assertEquals(5, ((Batcher) client).getBatchSize());

        final String originalName = "vivek";

        for (int i = 0; i < 9; i++)
        {
            PersonRedis object = new PersonRedis();
            object.setAge(32);
            object.setPersonId(ROW_KEY + i);
            object.setPersonName(originalName);
            em.persist(object);

            if (i >= 5)
            {
                PersonRedis result = (PersonRedis) client.find(PersonRedis.class, ROW_KEY + i);
                Assert.assertNull(result);
            }
            else if (i > 0 && i % 4 == 0)
            {
                PersonRedis result = (PersonRedis) client.find(PersonRedis.class, ROW_KEY + i);
                Assert.assertNotNull(result);
                Assert.assertEquals(result.getPersonId(), object.getPersonId());
                Assert.assertEquals(result.getAge(), object.getAge());
                Assert.assertEquals(result.getPersonName(), object.getPersonName());
            }
View Full Code Here

Examples of com.impetus.client.redis.RedisClient

        joinTableData.addJoinTableRecord(joinKey, inverseJoinKeys);

        EntityManager em = emf.createEntityManager();
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        RedisClient client = (RedisClient) clients.get(REDIS_PU);
        client.persistJoinTable(joinTableData);

        List<String> columns = client.getColumnsById(schemaName, tableName, joinColumn, inverseJoinColumn, joinKey,
                String.class);

        Assert.assertNotNull(columns);
        Assert.assertEquals(true, !columns.isEmpty());
        Assert.assertEquals(2, columns.size());
        Assert.assertEquals(true, columns.contains(inverseJoinKey1.toString()));
        Assert.assertEquals(true, columns.contains(inverseJoinKey2.toString()));

        client.deleteByColumn(schemaName, tableName, inverseJoinColumn, inverseJoinKey1);
        client.deleteByColumn(schemaName, tableName, inverseJoinColumn, inverseJoinKey2);

        columns = client.getColumnsById(schemaName, tableName, joinColumn, inverseJoinColumn, joinKey, String.class);

        Assert.assertTrue(columns.isEmpty());

    }
View Full Code Here

Examples of com.impetus.client.redis.RedisClient

            Object connectionObj = connectionField.get(clientFactory);
          
            EntityManager em = emf.createEntityManager();
            Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
            RedisClient redisClient = (RedisClient) clients.get(REDIS_PU);
            Assert.assertEquals(5, ((Batcher) redisClient).getBatchSize());
            Field field=redisClient.getClass().getDeclaredField("connection");
            field.setAccessible(true);
            Jedis connection=(Jedis) field.get(redisClient);
            Assert.assertEquals(6379, connection.getClient().getPort());
            Assert.assertEquals("localhost", connection.getClient().getHost());
            Assert.assertEquals(20000, connection.getClient().getTimeout());
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        init(config);

        Map<String, ClusterPartition> partitions = new HashMap<String, ClusterPartition>();

        for (URI addr : cfg.getNodeAddresses()) {
            RedisClient client = new RedisClient(group, addr.getHost(), addr.getPort(), cfg.getTimeout());
            RedisAsyncConnection<String, String> connection = client.connectAsync();
            String nodesValue = connection.clusterNodes().awaitUninterruptibly().getNow();
            System.out.println(nodesValue);

            List<ClusterNodeInfo> nodes = parse(nodesValue);
            for (ClusterNodeInfo clusterNodeInfo : nodes) {
                String id = clusterNodeInfo.getNodeId();
                if (clusterNodeInfo.getFlags().contains(Flag.SLAVE)) {
                    id = clusterNodeInfo.getSlaveOf();
                }
                ClusterPartition partition = partitions.get(id);
                if (partition == null) {
                    partition = new ClusterPartition();
                    partitions.put(id, partition);
                }

                if (clusterNodeInfo.getFlags().contains(Flag.FAIL)) {
                    partition.setMasterFail(true);
                }

                if (clusterNodeInfo.getFlags().contains(Flag.SLAVE)) {
                    partition.addSlaveAddress(clusterNodeInfo.getAddress());
                } else {
                    partition.setEndSlot(clusterNodeInfo.getEndSlot());
                    partition.setMasterAddress(clusterNodeInfo.getAddress());
                }
            }

            for (ClusterPartition partition : partitions.values()) {
                if (partition.isMasterFail()) {
                    continue;
                }

                MasterSlaveServersConfig c = create(cfg);
                log.info("master: {}", partition.getMasterAddress());
                c.setMasterAddress(partition.getMasterAddress());
                for (String slaveAddress : partition.getSlaveAddresses()) {
                    log.info("slave: {}", slaveAddress);
                    c.addSlaveAddress(slaveAddress);
                }

                MasterSlaveEntry entry = new MasterSlaveEntry(codec, group, c);
                entries.put(partition.getEndSlot(), entry);
            }

            client.shutdown();
            break;
        }

        this.config = create(cfg);
    }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        final AtomicReference<String> master = new AtomicReference<String>();
        final Set<String> freezeSlaves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
        final Set<String> addedSlaves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());

        for (final URI addr : cfg.getSentinelAddresses()) {
            RedisClient client = new RedisClient(group, addr.getHost(), addr.getPort(), cfg.getTimeout());
            nodeClients.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

        slaveBalancer.init(codec, config);

        List<URI> addresses = new ArrayList<URI>(config.getSlaveAddresses());
        addresses.add(config.getMasterAddress());
        for (URI address : addresses) {
            RedisClient client = new RedisClient(group, address.getHost(), address.getPort(), config.getTimeout());
            SubscribesConnectionEntry entry = new SubscribesConnectionEntry(client,
                    config.getSlaveConnectionPoolSize(),
                    config.getSlaveSubscriptionConnectionPoolSize());
            slaveBalancer.add(entry);
        }
View Full Code Here

Examples of com.lambdaworks.redis.RedisClient

        setupMasterEntry(config.getMasterAddress().getHost(), config.getMasterAddress().getPort());
    }

    public void setupMasterEntry(String host, int port) {
        RedisClient masterClient = new RedisClient(group, host, port, config.getTimeout());
        masterEntry = new ConnectionEntry(masterClient, config.getMasterConnectionPoolSize());
    }
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.