[infinispan-commits] Infinispan SVN: r1896 - in trunk: client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport and 5 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu Jun 10 10:01:59 EDT 2010
Author: galder.zamarreno at jboss.com
Date: 2010-06-10 10:01:57 -0400 (Thu, 10 Jun 2010)
New Revision: 1896
Modified:
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java
trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java
trunk/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala
trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala
trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala
trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala
Log:
[ISPN-489] (Avoid reading cache name for default cache in Hot Rod) Done.
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-06-10 13:56:45 UTC (rev 1895)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-06-10 14:01:57 UTC (rev 1896)
@@ -286,7 +286,7 @@
}
public <K, V> RemoteCache<K, V> getCache(boolean forceReturnValue) {
- return createRemoteCache(DefaultCacheManager.DEFAULT_CACHE_NAME, forceReturnValue);
+ return createRemoteCache("", forceReturnValue);
}
@Override
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java 2010-06-10 13:56:45 UTC (rev 1895)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java 2010-06-10 14:01:57 UTC (rev 1896)
@@ -82,7 +82,11 @@
@Override
public void writeString(String string) {
- writeArray(string.getBytes(CHARSET));
+ if (!string.isEmpty()) {
+ writeArray(string.getBytes(CHARSET));
+ } else {
+ writeVInt(0);
+ }
}
@Override
Modified: trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java
===================================================================
--- trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java 2010-06-10 13:56:45 UTC (rev 1895)
+++ trunk/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java 2010-06-10 14:01:57 UTC (rev 1896)
@@ -45,7 +45,7 @@
if (log.isTraceEnabled()) {
log.trace("About to validate(ping) connection to server " + key + ". TcpTransport is " + transport);
}
- long messageId = HotRodOperationsHelper.writeHeader(transport, HotRodConstants.PING_REQUEST, DefaultCacheManager.DEFAULT_CACHE_NAME, topologyId);
+ long messageId = HotRodOperationsHelper.writeHeader(transport, HotRodConstants.PING_REQUEST, "", topologyId);
short respStatus = HotRodOperationsHelper.readHeaderAndValidate(transport, messageId, HotRodConstants.PING_RESPONSE, topologyId);
if (respStatus == HotRodConstants.NO_ERROR_STATUS) {
if (log.isTraceEnabled())
Modified: trunk/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala
===================================================================
--- trunk/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala 2010-06-10 13:56:45 UTC (rev 1895)
+++ trunk/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala 2010-06-10 14:01:57 UTC (rev 1896)
@@ -21,16 +21,29 @@
override def readerIndex: Int = readerIndex
override def readBytes(dst: Array[Byte]) = buffer.readBytes(dst)
override def readRangedBytes: Array[Byte] = {
- val array = new Array[Byte](readUnsignedInt)
- readBytes(array)
- array;
+ val length = readUnsignedInt
+ if (length > 0) {
+ val array = new Array[Byte](length)
+ readBytes(array)
+ array;
+ } else {
+ Array[Byte]()
+ }
}
override def readableBytes = buffer.writerIndex - buffer.readerIndex
/**
* Reads length of String and then returns an UTF-8 formatted String of such length.
+ * If the length is 0, an empty String is returned.
*/
- override def readString: String = new String(readRangedBytes, "UTF8")
+ override def readString: String = {
+ val bytes = readRangedBytes
+ if (!bytes.isEmpty) {
+ new String(bytes, "UTF8")
+ } else {
+ ""
+ }
+ }
override def readLong: Long = buffer.readLong
override def readInt: Int = buffer.readInt
override def writeByte(value: Byte) = buffer.writeByte(value)
@@ -59,4 +72,4 @@
}
-object ChannelBufferAdapter extends Logging
\ No newline at end of file
+object ChannelBufferAdapter extends Logging
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-06-10 13:56:45 UTC (rev 1895)
+++ trunk/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala 2010-06-10 14:01:57 UTC (rev 1896)
@@ -72,10 +72,10 @@
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))
+ if (!cacheName.isEmpty && !cacheManager.getCacheNames.contains(cacheName))
throw new CacheNotFoundException("Cache with name '" + cacheName + "' not found amongst the configured caches")
- if (cacheName == DefaultCacheManager.DEFAULT_CACHE_NAME) cacheManager.getCache[ByteArrayKey, CacheValue]
+ if (cacheName.isEmpty) cacheManager.getCache[ByteArrayKey, CacheValue]
else cacheManager.getCache(cacheName)
}
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-06-10 13:56:45 UTC (rev 1895)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala 2010-06-10 14:01:57 UTC (rev 1896)
@@ -49,7 +49,7 @@
}
def testPutOnDefaultCache(m: Method) {
- val status = client.execute(0xA0, 0x01, DefaultCacheManager.DEFAULT_CACHE_NAME, k(m), 0, 0, v(m), 0, 1, 0).status
+ val status = client.execute(0xA0, 0x01, "", k(m), 0, 0, v(m), 0, 1, 0).status
assertStatus(status, Success)
val cache = cacheManager.getCache[ByteArrayKey, CacheValue]
val value = cache.get(new ByteArrayKey(k(m)))
Modified: trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala
===================================================================
--- trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala 2010-06-10 13:56:45 UTC (rev 1895)
+++ trunk/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala 2010-06-10 14:01:57 UTC (rev 1896)
@@ -228,7 +228,11 @@
buffer.writeUnsignedLong(op.id) // message id
buffer.writeByte(10) // version
buffer.writeByte(op.code) // opcode
- buffer.writeRangedBytes(op.cacheName.getBytes()) // cache name length + cache name
+ if (!op.cacheName.isEmpty) {
+ buffer.writeRangedBytes(op.cacheName.getBytes()) // cache name length + cache name
+ } else {
+ buffer.writeUnsignedInt(0) // Zero length
+ }
buffer.writeUnsignedInt(op.flags) // flags
buffer.writeByte(op.clientIntel) // client intelligence
buffer.writeUnsignedInt(op.topologyId) // topology id
@@ -478,4 +482,4 @@
class TestStatsResponse(override val messageId: Long, override val cacheName: String,
override val clientIntel: Short, val stats: Map[String, String],
override val topologyId: Int, override val topologyResponse: Option[AbstractTopologyResponse])
- extends TestResponse(messageId, cacheName, clientIntel, StatsResponse, Success, topologyId, topologyResponse)
\ No newline at end of file
+ extends TestResponse(messageId, cacheName, clientIntel, StatsResponse, Success, topologyId, topologyResponse)
More information about the infinispan-commits
mailing list