Skip to content

Commit b1be151

Browse files
committed
Merge branch 'master' into peer-recovery-retention-leases
2 parents fbc4477 + bfd8754 commit b1be151

File tree

200 files changed

+8802
-1545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+8802
-1545
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy

+1-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class RestIntegTestTask extends DefaultTask {
5959
Boolean includePackaged = false
6060

6161
RestIntegTestTask() {
62-
runner = project.tasks.create("${name}Runner", Test.class)
62+
runner = project.tasks.create("${name}Runner", RestTestRunnerTask.class)
6363
super.dependsOn(runner)
6464
clusterInit = project.tasks.create(name: "${name}Cluster#init", dependsOn: project.testClasses)
6565
runner.dependsOn(clusterInit)
@@ -77,10 +77,6 @@ class RestIntegTestTask extends DefaultTask {
7777
runner.useCluster project.testClusters."$name"
7878
}
7979

80-
// disable the build cache for rest test tasks
81-
// there are a number of inputs we aren't properly tracking here so we'll just not cache these for now
82-
runner.getOutputs().doNotCacheIf("Caching is disabled for REST integration tests", Specs.SATISFIES_ALL)
83-
8480
// override/add more for rest tests
8581
runner.maxParallelForks = 1
8682
runner.include('**/*IT.class')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.elasticsearch.gradle;
2+
3+
import java.util.List;
4+
5+
public abstract class AbstractLazyPropertyCollection {
6+
7+
final String name;
8+
final Object owner;
9+
10+
public AbstractLazyPropertyCollection(String name) {
11+
this(name, null);
12+
}
13+
14+
public AbstractLazyPropertyCollection(String name, Object owner) {
15+
this.name = name;
16+
this.owner = owner;
17+
}
18+
19+
abstract List<? extends Object> getNormalizedCollection();
20+
21+
void assertNotNull(Object value, String description) {
22+
if (value == null) {
23+
throw new NullPointerException(name + " " + description + " was null" + (owner != null ? " when configuring " + owner : ""));
24+
}
25+
}
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
package org.elasticsearch.gradle;
2+
3+
import org.gradle.api.tasks.Input;
4+
import org.gradle.api.tasks.Nested;
5+
6+
import java.util.ArrayList;
7+
import java.util.Collection;
8+
import java.util.Iterator;
9+
import java.util.List;
10+
import java.util.ListIterator;
11+
import java.util.function.Supplier;
12+
import java.util.stream.Collectors;
13+
14+
public class LazyPropertyList<T> extends AbstractLazyPropertyCollection implements List<T> {
15+
16+
private final List<PropertyListEntry<T>> delegate = new ArrayList<>();
17+
18+
public LazyPropertyList(String name) {
19+
super(name);
20+
}
21+
22+
public LazyPropertyList(String name, Object owner) {
23+
super(name, owner);
24+
}
25+
26+
@Override
27+
public int size() {
28+
return delegate.size();
29+
}
30+
31+
@Override
32+
public boolean isEmpty() {
33+
return delegate.isEmpty();
34+
}
35+
36+
@Override
37+
public boolean contains(Object o) {
38+
return delegate.stream().anyMatch(entry -> entry.getValue().equals(o));
39+
}
40+
41+
@Override
42+
public Iterator<T> iterator() {
43+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).iterator();
44+
}
45+
46+
@Override
47+
public Object[] toArray() {
48+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).toArray();
49+
}
50+
51+
@Override
52+
public <T1> T1[] toArray(T1[] a) {
53+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).toArray(a);
54+
}
55+
56+
@Override
57+
public boolean add(T t) {
58+
return delegate.add(new PropertyListEntry<>(() -> t, PropertyNormalization.DEFAULT));
59+
}
60+
61+
public boolean add(Supplier<T> supplier) {
62+
return delegate.add(new PropertyListEntry<>(supplier, PropertyNormalization.DEFAULT));
63+
}
64+
65+
public boolean add(Supplier<T> supplier, PropertyNormalization normalization) {
66+
return delegate.add(new PropertyListEntry<>(supplier, normalization));
67+
}
68+
69+
@Override
70+
public boolean remove(Object o) {
71+
throw new UnsupportedOperationException(this.getClass().getName() + " does not support remove()");
72+
}
73+
74+
@Override
75+
public boolean containsAll(Collection<?> c) {
76+
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).containsAll(c);
77+
}
78+
79+
@Override
80+
public boolean addAll(Collection<? extends T> c) {
81+
c.forEach(this::add);
82+
return true;
83+
}
84+
85+
@Override
86+
public boolean addAll(int index, Collection<? extends T> c) {
87+
int i = index;
88+
for (T item : c) {
89+
this.add(i++, item);
90+
}
91+
return true;
92+
}
93+
94+
@Override
95+
public boolean removeAll(Collection<?> c) {
96+
throw new UnsupportedOperationException(this.getClass().getName() + " does not support removeAll()");
97+
}
98+
99+
@Override
100+
public boolean retainAll(Collection<?> c) {
101+
throw new UnsupportedOperationException(this.getClass().getName() + " does not support retainAll()");
102+
}
103+
104+
@Override
105+
public void clear() {
106+
delegate.clear();
107+
}
108+
109+
@Override
110+
public T get(int index) {
111+
PropertyListEntry<T> entry = delegate.get(index);
112+
validate(entry);
113+
return entry.getValue();
114+
}
115+
116+
@Override
117+
public T set(int index, T element) {
118+
return delegate.set(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT)).getValue();
119+
}
120+
121+
@Override
122+
public void add(int index, T element) {
123+
delegate.add(index, new PropertyListEntry<>(() -> element, PropertyNormalization.DEFAULT));
124+
}
125+
126+
@Override
127+
public T remove(int index) {
128+
return delegate.remove(index).getValue();
129+
}
130+
131+
@Override
132+
public int indexOf(Object o) {
133+
for (int i = 0; i < delegate.size(); i++) {
134+
if (delegate.get(i).getValue().equals(o)) {
135+
return i;
136+
}
137+
}
138+
139+
return -1;
140+
}
141+
142+
@Override
143+
public int lastIndexOf(Object o) {
144+
int lastIndex = -1;
145+
for (int i = 0; i < delegate.size(); i++) {
146+
if (delegate.get(i).getValue().equals(o)) {
147+
lastIndex = i;
148+
}
149+
}
150+
151+
return lastIndex;
152+
}
153+
154+
@Override
155+
public ListIterator<T> listIterator() {
156+
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator();
157+
}
158+
159+
@Override
160+
public ListIterator<T> listIterator(int index) {
161+
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).listIterator(index);
162+
}
163+
164+
@Override
165+
public List<T> subList(int fromIndex, int toIndex) {
166+
return delegate.stream()
167+
.peek(this::validate)
168+
.map(PropertyListEntry::getValue)
169+
.collect(Collectors.toList())
170+
.subList(fromIndex, toIndex);
171+
}
172+
173+
@Override
174+
@Nested
175+
List<? extends Object> getNormalizedCollection() {
176+
return delegate.stream()
177+
.peek(this::validate)
178+
.filter(entry -> entry.getNormalization() != PropertyNormalization.IGNORE_VALUE)
179+
.collect(Collectors.toList());
180+
}
181+
182+
private void validate(PropertyListEntry<T> entry) {
183+
assertNotNull(entry.getValue(), "entry");
184+
}
185+
186+
private class PropertyListEntry<T> {
187+
private final Supplier<T> supplier;
188+
private final PropertyNormalization normalization;
189+
190+
PropertyListEntry(Supplier<T> supplier, PropertyNormalization normalization) {
191+
this.supplier = supplier;
192+
this.normalization = normalization;
193+
}
194+
195+
public PropertyNormalization getNormalization() {
196+
return normalization;
197+
}
198+
199+
@Input
200+
public T getValue() {
201+
assertNotNull(supplier, "supplier");
202+
return supplier.get();
203+
}
204+
}
205+
}

0 commit comments

Comments
 (0)