[infinispan-commits] Infinispan SVN: r1747 - in trunk/server/hotrod/src: test/scala/org/infinispan/server/hotrod and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Thu May 6 09:50:35 EDT 2010


Author: galder.zamarreno at jboss.com
Date: 2010-05-06 09:50:34 -0400 (Thu, 06 May 2010)
New Revision: 1747

Modified:
   trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodEncoder.scala
   trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodDistributionTest.scala
   trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodMultiNodeTest.scala
   trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodReplicationTest.scala
   trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodTestingUtil.scala
Log:
[ISPN-411] (Implement hash distribution headers in Hot Rod) Sort out testing code to avoid client test classes having to provide a topology cache configuration.

Modified: trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodEncoder.scala
===================================================================
--- trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodEncoder.scala	2010-05-06 11:42:19 UTC (rev 1746)
+++ trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodEncoder.scala	2010-05-06 13:50:34 UTC (rev 1747)
@@ -75,6 +75,7 @@
    }
 
    private def writeTopologyHeader(t: TopologyAwareResponse, buffer: ChannelBuffer) {
+      trace("Write topology change response header {0}", t)
       buffer.writeUnsignedInt(t.view.topologyId)
       buffer.writeUnsignedInt(t.view.members.size)
       t.view.members.foreach{address =>
@@ -85,6 +86,7 @@
 
    // TODO: Spec values when client intel is 3 but cache is not configured with distribution
    private def writeHashTopologyHeader(t: TopologyAwareResponse, buffer: ChannelBuffer) {
+      trace("Return topology change response header in spite of having a hash aware client {0}", t)
       buffer.writeUnsignedInt(t.view.topologyId)
       buffer.writeUnsignedShort(0) // Num key owners
       buffer.writeByte(0) // Hash function
@@ -98,6 +100,7 @@
    }
 
    private def writeHashTopologyHeader(h: HashDistAwareResponse, buffer: ChannelBuffer, r: Response) {
+      trace("Write hash distribution change response header {0}", h)
       buffer.writeUnsignedInt(h.view.topologyId)
       buffer.writeUnsignedShort(h.numOwners) // Num key owners
       buffer.writeByte(h.hashFunction) // Hash function

Modified: trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodDistributionTest.scala
===================================================================
--- trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodDistributionTest.scala	2010-05-06 11:42:19 UTC (rev 1746)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodDistributionTest.scala	2010-05-06 13:50:34 UTC (rev 1747)
@@ -9,7 +9,6 @@
 import test.HotRodTestingUtil._
 import org.testng.Assert._
 import collection.mutable.ListBuffer
-import org.infinispan.server.core.Logging
 import org.infinispan.distribution.UnionConsistentHash
 import org.infinispan.test.TestingUtil
 
@@ -56,7 +55,6 @@
 
       var cm = addClusterEnabledCacheManager()
       cm.defineConfiguration(cacheName, createCacheConfig)
-      cm.defineConfiguration(TopologyCacheName, createTopologyCacheConfig)
       val newServer = startHotRodServer(cm, servers.tail.head.getPort + 25)
       val newClient = new HotRodClient("127.0.0.1", newServer.getPort, cacheName, 60)
       try {

Modified: trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodMultiNodeTest.scala
===================================================================
--- trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodMultiNodeTest.scala	2010-05-06 11:42:19 UTC (rev 1746)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodMultiNodeTest.scala	2010-05-06 13:50:34 UTC (rev 1747)
@@ -6,7 +6,6 @@
 import test.HotRodClient
 import test.HotRodTestingUtil._
 import org.infinispan.config.Configuration.CacheMode
-import org.testng.Assert._
 
 /**
  * // TODO: Document this
@@ -23,7 +22,6 @@
       for (i <- 0 until 2) {
          val cm = addClusterEnabledCacheManager()
          cm.defineConfiguration(cacheName, createCacheConfig)
-         cm.defineConfiguration(TopologyCacheName, createTopologyCacheConfig)
       }
       hotRodServers = hotRodServers ::: List(startHotRodServer(cacheManagers.get(0)))
       hotRodServers = hotRodServers ::: List(startHotRodServer(cacheManagers.get(1), hotRodServers.head.getPort + 50))
@@ -53,14 +51,4 @@
 
    protected def createCacheConfig: Configuration
 
-   protected def createTopologyCacheConfig: Configuration = {
-      val topologyCacheConfig = new Configuration
-      topologyCacheConfig.setCacheMode(CacheMode.REPL_SYNC)
-      topologyCacheConfig.setSyncReplTimeout(10000) // Milliseconds
-      topologyCacheConfig.setFetchInMemoryState(true) // State transfer required
-      topologyCacheConfig.setSyncCommitPhase(true) // Only for testing, so that asserts work fine.
-      topologyCacheConfig.setSyncRollbackPhase(true) // Only for testing, so that asserts work fine.
-      topologyCacheConfig
-   }
-
 }
\ No newline at end of file

Modified: trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodReplicationTest.scala
===================================================================
--- trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodReplicationTest.scala	2010-05-06 11:42:19 UTC (rev 1746)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodReplicationTest.scala	2010-05-06 13:50:34 UTC (rev 1747)
@@ -17,8 +17,6 @@
 @Test(groups = Array("functional"), testName = "server.hotrod.HotRodReplicationTest")
 class HotRodReplicationTest extends HotRodMultiNodeTest {
 
-   import HotRodServer._
-
    override protected def cacheName: String = "hotRodReplSync"
 
    override protected def createCacheConfig: Configuration = {
@@ -92,7 +90,6 @@
 
       var cm = addClusterEnabledCacheManager()
       cm.defineConfiguration(cacheName, createCacheConfig)
-      cm.defineConfiguration(TopologyCacheName, createTopologyCacheConfig)
       val newServer = startHotRodServer(cm, servers.tail.head.getPort + 25)
 
       try {
@@ -119,7 +116,6 @@
 
       cm = addClusterEnabledCacheManager()
       cm.defineConfiguration(cacheName, createCacheConfig)
-      cm.defineConfiguration(TopologyCacheName, createTopologyCacheConfig)
       val crashingServer = startCrashingHotRodServer(cm, servers.tail.head.getPort + 11)
 
       try {

Modified: trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodTestingUtil.scala
===================================================================
--- trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodTestingUtil.scala	2010-05-06 11:42:19 UTC (rev 1746)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodTestingUtil.scala	2010-05-06 13:50:34 UTC (rev 1747)
@@ -9,6 +9,8 @@
 import org.testng.Assert._
 import org.infinispan.util.Util
 import org.infinispan.server.hotrod._
+import org.infinispan.config.Configuration.CacheMode
+import org.infinispan.config.Configuration
 
 /**
  * // TODO: Document this
@@ -29,8 +31,9 @@
 
    def startHotRodServer(manager: CacheManager, port: Int, idleTimeout: Int): HotRodServer = {
       val server = new HotRodServer {
+         import HotRodServer._
          override protected def defineTopologyCacheConfig(cacheManager: CacheManager) {
-            // No-op since topology cache configuration comes defined by the test
+            cacheManager.defineConfiguration(TopologyCacheName, createTopologyCacheConfig)
          }
       }
       server.start(host, port, manager, 0, 0, idleTimeout)
@@ -39,8 +42,9 @@
 
    def startCrashingHotRodServer(manager: CacheManager, port: Int): HotRodServer = {
       val server = new HotRodServer {
+         import HotRodServer._
          override protected def defineTopologyCacheConfig(cacheManager: CacheManager) {
-            // No-op since topology cache configuration comes defined by the test
+            cacheManager.defineConfiguration(TopologyCacheName, createTopologyCacheConfig)
          }
 
          override protected def removeSelfFromTopologyView {
@@ -136,6 +140,16 @@
       assertEquals(actual.port, expected.port)
       assertEquals(actual.hashIds, expectedHashIds)
    }
+
+   private def createTopologyCacheConfig: Configuration = {
+      val topologyCacheConfig = new Configuration
+      topologyCacheConfig.setCacheMode(CacheMode.REPL_SYNC)
+      topologyCacheConfig.setSyncReplTimeout(10000) // Milliseconds
+      topologyCacheConfig.setFetchInMemoryState(true) // State transfer required
+      topologyCacheConfig.setSyncCommitPhase(true) // Only for testing, so that asserts work fine.
+      topologyCacheConfig.setSyncRollbackPhase(true) // Only for testing, so that asserts work fine.
+      topologyCacheConfig
+   }
    
 } 
 



More information about the infinispan-commits mailing list