Author: trustin
Date: Sun Nov 14 06:31:57 2004
New Revision: 65595
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
Log:
Fixed: UDPOutputManager.write(ClientKey, ByteBuffer[]) doesn't flip the merged
ByteBuffer nor send any data out.
Added: GatheringOutputEvent.getBuffer() for possible later use
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/event/GatheringOutputEvent.java
Sun Nov 14 06:31:57 2004
@@ -14,7 +14,6 @@
* limitations under the License.
*
*/
-
package org.apache.seda.event;
import java.nio.ByteBuffer;
@@ -42,7 +41,8 @@
* @param clientKey the key of the client
* @param buffers the buffer array containing the chunk to output
*/
- public GatheringOutputEvent(Object source, ClientKey clientKey,
ByteBuffer[] buffers)
+ public GatheringOutputEvent(Object source, ClientKey clientKey,
+ ByteBuffer[] buffers)
{
super(source, clientKey);
this.buffers = buffers;
@@ -56,5 +56,30 @@
public ByteBuffer[] getBuffers()
{
return buffers;
+ }
+
+ /**
+ * Merges all buffers this event contains to a newly allocated
+ * [EMAIL PROTECTED] ByteBuffer} and returns it.
+ */
+ public ByteBuffer getBuffer()
+ {
+ int size = 0;
+
+ for (int i = buffers.length - 1; i >= 0; i--)
+ {
+ size += buffers[i].remaining();
+ }
+
+ ByteBuffer mergedBuf = ByteBuffer.allocate(size);
+
+ for (int i = 0; i < buffers.length; i++)
+ {
+ mergedBuf.put(buffers[i]);
+ }
+
+ mergedBuf.flip();
+
+ return mergedBuf;
}
}
Modified:
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
==============================================================================
---
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
(original)
+++
incubator/directory/seda/trunk/src/java/org/apache/seda/output/UDPOutputManager.java
Sun Nov 14 06:31:57 2004
@@ -146,6 +146,8 @@
{
mergedBuf.put(buffers[i]);
}
+
+ mergedBuf.flip();
udpKey.getSocket().getChannel().send(mergedBuf,
key.getRemoteAddress());
monitor.writeOccurred(this, key);