Author: david.lloyd(a)jboss.com
Date: 2010-02-28 20:02:47 -0500 (Sun, 28 Feb 2010)
New Revision: 5776
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryExternalizerFactory.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryObjectTable.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ReceivedRequestHandlerConnector.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/UnsentRequestHandlerConnector.java
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientAuthenticationHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerAuthenticationHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderContext.java
Log:
Make ClientConnector work across remote connections; begin to specify externalizers and
tables
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/EndpointImpl.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -723,8 +723,8 @@
return getMapFor(serviceType).get(name);
}
- public String getEndpointName() {
- return getName();
+ public Endpoint getEndpoint() {
+ return EndpointImpl.this;
}
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientAuthenticationHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientAuthenticationHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ClientAuthenticationHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -26,7 +26,6 @@
import java.nio.ByteBuffer;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
-import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.remoting3.CloseHandler;
import org.jboss.remoting3.spi.ConnectionHandler;
import org.jboss.remoting3.spi.ConnectionHandlerContext;
@@ -127,8 +126,7 @@
public ConnectionHandler createInstance(final
ConnectionHandlerContext connectionContext) {
// this happens immediately.
final MarshallerFactory marshallerFactory =
Marshalling.getMarshallerFactory("river");
- final MarshallingConfiguration marshallingConfiguration = new
MarshallingConfiguration();
- final RemoteConnectionHandler connectionHandler = new
RemoteConnectionHandler(connectionContext, remoteConnection, marshallerFactory,
marshallingConfiguration);
+ final RemoteConnectionHandler connectionHandler = new
RemoteConnectionHandler(connectionContext, remoteConnection, marshallerFactory);
remoteConnection.addCloseHandler(new CloseHandler<Object>()
{
public void handleClose(final Object closed) {
IoUtils.safeClose(connectionHandler);
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -52,8 +52,13 @@
try {
RemoteConnectionHandler.log.trace("Unmarshalling inbound
reply");
unmarshaller.start(outboundRequest.getByteInput());
- reply = unmarshaller.readObject();
- unmarshaller.close();
+ final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ try {
+ reply = unmarshaller.readObject();
+ unmarshaller.close();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
RemoteConnectionHandler.log.trace("Unmarshalled inbound reply
%s", reply);
} finally {
IoUtils.safeClose(unmarshaller);
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -55,8 +55,13 @@
try {
RemoteConnectionHandler.log.trace("Unmarshalling inbound
request");
unmarshaller.start(inboundRequest.getByteInput());
- request = unmarshaller.readObject();
- unmarshaller.close();
+ final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(remoteConnectionHandler);
+ try {
+ request = unmarshaller.readObject();
+ unmarshaller.close();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
RemoteConnectionHandler.log.trace("Unmarshalled inbound request
%s", request);
} finally {
IoUtils.safeClose(unmarshaller);
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -46,8 +46,13 @@
final RemoteConnectionHandler connectionHandler =
inboundRequest.getRemoteConnectionHandler();
final Marshaller marshaller =
connectionHandler.getMarshallerFactory().createMarshaller(connectionHandler.getMarshallingConfiguration());
marshaller.start(new NioByteOutput(new
OutboundReplyBufferWriter(inboundRequest, rid, false)));
- marshaller.writeObject(reply);
- marshaller.finish();
+ final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ try {
+ marshaller.writeObject(reply);
+ marshaller.finish();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
}
}
@@ -58,8 +63,13 @@
try {
final Marshaller marshaller =
connectionHandler.getMarshallerFactory().createMarshaller(connectionHandler.getMarshallingConfiguration());
marshaller.start(new NioByteOutput(new
OutboundReplyBufferWriter(inboundRequest, rid, true)));
- marshaller.writeObject(exception);
- marshaller.finish();
+ final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ try {
+ marshaller.writeObject(exception);
+ marshaller.finish();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
ok = true;
} finally {
if (! ok) {
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -57,11 +57,16 @@
}
final NioByteOutput byteOutput = new NioByteOutput(new
OutboundRequestBufferWriter(outboundRequest, rid));
try {
- RemoteConnectionHandler.log.trace("Starting sending request %s",
request);
+ RemoteConnectionHandler.log.trace("Starting sending request %s for
%s", request, Integer.valueOf(rid));
final Marshaller marshaller =
connectionHandler.getMarshallerFactory().createMarshaller(connectionHandler.getMarshallingConfiguration());
marshaller.start(byteOutput);
- marshaller.writeObject(request);
- marshaller.finish();
+ RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ try {
+ marshaller.writeObject(request);
+ marshaller.finish();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
RemoteConnectionHandler.log.trace("Finished sending request %s",
request);
} catch (IOException e) {
RemoteConnectionHandler.log.trace(e, "Got exception while marshalling
request %s", request);
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryExternalizerFactory.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryExternalizerFactory.java
(rev 0)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryExternalizerFactory.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.remote;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.jboss.marshalling.ClassExternalizerFactory;
+import org.jboss.marshalling.Creator;
+import org.jboss.marshalling.Externalizer;
+
+final class PrimaryExternalizerFactory implements ClassExternalizerFactory {
+
+ static final ClassExternalizerFactory INSTANCE = new PrimaryExternalizerFactory();
+
+ public Externalizer getExternalizer(final Class<?> type) {
+ if (type == UnsentRequestHandlerConnector.class) {
+ return new RequestHandlerConnectorExternalizer();
+ }
+ return null;
+ }
+
+ static class RequestHandlerConnectorExternalizer implements Externalizer {
+ static final RequestHandlerConnectorExternalizer INSTANCE = new
RequestHandlerConnectorExternalizer();
+
+ private static final long serialVersionUID = 8137262079765758375L;
+
+ public void writeExternal(final Object subject, final ObjectOutput output) throws
IOException {
+ final UnsentRequestHandlerConnector connector =
(UnsentRequestHandlerConnector) subject;
+ output.writeInt(connector.getClientId());
+ }
+
+ public Object createExternal(final Class<?> subjectType, final ObjectInput
input, final Creator defaultCreator) throws IOException, ClassNotFoundException {
+ return new
ReceivedRequestHandlerConnector(RemoteConnectionHandler.getCurrent(), input.readInt());
+ }
+
+ public void readExternal(final Object subject, final ObjectInput input) throws
IOException, ClassNotFoundException {
+ // n/a
+ }
+ }
+}
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryObjectTable.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryObjectTable.java
(rev 0)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/PrimaryObjectTable.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.remote;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import org.jboss.marshalling.Marshaller;
+import org.jboss.marshalling.ObjectTable;
+import org.jboss.marshalling.Unmarshaller;
+import org.jboss.remoting3.Endpoint;
+
+final class PrimaryObjectTable implements ObjectTable {
+
+ private final Endpoint endpoint;
+
+ PrimaryObjectTable(final Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ private static final Writer ZERO_WRITER = new ByteWriter(0);
+ private static final Writer ONE_WRITER = new ByteWriter(1);
+
+ private static final class ByteWriter implements Writer {
+ private final byte b;
+
+ private ByteWriter(final int b) {
+ this.b = (byte) b;
+ }
+
+ public void writeObject(final Marshaller marshaller, final Object object) throws
IOException {
+ marshaller.writeByte(b);
+ }
+ }
+
+ public Writer getObjectWriter(final Object object) throws IOException {
+ if (object == endpoint) {
+ return ZERO_WRITER;
+ } else if (object ==
PrimaryExternalizerFactory.RequestHandlerConnectorExternalizer.INSTANCE) {
+ return ONE_WRITER;
+ }
+ return null;
+ }
+
+ public Object readObject(final Unmarshaller unmarshaller) throws IOException,
ClassNotFoundException {
+ final int id = unmarshaller.readUnsignedByte();
+ switch (id) {
+ case 0: return endpoint;
+ case 1: return
PrimaryExternalizerFactory.RequestHandlerConnectorExternalizer.INSTANCE;
+ default: throw new StreamCorruptedException("Unknown object table ID
byte " + id);
+ }
+ }
+}
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ReceivedRequestHandlerConnector.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ReceivedRequestHandlerConnector.java
(rev 0)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ReceivedRequestHandlerConnector.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.remote;
+
+import org.jboss.marshalling.util.IntKeyMap;
+import org.jboss.remoting3.spi.RequestHandler;
+import org.jboss.remoting3.spi.RequestHandlerConnector;
+import org.jboss.xnio.Cancellable;
+import org.jboss.xnio.IoUtils;
+import org.jboss.xnio.Result;
+
+final class ReceivedRequestHandlerConnector implements RequestHandlerConnector {
+ private final RemoteConnectionHandler connectionHandler;
+ private final int clientId;
+
+ ReceivedRequestHandlerConnector(final RemoteConnectionHandler connectionHandler,
final int clientId) {
+ this.connectionHandler = connectionHandler;
+ this.clientId = clientId;
+ }
+
+ public Cancellable createRequestHandler(final Result<RequestHandler> result)
throws SecurityException {
+ final OutboundClient client = new OutboundClient(connectionHandler, clientId,
result, "anonymous", "anonymous");
+ final IntKeyMap<OutboundClient> outboundClients =
connectionHandler.getOutboundClients();
+ synchronized (outboundClients) {
+ outboundClients.put(clientId, client);
+ }
+ final OutboundRequestHandler requestHandler = new
OutboundRequestHandler(client);
+ synchronized (client) {
+ client.setState(OutboundClient.State.ESTABLISHED);
+ client.setResult(requestHandler);
+ }
+ result.setResult(requestHandler);
+ return IoUtils.nullCancellable();
+ }
+}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -27,6 +27,7 @@
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.marshalling.MarshallerFactory;
+import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.util.IntKeyMap;
import org.jboss.remoting3.IndeterminateOutcomeException;
@@ -66,19 +67,25 @@
private final AtomicBoolean closed = new AtomicBoolean();
- public RemoteConnectionHandler(final ConnectionHandlerContext connectionContext,
final RemoteConnection remoteConnection, final MarshallerFactory marshallerFactory, final
MarshallingConfiguration marshallingConfiguration) {
+ public RemoteConnectionHandler(final ConnectionHandlerContext connectionContext,
final RemoteConnection remoteConnection, final MarshallerFactory marshallerFactory) {
super(connectionContext.getConnectionProviderContext().getExecutor());
this.connectionContext = connectionContext;
this.remoteConnection = remoteConnection;
this.marshallerFactory = marshallerFactory;
- this.marshallingConfiguration = marshallingConfiguration;
+ final MarshallingConfiguration config = new MarshallingConfiguration();
+ config.setClassExternalizerFactory(PrimaryExternalizerFactory.INSTANCE);
+ config.setObjectTable(new
PrimaryObjectTable(connectionContext.getConnectionProviderContext().getEndpoint()));
+ config.setStreamHeader(Marshalling.nullStreamHeader());
+ // fixed for now (v0)
+ config.setVersion(2);
+ this.marshallingConfiguration = config;
}
public Cancellable open(final String serviceType, final String groupName, final
Result<RequestHandler> result) {
final OutboundClient outboundClient;
int id;
synchronized (outboundClients) {
- while (outboundClients.containsKey(id = random.nextInt()));
+ while (outboundClients.containsKey(id = random.nextInt() | 1));
outboundClient = new OutboundClient(this, id, result, serviceType,
groupName);
outboundClients.put(id, outboundClient);
}
@@ -105,7 +112,13 @@
}
public RequestHandlerConnector createConnector(final RequestHandler localHandler) {
- throw new UnsupportedOperationException();
+ final InboundClient inboundClient = new InboundClient(this, localHandler);
+ int id;
+ synchronized (inboundClients) {
+ while (inboundClients.containsKey(id = random.nextInt() & ~1));
+ inboundClients.put(id, inboundClient);
+ }
+ return new UnsentRequestHandlerConnector(id, this);
}
protected void closeAction() throws IOException {
@@ -183,4 +196,19 @@
RemoteConnection getRemoteConnection() {
return remoteConnection;
}
+
+ private static final ThreadLocal<RemoteConnectionHandler> current = new
ThreadLocal<RemoteConnectionHandler>();
+
+ static RemoteConnectionHandler getCurrent() {
+ return current.get();
+ }
+
+ static RemoteConnectionHandler setCurrent(RemoteConnectionHandler newCurrent) {
+ final ThreadLocal<RemoteConnectionHandler> current =
RemoteConnectionHandler.current;
+ try {
+ return current.get();
+ } finally {
+ current.set(newCurrent);
+ }
+ }
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteMessageHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -196,17 +196,17 @@
}
case RemoteProtocol.REQUEST_ACK_CHUNK: {
final int rid = buffer.getInt();
- final InboundRequest inboundRequest;
- final IntKeyMap<InboundRequest> inboundRequests =
connectionHandler.getInboundRequests();
- synchronized (inboundRequests) {
- inboundRequest = inboundRequests.get(rid);
+ final OutboundRequest outboundRequest;
+ final IntKeyMap<OutboundRequest> outboundRequests =
connectionHandler.getOutboundRequests();
+ synchronized (outboundRequests) {
+ outboundRequest = outboundRequests.get(rid);
}
- if (inboundRequest == null) {
+ if (outboundRequest == null) {
RemoteConnectionHandler.log.trace("Received request-ack-chunk
for unknown request ID %d", Integer.valueOf(rid));
return;
}
- synchronized (inboundRequest) {
- inboundRequest.ack();
+ synchronized (outboundRequest) {
+ outboundRequest.ack();
}
return;
}
@@ -239,17 +239,17 @@
}
case RemoteProtocol.REPLY_ACK_CHUNK: {
final int rid = buffer.getInt();
- final OutboundRequest outboundRequest;
- final IntKeyMap<OutboundRequest> outboundRequests =
connectionHandler.getOutboundRequests();
- synchronized (outboundRequests) {
- outboundRequest = outboundRequests.get(rid);
+ final InboundRequest inboundRequest;
+ final IntKeyMap<InboundRequest> inboundRequests =
connectionHandler.getInboundRequests();
+ synchronized (inboundRequests) {
+ inboundRequest = inboundRequests.get(rid);
}
- if (outboundRequest == null) {
+ if (inboundRequest == null) {
RemoteConnectionHandler.log.trace("Received reply-ack-chunk for
unknown request ID %d", Integer.valueOf(rid));
return;
}
- synchronized (outboundRequest) {
- outboundRequest.ack();
+ synchronized (inboundRequest) {
+ inboundRequest.ack();
}
return;
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerAuthenticationHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerAuthenticationHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerAuthenticationHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -71,8 +71,7 @@
connectionProviderContext.accept(new ConnectionHandlerFactory()
{
public ConnectionHandler createInstance(final
ConnectionHandlerContext connectionContext) {
final MarshallerFactory marshallerFactory =
Marshalling.getMarshallerFactory("river");
- final MarshallingConfiguration marshallingConfiguration =
new MarshallingConfiguration();
- final RemoteConnectionHandler connectionHandler = new
RemoteConnectionHandler(connectionContext, remoteConnection, marshallerFactory,
marshallingConfiguration);
+ final RemoteConnectionHandler connectionHandler = new
RemoteConnectionHandler(connectionContext, remoteConnection, marshallerFactory);
remoteConnection.addCloseHandler(new
CloseHandler<Object>() {
public void handleClose(final Object closed) {
IoUtils.safeClose(connectionHandler);
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerInitialAuthenticationHandler.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -26,7 +26,6 @@
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Set;
-import org.jboss.remoting3.RemotingOptions;
import org.jboss.remoting3.security.ServerAuthenticationProvider;
import org.jboss.remoting3.spi.ConnectionProviderContext;
import org.jboss.xnio.Buffers;
@@ -59,7 +58,7 @@
final String name = Buffers.getModifiedUtf8(buffer);
if (allowedMechs.contains(name)) {
RemoteConnectionHandler.log.trace("Selected SASL mechanism
%s", name);
- final String realm =
connectionProviderContext.getEndpointName();
+ final String realm =
connectionProviderContext.getEndpoint().getName();
final SaslServer server = Sasl.createSaslServer(name,
"remote", realm, saslPropertyMap, authenticationProvider.getCallbackHandler());
remoteConnection.setMessageHandler(new
ServerAuthenticationHandler(remoteConnection, server, connectionProviderContext));
RemoteConnectionHandler.log.trace("Sending initial
challenge");
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/ServerOpenListener.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -88,7 +88,7 @@
GreetingUtils.writeString(buffer, RemoteProtocol.GREETING_SASL_MECH, name);
RemoteConnectionHandler.log.trace("Offering SASL mechanism %s",
name);
}
- GreetingUtils.writeString(buffer, RemoteProtocol.GREETING_ENDPOINT_NAME,
connectionProviderContext.getEndpointName());
+ GreetingUtils.writeString(buffer, RemoteProtocol.GREETING_ENDPOINT_NAME,
connectionProviderContext.getEndpoint().getName());
// that's it!
buffer.flip();
buffer.putInt(0, buffer.remaining() - 4);
Added:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/UnsentRequestHandlerConnector.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/UnsentRequestHandlerConnector.java
(rev 0)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/UnsentRequestHandlerConnector.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.remote;
+
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import org.jboss.marshalling.util.IntKeyMap;
+import org.jboss.remoting3.spi.RequestHandler;
+import org.jboss.remoting3.spi.RequestHandlerConnector;
+import org.jboss.xnio.Cancellable;
+import org.jboss.xnio.Result;
+
+final class UnsentRequestHandlerConnector implements RequestHandlerConnector {
+
+ private static final AtomicIntegerFieldUpdater<UnsentRequestHandlerConnector>
sentUpdater = AtomicIntegerFieldUpdater.newUpdater(UnsentRequestHandlerConnector.class,
"sent");
+
+ private final int clientId;
+ private final RemoteConnectionHandler remoteConnectionHandler;
+ private volatile int sent = 0;
+
+ UnsentRequestHandlerConnector(final int clientId, final RemoteConnectionHandler
remoteConnectionHandler) {
+ this.clientId = clientId;
+ this.remoteConnectionHandler = remoteConnectionHandler;
+ }
+
+ public Cancellable createRequestHandler(final Result<RequestHandler> result)
throws SecurityException {
+ throw new SecurityException("Request handler not sent");
+ }
+
+ void send() {
+ sent = 1;
+ }
+
+ boolean isSent() {
+ return sent != 0;
+ }
+
+ int getClientId() {
+ return clientId;
+ }
+
+ protected void finalize() throws Throwable {
+ if (sentUpdater.compareAndSet(this, 0, 1)) {
+ // was not sent...
+ final IntKeyMap<InboundClient> inboundClients =
remoteConnectionHandler.getInboundClients();
+ synchronized (inboundClients) {
+ inboundClients.remove(clientId);
+ }
+ }
+ super.finalize();
+ }
+}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderContext.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderContext.java 2010-03-01
00:55:18 UTC (rev 5775)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/spi/ConnectionProviderContext.java 2010-03-01
01:02:47 UTC (rev 5776)
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.concurrent.Executor;
+import org.jboss.remoting3.Endpoint;
/**
* A context for a connection provider. This provides additional endpoint methods to
connection providers which are not
@@ -68,9 +69,9 @@
<T> T getProtocolServiceProvider(ProtocolServiceType<T> serviceType,
String name);
/**
- * Get the endpoint's name.
+ * Get the endpoint.
*
- * @return the endpoint name
+ * @return the endpoint
*/
- String getEndpointName();
+ Endpoint getEndpoint();
}