Initial partial implementation
This commit is contained in:
parent
be1576f26c
commit
665cd730fd
|
@ -1,6 +1,3 @@
|
||||||
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
|
|
||||||
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
|
|
||||||
|
|
||||||
name: Maven Package
|
name: Maven Package
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
@ -38,23 +35,6 @@ jobs:
|
||||||
env:
|
env:
|
||||||
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
||||||
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|
MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|
||||||
# - name: Deploy lucene to Maven (Release)
|
|
||||||
# if: github.ref == 'refs/heads/master'
|
|
||||||
# shell: bash
|
|
||||||
# run: |
|
|
||||||
# cd lucene
|
|
||||||
# ./gradlew assemble -x test -x errorprone publishToMavenLocal -x signJarsPublication
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-core -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/core/build/libs/lucene-core-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/core/build/libs/lucene-core-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/core/build/libs/lucene-core-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-join -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/join/build/libs/lucene-join-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/join/build/libs/lucene-join-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/join/build/libs/lucene-join-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-analysis-common -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/analysis/common/build/libs/lucene-analysis-common-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/analysis/common/build/libs/lucene-analysis-common-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/analysis/common/build/libs/lucene-analysis-common-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-analysis-icu -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/analysis/icu/build/libs/lucene-analysis-icu-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/analysis/icu/build/libs/lucene-analysis-icu-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/analysis/icu/build/libs/lucene-analysis-icu-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-codecs -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/codecs/build/libs/lucene-codecs-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/codecs/build/libs/lucene-codecs-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/codecs/build/libs/lucene-codecs-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-backward-codecs -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/backward-codecs/build/libs/lucene-backward-codecs-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/backward-codecs/build/libs/lucene-backward-codecs-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/backward-codecs/build/libs/lucene-backward-codecs-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-queries -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/queries/build/libs/lucene-queries-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/queries/build/libs/lucene-queries-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/queries/build/libs/lucene-queries-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# mvn deploy:deploy-file -DgroupId=org.lucene -DartifactId=lucene-misc -Dversion=9.0.0-SNAPSHOT -DgeneratePom=true -Dpackaging=jar -DrepositoryId=mchv-release-distribution -Durl=https://mvn.mchv.eu/repository/mchv-snapshot -Dfile=lucene/misc/build/libs/lucene-misc-9.0.0-SNAPSHOT.jar -Djavadoc=lucene/misc/build/libs/lucene-misc-9.0.0-SNAPSHOT-javadoc.jar -Dsources=lucene/misc/build/libs/lucene-misc-9.0.0-SNAPSHOT-sources.jar
|
|
||||||
# env:
|
|
||||||
# MAVEN_USERNAME: ${{ secrets.MCHV_USERNAME }}
|
|
||||||
# MAVEN_PASSWORD: ${{ secrets.MCHV_TOKEN }}
|
|
||||||
- name: Deploy to Maven (Release)
|
- name: Deploy to Maven (Release)
|
||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
target/
|
211
pom.xml
211
pom.xml
|
@ -0,0 +1,211 @@
|
||||||
|
<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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<name>CavalliumDBEngine Server</name>
|
||||||
|
|
||||||
|
<groupId>it.cavallium</groupId>
|
||||||
|
<artifactId>dbengine-server</artifactId>
|
||||||
|
<version>1.0.${revision}</version>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<revision>0-SNAPSHOT</revision>
|
||||||
|
<dbengine.ci>false</dbengine.ci>
|
||||||
|
</properties>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>mchv-release</id>
|
||||||
|
<name>MCHV Release Apache Maven Packages</name>
|
||||||
|
<url>https://mvn.mchv.eu/repository/mchv</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>mchv-snapshot</id>
|
||||||
|
<name>MCHV Snapshot Apache Maven Packages</name>
|
||||||
|
<url>https://mvn.mchv.eu/repository/mchv-snapshot</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>mulesoft-public-snapshots</id>
|
||||||
|
<name>MuleSoft public snapshots</name>
|
||||||
|
<url>https://repository.mulesoft.org/nexus/content/repositories/public</url>
|
||||||
|
<releases><enabled>false</enabled></releases>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>netty5-snapshots</id>
|
||||||
|
<name>Netty 5 snapshots</name>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<releases><enabled>true</enabled></releases>
|
||||||
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>mchv-release-distribution</id>
|
||||||
|
<name>MCHV Release Apache Maven Packages Distribution</name>
|
||||||
|
<url>https://mvn.mchv.eu/repository/mchv</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>mchv-snapshot-distribution</id>
|
||||||
|
<name>MCHV Snapshot Apache Maven Packages Distribution</name>
|
||||||
|
<url>https://mvn.mchv.eu/repository/mchv-snapshot</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:https://git.ignuranza.net/andreacavalli/CavalliumDBEngine-Server.git</connection>
|
||||||
|
<developerConnection>scm:git:https://git.ignuranza.net/andreacavalli/CavalliumDBEngine-Server.git</developerConnection>
|
||||||
|
<tag>HEAD</tag>
|
||||||
|
</scm>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.projectreactor</groupId>
|
||||||
|
<artifactId>reactor-bom</artifactId>
|
||||||
|
<version>2020.0.16</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lmax</groupId>
|
||||||
|
<artifactId>disruptor</artifactId>
|
||||||
|
<version>3.4.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.projectreactor.netty</groupId>
|
||||||
|
<artifactId>reactor-netty-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>it.cavallium</groupId>
|
||||||
|
<artifactId>dbengine</artifactId>
|
||||||
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.projectreactor.netty</groupId>
|
||||||
|
<artifactId>reactor-netty-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||||
|
<extensions>
|
||||||
|
<extension>
|
||||||
|
<groupId>kr.motd.maven</groupId>
|
||||||
|
<artifactId>os-maven-plugin</artifactId>
|
||||||
|
<version>1.5.0.Final</version>
|
||||||
|
</extension>
|
||||||
|
</extensions>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>3.0.0-M1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||||
|
<overWriteReleases>false</overWriteReleases>
|
||||||
|
<overWriteSnapshots>false</overWriteSnapshots>
|
||||||
|
<overWriteIfNewer>true</overWriteIfNewer>
|
||||||
|
<prependGroupId>true</prependGroupId>
|
||||||
|
<stripVersion>true</stripVersion>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<release>17</release>
|
||||||
|
<annotationProcessorPaths>
|
||||||
|
<annotationProcessorPath>
|
||||||
|
<groupId>io.soabase.record-builder</groupId>
|
||||||
|
<artifactId>record-builder-processor</artifactId>
|
||||||
|
<version>1.19</version>
|
||||||
|
</annotationProcessorPath>
|
||||||
|
</annotationProcessorPaths>
|
||||||
|
<annotationProcessors>
|
||||||
|
<annotationProcessor>io.soabase.recordbuilder.processor.RecordBuilderProcessor</annotationProcessor>
|
||||||
|
</annotationProcessors>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.0.0-M5</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>5.8.0-M1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<configuration>
|
||||||
|
<argLine>--add-modules jdk.incubator.foreign -Dforeign.restricted=permit --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --enable-native-access=ALL-UNNAMED</argLine>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>ci</name>
|
||||||
|
<value>${dbengine.ci}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
<version>3.0.0-M3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>enforce</id>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<dependencyConvergence/>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>enforce</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -1,18 +1,51 @@
|
||||||
package it.cavallium.dbengine.database.remote;
|
package it.cavallium.dbengine.database.remote;
|
||||||
|
|
||||||
|
import io.micrometer.core.instrument.MeterRegistry;
|
||||||
|
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
|
||||||
|
import io.micrometer.core.instrument.noop.NoopMeter;
|
||||||
|
import io.net5.buffer.api.DefaultBufferAllocators;
|
||||||
import io.netty.handler.ssl.ClientAuth;
|
import io.netty.handler.ssl.ClientAuth;
|
||||||
import io.netty.incubator.codec.quic.InsecureQuicTokenHandler;
|
import io.netty.incubator.codec.quic.InsecureQuicTokenHandler;
|
||||||
|
import io.netty.incubator.codec.quic.QuicConnectionIdGenerator;
|
||||||
import io.netty.incubator.codec.quic.QuicSslContext;
|
import io.netty.incubator.codec.quic.QuicSslContext;
|
||||||
import io.netty.incubator.codec.quic.QuicSslContextBuilder;
|
import io.netty.incubator.codec.quic.QuicSslContextBuilder;
|
||||||
|
import it.cavallium.dbengine.database.LLKeyValueDatabase;
|
||||||
|
import it.cavallium.dbengine.database.LLLuceneIndex;
|
||||||
|
import it.cavallium.dbengine.database.disk.LLLocalDatabaseConnection;
|
||||||
|
import it.cavallium.dbengine.database.remote.RPCCodecs.RPCClientBoundResponseDecoder;
|
||||||
|
import it.cavallium.dbengine.database.remote.RPCCodecs.RPCServerBoundRequestDecoder;
|
||||||
|
import it.cavallium.dbengine.rpc.current.data.GeneratedEntityId;
|
||||||
|
import it.cavallium.dbengine.rpc.current.data.GetDatabase;
|
||||||
import it.cavallium.dbengine.rpc.current.data.ServerBoundRequest;
|
import it.cavallium.dbengine.rpc.current.data.ServerBoundRequest;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
import reactor.core.publisher.SignalType;
|
||||||
|
|
||||||
public class QuicServer {
|
public class QuicServer {
|
||||||
|
|
||||||
|
private static final Logger LOG = LogManager.getLogger(QuicServer.class);
|
||||||
|
private static LLLocalDatabaseConnection localDb;
|
||||||
|
|
||||||
|
private static final AtomicLong nextResourceId = new AtomicLong(1);
|
||||||
|
private static final ConcurrentHashMap<String, Long> dbToId = new ConcurrentHashMap<>();
|
||||||
|
private static final ConcurrentHashMap<Long, LLKeyValueDatabase> dbById = new ConcurrentHashMap<>();
|
||||||
|
private static final ConcurrentHashMap<String, Long> indexToId = new ConcurrentHashMap<>();
|
||||||
|
private static final ConcurrentHashMap<Long, LLLuceneIndex> indexById = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static void main(String[] args) throws URISyntaxException {
|
public static void main(String[] args) throws URISyntaxException {
|
||||||
|
localDb = new LLLocalDatabaseConnection(DefaultBufferAllocators.preferredAllocator(),
|
||||||
|
new CompositeMeterRegistry(), Path.of("."), false);
|
||||||
String keyFileLocation = System.getProperty("it.cavalliumdb.keyFile", null);
|
String keyFileLocation = System.getProperty("it.cavalliumdb.keyFile", null);
|
||||||
String keyFilePassword = System.getProperty("it.cavalliumdb.keyPassword", null);
|
String keyFilePassword = System.getProperty("it.cavalliumdb.keyPassword", null);
|
||||||
String certFileLocation = System.getProperty("it.cavalliumdb.certFile", null);
|
String certFileLocation = System.getProperty("it.cavalliumdb.certFile", null);
|
||||||
|
@ -28,22 +61,59 @@ public class QuicServer {
|
||||||
.build();
|
.build();
|
||||||
var qs = reactor.netty.incubator.quic.QuicServer
|
var qs = reactor.netty.incubator.quic.QuicServer
|
||||||
.create()
|
.create()
|
||||||
.port(bindURI.getPort())
|
|
||||||
.host(bindURI.getHost())
|
|
||||||
.tokenHandler(InsecureQuicTokenHandler.INSTANCE)
|
.tokenHandler(InsecureQuicTokenHandler.INSTANCE)
|
||||||
|
.bindAddress(() -> new InetSocketAddress(bindURI.getHost(), bindURI.getPort()))
|
||||||
.secure(sslContext)
|
.secure(sslContext)
|
||||||
.handleStream((in, out) -> in
|
.idleTimeout(Duration.ofSeconds(30))
|
||||||
.withConnection(conn -> conn.addHandler(new RPCServerBoundRequestDecoder()))
|
.connectionIdAddressGenerator(QuicConnectionIdGenerator.randomGenerator())
|
||||||
|
.initialSettings(spec -> spec
|
||||||
|
.maxData(10000000)
|
||||||
|
.maxStreamDataBidirectionalLocal(1000000)
|
||||||
|
.maxStreamDataBidirectionalRemote(1000000)
|
||||||
|
.maxStreamsBidirectional(100)
|
||||||
|
.maxStreamsUnidirectional(100)
|
||||||
|
)
|
||||||
|
.handleStream((in, out) -> {
|
||||||
|
var inConn = in.withConnection(conn -> conn.addHandler(new RPCClientBoundResponseDecoder()));
|
||||||
|
var outConn = out.withConnection(conn -> conn.addHandler(new RPCServerBoundRequestDecoder()));
|
||||||
|
return inConn
|
||||||
.receiveObject()
|
.receiveObject()
|
||||||
.doFirst(() -> {
|
|
||||||
System.out.println("###################################Stream created");
|
|
||||||
})
|
|
||||||
.cast(ServerBoundRequest.class)
|
.cast(ServerBoundRequest.class)
|
||||||
.log()
|
.log("req", Level.INFO, SignalType.ON_NEXT)
|
||||||
.then()
|
.switchOnFirst((first, flux) -> {
|
||||||
);
|
if (first.hasValue()) {
|
||||||
qs.warmup().block();
|
var value = first.get();
|
||||||
|
if (value instanceof GetDatabase getDatabase) {
|
||||||
|
return handleGetDatabase(getDatabase);
|
||||||
|
} else {
|
||||||
|
return Mono.error(new UnsupportedOperationException("Unsupported request type: " + first));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return flux;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.doOnError(ex -> LOG.error("Failed to handle a request", ex))
|
||||||
|
.onErrorResume(ex -> Mono.empty())
|
||||||
|
.transform(outConn::sendObject);
|
||||||
|
});
|
||||||
var conn = qs.bindNow();
|
var conn = qs.bindNow();
|
||||||
conn.onDispose().block();
|
conn.onDispose().block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Mono<GeneratedEntityId> handleGetDatabase(GetDatabase getDatabase) {
|
||||||
|
Mono<GeneratedEntityId> dbCreationMono = localDb
|
||||||
|
.getDatabase(getDatabase.name(), getDatabase.columns(), getDatabase.databaseOptions())
|
||||||
|
.flatMap(db -> Mono.fromCallable(() -> {
|
||||||
|
long id = nextResourceId.getAndIncrement();
|
||||||
|
dbById.put(id, db);
|
||||||
|
dbToId.put(getDatabase.name(), id);
|
||||||
|
return GeneratedEntityId.of(id);
|
||||||
|
}));
|
||||||
|
|
||||||
|
Mono<GeneratedEntityId> existingDbMono = Mono
|
||||||
|
.fromSupplier(() -> dbToId.get(getDatabase.name()))
|
||||||
|
.map(GeneratedEntityId::of);
|
||||||
|
|
||||||
|
return existingDbMono.switchIfEmpty(dbCreationMono);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration>
|
||||||
|
<Appenders>
|
||||||
|
<Console name="LogToConsole" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout pattern="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} %highlight{${LOG_LEVEL_PATTERN:-%5p}}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=green, DEBUG=green bold, TRACE=blue} %style{%processId}{magenta} [%15.15t] %style{%-20.20c{1}}{cyan} : %m%n%ex"/>
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<!--
|
||||||
|
<Logger name="io.netty" level="INFO" additivity="false"/>
|
||||||
|
<Logger name="io.net5" level="INFO" additivity="false"/>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Root level="INFO">
|
||||||
|
<filters>
|
||||||
|
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||||
|
</filters>
|
||||||
|
<AppenderRef ref="LogToConsole"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
Loading…
Reference in New Issue