Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-31 03:52:07 -0500
committerEike Stepper2006-10-31 03:52:07 -0500
commit8d2e9ab07ea993aaf72e98c999100ac671e6d80c (patch)
tree92ca7c9fdb22afd56891feb488073585ea4f7ea5 /plugins/org.eclipse.net4j
parent83a95492d09d812d39fd2b578a7814615a0a57ee (diff)
downloadcdo-8d2e9ab07ea993aaf72e98c999100ac671e6d80c.tar.gz
cdo-8d2e9ab07ea993aaf72e98c999100ac671e6d80c.tar.xz
cdo-8d2e9ab07ea993aaf72e98c999100ac671e6d80c.zip
waitForSignals()
protocolData profiling TCPSelectorImpl.SELECT_TIMEOUT
Diffstat (limited to 'plugins/org.eclipse.net4j')
-rw-r--r--plugins/org.eclipse.net4j/build.properties6
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java19
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java4
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java25
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/PrintTraceHandler.java2
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java14
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java9
13 files changed, 74 insertions, 20 deletions
diff --git a/plugins/org.eclipse.net4j/build.properties b/plugins/org.eclipse.net4j/build.properties
index e6abbde356..666d03a9c6 100644
--- a/plugins/org.eclipse.net4j/build.properties
+++ b/plugins/org.eclipse.net4j/build.properties
@@ -3,4 +3,8 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
- .options
+ .options,\
+ about.html,\
+ copyright.txt,\
+ epl-v10.html,\
+ license.html
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
index 1f041040c8..d80e5d7938 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/AbstractConnector.java
@@ -348,8 +348,13 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
public Channel openChannel(String protocolID) throws ConnectorException
{
+ return openChannel(protocolID, null);
+ }
+
+ public Channel openChannel(String protocolID, Object protocolData) throws ConnectorException
+ {
short channelIndex = findFreeChannelIndex();
- ChannelImpl channel = createChannel(channelIndex, protocolID);
+ ChannelImpl channel = createChannel(channelIndex, protocolID, protocolData);
registerChannelWithPeer(channelIndex, protocolID);
try
@@ -368,10 +373,10 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return channel;
}
- public ChannelImpl createChannel(short channelIndex, String protocolID)
+ public ChannelImpl createChannel(short channelIndex, String protocolID, Object protocolData)
{
ChannelImpl channel = new ChannelImpl(receiveExecutor);
- Protocol protocol = createProtocol(protocolID, channel);
+ Protocol protocol = createProtocol(protocolID, channel, protocolData);
if (TRACER.isEnabled())
{
TRACER.trace(this, "Opening channel " + channelIndex //$NON-NLS-1$
@@ -391,9 +396,9 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
try
{
ChannelImpl channel = channels.get(channelIndex);
- if (channel == null || channel == NULL_CHANNEL)
+ if (channel == NULL_CHANNEL)
{
- throw new NullPointerException();
+ channel = null;
}
return channel;
@@ -467,7 +472,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
channels.set(channelIndex, NULL_CHANNEL);
}
- protected Protocol createProtocol(String protocolID, Channel channel)
+ protected Protocol createProtocol(String protocolID, Channel channel, Object protocolData)
{
if (protocolID == null || protocolID.length() == 0)
{
@@ -491,7 +496,7 @@ public abstract class AbstractConnector extends AbstractLifecycle implements Con
return null;
}
- return factory.createProtocol(channel);
+ return factory.createProtocol(channel, protocolData);
}
protected void fireChannelAboutToOpen(Channel channel)
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
index c1fbcc735f..ffbd48a2a5 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/embedded/AbstractEmbeddedConnector.java
@@ -49,7 +49,7 @@ public abstract class AbstractEmbeddedConnector extends AbstractConnector
{
try
{
- ChannelImpl channel = getPeer().createChannel(channelIndex, protocolID);
+ ChannelImpl channel = getPeer().createChannel(channelIndex, protocolID, null);
if (channel == null)
{
throw new ConnectorException("Failed to register channel with peer"); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
index 38bbe2d756..03daf2521b 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/ControlChannelImpl.java
@@ -105,7 +105,7 @@ public final class ControlChannelImpl extends ChannelImpl
byte[] handlerFactoryUTF8 = BufferUtil.getByteArray(byteBuffer);
String protocolID = BufferUtil.fromUTF8(handlerFactoryUTF8);
ChannelImpl channel = ((AbstractTCPConnector)getConnector()).createChannel(channelIndex,
- protocolID);
+ protocolID, null);
if (channel != null)
{
channel.activate();
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java
index 7c52c7772c..c96c59a385 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/transport/tcp/TCPSelectorImpl.java
@@ -36,7 +36,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_SELECTOR,
TCPSelectorImpl.class);
- private static final long SELECT_TIMEOUT = 100;
+ private static final long SELECT_TIMEOUT = 2;
private Selector selector;
@@ -204,7 +204,7 @@ public class TCPSelectorImpl extends AbstractLifecycle implements TCPSelector, R
try
{
- thread.join(2 * SELECT_TIMEOUT);
+ thread.join(2 * SELECT_TIMEOUT + 200);
}
catch (RuntimeException ex)
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 170f48aa5f..a3e7d0c04c 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -67,6 +67,26 @@ public abstract class SignalProtocol extends AbstractProtocol
this(channel, ((ChannelImpl)channel).getReceiveExecutor());
}
+ public boolean waitForSignals(long timeout)
+ {
+ synchronized (signals)
+ {
+ while (!signals.isEmpty())
+ {
+ try
+ {
+ signals.wait(timeout);
+ }
+ catch (InterruptedException ex)
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
public void handleBuffer(Buffer buffer)
{
ByteBuffer byteBuffer = buffer.getByteBuffer();
@@ -149,6 +169,11 @@ public abstract class SignalProtocol extends AbstractProtocol
{
int correlationID = signal.getCorrelationID();
signals.remove(correlationID);
+
+ synchronized (signals)
+ {
+ signals.notifyAll();
+ }
}
int getNextCorrelationID()
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
index c603b4f962..2d84c79c24 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/Connector.java
@@ -100,6 +100,8 @@ public interface Connector extends IRegistryElement<Integer>
*/
public Channel openChannel(String protocolID) throws ConnectorException;
+ public Channel openChannel(String protocolID, Object protocolData) throws ConnectorException;
+
/**
* Returns the {@link IRegistry} of {@link ProtocolFactory}s associated with
* this connector.
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
index d38effc4f2..611d4acff9 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/ProtocolFactory.java
@@ -38,5 +38,5 @@ public interface ProtocolFactory extends IRegistryElement<String>
public boolean isSymmetric();
- public Protocol createProtocol(Channel channel);
+ public Protocol createProtocol(Channel channel, Object protocolData);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java
index 36ab72a5df..51a00bb00a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferInputStream.java
@@ -37,7 +37,7 @@ public class BufferInputStream extends InputStream implements BufferHandler
private static final ContextTracer TRACER = new ContextTracer(Net4j.DEBUG_BUFFER_STREAM,
BufferInputStream.class);
- private BlockingQueue<Buffer> buffers = new LinkedBlockingQueue<Buffer>();
+ private BlockingQueue<Buffer> buffers = new LinkedBlockingQueue();
private Buffer currentBuffer;
@@ -67,8 +67,7 @@ public class BufferInputStream extends InputStream implements BufferHandler
return -1;
}
- final byte b = currentBuffer.getByteBuffer().get();
- final int result = b < 0 ? ~b : b;
+ final int result = currentBuffer.getByteBuffer().get() & 0xff;
if (TRACER.isEnabled())
{
TRACER.trace(this, "<-- " + HexUtil.toHex(result) //$NON-NLS-1$
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
index bbe5badead..ca612991c1 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/transport/util/BufferOutputStream.java
@@ -75,7 +75,7 @@ public class BufferOutputStream extends OutputStream
}
ByteBuffer buffer = currentBuffer.getByteBuffer();
- buffer.put((byte)(b > Byte.MAX_VALUE ? ~(b + Byte.MIN_VALUE) : b));
+ buffer.put((byte)b);
if (!buffer.hasRemaining())
{
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/PrintTraceHandler.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/PrintTraceHandler.java
index 6bcc19e3d3..d8cae7b5f6 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/PrintTraceHandler.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/om/trace/PrintTraceHandler.java
@@ -36,7 +36,7 @@ public class PrintTraceHandler implements OMTraceHandler
public void traced(Event event)
{
- stream.println("[TRACE] " + event.getMessage()); //$NON-NLS-1$
+ stream.println("[" + event.getInstance() + "] " + event.getMessage()); //$NON-NLS-1$
if (event.getThrowable() != null)
{
IOUtil.print(event.getThrowable(), stream);
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
index b83d9dacaf..9814e3c4fc 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
@@ -27,6 +27,11 @@ public class ExtendedDataInputStream extends DataInputStream implements Extended
public byte[] readByteArray() throws IOException
{
int length = readInt();
+ if (length < 0)
+ {
+ throw new IndexOutOfBoundsException();
+ }
+
byte[] b = new byte[length];
read(b);
return b;
@@ -34,6 +39,13 @@ public class ExtendedDataInputStream extends DataInputStream implements Extended
public String readString() throws IOException
{
- return new String(readByteArray());
+ try
+ {
+ return new String(readByteArray());
+ }
+ catch (IndexOutOfBoundsException ex)
+ {
+ return null;
+ }
}
}
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
index 5b0104a52a..337c2593b3 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataOutputStream.java
@@ -32,6 +32,13 @@ public class ExtendedDataOutputStream extends DataOutputStream implements Extend
public void writeString(String str) throws IOException
{
- writeByteArray(str.getBytes());
+ if (str != null)
+ {
+ writeByteArray(str.getBytes());
+ }
+ else
+ {
+ writeInt(-1);
+ }
}
}

Back to the top