Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/kaazing/gateway into tls…
Browse files Browse the repository at this point in the history
…tosslfix
  • Loading branch information
justinma246 committed Sep 14, 2016
2 parents aaba198 + 68812cb commit 0e54531
Show file tree
Hide file tree
Showing 131 changed files with 2,983 additions and 4,882 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
sudo: required
language: Java
jdk: oraclejdk8
services: docker
env:
global:
- secure: "eUJzrr3JIxDF1Cf6Qnlj+g1rtX0NOEoOKvMNw9V/0JYP++vtUW9GD11gJ0YwfRU4/za3R4WBcW8JgtvOiyDCZkIRd+1nTsHeKY/ERwFjG8S29X7R6DUEUHL00B03MGJ0NZyRE1lzDc/np4zqcuH8wHqzXwszu+iQsTqrzHegROM="
- secure: "F6oCHN9p/gAFymPD091Yq/7niP1swVRrox7wPUQ3g/ELpIl8GS5JD2GapfVhsdV5oOkIXn0JWmzNSAVrI9jeUVZUCtkUdr+OMdyzzS9iJHmDxQOGnz3/vefbV5VQTCIFZKzE2c7usVcaxkVj4E+Ao4pcrXoXOzbvx2In2D/7+B8="
before_install: certificates/add-to-cacerts.sh
install: mvn -q -B -U install -DskipTests -DskipITs
install:
- export DOCKER_HOST=tcp://127.0.0.1:2375
- mvn -q -B -U install -DskipTests -DskipITs
script:
- >
if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then
Expand Down
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@
<artifactId>gateway.service.update.check.management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.kaazing</groupId>
<artifactId>gateway.service.turn.proxy</artifactId>
<version>${project.version}</version>
</dependency>
<!-- transport dependencies -->
<dependency>
<groupId>org.kaazing</groupId>
Expand Down
4 changes: 0 additions & 4 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@
<groupId>org.kaazing</groupId>
<artifactId>gateway.service.update.check.management</artifactId>
</dependency>
<dependency>
<groupId>org.kaazing</groupId>
<artifactId>gateway.service.turn.proxy</artifactId>
</dependency>

<!-- transport dependencies -->
<dependency>
Expand Down
1 change: 0 additions & 1 deletion distribution/src/main/assembly/generic-bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<include>org.kaazing:gateway.service.amqp</include>
<include>org.kaazing:gateway.service.update.check</include>
<include>org.kaazing:gateway.service.turn.rest</include>
<include>org.kaazing:gateway.service.turn.proxy</include>

<!-- auth jars -->
<include>org.kaazing:gateway.security</include>
Expand Down
13 changes: 10 additions & 3 deletions distribution/src/main/gateway/conf/gateway-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
limitations under the License.
-->
<gateway-config xmlns="http://xmlns.kaazing.org/2015/11/gateway">
<gateway-config xmlns="http://xmlns.kaazing.org/2016/06/gateway">

<!--
#############################################################################
Expand Down Expand Up @@ -72,7 +72,7 @@

<type>echo</type>

<!-- Restrict cross site constraints before running in production -->
<!-- "*" is not secure for javascript applications, change before running in production -->
<cross-site-constraint>
<allow-origin>*</allow-origin>
</cross-site-constraint>
Expand All @@ -93,13 +93,20 @@

<realm-name>demo</realm-name>

<!-- Restrict cross site constraints before running in production -->
<!-- "*" is not secure for javascript applications, change before running in production -->
<cross-site-constraint>
<allow-origin>*</allow-origin>
</cross-site-constraint>
</service>


<service>
<name>Update Checker</name>
<description>Checks to see if a newer version of the Gateway is available</description>
<type>update.check</type>
</service>


<security>

<keystore>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.socket.Worker;
import org.jboss.netty.channel.socket.nio.NioWorker.ReadDispatcher;
import org.jboss.netty.channel.socket.nio.NioWorker.TcpReadDispatcher;
import org.jboss.netty.channel.socket.nio.NioWorker.UdpReadDispatcher;
import org.jboss.netty.channel.socket.nio.SocketSendBufferPool.SendBuffer;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
Expand Down Expand Up @@ -603,6 +606,9 @@ public void deregister(final AbstractNioChannel<?> channel) {
@Override
public void run() {
channels.remove(channel.getId().intValue());
if (channel instanceof NioChildDatagramChannel) {
return;
}

SelectionKey key = channel.channel.keyFor(selector);
if (key != null) {
Expand Down Expand Up @@ -633,15 +639,19 @@ public void run() {
try {
channels.put(channel.getId().intValue(), channel);

// TODO some channels no need to register with selector
if (channel instanceof NioChildDatagramChannel) {
return;
}

// ensure channel.writeSuspended cannot remain true due to race
// note: setOpWrite is a no-op before selectionKey is registered w/ selector
int rawInterestOps = channel.getRawInterestOps();
rawInterestOps |= SelectionKey.OP_WRITE;
channel.setRawInterestOpsNow(rawInterestOps);

channel.channel.register(selector, rawInterestOps, channel);
ReadDispatcher readDispatcher = channel instanceof NioSocketChannel
? new TcpReadDispatcher((NioSocketChannel) channel)
: new UdpReadDispatcher((NioDatagramChannel) channel);
channel.channel.register(selector, rawInterestOps, readDispatcher);
}
catch (ClosedChannelException e) {
close(channel, succeededFuture(channel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public NioDatagramChannelConfig getConfig() {
return config;
}

DatagramChannel getDatagramChannel() {
return channel;
}

public ChannelFuture joinGroup(InetAddress multicastAddress) {
try {
return joinGroup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
*/
class NioChildDatagramPipelineSink extends AbstractNioChannelSink {

private final WorkerPool<NioWorker> workerPool;

NioChildDatagramPipelineSink(final WorkerPool<NioWorker> workerPool) {
this.workerPool = workerPool;
}

/**
* Handle downstream event.
*
Expand Down Expand Up @@ -99,10 +93,6 @@ public void eventSunk(final ChannelPipeline pipeline, final ChannelEvent e)
}
}

AbstractNioWorker nextWorker() {
return workerPool.nextWorker();
}

private static final class ParentMessageEvent implements MessageEvent {

private final MessageEvent delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;

import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.channel.socket.DatagramChannel;
import org.jboss.netty.channel.socket.DatagramChannelFactory;
import org.jboss.netty.channel.socket.InternetProtocolFamily;
import org.jboss.netty.channel.socket.Worker;
import org.jboss.netty.channel.socket.oio.OioDatagramChannelFactory;
import org.jboss.netty.util.ExternalResourceReleasable;

Expand All @@ -53,19 +51,19 @@
*
* <h3>How threads work</h3>
* <p>
* There is only one thread type in a {@link NioDatagramChannelFactory};
* There is only one thread type in a {@link NioClientDatagramChannelFactory};
* worker threads.
*
* <h4>Worker threads</h4>
* <p>
* One {@link NioDatagramChannelFactory} can have one or more worker
* One {@link NioClientDatagramChannelFactory} can have one or more worker
* threads. A worker thread performs non-blocking read and write for one or
* more {@link DatagramChannel}s in a non-blocking mode.
*
* <h3>Life cycle of threads and graceful shutdown</h3>
* <p>
* All worker threads are acquired from the {@link Executor} which was specified
* when a {@link NioDatagramChannelFactory} was created. Therefore, you should
* when a {@link NioClientDatagramChannelFactory} was created. Therefore, you should
* make sure the specified {@link Executor} is able to lend the sufficient
* number of threads. It is the best bet to specify
* {@linkplain Executors#newCachedThreadPool() a cached thread pool}.
Expand All @@ -89,73 +87,40 @@
* <p>
* Multicast is not supported. Please use {@link OioDatagramChannelFactory}
* instead.
*
* @apiviz.landmark
*/
public class NioDatagramChannelFactory implements DatagramChannelFactory {
public class NioClientDatagramChannelFactory implements DatagramChannelFactory {

private final NioDatagramPipelineSink sink;
private final NioChildDatagramPipelineSink childSink;
private final WorkerPool<NioDatagramWorker> workerPool;
private final WorkerPool<NioWorker> childPool;
private final WorkerPool<NioWorker> workerPool;
private final InternetProtocolFamily family;
private boolean releasePool;

/**
* Create a new {@link NioDatagramChannelFactory} with a {@link Executors#newCachedThreadPool()}
* and without preferred {@link InternetProtocolFamily}. Please note that the {@link InternetProtocolFamily}
* of the channel will be platform (and possibly configuration) dependent and therefore
* unspecified. Use {@link #NioDatagramChannelFactory(InternetProtocolFamily)} if unsure.
*
* See {@link #NioDatagramChannelFactory(Executor)}
*/
public NioDatagramChannelFactory() {
this((InternetProtocolFamily) null);
}

/**
* Create a new {@link NioDatagramChannelFactory} with a {@link Executors#newCachedThreadPool()}.
*
* See {@link #NioDatagramChannelFactory(Executor)}
*/
public NioDatagramChannelFactory(InternetProtocolFamily family) {
workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), SelectorUtil.DEFAULT_IO_THREADS);
childPool = new NioWorkerPool(Executors.newCachedThreadPool(), SelectorUtil.DEFAULT_IO_THREADS);
this.family = family;
sink = new NioDatagramPipelineSink(workerPool);
childSink = new NioChildDatagramPipelineSink(childPool);
public NioClientDatagramChannelFactory(WorkerPool<NioWorker> workerPool) {
this.workerPool = workerPool;
this.family = null;
sink = new NioDatagramPipelineSink();
releasePool = true;
}

public DatagramChannel newChannel(final ChannelPipeline pipeline) {
return new NioDatagramChannel(this, pipeline, sink, sink.nextWorker(), family);
}

// mina.netty change - adding this to create child datagram channels
public NioChildDatagramChannel newChildChannel(Channel parent, final ChannelPipeline pipeline) {
return new NioChildDatagramChannel(parent, this, pipeline, childSink, childSink.nextWorker(), family);
return new NioDatagramChannel(this, pipeline, sink, workerPool.nextWorker(), family);
}

public void shutdown() {
workerPool.shutdown();
childPool.shutdown();
if (releasePool) {
releasePool();
}
}

public void releaseExternalResources() {
workerPool.shutdown();
childPool.shutdown();
releasePool();
}

private void releasePool() {
if (workerPool instanceof ExternalResourceReleasable) {
((ExternalResourceReleasable) workerPool).releaseExternalResources();
}
if (childPool instanceof ExternalResourceReleasable) {
((ExternalResourceReleasable) childPool).releaseExternalResources();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright 2007-2016, Kaazing Corporation. All rights reserved.
*
* Licensed 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.jboss.netty.channel.socket.nio;

import org.jboss.netty.util.ThreadNameDeterminer;

import java.util.concurrent.Executor;


/**
* Holds {@link NioServerDatagramBoss} instances to use
*/
public class NioDatagramBossPool extends AbstractNioBossPool<NioServerDatagramBoss> {
private final ThreadNameDeterminer determiner;

/**
* Create a new instance
*
* @param bossExecutor the {@link Executor} to use for server the {@link NioServerDatagramBoss}
* @param bossCount the number of {@link NioServerDatagramBoss} instances this {@link NioDatagramBossPool} will hold
* @param determiner the {@link ThreadNameDeterminer} to use for name the threads. Use {@code null}
* if you not want to set one explicit.
*/
public NioDatagramBossPool(Executor bossExecutor, int bossCount, ThreadNameDeterminer determiner) {
super(bossExecutor, bossCount, false);
this.determiner = determiner;
init();
}

/**
* Create a new instance using no {@link ThreadNameDeterminer}
*
* @param bossExecutor the {@link Executor} to use for server the {@link NioServerDatagramBoss}
* @param bossCount the number of {@link NioServerDatagramBoss} instances this {@link NioDatagramBossPool} will hold
*/
public NioDatagramBossPool(Executor bossExecutor, int bossCount) {
this(bossExecutor, bossCount, null);
}

@Override
protected NioServerDatagramBoss newBoss(Executor executor) {
return new NioServerDatagramBoss(executor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class NioDatagramChannel extends AbstractNioChannel<DatagramChannel>

NioDatagramChannel(final ChannelFactory factory,
final ChannelPipeline pipeline, final ChannelSink sink,
final NioDatagramWorker worker, InternetProtocolFamily family) {
final AbstractNioWorker worker, InternetProtocolFamily family) {
super(null, factory, pipeline, sink, worker, openNonBlockingChannel(family), true);
config = new DefaultNioDatagramChannelConfig(channel);

Expand Down Expand Up @@ -111,11 +111,6 @@ private static DatagramChannel openNonBlockingChannel(InternetProtocolFamily fam
}
}

@Override
public NioDatagramWorker getWorker() {
return (NioDatagramWorker) super.getWorker();
}

public boolean isBound() {
return isOpen() && channel.socket().isBound();
}
Expand Down
Loading

0 comments on commit 0e54531

Please sign in to comment.