You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/01/26 15:59:57 UTC

[05/10] qpid-jms git commit: remove the old transports, swap in previously-transitive dependency used for the new Netty transports

remove the old transports, swap in previously-transitive dependency used for the new Netty transports


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/d0dd23c4
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/d0dd23c4
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/d0dd23c4

Branch: refs/heads/master
Commit: d0dd23c40a0bc7a15153f6e73102dbdace0e92ae
Parents: f16bb7d
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Jan 26 11:56:21 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Jan 26 11:56:21 2015 +0000

----------------------------------------------------------------------
 pom.xml                                         |  17 +-
 qpid-jms-client/pom.xml                         |   8 +-
 .../qpid/jms/transports/vertx/SslTransport.java |  73 ------
 .../transports/vertx/SslTransportFactory.java   |  44 ----
 .../qpid/jms/transports/vertx/TcpTransport.java | 239 -------------------
 .../transports/vertx/TcpTransportFactory.java   |  38 ---
 6 files changed, 8 insertions(+), 411 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d0dd23c4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b10c958..5470d04 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,10 +49,10 @@
     <proton-version>1.0-SNAPSHOT</proton-version>
     <fuse-joram-tests-version>1.0</fuse-joram-tests-version>
     <jetty-version>8.1.16.v20140903</jetty-version>
-    <vertex-version>2.0.2-final</vertex-version>
     <mockito-version>1.10.16</mockito-version>
     <hamcrest-version>1.3</hamcrest-version>
     <xalan-version>2.7.2</xalan-version>
+    <netty-version>4.0.10.Final</netty-version>
 
     <!-- Maven Plugin Version for this Project -->
     <maven-javacc-plugin-version>2.6</maven-javacc-plugin-version>
@@ -126,6 +126,11 @@
         <version>1.1.1</version>
       </dependency>
       <dependency>
+        <groupId>io.netty</groupId>
+        <artifactId>netty-all</artifactId>
+        <version>${netty-version}</version>
+      </dependency>
+      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>${junit-version}</version>
@@ -158,16 +163,6 @@
         <artifactId>xalan</artifactId>
         <version>${xalan-version}</version>
       </dependency>
-      <dependency>
-        <groupId>io.vertx</groupId>
-        <artifactId>vertx-core</artifactId>
-        <version>${vertex-version}</version>
-      </dependency>
-      <dependency>
-        <groupId>io.vertx</groupId>
-        <artifactId>vertx-platform</artifactId>
-        <version>${vertex-version}</version>
-      </dependency>
     </dependencies>
   </dependencyManagement>
 

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d0dd23c4/qpid-jms-client/pom.xml
----------------------------------------------------------------------
diff --git a/qpid-jms-client/pom.xml b/qpid-jms-client/pom.xml
index a579365..6e752e2 100644
--- a/qpid-jms-client/pom.xml
+++ b/qpid-jms-client/pom.xml
@@ -50,12 +50,8 @@
       <artifactId>proton-j</artifactId>
     </dependency>
     <dependency>
-      <groupId>io.vertx</groupId>
-      <artifactId>vertx-core</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>io.vertx</groupId>
-      <artifactId>vertx-platform</artifactId>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-all</artifactId>
     </dependency>
 
     <!-- =================================== -->

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d0dd23c4/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransport.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransport.java
deleted file mode 100644
index 5ae5248..0000000
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransport.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms.transports.vertx;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.qpid.jms.transports.TransportListener;
-import org.apache.qpid.jms.transports.TransportOptions;
-import org.apache.qpid.jms.transports.TransportSslOptions;
-import org.vertx.java.core.net.NetClient;
-
-/**
- * Provides SSL configuration to the Vert.x NetClient object used by the underling
- * TCP based Transport.
- */
-public class SslTransport extends TcpTransport {
-
-    /**
-     * Create a new transport instance
-     *
-     * @param remoteLocation
-     *        the URI that defines the remote resource to connect to.
-     * @param options
-     *        the transport options used to configure the socket connection.
-     */
-    public SslTransport(URI remoteLocation, TransportOptions options) {
-        super(null, remoteLocation, options);
-    }
-
-    /**
-     * Create a new transport instance
-     *
-     * @param listener
-     *        the TransportListener that will receive events from this Transport.
-     * @param remoteLocation
-     *        the URI that defines the remote resource to connect to.
-     * @param options
-     *        the transport options used to configure the socket connection.
-     */
-    public SslTransport(TransportListener listener, URI remoteLocation, TransportOptions options) {
-        super(listener, remoteLocation, options);
-    }
-
-    @Override
-    protected void configureNetClient(NetClient client, TransportOptions options) throws IOException {
-        super.configureNetClient(client, options);
-
-        client.setSSL(true);
-        client.setKeyStorePath(getSslOptions().getKeyStoreLocation());
-        client.setKeyStorePassword(getSslOptions().getKeyStorePassword());
-        client.setTrustStorePath(getSslOptions().getTrustStoreLocation());
-        client.setTrustStorePassword(getSslOptions().getTrustStorePassword());
-    }
-
-    private TransportSslOptions getSslOptions() {
-        return (TransportSslOptions) options;
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d0dd23c4/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransportFactory.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransportFactory.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransportFactory.java
deleted file mode 100644
index 924f6a5..0000000
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/SslTransportFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms.transports.vertx;
-
-import java.net.URI;
-
-import org.apache.qpid.jms.transports.TransportFactory;
-import org.apache.qpid.jms.transports.TransportOptions;
-import org.apache.qpid.jms.transports.TransportSslOptions;
-
-/**
- * Create an SslTransport instance.
- */
-public class SslTransportFactory extends TransportFactory {
-
-    @Override
-    protected TransportOptions doCreateTransportOptions() {
-        return TransportSslOptions.INSTANCE.clone();
-    }
-
-    @Override
-    protected TcpTransport doCreateTransport(URI remoteURI, TransportOptions transportOptions) throws Exception {
-        return new SslTransport(remoteURI, transportOptions);
-    }
-
-    @Override
-    public String getName() {
-        return "SSL";
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d0dd23c4/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransport.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransport.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransport.java
deleted file mode 100644
index 332dacc..0000000
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransport.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms.transports.vertx;
-
-import io.netty.buffer.ByteBuf;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.qpid.jms.transports.Transport;
-import org.apache.qpid.jms.transports.TransportListener;
-import org.apache.qpid.jms.transports.TransportOptions;
-import org.apache.qpid.jms.util.IOExceptionSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.vertx.java.core.AsyncResult;
-import org.vertx.java.core.AsyncResultHandler;
-import org.vertx.java.core.Handler;
-import org.vertx.java.core.Vertx;
-import org.vertx.java.core.buffer.Buffer;
-import org.vertx.java.core.impl.DefaultVertxFactory;
-import org.vertx.java.core.net.NetClient;
-import org.vertx.java.core.net.NetSocket;
-
-/**
- * Vertex based TCP transport for raw data packets.
- */
-public class TcpTransport implements Transport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(TcpTransport.class);
-
-    private final Vertx vertx;
-    private final NetClient client;
-    private final URI remoteLocation;
-    private final AtomicBoolean connected = new AtomicBoolean();
-    private final AtomicBoolean closed = new AtomicBoolean();
-    private final AtomicReference<Throwable> connectionError = new AtomicReference<Throwable>();
-
-    protected NetSocket socket;
-    protected TransportListener listener;
-    protected TransportOptions options;
-
-    /**
-     * Create a new transport instance
-     *
-     * @param remoteLocation
-     *        the URI that defines the remote resource to connect to.
-     * @param options
-     *        the transport options used to configure the socket connection.
-     */
-    public TcpTransport(URI remoteLocation, TransportOptions options) {
-        this(null, remoteLocation, options);
-    }
-
-    /**
-     * Create a new transport instance
-     *
-     * @param listener
-     *        the TransportListener that will receive events from this Transport.
-     * @param remoteLocation
-     *        the URI that defines the remote resource to connect to.
-     * @param options
-     *        the transport options used to configure the socket connection.
-     */
-    public TcpTransport(TransportListener listener, URI remoteLocation, TransportOptions options) {
-        this.options = options;
-        this.listener = listener;
-        this.remoteLocation = remoteLocation;
-
-        DefaultVertxFactory vertxFactory = new DefaultVertxFactory();
-        this.vertx = vertxFactory.createVertx();
-        this.client = vertx.createNetClient();
-    }
-
-    @Override
-    public void connect() throws IOException {
-        final CountDownLatch connectLatch = new CountDownLatch(1);
-
-        if (listener == null) {
-            throw new IllegalStateException("A transport listener must be set before connection attempts.");
-        }
-
-        configureNetClient(client, getTransportOptions());
-
-        try {
-            client.connect(remoteLocation.getPort(), remoteLocation.getHost(), new AsyncResultHandler<NetSocket>() {
-                @Override
-                public void handle(AsyncResult<NetSocket> asyncResult) {
-                    if (asyncResult.succeeded()) {
-                        socket = asyncResult.result();
-                        LOG.info("We have connected! Socket is {}", socket);
-
-                        connected.set(true);
-                        connectLatch.countDown();
-
-                        socket.dataHandler(new Handler<Buffer>() {
-                            @Override
-                            public void handle(Buffer event) {
-                                listener.onData(event.getByteBuf());
-                            }
-                        });
-
-                        socket.closeHandler(new Handler<Void>() {
-                            @Override
-                            public void handle(Void event) {
-                                if (!closed.get()) {
-                                    connected.set(false);
-                                    listener.onTransportClosed();
-                                }
-                            }
-                        });
-
-                        socket.exceptionHandler(new Handler<Throwable>() {
-                            @Override
-                            public void handle(Throwable event) {
-                                if (!closed.get()) {
-                                    connected.set(false);
-                                    listener.onTransportError(event);
-                                }
-                            }
-                        });
-
-                    } else {
-                        connected.set(false);
-                        connectionError.set(asyncResult.cause());
-                        connectLatch.countDown();
-                    }
-                }
-            });
-        } catch (Throwable reason) {
-            LOG.info("Failed to connect to target Broker: {}", reason);
-            throw IOExceptionSupport.create(reason);
-        }
-
-        try {
-            connectLatch.await();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-        }
-
-        if (connectionError.get() != null) {
-            throw IOExceptionSupport.create(connectionError.get());
-        }
-    }
-
-    @Override
-    public void close() throws IOException {
-        if (closed.compareAndSet(false, true)) {
-            if (connected.get()) {
-                socket.close();
-                connected.set(false);
-            }
-
-            vertx.stop();
-        }
-    }
-
-    @Override
-    public void send(ByteBuf output) throws IOException {
-        checkConnected();
-        int length = output.readableBytes();
-        if (length == 0) {
-            return;
-        }
-
-        Buffer sendBuffer = new Buffer(output.copy());
-        vertx.eventBus().send(socket.writeHandlerID(), sendBuffer);
-    }
-
-    /**
-     * Allows a subclass to configure the NetClient beyond what this transport might do.
-     *
-     * @throws IOException if an error occurs.
-     */
-    protected void configureNetClient(NetClient client, TransportOptions options) throws IOException {
-        client.setSendBufferSize(options.getSendBufferSize());
-        client.setReceiveBufferSize(options.getReceiveBufferSize());
-        client.setSoLinger(options.getSoLinger());
-        client.setTCPKeepAlive(options.isTcpKeepAlive());
-        client.setTCPNoDelay(options.isTcpNoDelay());
-        if (options.getConnectTimeout() >= 0) {
-            client.setConnectTimeout(options.getConnectTimeout());
-        }
-    }
-
-    @Override
-    public boolean isConnected() {
-        return this.connected.get();
-    }
-
-    private void checkConnected() throws IOException {
-        if (!connected.get()) {
-            throw new IOException("Cannot send to a non-connected transport.");
-        }
-    }
-
-    @Override
-    public TransportListener getTransportListener() {
-        return this.listener;
-    }
-
-    @Override
-    public void setTransportListener(TransportListener listener) {
-        if (listener == null) {
-            throw new IllegalArgumentException("Listener cannot be set to null");
-        }
-
-        this.listener = listener;
-    }
-
-    /**
-     * @return the options used to configure the TCP socket.
-     */
-    @Override
-    public TransportOptions getTransportOptions() {
-        if (options == null) {
-            options = TransportOptions.DEFAULT_OPTIONS;
-        }
-
-        return options;
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d0dd23c4/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransportFactory.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransportFactory.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransportFactory.java
deleted file mode 100644
index e6a2dce..0000000
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/transports/vertx/TcpTransportFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.qpid.jms.transports.vertx;
-
-import java.net.URI;
-
-import org.apache.qpid.jms.transports.TransportFactory;
-import org.apache.qpid.jms.transports.TransportOptions;
-
-/**
- * Factory for creating the Vert.x based TCP Transport
- */
-public class TcpTransportFactory extends TransportFactory {
-
-    @Override
-    protected TcpTransport doCreateTransport(URI remoteURI, TransportOptions transportOptions) throws Exception {
-        return new TcpTransport(remoteURI, transportOptions);
-    }
-
-    @Override
-    public String getName() {
-        return "TCP";
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org