Metadata
When you connect to a DSE cluster with the DSE driver, additional information will be available in the metadata.
Nodes
Metadata.getNodes()
returns regular Node
instances, but they hold additional key/value pairs
in their getExtras()
field. The keys are listed in DseNodeProperties; refer to the javadocs of
that class for more details, in particular the runtime type of the values.
For example, here’s how to retrieve the DSE workloads of a node:
Node node = metadata.getNodes().values().iterator().next();
Set<String> workloads = (Set<String>) node.getExtras().get(DseNodeProperties.DSE_WORKLOADS);
Schema metadata
All schema metadata interfaces accessible through Metadata.getKeyspaces()
have a DSE-specific
subtype in the package com.datastax.dse.driver.api.core.metadata.schema. The objects returned by
the DSE driver implement those types, so you can safely cast:
for (KeyspaceMetadata keyspace : session.getMetadata().getKeyspaces().values()) {
DseKeyspaceMetadata dseKeyspace = (DseKeyspaceMetadata) keyspace;
}
If you’re calling a method that returns an optional and want to keep the result wrapped, use this pattern:
Optional<DseFunctionMetadata> f =
session
.getMetadata()
.getKeyspace("ks")
.flatMap(ks -> ks.getFunction("f"))
.map(DseFunctionMetadata.class::cast);
For future extensibility, there is a DseXxxMetadata
subtype for every OSS type. But currently (DSE
6.7), the only types that really add extra information are:
-
DseFunctionMetadata: add support for the
DETERMINISTIC
andMONOTONIC
keywords; -
DseAggregateMetadata: add support for the
MONOTONIC
keyword.
All other types (keyspaces, tables, etc.) are identical to their OSS counterparts.