/*
 * Opennaru, Inc. http://www.opennaru.com/
 *
 *  Copyright (C) 2014 Opennaru, Inc. and/or its affiliates.
 *  All rights reserved by Opennaru, Inc.
 *
 *  This is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU Lesser General Public License as
 *  published by the Free Software Foundation; either version 2.1 of
 *  the License, or (at your option) any later version.
 *
 *  This software is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this software; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 *  02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package test;

import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;

import java.util.Iterator;
import java.util.Set;

/**
 * @author Junshik Jeon(service@opennaru.com, nameislocus@gmail.com)
 */
public class RemoteCaches {
    public RemoteCaches() {

    }

    public void test() {

        RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.22:11422;192.168.0.23:11322", true);
        RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION");

        Set<Object> keySet = cache.keySet();

        Iterator<Object> i = keySet.iterator();
        System.out.println("=============");
        while (i.hasNext()) {
            Object key = i.next();
            System.out.println("> key=" + key);
            Object value = cache.get(key);
            System.out.println("> value=" + value);
            System.out.println("");
        }
        System.out.println("=============");
    }


    public void test2() {
        RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.22:11422;192.168.0.23:11322", true);
        RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_LOGIN");

        Set<Object> keySet = cache.keySet();

        Iterator<Object> i = keySet.iterator();
        System.out.println("=============");
        while (i.hasNext()) {
            Object key = i.next();
            System.out.println("> key=" + key);
            Object value = cache.get(key);
            System.out.println("> value=" + value);
            System.out.println("");
        }
        System.out.println("=============");
    }

    public void testRemoteCache() {
        RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.22:11422;192.168.0.23:11322", true);
        RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_REMOTE");

        Set<Object> keySet = cache.keySet();

        Iterator<Object> i = keySet.iterator();
        System.out.println("============= KHAN_SESSION_REMOTE");
        while (i.hasNext()) {
            Object key = i.next();
            System.out.println("> key=" + key);
            Object value = cache.get(key);
            System.out.println("> value=" + value);
            System.out.println("");
        }
        System.out.println("=============");
    }

    public void testRemoteLoginCache() {
        RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.22:11422;192.168.0.23:11322", true);
        RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_LOGIN_REMOTE");

        Set<Object> keySet = cache.keySet();

        Iterator<Object> i = keySet.iterator();
        System.out.println("============= KHAN_SESSION_LOGIN_REMOTE");
        while (i.hasNext()) {
            Object key = i.next();
            System.out.println("> key=" + key);
            Object value = cache.get(key);
            System.out.println("> value=" + value);
            System.out.println("");
        }
        System.out.println("=============");
    }

    public static void main(String[] args) {
        RemoteCaches remoteCaches = new RemoteCaches();
        remoteCaches.test();
        remoteCaches.test2();

        remoteCaches.testRemoteCache();
        remoteCaches.testRemoteLoginCache();
    }
}

@@ -1345,37 +1345,37 @@
 ger(%22192.168.0.2
-2:114
+3:113
 22;192.168.0.23:
@@ -1368,33 +1368,33 @@
 ;192.168.0.23:11
-3
+4
 22%22, true);%0A    
@@ -1600,32 +1600,45 @@
 n(%22=============
+ KHAN_SESSION
 %22);%0A        whil
@@ -2027,37 +2027,37 @@
 ger(%22192.168.0.2
-2:114
+3:113
 22;192.168.0.23:
@@ -2050,33 +2050,33 @@
 ;192.168.0.23:11
-3
+4
 22%22, true);%0A    
@@ -2247,32 +2247,32 @@
 Set.iterator();%0A
-
         System.o
@@ -2288,32 +2288,51 @@
 n(%22=============
+ KHAN_SESSION_LOGIN
 %22);%0A        whil

Test Config