Skip to content

Commit 5e23e24

Browse files
committed
Support for new, flexible wire protocol (V4).
The previous protocol is still supported for communication with servers that do not yet support V4. The version negotation is internal and automatic; however, use of V4 features will fail at runtime when attempted with an older server. Failure may be an empty or undefined result or an exception if the request cannot be serviced at all. The following new features or interfaces depend on the new protocol version: - added set/getDurability to QueryRequest for queries that modify data - added pagination information to TableUsageResult and TableUsageRequest - added shard percent usage information to TableUsageResult - added IndexInfo.getFieldTypes to return the type information on an index on a JSON field - added the ability to ask for and receive the schema of a query using * PrepareRequest.setGetQuerySchema * PreparedStatement.getQuerySchema - Cloud only: added use of ETags, DefinedTags and FreeFormTags in TableRequest and TableResult Changed: - Consistency is now a class and no longer a simple enumeration. Applications must be recompiled but source compatibility is maintained for all but the more complex use of an enumeration - Made one private serializer class public to allow for improved internal testing. - MapValue now implements Iterable
1 parent d1271ea commit 5e23e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4344
-149
lines changed

CHANGELOG.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22
All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog](http://keepachangelog.com/).
44

5+
## [Unpublished]
6+
7+
### Added
8+
- Support for new, flexible wire protocol (V4) has been added. The previous protocol
9+
is still supported for communication with servers that do not yet support V4. The
10+
version negotation is internal and automatic; however, use of V4 features will fail
11+
at runtime when attempted with an older server. Failure may be an empty or
12+
undefined result or an exception if the request cannot be serviced at all. The following
13+
new features or interfaces depend on the new protocol version
14+
- added set/getDurability to QueryRequest for queries that modify data
15+
- added pagination information to TableUsageResult and TableUsageRequest
16+
- added shard percent usage information to TableUsageResult
17+
- added IndexInfo.getFieldTypes to return the type information on an index on a JSON
18+
field
19+
- added the ability to ask for and receive the schema of a query using
20+
* PrepareRequest.setGetQuerySchema
21+
* PreparedStatement.getQuerySchema
22+
- Cloud only: added use of ETags, DefinedTags and FreeFormTags in TableRequest and TableResult
23+
24+
### Changed
25+
- Consistency is now a class and no longer a simple enumeration. Applications must
26+
be recompiled but source compatibility is maintained for all but the more complex
27+
use of an enumeration
28+
- Made one private serializer class public to allow for improved internal testing.
29+
- MapValue now implements Iterable
30+
531
## [5.3.7] 2022-10-18
632

733
### Changed
@@ -21,7 +47,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
2147

2248
## [5.3.5] 2022-07-20
2349

24-
### Changed
50+
### Added
2551
- Made one private serializer class public to allow for improved internal testing.
2652

2753
## [5.3.4] 2022-06-16
@@ -40,8 +66,6 @@ query that returns row_version() as a BinaryValue. The Version can be used for
4066
conditional put and delete operations
4167
- added support for setting an extension to the User Agent http header by
4268
setting the ExtensionUserAgent property on NoSQLHandlerConfig.
43-
44-
### Changed
4569
- Cloud only: Added OCI regions: CDG (Paris), MAD (Madrid), QRO (Queretaro)
4670

4771
## [5.3.2] 2022-03-21

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ project. The version changes with each release.
3737
<dependency>
3838
<groupId>com.oracle.nosql.sdk</groupId>
3939
<artifactId>nosqldriver</artifactId>
40-
<version>5.3.7</version>
40+
<version>5.4.7</version>
4141
</dependency>
4242
```
4343

@@ -140,6 +140,11 @@ You may run the Cloud Simulator on localhost.
140140
Authorization for the Cloud Simulator is a simple no-op class implemented directly
141141
in the Quickstart example.
142142

143+
## Logging
144+
145+
Addional logging can be enabled using a java properties file. For full details, see
146+
"Logging in the SDK" at https://oracle.github.io/nosql-java-sdk/oracle/nosql/driver/package-summary.html
147+
143148
## Quickstart
144149

145150
The following is a quick start tutorial to run a simple program in all supported

driver/pom.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
<groupId>com.oracle.nosql.sdk</groupId>
3131
<artifactId>nosqldriver</artifactId>
32-
<version>5.3.7</version>
32+
<version>5.4.7</version>
3333
<packaging>jar</packaging>
3434

3535
<organization>
@@ -46,8 +46,8 @@
4646
<copyright>Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.</copyright>
4747
<java.apidoc>http://docs.oracle.com/javase/8/docs/api</java.apidoc>
4848
<maven.deploy.skip>false</maven.deploy.skip>
49-
<netty.version>4.1.82.Final</netty.version>
50-
<jackson.version>2.12.5</jackson.version>
49+
<netty.version>4.1.85.Final</netty.version>
50+
<jackson.version>2.13.2</jackson.version>
5151
<bouncy.version>1.70</bouncy.version>
5252
<!-- by default, skip tests; tests require a profile -->
5353
<maven.test.skip>true</maven.test.skip>
@@ -347,7 +347,7 @@
347347
May need to post-process the doc to remove the package and link.
348348
-->
349349
<excludePackageNames>
350-
oracle.nosql.driver.http;oracle.nosql.driver.httpclient;oracle.nosql.driver.query;oracle.nosql.driver.util
350+
oracle.nosql.driver.http;oracle.nosql.driver.httpclient;oracle.nosql.driver.query;oracle.nosql.driver.util;oracle.nosql.driver.ops.serde.nson
351351
</excludePackageNames>
352352
<stylesheetfile>${basedir}/../doc/style.css</stylesheetfile>
353353
<show>public</show>
@@ -413,6 +413,16 @@
413413
<artifactId>exec-maven-plugin</artifactId>
414414
<version>3.0.0</version>
415415
<executions>
416+
<execution>
417+
<id>human-readable NSON string generation</id>
418+
<phase>generate-sources</phase>
419+
<configuration>
420+
<executable>${basedir}/scripts/build_nson_strings.sh</executable>
421+
</configuration>
422+
<goals>
423+
<goal>exec</goal>
424+
</goals>
425+
</execution>
416426
<execution>
417427
<id>add license files to runtime jar</id>
418428
<phase>package</phase>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
4+
#
5+
# This file was distributed by Oracle as part of a version of Oracle NoSQL
6+
# Database made available at:
7+
#
8+
# http://www.oracle.com/technetwork/database/database-technologies/nosqldb/downloads/index.html
9+
#
10+
# Please see the LICENSE file included in the top-level directory of the
11+
# appropriate version of Oracle NoSQL Database for a copy of the license and
12+
# additional information.
13+
14+
# this script creates java code to enable using human-readable strings for field
15+
# names in nson debug/logging/verbose output. It modifies NsonProtocol.java to
16+
# add a map of field names to human readable field names.
17+
18+
PROTOCOL_FILE=src/main/java/oracle/nosql/driver/ops/serde/nson/NsonProtocol.java
19+
20+
# delete everything after the last static string
21+
lastline=$(grep -n 'public static String [A-Z]' $PROTOCOL_FILE | tail -1 | sed -e 's/:.*$//')
22+
head -$lastline $PROTOCOL_FILE > /tmp/proto.$$
23+
24+
# add a static array of string arrays
25+
grep 'public static String ' /tmp/proto.$$ | awk 'BEGIN{printf("\n private static String[][] mapVals = new String[][] {\n");}{printf(" {%s,\"%s\"},\n",$4,$4);}END{printf(" };\n");}' >> /tmp/proto.$$
26+
27+
# add remaining logic
28+
cat << EOT >> /tmp/proto.$$
29+
30+
private static HashMap<String, String> fieldMap = null;
31+
32+
public static String readable(String field) {
33+
if (fieldMap == null) {
34+
fieldMap = new HashMap<String, String>();
35+
for (int x=0; x<mapVals.length; x++) {
36+
fieldMap.put(mapVals[x][0], mapVals[x][1]);
37+
}
38+
}
39+
String val = fieldMap.get(field);
40+
if (val == null) {
41+
return field;
42+
}
43+
return val;
44+
}
45+
}
46+
EOT
47+
48+
# replace file
49+
mv /tmp/proto.$$ $PROTOCOL_FILE
50+

driver/src/main/java/oracle/nosql/driver/Consistency.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,44 @@
2727
* Consistency can be specified as an optional argument to all read operations.
2828
* </p>
2929
*/
30-
public enum Consistency {
31-
EVENTUAL,
32-
ABSOLUTE
30+
public class Consistency {
31+
final private Type type;
32+
33+
public enum Type {
34+
EVENTUAL,
35+
ABSOLUTE
36+
}
37+
38+
public static Consistency ABSOLUTE = new Consistency(Type.ABSOLUTE);
39+
public static Consistency EVENTUAL = new Consistency(Type.EVENTUAL);
40+
41+
/**
42+
* Returns the {@link Type} of Consistency
43+
* @return the type
44+
*/
45+
public Type getType() {
46+
return type;
47+
}
48+
49+
/**
50+
* Returns true if this is Consistency.ABSOLUTE
51+
*
52+
* @return true if this instance represents ABSOLUTE Consistency
53+
*/
54+
public boolean isAbsolute() {
55+
return type == Type.ABSOLUTE;
56+
}
57+
58+
/**
59+
* Returns true if this is Consistency.EVENTUAL
60+
*
61+
* @return true if this instance represents EVENTUAL Consistency
62+
*/
63+
public boolean isEventual() {
64+
return type == Type.EVENTUAL;
65+
}
66+
67+
private Consistency(Type type) {
68+
this.type = type;
69+
}
3370
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*-
2+
* Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl/
6+
*/
7+
8+
package oracle.nosql.driver;
9+
10+
import java.util.Iterator;
11+
import java.util.Map;
12+
13+
import oracle.nosql.driver.values.FieldValue;
14+
import oracle.nosql.driver.values.MapValue;
15+
16+
/**
17+
* Cloud service only.
18+
*
19+
* DefinedTags is a class to encapsulate defined tags which are returned
20+
* from calls to {@link NoSQLHandle#getTable}. They can also be set during
21+
* table creation operations as well as alter table operations.
22+
* @since 5.4
23+
*/
24+
public class DefinedTags {
25+
private final MapValue tags;
26+
27+
/**
28+
* Creates a new instance of DefinedTags. This method along with
29+
* {@link #addTag} is used to add tags to a call to create or modify
30+
* a table.
31+
*/
32+
public DefinedTags() {
33+
tags = new MapValue();
34+
}
35+
36+
/**
37+
* Creates a new instance of DefinedTags from JSON string input.
38+
* @param jsonString a JSON string
39+
*/
40+
public DefinedTags(String jsonString) {
41+
tags = (MapValue) FieldValue.createFromJson(jsonString, null);
42+
}
43+
44+
/**
45+
* Adds a new tag to the set of tags in the specified namespace
46+
*
47+
* @param namespace the namespace for the tag
48+
* @param key the tag key
49+
* @param value the tag value
50+
* @return this
51+
*/
52+
public DefinedTags addTag(String namespace, String key, String value) {
53+
if (!tags.contains(namespace)) {
54+
tags.put(namespace, new MapValue());
55+
}
56+
MapValue nsMap = (MapValue) tags.get(namespace);
57+
nsMap.put(key, value);
58+
return this;
59+
}
60+
61+
/**
62+
* Returns the value of the named tag in the specified namespace or null
63+
* if it does not exist
64+
* @param namespace the namespace
65+
* @param key the key
66+
* @return the tag value or null
67+
*/
68+
public String getTag(String namespace, String key) {
69+
if (tags.contains(namespace)) {
70+
FieldValue val = ((MapValue)tags.get(namespace)).get(key);
71+
return val == null ? null : val.getString();
72+
}
73+
return null;
74+
}
75+
76+
/**
77+
* Returns true if the specified key exists in the specified namespace
78+
* @param namespace the namespace
79+
* @param key the key
80+
* @return true if the key exists
81+
*/
82+
public boolean contains(String namespace, String key) {
83+
if (tags.contains(namespace)) {
84+
return ((MapValue)tags.get(namespace)).contains(key);
85+
}
86+
return false;
87+
}
88+
89+
/**
90+
* Returns the free-form tags as a JSON string
91+
* @return the JSON string
92+
*/
93+
@Override
94+
public String toString() {
95+
return tags.toString();
96+
}
97+
}

0 commit comments

Comments
 (0)