[infinispan-commits] Infinispan SVN: r1895 - in branches/4.1.x: 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 09:56:46 EDT 2010
Author: galder.zamarreno at jboss.com
Date: 2010-06-10 09:56:45 -0400 (Thu, 10 Jun 2010)
New Revision: 1895
Modified:
branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java
branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java
branches/4.1.x/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala
branches/4.1.x/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala
branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala
branches/4.1.x/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: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/RemoteCacheManager.java 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/AbstractTransport.java 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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: branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java
===================================================================
--- branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/client/hotrod-client/src/main/java/org/infinispan/client/hotrod/impl/transport/tcp/TransportObjectFactory.java 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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: branches/4.1.x/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala
===================================================================
--- branches/4.1.x/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/server/core/src/main/scala/org/infinispan/server/core/transport/netty/ChannelBufferAdapter.scala 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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)
Modified: branches/4.1.x/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala
===================================================================
--- branches/4.1.x/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/server/hotrod/src/main/scala/org/infinispan/server/hotrod/HotRodDecoder.scala 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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: branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala
===================================================================
--- branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/HotRodFunctionalTest.scala 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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: branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala
===================================================================
--- branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala 2010-06-10 12:39:02 UTC (rev 1894)
+++ branches/4.1.x/server/hotrod/src/test/scala/org/infinispan/server/hotrod/test/HotRodClient.scala 2010-06-10 13:56:45 UTC (rev 1895)
@@ -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
More information about the infinispan-commits
mailing list