Skip to content

Commit a2473f1

Browse files
Merge pull request #463 from couchbase/3.8-api
3.8 api
2 parents 09a4255 + a850e1d commit a2473f1

18 files changed

Lines changed: 270 additions & 59 deletions

modules/concept-docs/pages/durability-replication-failure-considerations.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This page covers the durability options offered by Couchbase Server,
1919
with the rest of this section covering logging, health check, and observability --
2020
all key to understanding the health of a complex, distributed environment.
2121

22+
TIP: From Couchbase Server version 8.0 (including in Capella Operational), statistics from the SDK are collected automatically by the Cluster.
2223

2324

2425
include::{version-common}@sdk:shared:partial$durability-replication-failure-considerations.adoc[tag=intro]

modules/concept-docs/pages/response-time-observability.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
[abstract]
99
{description}
1010

11+
12+
[TIP]
13+
====
14+
In addition to Tracing and other metrics, and client logging, SDK is telemetry is also sent to the Server -- available from 8.0, and in new Capella Operational clusters -- for ingestion with other Prometheus metrics.
15+
Capella Operatioal exposes these metrics through the UI.
16+
====
17+
18+
19+
1120
include::{version-common}@sdk:shared:partial$rto.adoc[tag=rto]
1221

1322

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import com.couchbase.client.core.error.CouchbaseException;
2+
import com.couchbase.client.java.Cluster;
3+
import com.couchbase.client.java.ClusterOptions;
4+
import com.couchbase.client.java.json.JsonObject;
5+
import com.couchbase.client.java.query.QueryResult;
6+
import static com.couchbase.client.java.query.QueryOptions.queryOptions;
7+
8+
public class ParameterizedVectorQuery {
9+
static String connectionString = "couchbases://cb.<your-endpoint-here>.cloud.couchbase.com";
10+
static String username = "Administrator";
11+
static String password = "password";
12+
13+
public static void main(String[] args) throws Exception {
14+
Cluster cluster = Cluster.connect(
15+
connectionString,
16+
ClusterOptions.clusterOptions(username, password).environment(env -> {
17+
env.applyProfile("wan-development");
18+
})
19+
);
20+
21+
{
22+
try {
23+
// tag::parameterized[]
24+
final QueryResult result = cluster.query(
25+
"SELECT d.id, d.question, d.wanted_similar_color_from_search, " +
26+
" ARRAY_CONCAT( " +
27+
"d.couchbase_search_query.knn[0].vector[0:4], " +
28+
"['...'] " +
29+
") AS vector " +
30+
"FROM `vector-sample`.`color`.`rgb-questions` AS d " +
31+
"WHERE d.id = $id;",
32+
queryOptions()
33+
.parameters(JsonObject.create().put("id", "#87CEEB")));
34+
35+
for (JsonObject row : result.rowsAsObject()) {
36+
System.out.println(row);
37+
}
38+
// end::parameterized[]
39+
} catch (CouchbaseException ex) {
40+
ex.printStackTrace();
41+
}
42+
}
43+
}
44+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2021 Couchbase, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// tag::imports[]
18+
import com.couchbase.client.core.error.CouchbaseException;
19+
import com.couchbase.client.java.Cluster;
20+
import com.couchbase.client.java.ClusterOptions;
21+
import com.couchbase.client.java.json.JsonObject;
22+
import com.couchbase.client.java.query.QueryResult;
23+
import static com.couchbase.client.java.query.QueryOptions.queryOptions;
24+
// tag::imports[]
25+
26+
public class SimpleVectorQuery {
27+
static String connectionString = "couchbases://cb.<your-endpoint-here>.cloud.couchbase.com";
28+
static String username = "Administrator";
29+
static String password = "password";
30+
31+
public static void main(String[] args) throws Exception {
32+
Cluster cluster = Cluster.connect(
33+
connectionString,
34+
ClusterOptions.clusterOptions(username, password).environment(env -> {
35+
env.applyProfile("wan-development");
36+
})
37+
);
38+
39+
{
40+
try {
41+
// tag::hyperscale[]
42+
QueryResult result = cluster.query(
43+
"SELECT d.id, d.question, d.wanted_similar_color_from_search, " +
44+
" ARRAY_CONCAT( " +
45+
"d.couchbase_search_query.knn[0].vector[0:4], " +
46+
"['...'] " +
47+
") AS vector " +
48+
"FROM `vector-sample`.`color`.`rgb-questions` AS d " +
49+
"WHERE d.id = '#87CEEB';",
50+
queryOptions().metrics(true));
51+
52+
for (JsonObject row : result.rowsAsObject()) {
53+
System.out.println(row);
54+
}
55+
// end::hyperscale[]
56+
} catch (CouchbaseException ex) {
57+
ex.printStackTrace();
58+
}
59+
}
60+
}
61+
}

modules/devguide/examples/striptags.sh

100755100644
File mode changed.

modules/howtos/pages/collecting-information-and-logging.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,29 @@ Note that you need to run this command before any of the SDK code is initialized
255255
Once the SDK writes the logs with the tags to a file, you can then use the xref:7.2@server:cli:cbcli/cblogredaction.adoc[`cblogredaction` tool] to obfuscate the log.
256256

257257
* You may wish to read more on Log Redaction xref:7.2@server:manage:manage-logging/manage-logging.adoc#understanding_redaction[in the Server docs].
258+
259+
== SDK Telemetry from the Server
260+
261+
In addition to Tracing and other metrics, and client logging, SDK is telemetry is also sent to the Server -- available from 8.0, and in new Capella Operational clusters -- for ingestion with other Prometheus metrics.
262+
Capella Operatioal exposes these metrics through the UI.
263+
264+
For self-managed Server, collection can be disabled and enabled through the REST API:
265+
266+
[source,console]
267+
----
268+
curl --user Administrator:password http://172.17.0.2:8091/settings/appTelemetry -d enabled=true
269+
----
270+
271+
And the Prometheus-format metrics fetched with:
272+
273+
[source,console]
274+
----
275+
curl --user Administrator:password http://172.17.0.2:8091/metrics
276+
----
277+
278+
There may be advantages to collecting information this way,
279+
but note that metrics are collected per node,
280+
and a central Prometheus instance should be set to collect all metrics so that information is not lost in case of a sudden failover.
281+
282+
Also note that if the cluster is behind a load balancer, the collected metrics may not accurately record the actual correct node with which the SDK interacts.
283+

modules/howtos/pages/encrypting-using-sdk.adoc

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88

99
For a high-level overview of this feature, see xref:concept-docs:encryption.adoc[].
1010

11+
[TIP]
12+
.Native Encryption at Rest
13+
====
14+
Server 8.x (and new Capella Operational clusters) offer xref:server:learn:security/native-encryption-at-rest-overview.adoc[encryption at rest].
15+
It's a comprehensive way of encrypting all data in a non-ephemeral bucket,
16+
as well as logs, configuration data, and audit data.
17+
However, you may prefer the relative simplicity of key management in Field Level Encryption for use cases where there are a limited number of data to be encrypted.
18+
====
19+
20+
21+
22+
23+
1124
[#package]
1225
== Packaging
1326

@@ -179,47 +192,10 @@ include::devguide:example$java/EncryptingUsingSDK.java[tag=encrypting_using_sdk_
179192
[#migration-from-sdk2]
180193
== Migrating from SDK 2
181194

182-
WARNING: SDK 2 cannot read fields encrypted by SDK 3.
183-
184-
It's inadvisable to have both the old and new versions of your application active at the same time.
185-
The simplest way to migrate is to do an offline upgrade during a scheduled a maintenance window.
186-
For an online upgrade without downtime, consider a https://en.wikipedia.org/wiki/Blue-green_deployment[blue-green deployment^].
187-
188-
SDK 3 requires additional configuration to read fields encrypted by SDK 2.
189-
The rest of this section describes how to configure Field-Level Encryption in SDK 3 for backwards compatibility with SDK 2.
190-
191-
[#configure-field-name-prefix]
192-
=== Changing the field name prefix
193-
194-
In SDK 2, the default prefix for encrypted field names was `\__crypt_`.
195-
This caused problems for Couchbase Sync Gateway, which does not like field names to begin with an underscore.
196-
In SDK 3, the default prefix is `encrypted$`.
197-
198-
For compatibility with SDK 2, you can configure the `CryptoManager` to use the old `\__crypt_` prefix:
199-
200-
[source,java]
201-
----
202-
include::devguide:example$java/EncryptingUsingSDK.java[tag=legacy_field_name_prefix,indent=0]
203-
----
204-
205-
Alternatively, you can https://forums.couchbase.com/t/replacing-field-name-prefix/28786[rename the existing fields] using a {sqlpp_url}[{sqlpp} (formerly N1QL)] statement.
206-
207-
WARNING: In SDK 2, only top-level fields could be encrypted.
208-
SDK 3 allows encrypting fields at any depth.
209-
If you decide to rename the existing fields, make sure to do so _before_ writing any encrypted fields below the top level, otherwise it may be difficult to rename the nested fields using a generic {sqlpp} statement.
210-
195+
SDK 2.x reached end-of-life long ago,
196+
but should you have fields encrypted by SDK 2.x, and the need to read them from SDK 3.x,
197+
then follow the steps in the https://docs-archive.couchbase.com/java-sdk/3.4/howtos/encrypting-using-sdk.html#migration-from-sdk2[archived documents].
211198

212-
[#configure-legacy-decrypters]
213-
=== Enabling decrypters for legacy algorithms
214-
215-
The encryption algorithms used by SDK 2 are deprecated, and are no longer used for encrypting new data.
216-
To enable decrypting fields written by SDK 2, register the legacy decrypters when configuring the `CryptoManager`:
217-
218-
[source,java]
219-
----
220-
include::devguide:example$java/EncryptingUsingSDK.java[tag=legacy_decrypters,indent=0]
221-
----
222199

223-
NOTE: The legacy decrypters require a mapping function.
224-
For AES, this function accepts an encryption key name and returns the corresponding signing key name.
225-
For RSA, this function accepts a public key name and returns the corresponding private key name.
200+
IMPORTANT: The encryption algorithms used by SDK 2 are deprecated, and are no longer used for encrypting new data.
201+
Do not rely on the security of outdated encryption algorithms.

0 commit comments

Comments
 (0)