Elffuss BraidHub

kikocis/java-driver public

Merge branch '2.1' into 3.0.x
Changeset23d57c44d4080578c4cb1e7436d515d0b689cdd6ced25e4dbef3a3d0c87fcbec
Authorolim7t <omichallat+github@gmail.com> · 2016-04-01 19:53 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2016-04-01 19:53 +02:00
Parentseec6c6de3e64, 66e5cc716ac2

Browse the files at this changeset

7 files changed

modified driver-core/src/test/java/com/datastax/driver/core/CCMAccess.java +16 −2
@@ -203,11 +203,25 @@
203203 void updateNodeConfig(int n, Map<String, Object> configs);
204204
205205 /**
206- * Sets the workload for the {@code nth} host in the CCM cluster.
206+ * Updates the {@code nth} host's dse config file in the CCM cluster.
207207 *
208208 * @param n the node number (starting from 1).
209209 */
210- void setWorkload(int n, Workload workload);
210+ void updateDSENodeConfig(int n, String key, Object value);
211+
212+ /**
213+ * Updates the {@code nth} host's dse config file in the CCM cluster.
214+ *
215+ * @param n the node number (starting from 1).
216+ */
217+ void updateDSENodeConfig(int n, Map<String, Object> configs);
218+
219+ /**
220+ * Sets the workload(s) for the {@code nth} host in the CCM cluster.
221+ *
222+ * @param n the node number (starting from 1).
223+ */
224+ void setWorkload(int n, Workload... workload);
211225
212226
213227 // Methods blocking until nodes are up or down
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +25 −6
@@ -541,8 +541,27 @@
541541 }
542542
543543 @Override
544- public void setWorkload(int node, Workload workload) {
545- execute(CCM_COMMAND + " node%d setworkload %s", node, workload);
544+ public void updateDSENodeConfig(int n, String key, Object value) {
545+ updateDSENodeConfig(n, ImmutableMap.<String, Object>builder().put(key, value).build());
546+ }
547+
548+ @Override
549+ public void updateDSENodeConfig(int n, Map<String, Object> configs) {
550+ StringBuilder confStr = new StringBuilder();
551+ for (Map.Entry<String, Object> entry : configs.entrySet()) {
552+ confStr
553+ .append(entry.getKey())
554+ .append(":")
555+ .append(entry.getValue())
556+ .append(" ");
557+ }
558+ execute(CCM_COMMAND + " node%s updatedseconf %s", n, confStr);
559+ }
560+
561+ @Override
562+ public void setWorkload(int node, Workload... workload) {
563+ String workloadStr = Joiner.on(",").join(workload);
564+ execute(CCM_COMMAND + " node%d setworkload %s", node, workloadStr);
546565 }
547566
548567 private String execute(String command, Object... args) {
@@ -677,7 +696,7 @@
677696 private Set<String> jvmArgs = new LinkedHashSet<String>();
678697 private final Map<String, Object> cassandraConfiguration = Maps.newLinkedHashMap();
679698 private final Map<String, Object> dseConfiguration = Maps.newLinkedHashMap();
680- private Map<Integer, Workload> workloads = new HashMap<Integer, Workload>();
699+ private Map<Integer, Workload[]> workloads = new HashMap<Integer, Workload[]>();
681700
682701 private Builder() {
683702 cassandraConfiguration.put("start_rpc", false);
@@ -808,10 +827,10 @@
808827 * Sets the DSE workload for a given node.
809828 *
810829 * @param node The node to set the workload for (starting with 1).
811- * @param workload The workload (e.g. solr, spark, hadoop)
830+ * @param workload The workload(s) (e.g. solr, spark, hadoop)
812831 * @return This builder
813832 */
814- public Builder withWorkload(int node, Workload workload) {
833+ public Builder withWorkload(int node, Workload... workload) {
815834 this.workloads.put(node, workload);
816835 return this;
817836 }
@@ -837,7 +856,7 @@
837856 ccm.updateConfig(cassandraConfiguration);
838857 if (!dseConfiguration.isEmpty())
839858 ccm.updateDSEConfig(dseConfiguration);
840- for (Map.Entry<Integer, Workload> entry : workloads.entrySet()) {
859+ for (Map.Entry<Integer, Workload[]> entry : workloads.entrySet()) {
841860 ccm.setWorkload(entry.getKey(), entry.getValue());
842861 }
843862 if (start)
modified driver-core/src/test/java/com/datastax/driver/core/CCMCache.java +11 −1
@@ -191,7 +191,17 @@
191191 }
192192
193193 @Override
194- public void setWorkload(int n, Workload workload) {
194+ public void updateDSENodeConfig(int n, String key, Object value) {
195+ ccm.updateDSENodeConfig(n, key, value);
196+ }
197+
198+ @Override
199+ public void updateDSENodeConfig(int n, Map<String, Object> configs) {
200+ ccm.updateDSENodeConfig(n, configs);
201+ }
202+
203+ @Override
204+ public void setWorkload(int n, Workload... workload) {
195205 ccm.setWorkload(n, workload);
196206 }
197207
modified driver-core/src/test/java/com/datastax/driver/core/CCMConfig.java +1 −1
@@ -135,7 +135,7 @@
135135 *
136136 * @return The workloads to assign to each node.
137137 */
138- CCMAccess.Workload[] workloads() default {};
138+ CCMWorkload[] workloads() default {};
139139
140140 /**
141141 * Returns {@code true} if a {@link CCMBridge} instance should be automatically created, {@code false} otherwise.
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +19 −8
@@ -213,7 +213,17 @@
213213 }
214214
215215 @Override
216- public void setWorkload(int node, Workload workload) {
216+ public void updateDSENodeConfig(int n, String key, Object value) {
217+ throw new UnsupportedOperationException("This CCM cluster is read-only");
218+ }
219+
220+ @Override
221+ public void updateDSENodeConfig(int n, Map<String, Object> configs) {
222+ throw new UnsupportedOperationException("This CCM cluster is read-only");
223+ }
224+
225+ @Override
226+ public void setWorkload(int node, Workload... workload) {
217227 throw new UnsupportedOperationException("This CCM cluster is read-only");
218228 }
219229
@@ -351,17 +361,17 @@
351361 return args;
352362 }
353363
354- private List<Workload> workloads() {
364+ private List<Workload[]> workloads() {
355365 int total = 0;
356366 for (int perDc : numberOfNodes())
357367 total += perDc;
358- List<Workload> workloads = new ArrayList<Workload>(Collections.<Workload>nCopies(total, null));
368+ List<Workload[]> workloads = new ArrayList<Workload[]>(Collections.<Workload[]>nCopies(total, null));
359369 for (int i = annotations.size() - 1; i >= 0; i--) {
360370 CCMConfig ann = annotations.get(i);
361- Workload[] annWorkloads = ann.workloads();
371+ CCMWorkload[] annWorkloads = ann.workloads();
362372 for (int j = 0; j < annWorkloads.length; j++) {
363- Workload workload = annWorkloads[j];
364- workloads.set(j, workload);
373+ CCMWorkload nodeWorkloads = annWorkloads[j];
374+ workloads.set(j, nodeWorkloads.value());
365375 }
366376 }
367377 return workloads;
@@ -438,9 +448,9 @@
438448 for (String arg : jvmArgs()) {
439449 ccmBuilder.withJvmArgs(arg);
440450 }
441- List<Workload> workloads = workloads();
451+ List<Workload[]> workloads = workloads();
442452 for (int i = 0; i < workloads.size(); i++) {
443- Workload workload = workloads.get(i);
453+ Workload[] workload = workloads.get(i);
444454 if (workload != null)
445455 ccmBuilder.withWorkload(i + 1, workload);
446456 }
@@ -760,6 +770,7 @@
760770 }
761771 }
762772 }
773+
763774 /**
764775 * Signals that the test has encountered an unexpected error.
765776 * <p/>
added driver-core/src/test/java/com/datastax/driver/core/CCMWorkload.java +37 −0
@@ -0,0 +1,37 @@
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 java.lang.annotation.ElementType;
19+import java.lang.annotation.Retention;
20+import java.lang.annotation.RetentionPolicy;
21+import java.lang.annotation.Target;
22+
23+/**
24+ * A set of workloads to assign to a specific node.
25+ */
26+@Retention(RetentionPolicy.RUNTIME)
27+@Target(ElementType.ANNOTATION_TYPE)
28+public @interface CCMWorkload {
29+
30+ /**
31+ * The workloads to assign to a specific node.
32+ *
33+ * @return The workloads to assign to a specifc node.
34+ */
35+ CCMAccess.Workload[] value() default {};
36+
37+}
modified driver-core/src/test/java/com/datastax/driver/core/DseCCMClusterTest.java +13 −1
@@ -17,6 +17,8 @@
1717
1818 import org.testng.annotations.Test;
1919
20+import static com.datastax.driver.core.CCMAccess.Workload.*;
21+
2022 /**
2123 * A simple test to validate DSE setups.
2224 * <p/>
@@ -68,11 +70,21 @@
6870 * A correct example is as follows: {@code /usr/bin:/usr/local/bin:/bin:/usr/sbin:$JAVA_HOME/bin:$PATH}.
6971 */
7072 @Test(enabled = false)
71-@CCMConfig(dse = true, version = "4.8.3")
73+@CCMConfig(
74+ dse = true,
75+ numberOfNodes = 3,
76+ version = "4.8.3",
77+ workloads = {
78+ @CCMWorkload(solr),
79+ @CCMWorkload({spark, solr}),
80+ @CCMWorkload({cassandra, spark})
81+ }
82+)
7283 public class DseCCMClusterTest extends CCMTestsSupport {
7384
7485 @Test(groups = "short")
7586 public void should_conenct_to_dse() throws InterruptedException {
87+
7688 }
7789
7890 }