Merge pull request #3352 from eclipse/jetty-10.0.x-3351-restructure_unixsocket
Fixed #3351 - Restructure jetty-unixsocket module.
This commit is contained in:
commit
b9797b01eb
|
@ -296,7 +296,17 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-unixsocket</artifactId>
|
<artifactId>jetty-unixsocket-common</artifactId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket-client</artifactId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket-server</artifactId>
|
||||||
<version>10.0.0-SNAPSHOT</version>
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -617,7 +617,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-unixsocket</artifactId>
|
<artifactId>jetty-unixsocket-server</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>jetty-unixsocket</artifactId>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>jetty-unixsocket-client</artifactId>
|
||||||
|
<name>Jetty :: UnixSocket :: Client</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<bundle-symbolic-name>${project.groupId}.unixsocket.client</bundle-symbolic-name>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-client</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket-server</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||||
|
<artifactId>jetty-test-helper</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
module org.eclipse.jetty.unixsocket.client
|
||||||
|
{
|
||||||
|
exports org.eclipse.jetty.unixsocket.client;
|
||||||
|
|
||||||
|
requires jnr.enxio;
|
||||||
|
requires jnr.unixsocket;
|
||||||
|
requires org.eclipse.jetty.client;
|
||||||
|
requires org.eclipse.jetty.io;
|
||||||
|
requires org.eclipse.jetty.util;
|
||||||
|
requires org.eclipse.jetty.unixsocket.common;
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ import org.eclipse.jetty.io.ClientConnector;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.io.ManagedSelector;
|
import org.eclipse.jetty.io.ManagedSelector;
|
||||||
import org.eclipse.jetty.io.SelectorManager;
|
import org.eclipse.jetty.io.SelectorManager;
|
||||||
import org.eclipse.jetty.unixsocket.UnixSocketEndPoint;
|
import org.eclipse.jetty.unixsocket.common.UnixSocketEndPoint;
|
||||||
import org.eclipse.jetty.util.Promise;
|
import org.eclipse.jetty.util.Promise;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
|
@ -24,12 +24,10 @@ import java.io.PrintWriter;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.IO;
|
|
||||||
|
|
||||||
import jnr.unixsocket.UnixSocketAddress;
|
import jnr.unixsocket.UnixSocketAddress;
|
||||||
import jnr.unixsocket.UnixSocketChannel;
|
import jnr.unixsocket.UnixSocketChannel;
|
||||||
|
import org.eclipse.jetty.toolchain.test.IO;
|
||||||
|
|
||||||
public class UnixSocketClient
|
public class UnixSocketClient
|
||||||
{
|
{
|
|
@ -36,8 +36,8 @@ import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
import org.eclipse.jetty.toolchain.test.FS;
|
|
||||||
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
||||||
|
import org.eclipse.jetty.unixsocket.server.UnixSocketConnector;
|
||||||
import org.eclipse.jetty.util.StringUtil;
|
import org.eclipse.jetty.util.StringUtil;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
@ -49,8 +49,10 @@ import org.junit.jupiter.api.condition.EnabledOnOs;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assumptions.assumeTrue;
|
||||||
import static org.junit.jupiter.api.condition.OS.LINUX;
|
import static org.junit.jupiter.api.condition.OS.LINUX;
|
||||||
import static org.junit.jupiter.api.condition.OS.MAC;
|
import static org.junit.jupiter.api.condition.OS.MAC;
|
||||||
|
|
||||||
|
@ -69,12 +71,19 @@ public class UnixSocketTest
|
||||||
server = null;
|
server = null;
|
||||||
httpClient = null;
|
httpClient = null;
|
||||||
String unixSocketTmp = System.getProperty("unix.socket.tmp");
|
String unixSocketTmp = System.getProperty("unix.socket.tmp");
|
||||||
|
Path unixSocket;
|
||||||
if (StringUtil.isNotBlank(unixSocketTmp))
|
if (StringUtil.isNotBlank(unixSocketTmp))
|
||||||
sockFile = Files.createTempFile(Paths.get(unixSocketTmp), "unix", ".sock");
|
unixSocket = Files.createTempFile(Paths.get(unixSocketTmp), "unix", ".sock");
|
||||||
else
|
else
|
||||||
sockFile = Files.createTempFile("unix", ".sock");
|
unixSocket = Files.createTempFile("unix", ".sock");
|
||||||
|
if (unixSocket.toAbsolutePath().toString().length() > UnixSocketConnector.MAX_UNIX_SOCKET_PATH_LENGTH)
|
||||||
|
{
|
||||||
|
Path tmp = Paths.get("/tmp");
|
||||||
|
assumeTrue(Files.exists(tmp) && Files.isDirectory(tmp));
|
||||||
|
unixSocket = Files.createTempFile(tmp, "unix", ".sock");
|
||||||
|
}
|
||||||
|
sockFile = unixSocket;
|
||||||
assertTrue(Files.deleteIfExists(sockFile), "temp sock file cannot be deleted");
|
assertTrue(Files.deleteIfExists(sockFile), "temp sock file cannot be deleted");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
|
@ -84,8 +93,8 @@ public class UnixSocketTest
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
if (server != null)
|
if (server != null)
|
||||||
server.stop();
|
server.stop();
|
||||||
// Force delete, this will fail if UnixSocket was not closed properly in the implementation
|
if (sockFile != null)
|
||||||
FS.delete(sockFile);
|
assertFalse(Files.exists(sockFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
|
@ -0,0 +1,3 @@
|
||||||
|
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||||
|
#org.eclipse.jetty.LEVEL=DEBUG
|
||||||
|
#org.eclipse.jetty.unixsocket.LEVEL=DEBUG
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket</artifactId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>jetty-unixsocket-common</artifactId>
|
||||||
|
<name>Jetty :: UnixSocket :: Common</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<bundle-symbolic-name>${project.groupId}.unixsocket.common</bundle-symbolic-name>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-io</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-util</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jnr</groupId>
|
||||||
|
<artifactId>jnr-unixsocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
module org.eclipse.jetty.unixsocket.common
|
||||||
|
{
|
||||||
|
exports org.eclipse.jetty.unixsocket.common;
|
||||||
|
|
||||||
|
requires jnr.unixsocket;
|
||||||
|
requires org.eclipse.jetty.io;
|
||||||
|
requires org.eclipse.jetty.util;
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
package org.eclipse.jetty.unixsocket;
|
package org.eclipse.jetty.unixsocket.common;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
|
@ -16,7 +16,7 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
package org.eclipse.jetty.unixsocket;
|
package org.eclipse.jetty.unixsocket.common;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.channels.SelectionKey;
|
import java.nio.channels.SelectionKey;
|
||||||
|
@ -37,7 +37,6 @@ public class JnrTest
|
||||||
path.deleteOnExit();
|
path.deleteOnExit();
|
||||||
UnixSocketAddress address = new UnixSocketAddress(path);
|
UnixSocketAddress address = new UnixSocketAddress(path);
|
||||||
|
|
||||||
|
|
||||||
UnixServerSocketChannel serverChannel = UnixServerSocketChannel.open();
|
UnixServerSocketChannel serverChannel = UnixServerSocketChannel.open();
|
||||||
Selector serverSelector = NativeSelectorProvider.getInstance().openSelector();
|
Selector serverSelector = NativeSelectorProvider.getInstance().openSelector();
|
||||||
serverChannel.configureBlocking(false);
|
serverChannel.configureBlocking(false);
|
||||||
|
@ -74,7 +73,6 @@ public class JnrTest
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
System.err.printf("server read=%d%n",read);
|
System.err.printf("server read=%d%n",read);
|
||||||
|
|
||||||
|
|
||||||
selected = clientSelector.selectNow();
|
selected = clientSelector.selectNow();
|
||||||
System.err.printf("clientSelected=%d %s%n",selected,clientSelector.selectedKeys());
|
System.err.printf("clientSelected=%d %s%n",selected,clientSelector.selectedKeys());
|
||||||
|
|
||||||
|
@ -92,8 +90,6 @@ public class JnrTest
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
System.err.printf("server read=%d '%s'%n",read,new String(buffer.array(),0,buffer.limit(),StandardCharsets.ISO_8859_1));
|
System.err.printf("server read=%d '%s'%n",read,new String(buffer.array(),0,buffer.limit(),StandardCharsets.ISO_8859_1));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
selected = clientSelector.selectNow();
|
selected = clientSelector.selectNow();
|
||||||
System.err.printf("clientSelected=%d %s%n",selected,clientSelector.selectedKeys());
|
System.err.printf("clientSelected=%d %s%n",selected,clientSelector.selectedKeys());
|
||||||
|
|
||||||
|
@ -116,10 +112,8 @@ public class JnrTest
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
System.err.printf("client read=%d '%s'%n",read,new String(buffer.array(),0,buffer.limit(),StandardCharsets.ISO_8859_1));
|
System.err.printf("client read=%d '%s'%n",read,new String(buffer.array(),0,buffer.limit(),StandardCharsets.ISO_8859_1));
|
||||||
|
|
||||||
|
|
||||||
System.err.println("So far so good.... now it gets strange...");
|
System.err.println("So far so good.... now it gets strange...");
|
||||||
|
|
||||||
|
|
||||||
// Let's write until flow control hit
|
// Let's write until flow control hit
|
||||||
|
|
||||||
int size = buffer.capacity();
|
int size = buffer.capacity();
|
||||||
|
@ -142,8 +136,6 @@ public class JnrTest
|
||||||
|
|
||||||
System.err.printf("server wrote %d before flow control%n",written);
|
System.err.printf("server wrote %d before flow control%n",written);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
selected = clientSelector.selectNow();
|
selected = clientSelector.selectNow();
|
||||||
System.err.printf("clientSelected=%d %s%n",selected,clientSelector.selectedKeys());
|
System.err.printf("clientSelected=%d %s%n",selected,clientSelector.selectedKeys());
|
||||||
key = clientSelector.selectedKeys().iterator().next();
|
key = clientSelector.selectedKeys().iterator().next();
|
||||||
|
@ -156,10 +148,7 @@ public class JnrTest
|
||||||
buffer.flip();
|
buffer.flip();
|
||||||
System.err.printf("client read=%d '%s'%n",read,new String(buffer.array(),0,buffer.limit(),StandardCharsets.ISO_8859_1));
|
System.err.printf("client read=%d '%s'%n",read,new String(buffer.array(),0,buffer.limit(),StandardCharsets.ISO_8859_1));
|
||||||
|
|
||||||
|
|
||||||
server.close();
|
server.close();
|
||||||
client.close();
|
client.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>jetty-unixsocket</artifactId>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>jetty-unixsocket-server</artifactId>
|
||||||
|
<name>Jetty :: UnixSocket :: Server</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<bundle-symbolic-name>${project.groupId}.unixsocket.server</bundle-symbolic-name>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-server</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="unixSocketHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
<Configure id="unixSocketHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||||
<Call name="addCustomizer">
|
<Call name="addCustomizer">
|
||||||
<Arg>
|
<Arg>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="unixSocketConnector" class="org.eclipse.jetty.unixsocket.UnixSocketConnector">
|
<Configure id="unixSocketConnector" class="org.eclipse.jetty.unixsocket.server.UnixSocketConnector">
|
||||||
<Call name="addConnectionFactory">
|
<Call name="addConnectionFactory">
|
||||||
<Arg>
|
<Arg>
|
||||||
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
|
@ -1,10 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<Configure id="unixSocketConnector" class="org.eclipse.jetty.unixsocket.server.UnixSocketConnector">
|
||||||
<!-- Configure a HTTP2 on the ssl connector. -->
|
|
||||||
<!-- ============================================================= -->
|
|
||||||
<Configure id="unixSocketConnector" class="org.eclipse.jetty.unixsocket.UnixSocketConnector">
|
|
||||||
<Call name="addConnectionFactory">
|
<Call name="addConnectionFactory">
|
||||||
<Arg>
|
<Arg>
|
||||||
<New class="org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory">
|
<New class="org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory">
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="unixSocketHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
<Configure id="unixSocketHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||||
<Call name="addCustomizer">
|
<Call name="addCustomizer">
|
||||||
<Arg>
|
<Arg>
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
|
||||||
|
|
||||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
@ -8,14 +8,10 @@
|
||||||
|
|
||||||
<Call name="addConnector">
|
<Call name="addConnector">
|
||||||
<Arg>
|
<Arg>
|
||||||
<New id="unixSocketConnector" class="org.eclipse.jetty.unixsocket.UnixSocketConnector">
|
<New id="unixSocketConnector" class="org.eclipse.jetty.unixsocket.server.UnixSocketConnector">
|
||||||
<Arg name="server"><Ref refid="Server" /></Arg>
|
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||||
<Arg name="selectors" type="int"><Property name="jetty.unixsocket.selectors" default="-1"/></Arg>
|
<Arg name="selectors" type="int"><Property name="jetty.unixsocket.selectors" default="-1"/></Arg>
|
||||||
<Arg name="factories">
|
<Set name="unixSocket"><Property name="jetty.unixsocket.path" default="/tmp/jetty.sock" /></Set>
|
||||||
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
|
||||||
</Array>
|
|
||||||
</Arg>
|
|
||||||
<Set name="unixSocket"><Property name="jetty.unixsocket" default="/tmp/jetty.sock" /></Set>
|
|
||||||
<Set name="idleTimeout"><Property name="jetty.unixsocket.idleTimeout" default="30000"/></Set>
|
<Set name="idleTimeout"><Property name="jetty.unixsocket.idleTimeout" default="30000"/></Set>
|
||||||
<Set name="acceptQueueSize"><Property name="jetty.unixsocket.acceptQueueSize" default="0"/></Set>
|
<Set name="acceptQueueSize"><Property name="jetty.unixsocket.acceptQueueSize" default="0"/></Set>
|
||||||
</New>
|
</New>
|
|
@ -38,7 +38,7 @@ lib/jetty-unixsocket-${jetty.version}.jar
|
||||||
lib/jnr/*.jar
|
lib/jnr/*.jar
|
||||||
|
|
||||||
[license]
|
[license]
|
||||||
Jetty UnixSockets is implmented using the Java Native Runtime, which is an
|
Jetty UnixSockets is implemented using the Java Native Runtime, which is an
|
||||||
open source project hosted on Github and released under the Apache 2.0 license.
|
open source project hosted on Github and released under the Apache 2.0 license.
|
||||||
https://github.com/jnr/jnr-unixsocket
|
https://github.com/jnr/jnr-unixsocket
|
||||||
http://www.apache.org/licenses/LICENSE-2.0.html
|
http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -46,13 +46,13 @@ http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
[ini-template]
|
[ini-template]
|
||||||
### Unix SocketHTTP Connector Configuration
|
### Unix SocketHTTP Connector Configuration
|
||||||
|
|
||||||
## Connector host/address to bind to
|
## Unix socket path to bind to
|
||||||
# jetty.unixsocket=/tmp/jetty.sock
|
# jetty.unixsocket.path=/tmp/jetty.sock
|
||||||
|
|
||||||
## Connector idle timeout in milliseconds
|
## Connector idle timeout in milliseconds
|
||||||
# jetty.unixsocket.idleTimeout=30000
|
# jetty.unixsocket.idleTimeout=30000
|
||||||
|
|
||||||
## Number of selectors (-1 picks default 1)
|
## Number of selectors (-1 picks default)
|
||||||
# jetty.unixsocket.selectors=-1
|
# jetty.unixsocket.selectors=-1
|
||||||
|
|
||||||
## ServerSocketChannel backlog (0 picks platform default)
|
## ServerSocketChannel backlog (0 picks platform default)
|
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
module org.eclipse.jetty.unixsocket.server
|
||||||
|
{
|
||||||
|
exports org.eclipse.jetty.unixsocket.server;
|
||||||
|
|
||||||
|
requires jnr.enxio;
|
||||||
|
requires jnr.unixsocket;
|
||||||
|
requires org.eclipse.jetty.io;
|
||||||
|
requires org.eclipse.jetty.server;
|
||||||
|
requires org.eclipse.jetty.unixsocket.common;
|
||||||
|
requires org.eclipse.jetty.util;
|
||||||
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
//
|
//
|
||||||
|
|
||||||
package org.eclipse.jetty.unixsocket;
|
package org.eclipse.jetty.unixsocket.server;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -28,8 +28,11 @@ import java.nio.channels.Selector;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
|
import jnr.enxio.channels.NativeSelectorProvider;
|
||||||
|
import jnr.unixsocket.UnixServerSocketChannel;
|
||||||
|
import jnr.unixsocket.UnixSocketAddress;
|
||||||
|
import jnr.unixsocket.UnixSocketChannel;
|
||||||
import org.eclipse.jetty.io.ByteBufferPool;
|
import org.eclipse.jetty.io.ByteBufferPool;
|
||||||
import org.eclipse.jetty.io.Connection;
|
import org.eclipse.jetty.io.Connection;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
|
@ -41,6 +44,7 @@ import org.eclipse.jetty.server.ConnectionFactory;
|
||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||||
|
import org.eclipse.jetty.unixsocket.common.UnixSocketEndPoint;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||||
import org.eclipse.jetty.util.annotation.Name;
|
import org.eclipse.jetty.util.annotation.Name;
|
||||||
|
@ -49,17 +53,11 @@ import org.eclipse.jetty.util.log.Logger;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
|
|
||||||
import jnr.enxio.channels.NativeSelectorProvider;
|
|
||||||
import jnr.unixsocket.UnixServerSocketChannel;
|
|
||||||
import jnr.unixsocket.UnixSocketAddress;
|
|
||||||
import jnr.unixsocket.UnixSocketChannel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@ManagedObject("Connector using UNIX Socket")
|
@ManagedObject("Connector using UNIX Socket")
|
||||||
public class UnixSocketConnector extends AbstractConnector
|
public class UnixSocketConnector extends AbstractConnector
|
||||||
{
|
{
|
||||||
|
// See SockAddrUnix.ADDR_LENGTH.
|
||||||
|
public static final int MAX_UNIX_SOCKET_PATH_LENGTH = 107;
|
||||||
private static final Logger LOG = Log.getLogger(UnixSocketConnector.class);
|
private static final Logger LOG = Log.getLogger(UnixSocketConnector.class);
|
||||||
|
|
||||||
private final SelectorManager _manager;
|
private final SelectorManager _manager;
|
||||||
|
@ -68,134 +66,110 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
private volatile int _acceptQueueSize = 0;
|
private volatile int _acceptQueueSize = 0;
|
||||||
private volatile boolean _reuseAddress = true;
|
private volatile boolean _reuseAddress = true;
|
||||||
|
|
||||||
|
/**
|
||||||
/* ------------------------------------------------------------ */
|
* HTTP Server Connection.
|
||||||
/** HTTP Server Connection.
|
|
||||||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
||||||
|
*
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(@Name("server") Server server)
|
public UnixSocketConnector(@Name("server") Server server)
|
||||||
{
|
{
|
||||||
this(server,null,null,null,-1,new HttpConnectionFactory());
|
this(server, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/**
|
||||||
/** HTTP Server Connection.
|
* HTTP Server Connection.
|
||||||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
||||||
|
*
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
* @param selectors
|
* @param selectors the number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||||
* the number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(
|
public UnixSocketConnector(@Name("server") Server server, @Name("selectors") int selectors)
|
||||||
@Name("server") Server server,
|
|
||||||
@Name("selectors") int selectors)
|
|
||||||
{
|
{
|
||||||
this(server,null,null,null,selectors,new HttpConnectionFactory());
|
this(server, selectors, new HttpConnectionFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/**
|
||||||
/** HTTP Server Connection.
|
* Generic Server Connection with default configuration.
|
||||||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
* <p>Construct a Server Connector with the passed Connection factories.</p>
|
||||||
|
*
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
* @param selectors
|
|
||||||
* the number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
|
||||||
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(
|
public UnixSocketConnector(@Name("server") Server server, @Name("factories") ConnectionFactory... factories)
|
||||||
@Name("server") Server server,
|
{
|
||||||
@Name("selectors") int selectors,
|
this(server, -1, factories);
|
||||||
@Name("factories") ConnectionFactory... factories)
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HTTP Server Connection.
|
||||||
|
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the only factory.</p>
|
||||||
|
*
|
||||||
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
|
* @param selectors the number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||||
|
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
||||||
|
*/
|
||||||
|
public UnixSocketConnector(@Name("server") Server server, @Name("selectors") int selectors, @Name("factories") ConnectionFactory... factories)
|
||||||
{
|
{
|
||||||
this(server, null, null, null, selectors, factories);
|
this(server, null, null, null, selectors, factories);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/**
|
||||||
/** Generic Server Connection with default configuration.
|
* HTTP Server Connection.
|
||||||
* <p>Construct a Server Connector with the passed Connection factories.</p>
|
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
|
||||||
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
|
||||||
*/
|
|
||||||
public UnixSocketConnector(
|
|
||||||
@Name("server") Server server,
|
|
||||||
@Name("factories") ConnectionFactory... factories)
|
|
||||||
{
|
|
||||||
this(server,null,null,null,-1,factories);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/** HTTP Server Connection.
|
|
||||||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the primary protocol</p>.
|
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the primary protocol</p>.
|
||||||
|
*
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
||||||
* list of HTTP Connection Factory.
|
* list of HTTP Connection Factory.
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(
|
public UnixSocketConnector(@Name("server") Server server, @Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||||
@Name("server") Server server,
|
|
||||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
|
||||||
{
|
{
|
||||||
this(server,null,null,null,-1,AbstractConnectionFactory.getFactories(sslContextFactory,new HttpConnectionFactory()));
|
this(server, -1, sslContextFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/**
|
||||||
/** HTTP Server Connection.
|
* HTTP Server Connection.
|
||||||
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the primary protocol</p>.
|
* <p>Construct a ServerConnector with a private instance of {@link HttpConnectionFactory} as the primary protocol</p>.
|
||||||
|
*
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
||||||
* list of HTTP Connection Factory.
|
* list of HTTP Connection Factory.
|
||||||
* @param selectors
|
* @param selectors the number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
||||||
* the number of selector threads, or <=0 for a default value. Selectors notice and schedule established connection that can make IO progress.
|
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(
|
public UnixSocketConnector(@Name("server") Server server, @Name("selectors") int selectors, @Name("sslContextFactory") SslContextFactory sslContextFactory)
|
||||||
@Name("server") Server server,
|
|
||||||
@Name("selectors") int selectors,
|
|
||||||
@Name("sslContextFactory") SslContextFactory sslContextFactory)
|
|
||||||
{
|
{
|
||||||
this(server, null, null, null, selectors, AbstractConnectionFactory.getFactories(sslContextFactory, new HttpConnectionFactory()));
|
this(server, null, null, null, selectors, AbstractConnectionFactory.getFactories(sslContextFactory, new HttpConnectionFactory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/**
|
||||||
/** Generic SSL Server Connection.
|
* Generic SSL Server Connection.
|
||||||
|
*
|
||||||
* @param server The {@link Server} this connector will accept connection for.
|
* @param server The {@link Server} this connector will accept connection for.
|
||||||
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
* @param sslContextFactory If non null, then a {@link SslConnectionFactory} is instantiated and prepended to the
|
||||||
* list of ConnectionFactories, with the first factory being the default protocol for the SslConnectionFactory.
|
* list of ConnectionFactories, with the first factory being the default protocol for the SslConnectionFactory.
|
||||||
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(
|
public UnixSocketConnector(@Name("server") Server server, @Name("sslContextFactory") SslContextFactory sslContextFactory, @Name("factories") ConnectionFactory... factories)
|
||||||
@Name("server") Server server,
|
|
||||||
@Name("sslContextFactory") SslContextFactory sslContextFactory,
|
|
||||||
@Name("factories") ConnectionFactory... factories)
|
|
||||||
{
|
{
|
||||||
this(server, null, null, null, -1, AbstractConnectionFactory.getFactories(sslContextFactory, factories));
|
this(server, null, null, null, -1, AbstractConnectionFactory.getFactories(sslContextFactory, factories));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generic Server Connection.
|
/**
|
||||||
* @param server
|
* Generic Server Connection.
|
||||||
* The server this connector will be accept connection for.
|
*
|
||||||
* @param executor
|
* @param server The server this connector will be accept connection for.
|
||||||
* An executor used to run tasks for handling requests, acceptors and selectors.
|
* @param executor An executor used to run tasks for handling requests, acceptors and selectors.
|
||||||
* If null then use the servers executor
|
* If null then use the servers executor
|
||||||
* @param scheduler
|
* @param scheduler A scheduler used to schedule timeouts. If null then use the servers scheduler
|
||||||
* A scheduler used to schedule timeouts. If null then use the servers scheduler
|
* @param bufferPool A ByteBuffer pool used to allocate buffers. If null then create a private pool with default configuration.
|
||||||
* @param bufferPool
|
* @param selectors the number of selector threads, or <=0 for a default value(1). Selectors notice and schedule established connection that can make IO progress.
|
||||||
* A ByteBuffer pool used to allocate buffers. If null then create a private pool with default configuration.
|
* @param factories Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
||||||
* @param selectors
|
|
||||||
* the number of selector threads, or <=0 for a default value(1). Selectors notice and schedule established connection that can make IO progress.
|
|
||||||
* @param factories
|
|
||||||
* Zero or more {@link ConnectionFactory} instances used to create and configure connections.
|
|
||||||
*/
|
*/
|
||||||
public UnixSocketConnector(
|
public UnixSocketConnector(@Name("server") Server server, @Name("executor") Executor executor, @Name("scheduler") Scheduler scheduler, @Name("bufferPool") ByteBufferPool bufferPool, @Name("selectors") int selectors, @Name("factories") ConnectionFactory... factories)
|
||||||
@Name("server") Server server,
|
|
||||||
@Name("executor") Executor executor,
|
|
||||||
@Name("scheduler") Scheduler scheduler,
|
|
||||||
@Name("bufferPool") ByteBufferPool bufferPool,
|
|
||||||
@Name("selectors") int selectors,
|
|
||||||
@Name("factories") ConnectionFactory... factories)
|
|
||||||
{
|
{
|
||||||
super(server, executor, scheduler, bufferPool, 0, factories);
|
super(server, executor, scheduler, bufferPool, 0, factories);
|
||||||
_manager = newSelectorManager(getExecutor(), getScheduler(),
|
_manager = newSelectorManager(getExecutor(), getScheduler(), selectors > 0 ? selectors : 1);
|
||||||
selectors>0?selectors:1);
|
|
||||||
addBean(_manager, true);
|
addBean(_manager, true);
|
||||||
setAcceptorPriorityDelta(-2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ManagedAttribute
|
@ManagedAttribute
|
||||||
|
@ -206,6 +180,8 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
|
|
||||||
public void setUnixSocket(String filename)
|
public void setUnixSocket(String filename)
|
||||||
{
|
{
|
||||||
|
if (filename.length() > MAX_UNIX_SOCKET_PATH_LENGTH)
|
||||||
|
throw new IllegalArgumentException("Unix socket path too long");
|
||||||
_unixSocket = filename;
|
_unixSocket = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +195,6 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
{
|
{
|
||||||
open();
|
open();
|
||||||
super.doStart();
|
super.doStart();
|
||||||
|
|
||||||
if (getAcceptors() == 0)
|
if (getAcceptors() == 0)
|
||||||
_manager.acceptor(_acceptChannel);
|
_manager.acceptor(_acceptChannel);
|
||||||
}
|
}
|
||||||
|
@ -231,13 +206,6 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOpen()
|
|
||||||
{
|
|
||||||
UnixServerSocketChannel channel = _acceptChannel;
|
|
||||||
return channel!=null && channel.isOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void open() throws IOException
|
public void open() throws IOException
|
||||||
{
|
{
|
||||||
if (_acceptChannel == null)
|
if (_acceptChannel == null)
|
||||||
|
@ -246,7 +214,6 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
file.deleteOnExit();
|
file.deleteOnExit();
|
||||||
SocketAddress bindAddress = new UnixSocketAddress(file);
|
SocketAddress bindAddress = new UnixSocketAddress(file);
|
||||||
UnixServerSocketChannel serverChannel = UnixServerSocketChannel.open();
|
UnixServerSocketChannel serverChannel = UnixServerSocketChannel.open();
|
||||||
|
|
||||||
serverChannel.configureBlocking(getAcceptors() > 0);
|
serverChannel.configureBlocking(getAcceptors() > 0);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -264,13 +231,6 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Future<Void> shutdown()
|
|
||||||
{
|
|
||||||
// shutdown all the connections
|
|
||||||
return super.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close()
|
public void close()
|
||||||
{
|
{
|
||||||
UnixServerSocketChannel serverChannel = _acceptChannel;
|
UnixServerSocketChannel serverChannel = _acceptChannel;
|
||||||
|
@ -340,7 +300,6 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
return new UnixSocketEndPoint((UnixSocketChannel)channel, selector, key, getScheduler());
|
return new UnixSocketEndPoint((UnixSocketChannel)channel, selector, key, getScheduler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the accept queue size
|
* @return the accept queue size
|
||||||
*/
|
*/
|
||||||
|
@ -376,7 +335,6 @@ public class UnixSocketConnector extends AbstractConnector
|
||||||
_reuseAddress = reuseAddress;
|
_reuseAddress = reuseAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
|
@ -34,6 +34,7 @@ import org.eclipse.jetty.server.ProxyConnectionFactory;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
|
import org.eclipse.jetty.unixsocket.server.UnixSocketConnector;
|
||||||
|
|
||||||
public class UnixSocketProxyServer
|
public class UnixSocketProxyServer
|
||||||
{
|
{
|
|
@ -25,15 +25,14 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.eclipse.jetty.server.HttpConnectionFactory;
|
import org.eclipse.jetty.server.HttpConnectionFactory;
|
||||||
import org.eclipse.jetty.server.ProxyConnectionFactory;
|
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
|
import org.eclipse.jetty.unixsocket.server.UnixSocketConnector;
|
||||||
|
|
||||||
public class UnixSocketServer
|
public class UnixSocketServer
|
||||||
{
|
{
|
||||||
|
@ -53,7 +52,7 @@ public class UnixSocketServer
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void doNonErrorHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
protected void doNonErrorHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||||
throws IOException, ServletException
|
throws IOException
|
||||||
{
|
{
|
||||||
int l = 0;
|
int l = 0;
|
||||||
if (request.getContentLength()!=0)
|
if (request.getContentLength()!=0)
|
|
@ -0,0 +1,3 @@
|
||||||
|
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||||
|
#org.eclipse.jetty.LEVEL=DEBUG
|
||||||
|
#org.eclipse.jetty.unixsocket.LEVEL=DEBUG
|
|
@ -1,48 +1,21 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-project</artifactId>
|
<artifactId>jetty-project</artifactId>
|
||||||
<version>10.0.0-SNAPSHOT</version>
|
<version>10.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>jetty-unixsocket</artifactId>
|
<artifactId>jetty-unixsocket</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
<name>Jetty :: UnixSocket</name>
|
<name>Jetty :: UnixSocket</name>
|
||||||
<description>Jetty UnixSocket</description>
|
<description>Jetty UnixSocket Parent</description>
|
||||||
<url>http://www.eclipse.org/jetty</url>
|
|
||||||
<properties>
|
<modules>
|
||||||
<bundle-symbolic-name>${project.groupId}.unixsocket</bundle-symbolic-name>
|
<module>jetty-unixsocket-common</module>
|
||||||
</properties>
|
<module>jetty-unixsocket-client</module>
|
||||||
<build>
|
<module>jetty-unixsocket-server</module>
|
||||||
<plugins>
|
</modules>
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>findbugs-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<onlyAnalyze>org.eclipse.jetty.unixsocket.*</onlyAnalyze>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-server</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.jnr</groupId>
|
|
||||||
<artifactId>jnr-unixsocket</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-client</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
|
||||||
<artifactId>jetty-test-helper</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Binary file not shown.
|
@ -1,8 +0,0 @@
|
||||||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
|
||||||
#org.eclipse.jetty.LEVEL=DEBUG
|
|
||||||
#org.eclipse.jetty.client.LEVEL=DEBUG
|
|
||||||
#org.eclipse.jetty.proxy.LEVEL=DEBUG
|
|
||||||
#org.eclipse.jetty.unixsocket.LEVEL=DEBUG
|
|
||||||
#org.eclipse.jetty.io.LEVEL=DEBUG
|
|
||||||
#org.eclipse.jetty.server.ProxyConnectionFactory.LEVEL=DEBUG
|
|
||||||
#org.eclipse.jetty.unixsocket.LEVEL=DEBUG
|
|
2
pom.xml
2
pom.xml
|
@ -1034,7 +1034,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.jnr</groupId>
|
<groupId>com.github.jnr</groupId>
|
||||||
<artifactId>jnr-unixsocket</artifactId>
|
<artifactId>jnr-unixsocket</artifactId>
|
||||||
<version>0.20</version>
|
<version>0.22</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|
|
@ -86,7 +86,13 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-unixsocket</artifactId>
|
<artifactId>jetty-unixsocket-client</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-unixsocket-server</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -18,20 +18,6 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.http.client;
|
package org.eclipse.jetty.http.client;
|
||||||
|
|
||||||
import static java.nio.ByteBuffer.wrap;
|
|
||||||
import static org.eclipse.jetty.http.client.Transport.FCGI;
|
|
||||||
import static org.eclipse.jetty.util.BufferUtil.toArray;
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
|
||||||
import static org.hamcrest.Matchers.is;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -85,7 +71,7 @@ import org.eclipse.jetty.server.HttpInput.Content;
|
||||||
import org.eclipse.jetty.server.Request;
|
import org.eclipse.jetty.server.Request;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
import org.eclipse.jetty.server.handler.ContextHandler.Context;
|
import org.eclipse.jetty.server.handler.ContextHandler.Context;
|
||||||
import org.eclipse.jetty.unixsocket.UnixSocketConnector;
|
import org.eclipse.jetty.unixsocket.server.UnixSocketConnector;
|
||||||
import org.eclipse.jetty.util.BufferUtil;
|
import org.eclipse.jetty.util.BufferUtil;
|
||||||
import org.eclipse.jetty.util.FuturePromise;
|
import org.eclipse.jetty.util.FuturePromise;
|
||||||
import org.eclipse.jetty.util.log.StacklessLogging;
|
import org.eclipse.jetty.util.log.StacklessLogging;
|
||||||
|
@ -96,6 +82,20 @@ import org.junit.jupiter.api.Tag;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.ArgumentsSource;
|
import org.junit.jupiter.params.provider.ArgumentsSource;
|
||||||
|
|
||||||
|
import static java.nio.ByteBuffer.wrap;
|
||||||
|
import static org.eclipse.jetty.http.client.Transport.FCGI;
|
||||||
|
import static org.eclipse.jetty.util.BufferUtil.toArray;
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class AsyncIOServletTest extends AbstractTest<AsyncIOServletTest.AsyncTransportScenario>
|
public class AsyncIOServletTest extends AbstractTest<AsyncIOServletTest.AsyncTransportScenario>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,8 +53,8 @@ import org.eclipse.jetty.server.Connector;
|
||||||
import org.eclipse.jetty.server.Server;
|
import org.eclipse.jetty.server.Server;
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||||
import org.eclipse.jetty.unixsocket.UnixSocketConnector;
|
|
||||||
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
||||||
|
import org.eclipse.jetty.unixsocket.server.UnixSocketConnector;
|
||||||
import org.eclipse.jetty.util.IO;
|
import org.eclipse.jetty.util.IO;
|
||||||
import org.eclipse.jetty.util.LeakDetector;
|
import org.eclipse.jetty.util.LeakDetector;
|
||||||
import org.eclipse.jetty.util.ProcessorUtils;
|
import org.eclipse.jetty.util.ProcessorUtils;
|
||||||
|
|
|
@ -56,8 +56,8 @@ import org.eclipse.jetty.server.SslConnectionFactory;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
import org.eclipse.jetty.unixsocket.UnixSocketConnector;
|
|
||||||
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets;
|
||||||
|
import org.eclipse.jetty.unixsocket.server.UnixSocketConnector;
|
||||||
import org.eclipse.jetty.util.BlockingArrayQueue;
|
import org.eclipse.jetty.util.BlockingArrayQueue;
|
||||||
import org.eclipse.jetty.util.SocketAddressResolver;
|
import org.eclipse.jetty.util.SocketAddressResolver;
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
|
Loading…
Reference in New Issue