Skip to content

Commit e7be2e9

Browse files
olim7tadutra
authored andcommitted
JAVA-2428: Add developer docs (apache#1339)
1 parent bc74cd2 commit e7be2e9

File tree

17 files changed

+1330
-24
lines changed

17 files changed

+1330
-24
lines changed

changelog/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 4.3.0 (in progress)
66

7+
- [documentation] JAVA-2428: Add developer docs
78
- [documentation] JAVA-2503: Migrate Cloud "getting started" page to driver manual
89
- [improvement] JAVA-2484: Add errors for cloud misconfiguration
910
- [improvement] JAVA-2490: Allow to read the secure bundle from an InputStream

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/NodeInfo.java

+17-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
*/
3636
public interface NodeInfo {
3737

38-
/** The endpoint that the driver will use to connect to the node. */
38+
/**
39+
* The endpoint that the driver will use to connect to the node.
40+
*
41+
* <p>This information is required; the driver will not function properly if this method returns
42+
* {@code null}.
43+
*/
3944
@NonNull
4045
EndPoint getEndPoint();
4146

@@ -124,6 +129,9 @@ public interface NodeInfo {
124129
/**
125130
* An additional map of free-form properties, that can be used by custom implementations. They
126131
* will be copied as-is into {@link Node#getExtras()}.
132+
*
133+
* <p>This is not required; if you don't have anything specific to report here, it can be null or
134+
* empty.
127135
*/
128136
@Nullable
129137
Map<String, Object> getExtras();
@@ -138,7 +146,14 @@ public interface NodeInfo {
138146
@NonNull
139147
UUID getHostId();
140148

141-
/** The current version that is associated with the nodes schema. */
149+
/**
150+
* The current version that is associated with the node's schema.
151+
*
152+
* <p>This is not required; the driver reports it in {@link Node#getSchemaVersion()}, but for
153+
* informational purposes only. It is not used anywhere internally (schema agreement is checked
154+
* with {@link TopologyMonitor#checkSchemaAgreement()}, which by default queries system tables
155+
* directly, not this field).
156+
*/
142157
@Nullable
143158
UUID getSchemaVersion();
144159
}

core/src/main/java/com/datastax/oss/driver/internal/core/metadata/TopologyMonitor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ public interface TopologyMonitor extends AsyncAutoCloseable {
4444
*
4545
* <p>The completion of the future returned by this method marks the point when the driver
4646
* considers itself "connected" to the cluster, and proceeds with the rest of the initialization:
47-
* refreshing the list of nodes and the metadata, opening connection pools, etc.
47+
* refreshing the list of nodes and the metadata, opening connection pools, etc. By then, the
48+
* topology monitor should be ready to accept calls to its other methods; in particular, {@link
49+
* #refreshNodeList()} will be called shortly after the completion of the future, to load the
50+
* initial list of nodes to connect to.
4851
*
4952
* <p>If {@code advanced.reconnect-on-init = true} in the configuration, this method is
5053
* responsible for handling reconnection. That is, if the initial attempt to "connect" to the

manual/.nav

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ mapper
44
api_conventions
55
case_sensitivity
66
osgi
7-
cloud
7+
cloud
8+
developer

manual/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Driver modules:
66
* [Query builder](query_builder/): a fluent API to create CQL queries programmatically.
77
* [Mapper](mapper/): generates the boilerplate to execute queries and convert the results into
88
application-level objects.
9+
* [Developer docs](developer/): explains the codebase and internal extension points for advanced
10+
customization.
911

1012
Common topics:
1113

manual/core/ssl/README.md

+6-20
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
Secure the traffic between the driver and Cassandra.
66

7-
* `advanced.ssl-engine-factory` in the configuration; defaults to none, also available: JSSE, or
8-
write your own.
7+
* `advanced.ssl-engine-factory` in the configuration; defaults to none, also available:
8+
config-based, or write your own.
99
* or programmatically:
1010
[CqlSession.builder().withSslEngineFactory()][SessionBuilder.withSslEngineFactory] or
1111
[CqlSession.builder().withSslContext()][SessionBuilder.withSslContext].
@@ -178,26 +178,12 @@ CqlSession session = CqlSession.builder()
178178
.build();
179179
```
180180

181-
#### Netty
181+
#### Netty-tcnative
182182

183-
Netty provides a more efficient SSL implementation based on native OpenSSL support. It's possible to
184-
customize the driver to use it instead of JSSE.
183+
Netty supports native integration with OpenSSL / boringssl. The driver does not provide this out of
184+
the box, but with a bit of custom development it is fairly easy to add. See
185+
[SslHandlerFactory](../../developer/netty_pipeline/#ssl-handler-factory) in the developer docs.
185186

186-
This is an advanced topic and beyond the scope of this document, but here is an overview:
187-
188-
1. add a dependency to Netty-tcnative: follow
189-
[these instructions](http://netty.io/wiki/forked-tomcat-native.html);
190-
2. write your own implementation of the driver's `SslHandlerFactory`. This is a higher-level
191-
abstraction than `SslEngineFactory`, that returns a Netty `SslHandler`. You'll build this handler
192-
with Netty's own `SslContext`;
193-
3. write a subclass of `DefaultDriverContext` that overrides `buildSslHandlerFactory()` to return
194-
the custom `SslHandlerFactory` you wrote in step 2. This will cause the driver to completely
195-
ignore the `ssl-engine-factory` options in the configuration;
196-
4. write a subclass of `SessionBuilder` that overrides `buildContext` to return the custom context
197-
that you wrote in step 3.
198-
5. build your session with your custom builder.
199-
200-
Note that this approach relies on the driver's [internal API](../../api_conventions).
201187

202188
[dsClientToNode]: https://docs.datastax.com/en/cassandra/3.0/cassandra/configuration/secureSSLClientToNode.html
203189
[pickle]: http://thelastpickle.com/blog/2015/09/30/hardening-cassandra-step-by-step-part-1-server-to-server.html

manual/developer/.nav

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
common
2+
native_protocol
3+
netty_pipeline
4+
request_execution
5+
admin

manual/developer/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Developer docs
2+
3+
This section explains how driver internals work. The intended audience is:
4+
5+
* driver developers and contributors;
6+
* framework authors, or architects who want to write advanced customizations and integrations.
7+
8+
Most of this material will involve "internal" packages; see [API conventions](../api_conventions/)
9+
for more explanations.
10+
11+
We recommend reading about the [common infrastructure](common/) first. Then the documentation goes
12+
from lowest to highest level:
13+
14+
* [Native protocol layer](native_protocol/): binary encoding of the TCP payloads;
15+
* [Netty pipeline](netty_pipeline/): networking and low-level stream management;
16+
* [Request execution](request_execution/): higher-level handling of user requests and responses;
17+
* [Administrative tasks](admin/): everything else (cluster state and metadata).
18+
19+
If you're reading this on GitHub, the `.nav` file in each directory contains a suggested order.

0 commit comments

Comments
 (0)