[infinispan-commits] Infinispan SVN: r1802 - in trunk/server/hotrod/src: test/scala/org/infinispan/server/hotrod and 1 other directory.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue May 18 08:28:06 EDT 2010
Author: galder.zamarreno at jboss.com
Date: 2010-05-18 08:28:01 -0400 (Tue, 18 May 2010)
New Revision: 1802
Modified:
trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala
trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala
Log:
[ISPN-406] (Avoid remote requests to the topology cache) Done.
Modified: trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala
===================================================================
--- trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala 2010-05-18 12:13:42 UTC (rev 1801)
+++ trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala 2010-05-18 12:28:01 UTC (rev 1802)
@@ -18,6 +18,7 @@
*/
class HotRodDecoder(cacheManager: CacheManager) extends AbstractProtocolDecoder[CacheKey, CacheValue] {
import HotRodDecoder._
+ import HotRodServer.TopologyCacheName
type SuitableHeader = HotRodHeader
type SuitableParameters = RequestParameters
@@ -65,6 +66,9 @@
override def getCache(header: HotRodHeader): Cache[CacheKey, CacheValue] = {
val cacheName = header.cacheName
+ if (cacheName == TopologyCacheName)
+ throw new CacheException("Remote requests are not allowed to topology cache. Do no send remote requests to cache " + TopologyCacheName)
+
if (cacheName != DefaultCacheManager.DEFAULT_CACHE_NAME && !cacheManager.getCacheNames.contains(cacheName))
throw new CacheNotFoundException("Cache with name '" + cacheName + "' not found amongst the configured caches")
Modified: trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala
===================================================================
--- trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala 2010-05-18 12:13:42 UTC (rev 1801)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala 2010-05-18 12:28:01 UTC (rev 1802)
@@ -25,6 +25,8 @@
@Test(groups = Array("functional"), testName = "server.hotrod.HotRodFunctionalTest")
class HotRodFunctionalTest extends HotRodSingleNodeTest {
+ import HotRodServer.TopologyCacheName
+
def testUnknownCommand(m: Method) {
val status = client.execute(0xA0, 0x77, cacheName, k(m) , 0, 0, v(m), 0, 1, 0).status
assertEquals(status, UnknownOperation,
@@ -53,11 +55,19 @@
}
def testPutOnUndefinedCache(m: Method) {
- var status = client.execute(0xA0, 0x01, "boomooo", k(m), 0, 0, v(m), 0, 1, 0).status
- assertEquals(status, ServerError, "Status should have been 'ServerError' but instead was: " + status)
+ var resp = client.execute(0xA0, 0x01, "boomooo", k(m), 0, 0, v(m), 0, 1, 0).asInstanceOf[ErrorResponse]
+ assertTrue(resp.msg.contains("CacheNotFoundException"))
+ assertEquals(resp.status, ServerError, "Status should have been 'ServerError' but instead was: " + resp.status)
client.assertPut(m)
}
+ def testPutOnTopologyCache(m: Method) {
+ val resp = client.execute(0xA0, 0x01, TopologyCacheName, k(m), 0, 0, v(m), 0, 1, 0).asInstanceOf[ErrorResponse]
+ assertTrue(resp.msg.contains("Remote requests are not allowed to topology cache."))
+ assertEquals(resp.status, ServerError, "Status should have been 'ServerError' but instead was: " + resp.status)
+ client.assertPut(m)
+ }
+
def testPutWithLifespan(m: Method) {
client.assertPut(m, 1, 0)
Thread.sleep(1100)
More information about the infinispan-commits
mailing list