Skip to content

Commit c0e4adc

Browse files
committed
Update versions, flag to disable devops
1 parent f5d1454 commit c0e4adc

File tree

21 files changed

+392
-56
lines changed

21 files changed

+392
-56
lines changed

astra-sdk/src/main/java/com/datastax/astra/sdk/AstraClient.java

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -166,34 +166,56 @@ public AstraClient(AstraClientConfig config) {
166166
// ---------------------------------------------------
167167
// Stargate Node per region
168168
// ---------------------------------------------------
169-
Optional<Database> db = apiDevopsDatabases.database(config.getDatabaseId()).find();
170-
if (!db.isPresent()) {
171-
throw new IllegalArgumentException("Cannot retrieve db with id " + config.getDatabaseId());
172-
}
173-
174-
// Loop on regions
175-
db.get().getInfo().getDatacenters().stream().forEach(dc -> {
176-
config.getStargateConfig().withApiNodeDC(dc.getRegion(),
177-
new StargateNodeConfig(
178-
// node name = region, we got a single per region LB is done by Astra
179-
dc.getRegion(),
180-
// url or rest api
181-
ApiLocator.getApiRestEndpoint(config.getDatabaseId(), dc.getRegion()),
182-
// url of graphql API
183-
ApiLocator.getApiGraphQLEndPoint(config.getDatabaseId(), dc.getRegion()),
184-
// host for grpc
185-
ApiLocator.getApiGrpcEndPoint(config.getDatabaseId(), dc.getRegion()),
186-
// port for grpc
187-
AstraClientConfig.GRPC_PORT));
169+
170+
if (config.isEnabledCrossRegionFailOver()) {
171+
Optional<Database> db = apiDevopsDatabases.database(config.getDatabaseId()).find();
172+
if (!db.isPresent()) {
173+
throw new IllegalArgumentException("Cannot retrieve db with id " + config.getDatabaseId());
174+
}
175+
176+
// Loop on regions
177+
db.get().getInfo().getDatacenters().stream().forEach(dc -> {
178+
config.getStargateConfig().withApiNodeDC(dc.getRegion(),
179+
new StargateNodeConfig(
180+
// node name = region, we got a single per region LB is done by Astra
181+
dc.getRegion(),
182+
// url or rest api
183+
ApiLocator.getApiRestEndpoint(config.getDatabaseId(), dc.getRegion()),
184+
// url of graphql API
185+
ApiLocator.getApiGraphQLEndPoint(config.getDatabaseId(), dc.getRegion()),
186+
// host for grpc
187+
ApiLocator.getApiGrpcEndPoint(config.getDatabaseId(), dc.getRegion()),
188+
// port for grpc
189+
AstraClientConfig.GRPC_PORT));
190+
191+
config.getStargateConfig()
192+
.withCqlCloudSecureConnectBundleDC(dc.getRegion(),
193+
config.getSecureConnectBundleFolder()
194+
+ File.separator
195+
+ AstraClientConfig.buildScbFileName(config.getDatabaseId(), dc.getRegion()));
196+
}
197+
);
188198

199+
} else {
200+
LOGGER.info("+ Cross-region failback is disabled.");
201+
config.getStargateConfig().withApiNodeDC(currentDatabaseRegion,
202+
new StargateNodeConfig(
203+
// node name = region, we got a single per region LB is done by Astra
204+
this.currentDatabaseRegion,
205+
// url or rest api
206+
ApiLocator.getApiRestEndpoint(config.getDatabaseId(), currentDatabaseRegion),
207+
// url of graphql API
208+
ApiLocator.getApiGraphQLEndPoint(config.getDatabaseId(), currentDatabaseRegion),
209+
// host for grpc
210+
ApiLocator.getApiGrpcEndPoint(config.getDatabaseId(), currentDatabaseRegion),
211+
// port for grpc
212+
AstraClientConfig.GRPC_PORT));
189213
config.getStargateConfig()
190-
.withCqlCloudSecureConnectBundleDC(dc.getRegion(),
191-
config.getSecureConnectBundleFolder()
192-
+ File.separator
193-
+ AstraClientConfig.buildScbFileName(config.getDatabaseId(), dc.getRegion()));
194-
}
195-
);
196-
214+
.withCqlCloudSecureConnectBundleDC(currentDatabaseRegion,
215+
config.getSecureConnectBundleFolder()
216+
+ File.separator
217+
+ AstraClientConfig.buildScbFileName(config.getDatabaseId(), currentDatabaseRegion));
218+
}
197219
this.stargateClient = config.getStargateConfig().build();
198220

199221
} else {

astra-sdk/src/main/java/com/datastax/astra/sdk/config/AstraClientConfig.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public AstraClientConfig withHttpObservers(Map<String, ApiInvocationObserver> ob
271271
stargateConfig.withHttpObservers(observers);
272272
return this;
273273
}
274-
274+
275275
// ------------------------------------------------
276276
// ----------------- Grpc -------------------------
277277
// ------------------------------------------------
@@ -287,12 +287,15 @@ public AstraClientConfig enableGrpc() {
287287
}
288288

289289
// ------------------------------------------------
290-
// -------------- CqlSession ----------------------
290+
// -------------- Devops Apis ----------------------
291291
// ------------------------------------------------
292292

293293
/** Enable SCB download to target folder. */
294294
private boolean downloadSecureConnectBundle = true;
295295

296+
/** Enable SCB download to target folder. */
297+
private boolean crossRegionFailOver = true;
298+
296299
/** Folder to load secure connect bundle with formated names scb_dbid_region.zip */
297300
private String secureConnectBundleFolder = DEFAULT_SCB_FOLDER;
298301

@@ -329,6 +332,16 @@ public boolean isEnabledDownloadSecureConnectBundle() {
329332
return downloadSecureConnectBundle;
330333
}
331334

335+
/**
336+
* Getter for crossRegionFailOver.
337+
*
338+
* @return
339+
* crossRegionFailOver value
340+
*/
341+
public boolean isEnabledCrossRegionFailOver() {
342+
return crossRegionFailOver;
343+
}
344+
332345
/**
333346
* Enable SCB downloads.
334347
*
@@ -340,6 +353,17 @@ public AstraClientConfig enableDownloadSecureConnectBundle() {
340353
return this;
341354
}
342355

356+
/**
357+
* Enable crossRegionFailOver
358+
*
359+
* @return
360+
* current reference.
361+
*/
362+
public AstraClientConfig enableCrossRegionFailOver() {
363+
this.crossRegionFailOver = true;
364+
return this;
365+
}
366+
343367
/**
344368
* Disable SCB downloads.
345369
*
@@ -352,12 +376,13 @@ public AstraClientConfig disableDownloadSecureConnectBundle() {
352376
}
353377

354378
/**
355-
* Enable CqlSession
379+
* Disable crossRegionFailOver
356380
*
357-
* @return reference enforcing cqlsession disabled
381+
* @return
382+
* current reference.
358383
*/
359-
public AstraClientConfig enableCql() {
360-
stargateConfig.enableCql();
384+
public AstraClientConfig disableCrossRegionFailOver() {
385+
this.crossRegionFailOver = false;
361386
return this;
362387
}
363388

@@ -373,6 +398,20 @@ public AstraClientConfig withCqlCloudSecureConnectBundle(String scbFile) {
373398
return this;
374399
}
375400

401+
// ------------------------------------------------
402+
// -------------- CqlSession ----------------------
403+
// ------------------------------------------------
404+
405+
/**
406+
* Enable CqlSession
407+
*
408+
* @return reference enforcing cqlsession disabled
409+
*/
410+
public AstraClientConfig enableCql() {
411+
stargateConfig.enableCql();
412+
return this;
413+
}
414+
376415
/**
377416
* Populate config.
378417
*
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.datastax.astra.sdk.organizations;
22

3+
/**
4+
* Workshop with key management.
5+
*
6+
* @author Cedrick LUNVEN (@clunven)
7+
*/
38
public class KeysClient {
4-
59
}

astra-sdk/src/main/java/com/datastax/astra/sdk/organizations/domain/Key.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class Key implements Serializable {
1212
/** Serial key. */
1313
private static final long serialVersionUID = 3301168004898303754L;
1414

15-
/** organization for the key. */
15+
/** organization for the. */
1616
private String organizationId;
1717

1818
/* cloud provider. */

astra-spring-boot-autoconfigure/src/main/java/com/datastax/astra/boot/AstraClientProperties.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ public static class Api {
116116
/** Astra database region. */
117117
private String databaseRegion;
118118

119+
/** If enabled try to failback. */
120+
private Boolean crossRegionFailback;
121+
119122
/** Configuration regarding gRPC. */
120123
private Grpc grpc;
121124

@@ -194,6 +197,25 @@ public Grpc getGrpc() {
194197
public void setGrpc(Grpc grpc) {
195198
this.grpc = grpc;
196199
}
200+
201+
/**
202+
* Getter accessor for attribute 'crossRegionFailback'.
203+
*
204+
* @return
205+
* current value of 'crossRegionFailback'
206+
*/
207+
public Boolean getCrossRegionFailback() {
208+
return crossRegionFailback;
209+
}
210+
211+
/**
212+
* Setter accessor for attribute 'crossRegionFailback'.
213+
* @param crossRegionFailback
214+
* new value for 'crossRegionFailback '
215+
*/
216+
public void setCrossRegionFailback(Boolean crossRegionFailback) {
217+
this.crossRegionFailback = crossRegionFailback;
218+
}
197219

198220
}
199221

astra-spring-boot-autoconfigure/src/main/java/com/datastax/astra/boot/AstraSpringAutoConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public AstraClient astraClient() {
109109
builder.withDatabaseRegion(api.getDatabaseRegion());
110110
LOGGER.debug("+ Api /dbRegion detected {}", api.getDatabaseRegion());
111111
}
112+
if (!api.getCrossRegionFailback()) {
113+
builder.disableCrossRegionFailOver();
114+
LOGGER.debug("+ Cross Region Failback is disabled");
115+
}
116+
112117
if (api.getGrpc()!= null) {
113118
Grpc grpc = api.getGrpc();
114119
if (grpc.isEnabled()) {

astra-spring-boot-autoconfigure/src/main/java/com/datastax/astra/boot/utils/DataStaxDriverSpringConfig.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313

1414
import com.typesafe.config.Config;
1515

16+
/**
17+
* Configuration Object.
18+
*
19+
* @author Cedrick LUNVEN (@clunven)
20+
*/
1621
public class DataStaxDriverSpringConfig {
1722

1823
/** Prefix to watch for custom driver configuration. */
1924
private static final String DRIVER_CONFIG_PREFIX = "astra.cql.driver-config";
25+
/** Prefix to watch for custom driver configuration. */
2026
private static final String DRIVER_CONFIG_CORE = "datastax-java-driver";
2127

22-
2328
/**
2429
* Pattern to match "some-path.some-key[#]" to convert list value properties to TypeSafe format.
2530
* Example list:
@@ -45,6 +50,8 @@ public class DataStaxDriverSpringConfig {
4550
* properties mechanism. These can come from a properties file (or YAML or XML file), system
4651
* properties, or some other mechanism by which Spring initializes properties.
4752
*
53+
* @param env
54+
* current environment
4855
* @return {@link Map} object with driver-related configuration property values.
4956
*/
5057
public static Map<String, String> driverConfigFromSpring(ConfigurableEnvironment env) {

astra-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"type": "java.lang.String",
1414
"defaultValue": "us-east-1",
1515
"description": "Main region name of an Astra database to connect (also Datacenter name)"},
16+
{ "name": "astra.api.cross-region-failback",
17+
"type": "java.lang.Boolean",
18+
"defaultValue": "true",
19+
"description": "If enabled, and Astra contains multiple regions, on region failure will failback"},
1620
{ "name": "astra.api.grpc.enabled",
1721
"type": "java.lang.Boolean",
1822
"description":"If set to true a connection will be established to Astra using gRPC stubs",

astra-spring-boot-autoconfigure/src/main/resources/sample.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ astra:
55
database-region: CHANGE_ME
66
grpc:
77
enabled: false
8+
grpc:
9+
enabled: false
810
cql:
911
enabled: true
1012
download-scb:

pom.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@
2222
</licenses>
2323
<properties>
2424
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25-
<java-driver.version>4.14.1</java-driver.version>
26-
<logback.version>1.2.9</logback.version>
27-
<jackson.version>2.13.3</jackson.version>
25+
<java-driver.version>4.15.0</java-driver.version>
26+
<logback.version>1.4.1</logback.version>
27+
<jackson.version>2.13.4</jackson.version>
2828
<json-schema.version>1.5.1</json-schema.version>
2929
<httpclient.version>5.1.2</httpclient.version>
30-
<pulsar.version>2.10.0</pulsar.version>
30+
<pulsar.version>2.10.1</pulsar.version>
3131
<stargate-grpc.version>1.0.63</stargate-grpc.version>
32-
<grpc-netty.version>1.47.0</grpc-netty.version>
32+
<grpc-netty.version>1.49.1</grpc-netty.version>
3333
<slf4j.version>1.7.36</slf4j.version>
3434
<!-- Spring -->
35-
<spring.version>5.3.21</spring.version>
36-
<spring-boot.version>2.7.0</spring-boot.version>
37-
<spring-data.version>3.4.1</spring-data.version>
38-
<spring-security.version>5.7.2</spring-security.version>
35+
<spring.version>5.3.23</spring.version>
36+
<spring-boot.version>2.7.4</spring-boot.version>
37+
<spring-data.version>3.4.3</spring-data.version>
38+
<spring-security.version>5.7.3</spring-security.version>
3939
<!-- Junit -->
40-
<junit-platform.version>1.8.2</junit-platform.version>
41-
<junit-jupiter.version>5.8.2</junit-jupiter.version>
40+
<junit-platform.version>1.9.1</junit-platform.version>
41+
<junit-jupiter.version>5.9.1</junit-jupiter.version>
4242
<!-- Java -->
4343
<maven.plugin.compiler.source>1.8</maven.plugin.compiler.source>
4444
<maven.plugin.compiler.target>1.8</maven.plugin.compiler.target>
@@ -359,6 +359,7 @@
359359
</execution>
360360
</executions>
361361
<configuration>
362+
<excludePackageNames>com.datastax.stargate.graphql</excludePackageNames>
362363
<source>${maven.plugin.javadoc.source}</source>
363364
</configuration>
364365
</plugin>

0 commit comments

Comments
 (0)