Elffuss BraidHub

kikocis/java-driver public

JAVA-1042: Include DSE version and workload in Host data.

This commit contains contributions by Andrew Tolbert (@tolbertam),
in particular tests for both JAVA-1042 and JAVA-1035.
Changeset72031067a18f08fd7a2ce71120374e5d5b691d13a738cd4e9fb566d6a4dbbb1d
AuthorDan Jatnieks <danj@datastax.com> · 2016-01-26 19:21 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-28 11:30 +01:00
Parentsa6b44c4c2439

Browse the files at this changeset

7 files changed

modified changelog/README.md +1 −0
@@ -6,6 +6,7 @@
66 - [improvement] JAVA-1035: Expose host broadcast_address and listen_address if available.
77 - [new feature] JAVA-1037: Allow named parameters in simple statements.
88 - [improvement] JAVA-1033: Allow per-statement read timeout.
9+- [improvement] JAVA-1042: Include DSE version and workload in Host data.
910
1011 Merged from 2.1 branch:
1112
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +24 −0
@@ -503,6 +503,14 @@
503503 : null;
504504 host.setListenAddress(listenAddress);
505505
506+ if (row.getColumnDefinitions().contains("workload")) {
507+ String dseWorkload = row.getString("workload");
508+ host.setDseWorkload(dseWorkload);
509+ }
510+ if (row.getColumnDefinitions().contains("dse_version")) {
511+ String dseVersion = row.getString("dse_version");
512+ host.setDseVersion(dseVersion);
513+ }
506514 }
507515
508516 private static void updateLocationInfo(Host host, String datacenter, String rack, boolean isInitialConnection, Cluster.Manager cluster) {
@@ -565,7 +573,10 @@
565573 List<String> racks = new ArrayList<String>();
566574 List<String> cassandraVersions = new ArrayList<String>();
567575 List<InetAddress> broadcastAddresses = new ArrayList<InetAddress>();
576+ List<InetAddress> listenAddresses = new ArrayList<InetAddress>();
568577 List<Set<String>> allTokens = new ArrayList<Set<String>>();
578+ List<String> dseVersions = new ArrayList<String>();
579+ List<String> dseWorkloads = new ArrayList<String>();
569580
570581 for (Row row : peersFuture.get()) {
571582 InetSocketAddress rpcAddress = rpcAddressForPeerHost(row, connection.address, cluster, logMissingRpcAddresses);
@@ -579,6 +590,12 @@
579590 broadcastAddresses.add(row.getInet("peer"));
580591 if (metadataEnabled)
581592 allTokens.add(row.getSet("tokens", String.class));
593+ InetAddress listenAddress = row.getColumnDefinitions().contains("listen_address") ? row.getInet("listen_address") : null;
594+ listenAddresses.add(listenAddress);
595+ String dseWorkload = row.getColumnDefinitions().contains("workload") ? row.getString("workload") : null;
596+ dseWorkloads.add(dseWorkload);
597+ String dseVersion = row.getColumnDefinitions().contains("dse_version") ? row.getString("dse_version") : null;
598+ dseVersions.add(dseVersion);
582599 }
583600
584601 for (int i = 0; i < foundHosts.size(); i++) {
@@ -603,6 +620,13 @@
603620 host.setVersion(cassandraVersions.get(i));
604621 if (broadcastAddresses.get(i) != null)
605622 host.setBroadcastAddress(broadcastAddresses.get(i));
623+ if (listenAddresses.get(i) != null)
624+ host.setListenAddress(listenAddresses.get(i));
625+
626+ if (dseVersions.get(i) != null)
627+ host.setDseVersion(dseVersions.get(i));
628+ if (dseWorkloads.get(i) != null)
629+ host.setDseWorkload(dseWorkloads.get(i));
606630
607631 if (metadataEnabled && partitioner != null && !allTokens.get(i).isEmpty())
608632 tokenMap.put(host, allTokens.get(i));
modified driver-core/src/main/java/com/datastax/driver/core/Host.java +54 −8
@@ -74,6 +74,9 @@
7474
7575 private volatile Set<Token> tokens;
7676
77+ private volatile String dseWorkload;
78+ private volatile VersionNumber dseVersion;
79+
7780 // ClusterMetadata keeps one Host object per inet address and we rely on this (more precisely,
7881 // we rely on the fact that we can use Object equality as a valid equality), so don't use
7982 // that constructor but ClusterMetadata.getHost instead.
@@ -113,6 +116,22 @@
113116 this.listenAddress = listenAddress;
114117 }
115118
119+ void setDseVersion(String dseVersion) {
120+ VersionNumber versionNumber = null;
121+ try {
122+ if (dseVersion != null) {
123+ versionNumber = VersionNumber.parse(dseVersion);
124+ }
125+ } catch (IllegalArgumentException e) {
126+ logger.warn("Error parsing DSE version {}. This shouldn't have happened", dseVersion);
127+ }
128+ this.dseVersion = versionNumber;
129+ }
130+
131+ void setDseWorkload(String dseWorkload) {
132+ this.dseWorkload = dseWorkload;
133+ }
134+
116135 /**
117136 * Returns the address that the driver will use to connect to the node.
118137 * <p/>
@@ -138,14 +157,14 @@
138157 * </ol>
139158 *
140159 * @return the address and port.
141- * @see <a href="https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html>The cassandra.yaml configuration file</a>
160+ * @see <a href="https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html">The cassandra.yaml configuration file</a>
142161 */
143162 public InetSocketAddress getSocketAddress() {
144163 return address;
145164 }
146165
147166 /**
148- * Returns the node broadcast address, i.e. the IP by which it should be contacted by other peers in the cluster.
167+ * Returns the node broadcast address, that is, the IP by which it should be contacted by other peers in the cluster.
149168 * <p/>
150169 * This corresponds to the {@code broadcast_address} cassandra.yaml file setting and
151170 * is by default the same as {@link #getListenAddress()}, unless specified
@@ -157,14 +176,14 @@
157176 * case this method will return {@code null}.
158177 *
159178 * @return the node broadcast address.
160- * @see <a href="https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html>The cassandra.yaml configuration file</a>
179+ * @see <a href="https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html">The cassandra.yaml configuration file</a>
161180 */
162181 public InetAddress getBroadcastAddress() {
163182 return broadcastAddress;
164183 }
165184
166185 /**
167- * Returns the node listen address, i.e. the IP the node uses to contact other peers in the cluster.
186+ * Returns the node listen address, that is, the IP the node uses to contact other peers in the cluster.
168187 * <p/>
169188 * This corresponds to the {@code listen_address} cassandra.yaml file setting.
170189 * <em>This is NOT the address clients should use to contact this node</em>.
@@ -174,7 +193,7 @@
174193 * case this method will return {@code null}.
175194 *
176195 * @return the node listen address.
177- * @see <a href="https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html>The cassandra.yaml configuration file</a>
196+ * @see <a href="https://docs.datastax.com/en/cassandra/2.1/cassandra/configuration/configCassandra_yaml_r.html">The cassandra.yaml configuration file</a>
178197 */
179198 public InetAddress getListenAddress() {
180199 return listenAddress;
@@ -199,7 +218,7 @@
199218 * <p/>
200219 * The returned rack name is the one as known by Cassandra.
201220 * It is also possible for this information to be unavailable. In that case
202- * this method returns {@code null}, and the caller should always aware of this
221+ * this method returns {@code null}, and the caller should always be aware of this
203222 * possibility.
204223 *
205224 * @return the Cassandra rack name or null if the rack is unavailable
@@ -211,8 +230,9 @@
211230 /**
212231 * The Cassandra version the host is running.
213232 * <p/>
214- * As for other host information fetch from Cassandra above, the returned
215- * version can theoretically be null if the information is unavailable.
233+ * It is also possible for this information to be unavailable. In that case
234+ * this method returns {@code null}, and the caller should always be aware of this
235+ * possibility.
216236 *
217237 * @return the Cassandra version the host is running.
218238 */
@@ -220,6 +240,32 @@
220240 return cassandraVersion;
221241 }
222242
243+ /**
244+ * The DSE version the host is running.
245+ * <p/>
246+ * It is also possible for this information to be unavailable. In that case
247+ * this method returns {@code null}, and the caller should always be aware of this
248+ * possibility.
249+ *
250+ * @return the DSE version the host is running.
251+ */
252+ public VersionNumber getDseVersion() {
253+ return dseVersion;
254+ }
255+
256+ /**
257+ * The DSE Workload the host is running.
258+ * <p/>
259+ * It is also possible for this information to be unavailable. In that case
260+ * this method returns {@code null}, and the caller should always be aware of this
261+ * possibility.
262+ *
263+ * @return the DSE workload the host is running.
264+ */
265+ public String getDseWorkload() {
266+ return dseWorkload;
267+ }
268+
223269 /**
224270 * Returns the tokens that this host owns.
225271 *
modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +41 −0
@@ -20,6 +20,7 @@
2020 import com.datastax.driver.core.policies.LoadBalancingPolicy;
2121 import org.assertj.core.api.AbstractAssert;
2222
23+import java.net.InetAddress;
2324 import java.util.concurrent.CountDownLatch;
2425 import java.util.concurrent.TimeUnit;
2526
@@ -128,4 +129,44 @@
128129 fail(actual + " did not go down within " + duration + " " + unit);
129130 return this;
130131 }
132+
133+ public HostAssert hasWorkload(String workload) {
134+ assertThat(actual.getDseWorkload()).isNotNull().isEqualTo(workload);
135+ return this;
136+ }
137+
138+ public HostAssert hasNoWorkload() {
139+ assertThat(actual.getDseWorkload()).isNull();
140+ return this;
141+ }
142+
143+ public HostAssert hasDseVersion(VersionNumber versionNumber) {
144+ assertThat(actual.getDseVersion()).isNotNull().isEqualTo(versionNumber);
145+ return this;
146+ }
147+
148+ public HostAssert hasNoDseVersion() {
149+ assertThat(actual.getDseVersion()).isNull();
150+ return this;
151+ }
152+
153+ public HostAssert hasListenAddress(InetAddress address) {
154+ assertThat(actual.getListenAddress()).isNotNull().isEqualTo(address);
155+ return this;
156+ }
157+
158+ public HostAssert hasNoListenAddress() {
159+ assertThat(actual.getListenAddress()).isNull();
160+ return this;
161+ }
162+
163+ public HostAssert hasBroadcastAddress(InetAddress address) {
164+ assertThat(actual.getBroadcastAddress()).isNotNull().isEqualTo(address);
165+ return this;
166+ }
167+
168+ public HostAssert hasNoBroadcastAddress() {
169+ assertThat(actual.getBroadcastAddress()).isNull();
170+ return this;
171+ }
131172 }
added driver-core/src/test/java/com/datastax/driver/core/HostMetadataIntegrationTest.java +288 −0
@@ -0,0 +1,288 @@
1+/*
2+ * Copyright (C) 2012-2015 DataStax 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+package com.datastax.driver.core;
17+
18+import org.apache.log4j.Level;
19+import org.apache.log4j.Logger;
20+import org.testng.annotations.Test;
21+
22+import java.net.InetAddress;
23+
24+import static com.datastax.driver.core.Assertions.assertThat;
25+import static com.datastax.driver.core.CCMAccess.Workload.solr;
26+import static com.datastax.driver.core.CCMAccess.Workload.spark;
27+import static com.datastax.driver.core.TestUtils.nonDebouncingQueryOptions;
28+import static com.datastax.driver.core.TestUtils.nonQuietClusterCloseOptions;
29+
30+public class HostMetadataIntegrationTest {
31+
32+ /**
33+ * Validates that when given a DSE cluster that the workload and dse versions are properly
34+ * parsed and set on the respective {@link Host} instances.
35+ * <p/>
36+ * This test is disabled as running DSE with workloads is intensive and has unreliable results
37+ * when running CCM with multiple workloads.
38+ * <p/>
39+ * FIXME: this test is currently disabled because nodes with specific workload
40+ * do not seem to come up within the allocated time.
41+ *
42+ * @test_category host:metadata
43+ * @jira_ticket JAVA1042
44+ * @see HostMetadataIntegrationTest#should_parse_dse_workload_and_version_if_available()
45+ */
46+ @Test(groups = "long", enabled = false)
47+ public void test_mixed_dse_workload() {
48+ CCMBridge.Builder builder = CCMBridge.builder()
49+ .withNodes(3)
50+ .withDSE()
51+ .withVersion("4.8.3")
52+ .withWorkload(2, solr)
53+ .withWorkload(3, spark);
54+ CCMAccess ccm = CCMCache.get(builder);
55+
56+ VersionNumber version = VersionNumber.parse("4.8.3");
57+
58+ Cluster cluster = Cluster.builder()
59+ .addContactPoints(ccm.addressOfNode(1).getAddress())
60+ .withPort(ccm.getBinaryPort())
61+ .withQueryOptions(nonDebouncingQueryOptions())
62+ .build();
63+ try {
64+ cluster.connect();
65+
66+ assertThat(cluster).host(1).hasWorkload("Cassandra").hasDseVersion(version);
67+ assertThat(cluster).host(2).hasWorkload("Search").hasDseVersion(version);
68+ assertThat(cluster).host(3).hasWorkload("Analytics").hasDseVersion(version);
69+ } finally {
70+ cluster.close();
71+ ccm.close();
72+ }
73+ }
74+
75+ /**
76+ * Validates that {@link Host#getDseVersion()} and {@link Host#getDseWorkload()} return values defined in
77+ * the <code>dse_version</code> and <code>workload</code> columns if they are present in <code>system.local</code>
78+ * or <code>system.peers</code> otherwise they return null.
79+ *
80+ * @test_category host:metadata
81+ * @jira_ticket JAVA-1042
82+ */
83+ @Test(groups = "short'")
84+ public void should_parse_dse_workload_and_version_if_available() {
85+ // given: A 5 node cluster with all nodes having a workload and dse_version except node 2.
86+ ScassandraCluster scassandraCluster = ScassandraCluster.builder()
87+ .withIpPrefix(TestUtils.IP_PREFIX)
88+ .withNodes(5)
89+ .forcePeerInfo(1, 1, "workload", "Analytics")
90+ .forcePeerInfo(1, 1, "dse_version", "4.8.4")
91+ .forcePeerInfo(1, 3, "workload", "Solr")
92+ .forcePeerInfo(1, 3, "dse_version", "4.8.4")
93+ .forcePeerInfo(1, 4, "workload", "Cassandra")
94+ .forcePeerInfo(1, 4, "dse_version", "4.8.4")
95+ .forcePeerInfo(1, 5, "workload", "AmazingNewFeature")
96+ .forcePeerInfo(1, 5, "dse_version", "5.0.0")
97+ .build();
98+
99+ Cluster cluster = Cluster.builder()
100+ .addContactPoints(scassandraCluster.address(1).getAddress())
101+ .withPort(scassandraCluster.getBinaryPort())
102+ .withNettyOptions(nonQuietClusterCloseOptions)
103+ .build();
104+
105+ try {
106+ scassandraCluster.init();
107+ // when: initializing a cluster instance.
108+ cluster.init();
109+
110+ // then: All nodes except node 2 should have a workload and dse version.
111+ assertThat(cluster).host(1).hasWorkload("Analytics").hasDseVersion(VersionNumber.parse("4.8.4"));
112+ assertThat(cluster).host(2).hasNoWorkload().hasNoDseVersion();
113+ assertThat(cluster).host(3).hasWorkload("Solr").hasDseVersion(VersionNumber.parse("4.8.4"));
114+ assertThat(cluster).host(4).hasWorkload("Cassandra").hasDseVersion(VersionNumber.parse("4.8.4"));
115+ assertThat(cluster).host(5).hasWorkload("AmazingNewFeature").hasDseVersion(VersionNumber.parse("5.0.0"));
116+ } finally {
117+ cluster.close();
118+ scassandraCluster.stop();
119+ }
120+ }
121+
122+ /**
123+ * Validates that {@link Host#getDseVersion()} and {@link Host#getDseWorkload()} return null if
124+ * the <code>dse_version</code> and <code>workload</code> columns are not present in <code>system.local</code>
125+ * for the control host.
126+ *
127+ * @test_category host:metadata
128+ * @jira_ticket JAVA-1042
129+ */
130+ @Test(groups = "short")
131+ public void should_not_parse_dse_workload_and_version_if_not_present_in_local_table() {
132+ // given: A cluster with node 1 (control host) not having a workload or dse_version set, and node 2 with those
133+ // columns set.
134+ ScassandraCluster scassandraCluster = ScassandraCluster.builder()
135+ .withIpPrefix(TestUtils.IP_PREFIX)
136+ .withNodes(2)
137+ .forcePeerInfo(1, 2, "workload", "Analytics")
138+ .forcePeerInfo(1, 2, "dse_version", "4.8.4")
139+ .build();
140+
141+ Cluster cluster = Cluster.builder()
142+ .addContactPoints(scassandraCluster.address(1).getAddress())
143+ .withPort(scassandraCluster.getBinaryPort())
144+ .withNettyOptions(nonQuietClusterCloseOptions)
145+ .build();
146+
147+ try {
148+ scassandraCluster.init();
149+ // when: initializing a cluster instance.
150+ cluster.init();
151+
152+ // then:
153+ // - node 1 should have no workload or dse version.
154+ // - node 2 should have a workload and a dse version.
155+ assertThat(cluster).host(1).hasNoWorkload().hasNoDseVersion();
156+ assertThat(cluster).host(2).hasWorkload("Analytics").hasDseVersion(VersionNumber.parse("4.8.4"));
157+ } finally {
158+ cluster.close();
159+ scassandraCluster.stop();
160+ }
161+ }
162+
163+ /**
164+ * Validates that if <code>dse_version</code> column is a non-version value in <code>system.local</code> or
165+ * <code>system.peers</code> that a warning is logged and {@link Host#getDseVersion()} returns null.
166+ *
167+ * @test_category host:metadata
168+ * @jira_ticket JAVA-1042
169+ */
170+ @Test(groups = "short")
171+ public void should_log_warning_when_invalid_version_used_for_dse_version() {
172+ // given: A cluster with a node that has an invalid version for dse_version in system.local.
173+ ScassandraCluster scassandraCluster = ScassandraCluster.builder()
174+ .withIpPrefix(TestUtils.IP_PREFIX)
175+ .withNodes(1)
176+ .forcePeerInfo(1, 1, "workload", "Analytics")
177+ .forcePeerInfo(1, 1, "dse_version", "Invalid Version!")
178+ .build();
179+
180+ Cluster cluster = Cluster.builder()
181+ .addContactPoints(scassandraCluster.address(1).getAddress())
182+ .withPort(scassandraCluster.getBinaryPort())
183+ .withNettyOptions(nonQuietClusterCloseOptions)
184+ .build();
185+
186+ MemoryAppender logs = new MemoryAppender();
187+ Logger logger = Logger.getLogger(Host.class);
188+ Level originalLoggerLevel = logger.getLevel();
189+ logger.setLevel(Level.WARN);
190+ logger.addAppender(logs);
191+
192+ try {
193+ scassandraCluster.init();
194+ // when: initializing a cluster instance.
195+ cluster.init();
196+
197+ // then: dse version for that host should not be set and a warning shall be logged.
198+ assertThat(logs.get())
199+ .contains("Error parsing DSE version Invalid Version!. This shouldn't have happened");
200+ assertThat(cluster).host(1).hasNoDseVersion().hasWorkload("Analytics");
201+ } finally {
202+ logger.removeAppender(logs);
203+ logger.setLevel(originalLoggerLevel);
204+ cluster.close();
205+ scassandraCluster.stop();
206+ }
207+ }
208+
209+ /**
210+ * Validates that {@link Host#getBroadcastAddress()} is set for all hosts (control host or not) in the default
211+ * case of a cluster, as the broadcast address is derived from <code>broadcast_address</code> in
212+ * <code>system.local</code> and <code>peer</code> in <code>system.peers</code>.
213+ *
214+ * @test_category host:metadata
215+ * @jira_ticket JAVA-1035
216+ */
217+ @Test(groups = "short")
218+ public void should_set_broadcast_address_for_all_nodes() {
219+ // given: A cluster with 3 nodes.
220+ ScassandraCluster scassandraCluster = ScassandraCluster.builder()
221+ .withIpPrefix(TestUtils.IP_PREFIX)
222+ .withNodes(3)
223+ .build();
224+
225+ Cluster cluster = Cluster.builder()
226+ .addContactPoints(scassandraCluster.address(1).getAddress())
227+ .withPort(scassandraCluster.getBinaryPort())
228+ .withNettyOptions(nonQuietClusterCloseOptions)
229+ .build();
230+
231+ try {
232+ scassandraCluster.init();
233+ // when: initializing a cluster instance.
234+ cluster.init();
235+
236+ // then: broadcast address should be set for each host:
237+ // - broadcast_address is used for system.local and is always present, so control host should have it.
238+ // - peer column is used for system.peers to resolve broadcast address and is always present.
239+ for (int i = 1; i <= scassandraCluster.nodes().size(); i++) {
240+ assertThat(cluster).host(i).hasBroadcastAddress(TestUtils.addressOfNode(i));
241+ }
242+ } finally {
243+ cluster.close();
244+ scassandraCluster.stop();
245+ }
246+ }
247+
248+ /**
249+ * Validates that {@link Host#getListenAddress()} is set for a host if and only if the <code>listen_address</code>
250+ * column is present and set in the <code>system.peers</code> table or if the host is the control host.
251+ *
252+ * @test_category host:metadata
253+ * @jira_ticket JAVA-1035
254+ */
255+ @Test(groups = "short")
256+ public void should_set_listen_address_if_available() {
257+ // given: A Cluster with 3 nodes and node 2 being configured with a listen address in its peers table.
258+ InetAddress listenAddress = TestUtils.addressOfNode(10);
259+ ScassandraCluster scassandraCluster = ScassandraCluster.builder()
260+ .withIpPrefix(TestUtils.IP_PREFIX)
261+ .withNodes(3)
262+ .forcePeerInfo(1, 2, "listen_address", listenAddress)
263+ .build();
264+
265+ Cluster cluster = Cluster.builder()
266+ .addContactPoints(scassandraCluster.address(1).getAddress())
267+ .withPort(scassandraCluster.getBinaryPort())
268+ .withNettyOptions(nonQuietClusterCloseOptions)
269+ .build();
270+
271+ try {
272+ // when: initializing a cluster instance.
273+ scassandraCluster.init();
274+ cluster.init();
275+
276+ // then: listen address should be set appropriate for each host:
277+ // - Control Host will always have a listen address (listen_address should always be present).
278+ assertThat(cluster).host(1).hasListenAddress(TestUtils.addressOfNode(1));
279+ // - Host 2 should have a listen address since we provided one.
280+ assertThat(cluster).host(2).hasListenAddress(listenAddress);
281+ // - Host 3 should have no listen address as it wasn't provided.
282+ assertThat(cluster).host(3).hasNoListenAddress();
283+ } finally {
284+ cluster.close();
285+ scassandraCluster.stop();
286+ }
287+ }
288+}
modified driver-core/src/test/java/com/datastax/driver/core/ScassandraCluster.java +33 −9
@@ -287,31 +287,42 @@
287287 if (node == peer) { // prime system.local.
288288 metadata = SELECT_LOCAL;
289289 query = "SELECT * FROM system.local WHERE key='local'";
290- row = ImmutableMap.<String, Object>builder()
290+ ImmutableMap.Builder<String, Object> rowBuilder = ImmutableMap.<String, Object>builder()
291291 .put("key", "local")
292292 .put("bootstrapped", "COMPLETED")
293293 .put("broadcast_address", address)
294294 .put("cluster_name", "scassandra")
295295 .put("cql_version", "3.2.0")
296296 .put("data_center", datacenter(dc))
297- .put("listen_address", address)
297+ .put("listen_address", getPeerInfo(dc, n + 1, "listen_address", address))
298298 .put("partitioner", "org.apache.cassandra.dht.Murmur3Partitioner")
299299 .put("rack", "rack1")
300300 .put("release_version", getPeerInfo(dc, n + 1, "release_version", "2.1.8"))
301- .put("tokens", ImmutableSet.of(tokens.get(n)))
302- .build();
301+ .put("tokens", ImmutableSet.of(tokens.get(n)));
302+
303+ // These columns might not always be present, we don't have to specify them in the scassandra
304+ // column metadata as it will default them to text columns.
305+ rowBuilder = addInfoIfExists(rowBuilder, dc, n + 1, "dse_version");
306+ rowBuilder = addInfoIfExists(rowBuilder, dc, n + 1, "workload");
307+
308+ row = rowBuilder.build();
303309 } else { // prime system.peers.
304310 query = "SELECT * FROM system.peers WHERE peer='" + address + "'";
305311 metadata = SELECT_PEERS;
306- row = ImmutableMap.<String, Object>builder()
312+ ImmutableMap.Builder<String, Object> rowBuilder = ImmutableMap.<String, Object>builder()
307313 .put("peer", address)
308314 .put("rpc_address", address)
309315 .put("data_center", datacenter(dc))
310316 .put("rack", "rack1")
311317 .put("release_version", getPeerInfo(dc, n + 1, "release_version", "2.1.8"))
312- .put("tokens", ImmutableSet.of(Long.toString(tokens.get(n))))
313- .build();
314- rows.add(row);
318+ .put("tokens", ImmutableSet.of(Long.toString(tokens.get(n))));
319+
320+ rowBuilder = addInfoIfExists(rowBuilder, dc, n + 1, "listen_address");
321+ rowBuilder = addInfoIfExists(rowBuilder, dc, n + 1, "dse_version");
322+ rowBuilder = addInfoIfExists(rowBuilder, dc, n + 1, "workload");
323+
324+ row = rowBuilder.build();
325+ rows.add(rowBuilder.build());
315326 }
316327 client.prime(PrimingRequest.queryBuilder()
317328 .withQuery(query)
@@ -353,6 +364,18 @@
353364 .build());
354365 }
355366
367+ private ImmutableMap.Builder<String, Object> addInfoIfExists(ImmutableMap.Builder<String, Object> builder, int dc, int node, String property) {
368+ Map<Integer, Map<String, Object>> forDc = forcedPeerInfos.get(dc);
369+ if (forDc == null)
370+ return builder;
371+
372+ Map<String, Object> forNode = forDc.get(node);
373+ if (forNode == null)
374+ return builder;
375+
376+ return (forNode.containsKey(property)) ? builder.put(property, forNode.get(property)) : builder;
377+ }
378+
356379 private Object getPeerInfo(int dc, int node, String property, Object defaultValue) {
357380 Map<Integer, Map<String, Object>> forDc = forcedPeerInfos.get(dc);
358381 if (forDc == null)
@@ -373,7 +396,8 @@
373396 column("data_center", TEXT),
374397 column("rack", TEXT),
375398 column("release_version", TEXT),
376- column("tokens", set(TEXT))
399+ column("tokens", set(TEXT)),
400+ column("listen_address", INET)
377401 };
378402
379403 static final org.scassandra.http.client.types.ColumnMetadata[] SELECT_LOCAL = {
modified driver-core/src/test/java/com/datastax/driver/core/TestUtils.java +1 −1
@@ -569,7 +569,7 @@
569569 */
570570 public static InetAddress addressOfNode(int i) {
571571 try {
572- return InetAddress.getByName(IP_PREFIX + 1);
572+ return InetAddress.getByName(IP_PREFIX + i);
573573 } catch (UnknownHostException e) {
574574 // should never happen
575575 throw Throwables.propagate(e);