summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-26 03:38:13 (EDT)
committerEike Stepper2008-05-26 03:38:13 (EDT)
commita3edc0a7cea000746c390e2bb301aeef928fa067 (patch)
tree88d75f5f8b78f9a09b089ec31d91023bdb5486a5
parent070c5fef0db2896d02c4d93241dfd64bdbe4b8c0 (diff)
downloadcdo-a3edc0a7cea000746c390e2bb301aeef928fa067.zip
cdo-a3edc0a7cea000746c390e2bb301aeef928fa067.tar.gz
cdo-a3edc0a7cea000746c390e2bb301aeef928fa067.tar.bz2
[232648] Provide an HTTPConnector
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232648
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java8
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java7
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java39
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java2
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java26
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java4
-rw-r--r--plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/QueuedBuffer.java29
7 files changed, 78 insertions, 37 deletions
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java
index ce1322e..7973daf 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/http/INet4jTransportServlet.java
@@ -21,7 +21,9 @@ public interface INet4jTransportServlet extends Servlet
public static final int OPCODE_OPEN_CHANNEL = 2;
- public static final int OPCODE_SEND_BUFFER = 3;
+ public static final int OPCODE_CLOSE_CHANNEL = 3;
+
+ public static final int OPCODE_BUFFER = 4;
public RequestHandler getRequestHandler();
@@ -38,6 +40,8 @@ public interface INet4jTransportServlet extends Servlet
public void handleOpenChannel(String connectorID, short channelIndex, int channelID, String protocolType);
- public void handleSendBuffer(String connectorID, short channelIndex, byte[] data);
+ public void handleCloseChannel(String connectorID, short channelIndex);
+
+ public void handleBuffer(String connectorID, short channelIndex, byte[] data);
}
}
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java
index 3b411d6..84f75a8 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPAcceptor.java
@@ -165,7 +165,12 @@ public class HTTPAcceptor extends Acceptor implements IHTTPAcceptor, INet4jTrans
channel.activate();
}
- public void handleSendBuffer(String connectorID, short channelIndex, byte[] data)
+ public void handleCloseChannel(String connectorID, short channelIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void handleBuffer(String connectorID, short channelIndex, byte[] data)
{
HTTPServerConnector connector = httpConnectors.get(connectorID);
if (connector == null)
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java
index 0fe0d0e..a13e3ac 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPChannel.java
@@ -10,21 +10,38 @@
**************************************************************************/
package org.eclipse.net4j.internal.http;
+import org.eclipse.net4j.buffer.IBuffer;
+
import org.eclipse.internal.net4j.channel.Channel;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* @author Eike Stepper
*/
public class HTTPChannel extends Channel
{
+ private long outputBufferCount;
+
private long inputBufferCount;
- private long outputBufferCount;
+ private Map<Long, IBuffer> inputBufferQuarantine = new ConcurrentHashMap<Long, IBuffer>();
public HTTPChannel()
{
}
+ public long getOutputBufferCount()
+ {
+ return outputBufferCount;
+ }
+
+ public void increaseOutputBufferCount()
+ {
+ ++outputBufferCount;
+ }
+
public long getInputBufferCount()
{
return inputBufferCount;
@@ -35,13 +52,25 @@ public class HTTPChannel extends Channel
++inputBufferCount;
}
- public long getOutputBufferCount()
+ public void quarantineInputBuffer(long count, IBuffer buffer)
{
- return outputBufferCount;
+ inputBufferQuarantine.put(count, buffer);
}
- public void increaseOutputBufferCount()
+ public IBuffer getQuarantinedInputBuffer(long count)
{
- ++outputBufferCount;
+ return inputBufferQuarantine.remove(count);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ for (IBuffer buffer : inputBufferQuarantine.values())
+ {
+ buffer.release();
+ }
+
+ inputBufferQuarantine.clear();
+ super.doDeactivate();
}
}
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java
index cdcc796..449d871 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPClientConnector.java
@@ -91,7 +91,7 @@ public class HTTPClientConnector extends HTTPConnector
{
public void handleOut(ExtendedDataOutputStream out) throws IOException
{
- out.writeByte(INet4jTransportServlet.OPCODE_SEND_BUFFER);
+ out.writeByte(INet4jTransportServlet.OPCODE_BUFFER);
out.writeString(getConnectorID());
out.writeShort(channel.getChannelIndex());
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java
index 1307536..b4029db 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/HTTPConnector.java
@@ -87,30 +87,4 @@ public abstract class HTTPConnector extends Connector implements IHTTPConnector
{
return new HTTPChannel();
}
-
- /**
- * @author Eike Stepper
- */
- public static final class QueuedBuffer
- {
- private IBuffer buffer;
-
- private long channelCount;
-
- public QueuedBuffer(IBuffer buffer, long channelCount)
- {
- this.buffer = buffer;
- this.channelCount = channelCount;
- }
-
- public IBuffer getBuffer()
- {
- return buffer;
- }
-
- public long getChannelCount()
- {
- return channelCount;
- }
- }
}
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java
index b2801a0..2d622c6 100644
--- a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/Net4jTransportServlet.java
@@ -98,7 +98,7 @@ public class Net4jTransportServlet extends HttpServlet implements INet4jTranspor
doOpenChannel(in, out);
break;
- case OPCODE_SEND_BUFFER:
+ case OPCODE_BUFFER:
doSendBuffer(in, out);
break;
}
@@ -209,7 +209,7 @@ public class Net4jTransportServlet extends HttpServlet implements INet4jTranspor
}
// TODO Consider passing the stream!
- requestHandler.handleSendBuffer(connectorID, channelIndex, data);
+ requestHandler.handleBuffer(connectorID, channelIndex, data);
out.writeBoolean(true);
}
catch (Exception ex)
diff --git a/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/QueuedBuffer.java b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/QueuedBuffer.java
new file mode 100644
index 0000000..9eeed6e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.http/src/org/eclipse/net4j/internal/http/QueuedBuffer.java
@@ -0,0 +1,29 @@
+package org.eclipse.net4j.internal.http;
+
+import org.eclipse.net4j.buffer.IBuffer;
+
+/**
+ * @author Eike Stepper
+ */
+public final class QueuedBuffer
+{
+ private IBuffer buffer;
+
+ private long channelCount;
+
+ public QueuedBuffer(IBuffer buffer, long channelCount)
+ {
+ this.buffer = buffer;
+ this.channelCount = channelCount;
+ }
+
+ public IBuffer getBuffer()
+ {
+ return buffer;
+ }
+
+ public long getChannelCount()
+ {
+ return channelCount;
+ }
+} \ No newline at end of file