Skip to content

Commit 08e0f6a

Browse files
authored
Merge pull request #70 from vinscom/upgrade-to-3.7.1
Upgrade to 3.7.1
2 parents 80722aa + fda0aa4 commit 08e0f6a

File tree

9 files changed

+73
-40
lines changed

9 files changed

+73
-40
lines changed

Jenkinsfile

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
pipeline {
22
agent any
33
stages {
4-
stage('install') {
4+
stage('Build and Test') {
55
steps {
66
withSonarQubeEnv('SonarCloud') {
77
withMaven(maven: 'M3') {
8-
sh "mvn clean install sonar:sonar -Dsonar.projectKey=vinscom_api-framework -Dsonar.organization=vinscom-github -Dsonar.branch.name=${GIT_BRANCH}"
8+
sh "mvn clean package sonar:sonar -Dsonar.projectKey=vinscom_api-framework -Dsonar.organization=vinscom-github -Dsonar.branch.name=${GIT_BRANCH}"
99
}
10+
junit 'target/surefire-reports/TEST-*.xml'
1011
}
1112
}
1213
}
13-
stage("Quality Gate") {
14+
stage('Deploy Snapshot') {
15+
when {
16+
branch 'master'
17+
}
18+
steps {
19+
withMaven(maven: 'M3') {
20+
sh "mvn deploy -P pgp,release"
21+
}
22+
}
23+
}
24+
stage('Deploy Release') {
25+
when {
26+
expression {
27+
env.TAG_NAME =~ /[0-9]+.[0-9]+.[0-9]+/
28+
}
29+
}
1430
steps {
15-
junit '**/target/surefire-reports/TEST-*.xml'
31+
withMaven(maven: 'M3') {
32+
sh "mvn versions:set -DnewVersion=${TAG_NAME}"
33+
sh "mvn deploy -P pgp,release"
34+
sh "mvn nexus-staging:release -P pgp,release"
35+
}
1636
}
1737
}
1838
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#/io/vertx/core/VertxInstance
22
$class=io.vertx.core.VertxInstance
33

4-
clusterEnable^=/io/vertx/core/VertxOptions.clustered
54
vertxOptions=/io/vertx/core/VertxOptions
5+
log=true
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#/io/vertx/core/VertxOptions
22
$class=io.vertx.core.VertxOptions
33

4-
clustered=true
54
clusterManager=/io/vertx/spi/cluster/ClusterManager
65
metricsOptions=/io/vertx/ext/dropwizard/DropwizardMetricsOptions
76
preferNativeTransport=false
7+
workerPoolSize=1000
8+
eventBusOptions=/io/vertx/core/eventbus/EventBusOptions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#/io/vertx/core/eventbus/EventBusOptions
2+
$class=io.vertx.core.eventbus.EventBusOptions
3+
4+
clustered=true

config-layers/common/io/vertx/ext/web/sstore/SessionStoreInstance.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
$class=io.vertx.reactivex.ext.web.sstore.SessionStoreInstance
33

44
vertx=/io/vertx/core/Vertx
5-
clusterEnable^=/io/vertx/core/VertxOptions.clustered
5+
clusterEnable^=/io/vertx/core/Vertx.clustered

config-layers/test/io/vertx/core/VertxOptions.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>in.erail</groupId>
66
<artifactId>api-framework</artifactId>
7-
<version>2.4.9</version>
7+
<version>2.4.10-SNAPSHOT</version>
88
<packaging>jar</packaging>
99
<developers>
1010
<developer>
@@ -102,7 +102,7 @@
102102
</profile>
103103
</profiles>
104104
<properties>
105-
<vertx.version>3.7.0</vertx.version>
105+
<vertx.version>3.7.1</vertx.version>
106106
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
107107
<maven.compiler.source>1.8</maven.compiler.source>
108108
<maven.compiler.target>1.8</maven.compiler.target>
@@ -178,7 +178,7 @@
178178
<dependency>
179179
<groupId>io.netty</groupId>
180180
<artifactId>netty-transport-native-epoll</artifactId>
181-
<version>4.1.30.Final</version>
181+
<version>4.1.34.Final</version>
182182
<classifier>linux-x86_64</classifier>
183183
</dependency>
184184
<dependency>
@@ -189,7 +189,7 @@
189189
<dependency>
190190
<groupId>in.erail</groupId>
191191
<artifactId>glue</artifactId>
192-
<version>2.4.9</version>
192+
<version>2.4.10</version>
193193
</dependency>
194194
<dependency>
195195
<groupId>javax.persistence</groupId>

src/main/java/in/erail/security/SecurityTools.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
*/
77
import in.erail.glue.annotation.StartService;
88
import io.reactivex.Single;
9+
import io.vertx.core.eventbus.EventBusOptions;
910
import io.vertx.reactivex.core.Vertx;
1011
import java.security.InvalidAlgorithmParameterException;
1112
import java.security.InvalidKeyException;
1213
import java.security.NoSuchAlgorithmException;
1314
import java.security.SecureRandom;
1415
import java.util.Arrays;
1516
import java.util.Base64;
17+
import java.util.Optional;
1618
import java.util.concurrent.CompletableFuture;
1719
import java.util.concurrent.ExecutionException;
1820
import javax.crypto.BadPaddingException;
@@ -36,20 +38,23 @@ public class SecurityTools {
3638
public void startup() {
3739

3840
setRandom(new SecureRandom());
39-
40-
if (!getVertx().isClustered()) {
41-
mGlobalUniqueString.complete("A" + mRandom.nextInt());
42-
return;
41+
42+
if (getVertx().isClustered()) {
43+
byte[] key = generateKey().get();
44+
addValueToClusterMap("key", key)
45+
.subscribe((k) -> {
46+
String unique = Base64.getEncoder().encodeToString(Arrays.copyOfRange(k, 0, 5));
47+
mGlobalUniqueString.complete(unique.replace("=", ""));
48+
getLog().info(() -> String.format("GlobalUniqueString:[%s]", unique));
49+
50+
mKeySpec.complete(new SecretKeySpec(k, "AES"));
51+
});
52+
} else {
53+
byte[] k = generateKey().get();
54+
String unique = Base64.getEncoder().encodeToString(Arrays.copyOfRange(k, 0, 5));
55+
mGlobalUniqueString.complete(unique.replace("=", ""));
56+
mKeySpec.complete(new SecretKeySpec(k, "AES"));
4357
}
44-
45-
generateKey()
46-
.flatMap(v -> addValueToClusterMap("key", v))
47-
.subscribe((key) -> {
48-
mKeySpec.complete(new SecretKeySpec(key, "AES"));
49-
String unique = Base64.getEncoder().encodeToString(Arrays.copyOfRange(key, 0, 5));
50-
mGlobalUniqueString.complete(unique.replace("=", ""));
51-
getLog().info(() -> String.format("GlobalUniqueString:[%s]", unique));
52-
});
5358
}
5459

5560
protected Single<byte[]> addValueToClusterMap(String pKey, byte[] pValue) {
@@ -60,15 +65,15 @@ protected Single<byte[]> addValueToClusterMap(String pKey, byte[] pValue) {
6065
.toSingle(pValue);
6166
}
6267

63-
protected Single<byte[]> generateKey() {
64-
KeyGenerator keygen;
68+
protected Optional<byte[]> generateKey() {
6569
try {
66-
keygen = KeyGenerator.getInstance("AES");
70+
KeyGenerator keygen = KeyGenerator.getInstance("AES");
71+
keygen.init(128);
72+
return Optional.of(keygen.generateKey().getEncoded());
6773
} catch (NoSuchAlgorithmException ex) {
68-
return Single.error(ex);
74+
getLog().error(ex);
6975
}
70-
keygen.init(128);
71-
return Single.just(keygen.generateKey().getEncoded());
76+
return Optional.empty();
7277
}
7378

7479
/**

src/main/java/io/vertx/core/VertxInstance.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@
66
import in.erail.glue.annotation.StartService;
77
import io.reactivex.plugins.RxJavaPlugins;
88
import io.vertx.reactivex.core.RxHelper;
9+
import org.apache.logging.log4j.Logger;
910

1011
public class VertxInstance {
1112

13+
private Logger mLog;
1214
private VertxOptions mVertxOptions;
13-
private boolean mClusterEnable = true;
1415
private final CompletableFuture<Vertx> mVertx = new CompletableFuture<>();
1516

1617
@StartService
1718
public void start() {
18-
if (isClusterEnable()) {
19-
Vertx.rxClusteredVertx(getVertxOptions()).subscribe((t) -> mVertx.complete(t));
19+
if (getVertxOptions().getEventBusOptions().isClustered()) {
20+
getLog().info(() -> "Starting Vertx in Cluster Mode");
21+
Vertx
22+
.rxClusteredVertx(getVertxOptions())
23+
.doOnSuccess(v -> getLog().info(() -> "Vertx is running in cluster mode"))
24+
.subscribe((t) -> mVertx.complete(t));
2025
} else {
26+
getLog().info(() -> "Starting Vertx in Cluster Mode");
2127
mVertx.complete(Vertx.vertx(getVertxOptions()));
2228
}
2329

@@ -39,12 +45,12 @@ public void setVertxOptions(VertxOptions pVertxOptions) {
3945
this.mVertxOptions = pVertxOptions;
4046
}
4147

42-
public boolean isClusterEnable() {
43-
return mClusterEnable;
48+
public Logger getLog() {
49+
return mLog;
4450
}
4551

46-
public void setClusterEnable(boolean pClusterEnable) {
47-
this.mClusterEnable = pClusterEnable;
52+
public void setLog(Logger pLog) {
53+
this.mLog = pLog;
4854
}
4955

5056
}

0 commit comments

Comments
 (0)