Skip to content

Commit

Permalink
[*] switched to Tomcat 8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-karpovich committed Mar 11, 2024
1 parent cb71ba8 commit 11bd024
Show file tree
Hide file tree
Showing 32 changed files with 749 additions and 748 deletions.
7 changes: 4 additions & 3 deletions java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,13 @@ configure(leafProjects) {
// entry 'hadoop-yarn-common'
// }

dependencySet(group: 'org.apache.tomcat.embed', version: '8.0.53') {
dependencySet(group: 'org.apache.tomcat.embed', version: '8.5.90') {
entry 'tomcat-embed-core' // Tomcat core
entry 'tomcat-embed-jasper' // Tomcat JSP support
entry 'tomcat-embed-logging-juli' // Tomcat Logging
}

dependency 'org.apache.tomcat.embed:tomcat-embed-logging-juli:8.5.2'

dependencySet(group: 'io.aeron', version: '1.38.1') {
entry 'aeron-client'
entry 'aeron-driver'
Expand Down Expand Up @@ -245,7 +246,7 @@ configure(leafProjects) {
dependency 'commons-codec:commons-codec:1.13'
dependency 'commons-net:commons-net:3.9.0'

dependency 'org.apache.commons:commons-compress:1.21'
dependency 'org.apache.commons:commons-compress:1.26.0'
dependency 'org.apache.commons:commons-lang3:3.7'
dependency 'org.apache.commons:commons-math3:3.6'
dependency 'org.apache.commons:commons-text:1.10.0'
Expand Down
2 changes: 1 addition & 1 deletion java/installer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
izpack 'com.fasterxml.jackson.core:jackson-core:2.10.5'
izpack 'com.fasterxml.jackson.core:jackson-annotations:2.10.5'

izpack 'org.apache.commons:commons-compress:1.19'
izpack 'org.apache.commons:commons-compress:1.26.0'
izpack 'commons-io:commons-io:2.7'

izpack 'org.apache.pdfbox:pdfbox:2.0.24'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ public interface EmbeddedServer {
* @return port number
*/
int getPort();

int getWebPort();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.epam.deltix.util.vsocket;

public interface DBConnectionAcceptor {
boolean accept(String clientId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.epam.deltix.util.vsocket;

public class DefaultConnectionAcceptor implements DBConnectionAcceptor {
public static final DefaultConnectionAcceptor INSTANCE = new DefaultConnectionAcceptor();

private DefaultConnectionAcceptor() {
}

@Override
public boolean accept(String clientId) {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class VSServerFramework implements ConnectionHandshakeHandler, Disposable
public final static short MAX_SOCKETS_PER_CONNECTION = 8;

private final Map <String, Connector> dispatchers =
new HashMap <> ();
new HashMap <> ();

private final QuickExecutor executor;
private final ContextContainer contextContainer;
Expand All @@ -60,6 +60,8 @@ public class VSServerFramework implements ConnectionHandshakeHandler, Disposable

private TransportType transportType = TransportType.SOCKET_TCP;

private final DBConnectionAcceptor connectionAcceptor;

public static final Comparator <VSDispatcher> comparator = new Comparator <VSDispatcher>() {

@Override
Expand All @@ -68,8 +70,14 @@ public int compare (VSDispatcher o1, VSDispatcher o2) {
}
};

public VSServerFramework(QuickExecutor executor, int reconnectInterval,
VSCompression compression, int connectionsLimit, short socketsPerConnection, ContextContainer contextContainer) {
public VSServerFramework(QuickExecutor executor,
int reconnectInterval,
VSCompression compression,
int connectionsLimit,
short socketsPerConnection,
ContextContainer contextContainer,
DBConnectionAcceptor connectionAcceptor) {
this.connectionAcceptor = connectionAcceptor;
this.executor = executor;
this.reconnectInterval = reconnectInterval;
this.time = System.currentTimeMillis();
Expand All @@ -81,7 +89,7 @@ public VSServerFramework(QuickExecutor executor, int reconnectInterval,
}

public VSServerFramework(QuickExecutor executor, int reconnectInterval, VSCompression compression, ContextContainer contextContainer) {
this(executor, reconnectInterval, compression, MAX_CONNECTIONS, MAX_SOCKETS_PER_CONNECTION, contextContainer);
this(executor, reconnectInterval, compression, MAX_CONNECTIONS, MAX_SOCKETS_PER_CONNECTION, contextContainer, DefaultConnectionAcceptor.INSTANCE);
}

public QuickExecutor getExecutor () {
Expand All @@ -102,6 +110,12 @@ public QuickExecutor getExecutor () {
return (ret);
}

public int getDispatchersCount() {
synchronized (dispatchers) {
return dispatchers.size();
}
}

public VSDispatcher getDispatcher(String id) {
synchronized (dispatchers) {
Connector connector = dispatchers.get(id);
Expand Down Expand Up @@ -148,8 +162,8 @@ public boolean handleHandshake (Socket s) throws IOException {
s.setKeepAlive(true);

return handleHandshake(
SocketConnectionFactory.createConnection(
s, new BufferedInputStream(s.getInputStream()), s.getOutputStream())
SocketConnectionFactory.createConnection(
s, new BufferedInputStream(s.getInputStream()), s.getOutputStream())
);
}

Expand All @@ -161,7 +175,7 @@ public boolean handleHandshake(Socket s, BufferedInputStream is, OutputStream os
s.setKeepAlive(true);

return handleHandshake(
SocketConnectionFactory.createConnection(s, is, os)
SocketConnectionFactory.createConnection(s, is, os)
);
}

Expand Down Expand Up @@ -210,17 +224,23 @@ private boolean handleHandshakeInternal (Connection c) throws IOExc

if (!isCompatible) {
VSProtocol.LOGGER.severe (
"Connection from " + clientId + " rejected due to incompatible protocol version #" +
clientVersion + " (accepted: " +
MIN_COMPATIBLE_CLIENT_VERSION + " .. " +
MAX_COMPATIBLE_CLIENT_VERSION + ")"
"Connection from " + clientId + " rejected due to incompatible protocol version #" +
clientVersion + " (accepted: " +
MIN_COMPATIBLE_CLIENT_VERSION + " .. " +
MAX_COMPATIBLE_CLIENT_VERSION + ")"
);

dout.writeByte (VSProtocol.CONN_RESP_INCOMPATIBLE_CLIENT);
dout.flush ();
return (false);
}

if (!connectionAcceptor.accept(clientId)) {
dout.writeByte(VSProtocol.CONN_RESP_CONNECTION_REJECTED);
dout.flush();
return false;
}

dout.writeInt(tlsContext == null ? 0 : tlsContext.port);

if (clientVersion > 1014)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ public void removePropertyChangeListener(PropertyChangeListener propertyChangeLi
//To change body of implemented methods use File | Settings | File Templates.
}

@Override
public String[] getRoles(Principal principal) {
return new String[0];
}

@Override
public boolean isAvailable() {
return true;
}

@Override
public Principal authenticate(String username, String credentials) {
try {
Expand All @@ -106,6 +116,11 @@ public Principal authenticate(String s, String s1, String s2, String s3, String
return null;
}

@Override
public Principal authenticate(String username, String digest, String nonce, String nc, String cnonce, String qop, String realm, String digestA2, String algorithm) {
return null;
}

@Override
public Principal authenticate(GSSContext gssContext, boolean storeCreds) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.epam.deltix.qsrv.comm.cat;

import com.epam.deltix.util.io.IOUtil;
import com.epam.deltix.util.lang.Disposable;
import com.epam.deltix.util.tomcat.ConnectionHandler;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SocketServer extends Thread implements Disposable {

public static final Logger LOGGER = Logger.getLogger ("deltix.tickdb.server");

private final ConnectionHandler connectionHandler;
private final ServerSocket serverSocket;
private final ExecutorService executor = Executors.newFixedThreadPool(4);
private volatile boolean running;

public SocketServer(ConnectionHandler connectionHandler) throws IOException {
this(0, connectionHandler);
}

public SocketServer(int port, ConnectionHandler connectionHandler) throws IOException {
this(port, null, connectionHandler);
}

public SocketServer(int port, InetAddress address, ConnectionHandler connectionHandler) throws IOException {
this(new ServerSocket(port, 0, address), connectionHandler);
}

public SocketServer(ServerSocket serverSocket, ConnectionHandler connectionHandler) {
super("VSServer on " + serverSocket);

this.serverSocket = serverSocket;
this.connectionHandler = connectionHandler;
}

public int getLocalPort() {
return (serverSocket.getLocalPort());
}

public int getSoTimeout() throws IOException {
return serverSocket.getSoTimeout();
}

public void setSoTimeout(int readTimeout) throws SocketException {
serverSocket.setSoTimeout(readTimeout);
}

@Override
public void run() {
running = true;

LOGGER.log(Level.INFO, "Listening connections on port: " + serverSocket.getLocalPort());

while (running) {
try {
final Socket s = serverSocket.accept();

executor.execute(() -> {
try {
BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
OutputStream os = s.getOutputStream();
if (!connectionHandler.handleConnection(s, bis, os)) {
s.close();
}
} catch (Throwable t) {
IOUtil.close(s);
LOGGER.log(
Level.SEVERE,
"Exception while handling handshake",
t
);
}
});
} catch (IOException iox) {
if (!serverSocket.isClosed())
LOGGER.log(
Level.SEVERE,
"Exception while accepting connections",
iox
);
}
}

if (!serverSocket.isClosed())
IOUtil.close(serverSocket);
}

@Override
public void close() {
running = false;
IOUtil.close(serverSocket);
executor.shutdownNow();
interrupt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class StartConfiguration {

private static ObjectToObjectHashMap<Type, String> DEFAULTS = new ObjectToObjectHashMap<>();
private static final ObjectToObjectHashMap<Type, String> DEFAULTS = new ObjectToObjectHashMap<>();
static {
DEFAULTS.put(Type.TimeBase, "com.epam.deltix.qsrv.config.TimebaseServiceExecutor");
DEFAULTS.put(Type.QuantServer, QuantServerExecutor.class.getName());
Expand All @@ -37,7 +37,9 @@ public class StartConfiguration {

public int port;

private ObjectToObjectHashMap<Type, ServiceExecutor> executors = new ObjectToObjectHashMap<>();
public int webPort;

private final ObjectToObjectHashMap<Type, ServiceExecutor> executors = new ObjectToObjectHashMap<>();

public static StartConfiguration create(boolean timebase, boolean aggregator, boolean uhf) throws IOException {
return create(timebase, aggregator, uhf, false, false, -1);
Expand Down
Loading

0 comments on commit 11bd024

Please sign in to comment.