Elffuss BraidHub

kikocis/java-driver public

Allow multiple workloads to be specified per node in @CCMConfig.
Changesetbdbef4d2f3a9a79815223e216881c158f7e622e5ed546176ca5ce71c47e05d46
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-03-22 19:18 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2016-04-01 19:51 +02:00
Parents2204d64a11c8

Browse the files at this changeset

4 files changed

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 +7 −7
@@ -361,17 +361,17 @@
361361 return args;
362362 }
363363
364- private List<Workload> workloads() {
364+ private List<Workload[]> workloads() {
365365 int total = 0;
366366 for (int perDc : numberOfNodes())
367367 total += perDc;
368- List<Workload> workloads = new ArrayList<Workload>(Collections.<Workload>nCopies(total, null));
368+ List<Workload[]> workloads = new ArrayList<Workload[]>(Collections.<Workload[]>nCopies(total, null));
369369 for (int i = annotations.size() - 1; i >= 0; i--) {
370370 CCMConfig ann = annotations.get(i);
371- Workload[] annWorkloads = ann.workloads();
371+ CCMWorkload[] annWorkloads = ann.workloads();
372372 for (int j = 0; j < annWorkloads.length; j++) {
373- Workload workload = annWorkloads[j];
374- workloads.set(j, workload);
373+ CCMWorkload nodeWorkloads = annWorkloads[j];
374+ workloads.set(j, nodeWorkloads.value());
375375 }
376376 }
377377 return workloads;
@@ -448,9 +448,9 @@
448448 for (String arg : jvmArgs()) {
449449 ccmBuilder.withJvmArgs(arg);
450450 }
451- List<Workload> workloads = workloads();
451+ List<Workload[]> workloads = workloads();
452452 for (int i = 0; i < workloads.size(); i++) {
453- Workload workload = workloads.get(i);
453+ Workload[] workload = workloads.get(i);
454454 if (workload != null)
455455 ccmBuilder.withWorkload(i + 1, workload);
456456 }
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 }