[jboss-cvs] JBossAS SVN: r109548 - in branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid: hotrod and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 29 18:09:53 EST 2010
Author: rachmatowicz at jboss.com
Date: 2010-11-29 18:09:53 -0500 (Mon, 29 Nov 2010)
New Revision: 109548
Added:
branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/
branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node0OnlyBalancingStrategy.java
branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node1OnlyBalancingStrategy.java
Modified:
branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientRemoteCacheManagerTestCase.java
Log:
Update HotRodClintRemoteCacheManagerTestcase
Added: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node0OnlyBalancingStrategy.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node0OnlyBalancingStrategy.java (rev 0)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node0OnlyBalancingStrategy.java 2010-11-29 23:09:53 UTC (rev 109548)
@@ -0,0 +1,71 @@
+package org.jboss.test.cluster.datagrid.hotrod;
+
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import net.jcip.annotations.ThreadSafe;
+
+import org.infinispan.client.hotrod.impl.transport.tcp.RequestBalancingStrategy;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+/*
+ * Load balancing strategy which always sends to node0.
+ */
+ at ThreadSafe
+public class Node0OnlyBalancingStrategy implements RequestBalancingStrategy {
+
+ private static final Log log = LogFactory.getLog(Node0OnlyBalancingStrategy.class);
+
+ private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+ private final Lock readLock = readWriteLock.readLock();
+ private final Lock writeLock = readWriteLock.writeLock();
+
+ private volatile InetSocketAddress[] servers;
+
+ private static String host;
+ private static int port = 11222;
+ private static InetSocketAddress server;
+
+ static {
+ host = System.getProperty("jbosstest.cluster.node0", "localhost") ;
+ server = new InetSocketAddress(host, port) ;
+ if (log.isDebugEnabled())
+ log.trace("node0 server = " + server);
+ }
+
+ /*
+ * This gets called by ReemoteCache upon receiving a toplogy update,
+ * among other callers.
+ */
+ @Override
+ public void setServers(Collection<InetSocketAddress> servers) {
+ writeLock.lock();
+ try {
+ this.servers = servers.toArray(new InetSocketAddress[servers.size()]);
+ if (log.isTraceEnabled()) {
+ log.trace("New server list is: " + Arrays.toString(this.servers));
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Multiple threads might call this method at the same time.
+ */
+ @Override
+ public InetSocketAddress nextServer() {
+ readLock.lock();
+ try {
+ return server;
+ } finally {
+ readLock.unlock();
+ }
+ }
+}
+
Added: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node1OnlyBalancingStrategy.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node1OnlyBalancingStrategy.java (rev 0)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/hotrod/Node1OnlyBalancingStrategy.java 2010-11-29 23:09:53 UTC (rev 109548)
@@ -0,0 +1,71 @@
+package org.jboss.test.cluster.datagrid.hotrod;
+
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import net.jcip.annotations.ThreadSafe;
+
+import org.infinispan.client.hotrod.impl.transport.tcp.RequestBalancingStrategy;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+/*
+ * Load balancing strategy which always sends to node0
+ */
+ at ThreadSafe
+public class Node1OnlyBalancingStrategy implements RequestBalancingStrategy {
+
+ private static final Log log = LogFactory.getLog(Node1OnlyBalancingStrategy.class);
+
+ private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+ private final Lock readLock = readWriteLock.readLock();
+ private final Lock writeLock = readWriteLock.writeLock();
+
+ private volatile InetSocketAddress[] servers;
+
+ private static String host;
+ private static int port = 11222;
+ private static InetSocketAddress server;
+
+ static {
+ host = System.getProperty("jbosstest.cluster.node1", "localhost") ;
+ server = new InetSocketAddress(host, port) ;
+ if (log.isDebugEnabled())
+ log.trace("node1 server = " + server);
+ }
+
+ /*
+ * This gets called by ReemoteCache upon receiving a toplogy update,
+ * among other callers.
+ */
+ @Override
+ public void setServers(Collection<InetSocketAddress> servers) {
+ writeLock.lock();
+ try {
+ this.servers = servers.toArray(new InetSocketAddress[servers.size()]);
+ if (log.isTraceEnabled()) {
+ log.trace("New server list is: " + Arrays.toString(this.servers));
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Multiple threads might call this method at the same time.
+ */
+ @Override
+ public InetSocketAddress nextServer() {
+ readLock.lock();
+ try {
+ return server;
+ } finally {
+ readLock.unlock();
+ }
+ }
+}
+
Modified: branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientRemoteCacheManagerTestCase.java
===================================================================
--- branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientRemoteCacheManagerTestCase.java 2010-11-29 21:23:19 UTC (rev 109547)
+++ branches/JBPAPP_5_1_datagrid/testsuite/src/main/org/jboss/test/cluster/datagrid/test/HotRodClientRemoteCacheManagerTestCase.java 2010-11-29 23:09:53 UTC (rev 109548)
@@ -115,8 +115,10 @@
super.setUp() ;
// per-test setup
- System.out.println("per test tearing down") ;
-
+ System.out.println("per test set up") ;
+ servers = getServers() ;
+ // in case we need it
+ hotRodServerList = servers[0] + ":" + "11222" + ";" + servers[1] + ":" + "11222";
}
/*
@@ -142,6 +144,13 @@
*/
public void testPropertiesConstructor() {
+ Properties props = getRemoteCacheManagerProperties(hotRodServerList);
+ RemoteCacheManager rcm = new RemoteCacheManager(props, false);
+
+ // check started status
+ assert rcm.isStarted() == false;
+ rcm.start();
+ assert rcm.isStarted() == true ;
}
/*
@@ -234,7 +243,45 @@
Map<String,String> cacheElements = c.getBulk();
System.out.println(description + " : " + cacheElements);
}
+
+ private Properties getRemoteCacheManagerProperties(String hotRodServerList) {
+ Properties props = new Properties();
+ // load balancing \
+
+ props.put("infinispan.client.hotrod.request_balancing_strategy",
+ // "org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy");
+ "org.jboss.test.cluster.datagrid.hotrod.Node0OnlyBalancingStrategy");
+ // list of HotRod servers available to connect to \
+
+ props.put("infinispan.client.hotrod.server_list", hotRodServerList);
+ props.put("infinispan.client.hotrod.force_return_values", "false");
+ // TCP stuff \
+
+ props.put("infinispan.client.hotrod.tcp_no_delay", "true");
+ props.put("infinispan.client.hotrod.ping_on_startup", "true");
+ props.put("infinispan.client.hotrod.transport_factory",
+ "org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory");
+ // marshalling \
+
+ props.put("infinispan.client.hotrod.marshaller", "org.infinispan.marshall.jboss.GenericJBossMarshaller");
+ // executors \
+
+ props.put("infinispan.client.hotrod.async_executor_factory",
+ "org.infinispan.client.hotrod.impl.async.DefaultAsyncExecutorFactory");
+ props.put("infinispan.client.hotrod.default_executor_factory.pool_size", "10");
+ props.put("infinispan.client.hotrod.default_executor_factory.queue_size", "100000");
+ // hashing \
+
+ props.put("infinispan.client.hotrod.hash_function_impl.1",
+ "org.infinispan.client.hotrod.impl.consistenthash.ConsistentHashV1");
+ props.put("infinispan.client.hotrod.key_size_estimate", "64");
+ props.put("infinispan.client.hotrod.value_size_estimate", "512");
+
+ return props ;
+ }
}
+
+
More information about the jboss-cvs-commits
mailing list