Skip to content

Commit 994869c

Browse files
committed
Merge branch 'master' into log_file_format_finder
2 parents cf06c02 + f709c2f commit 994869c

File tree

899 files changed

+15460
-8050
lines changed

Some content is hidden

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

899 files changed

+15460
-8050
lines changed

client/benchmark/src/main/java/org/elasticsearch/client/benchmark/ops/bulk/BulkBenchmarkTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
package org.elasticsearch.client.benchmark.ops.bulk;
2020

2121
import org.apache.logging.log4j.Logger;
22+
import org.apache.logging.log4j.LogManager;
2223
import org.elasticsearch.ElasticsearchException;
2324
import org.elasticsearch.client.benchmark.BenchmarkTask;
2425
import org.elasticsearch.client.benchmark.metrics.Sample;
2526
import org.elasticsearch.client.benchmark.metrics.SampleRecorder;
2627
import org.elasticsearch.common.SuppressForbidden;
2728
import org.elasticsearch.common.io.PathUtils;
28-
import org.elasticsearch.common.logging.ESLoggerFactory;
2929

3030
import java.io.BufferedReader;
3131
import java.io.IOException;
@@ -135,7 +135,7 @@ private void sendBulk(List<String> bulkData) throws InterruptedException {
135135

136136

137137
private static final class BulkIndexer implements Runnable {
138-
private static final Logger logger = ESLoggerFactory.getLogger(BulkIndexer.class.getName());
138+
private static final Logger logger = LogManager.getLogger(BulkIndexer.class);
139139

140140
private final BlockingQueue<List<String>> bulkData;
141141
private final int warmupIterations;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.security.support.expressiondsl;
21+
22+
import org.elasticsearch.common.xcontent.ToXContentObject;
23+
24+
/**
25+
* Implementations of this interface represent an expression used for user role mapping
26+
* that can later be resolved to a boolean value.
27+
*/
28+
public interface RoleMapperExpression extends ToXContentObject {
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.security.support.expressiondsl.expressions;
21+
22+
import org.elasticsearch.client.security.support.expressiondsl.RoleMapperExpression;
23+
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
27+
/**
28+
* An expression that evaluates to <code>true</code> if-and-only-if all its children
29+
* evaluate to <code>true</code>.
30+
* An <em>all</em> expression with no children is always <code>true</code>.
31+
*/
32+
public final class AllRoleMapperExpression extends CompositeRoleMapperExpression {
33+
34+
private AllRoleMapperExpression(String name, RoleMapperExpression[] elements) {
35+
super(name, elements);
36+
}
37+
38+
public static Builder builder() {
39+
return new Builder();
40+
}
41+
42+
public static final class Builder {
43+
private List<RoleMapperExpression> elements = new ArrayList<>();
44+
45+
public Builder addExpression(final RoleMapperExpression expression) {
46+
assert expression != null : "expression cannot be null";
47+
elements.add(expression);
48+
return this;
49+
}
50+
51+
public AllRoleMapperExpression build() {
52+
return new AllRoleMapperExpression(CompositeType.ALL.getName(), elements.toArray(new RoleMapperExpression[0]));
53+
}
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.security.support.expressiondsl.expressions;
21+
22+
import org.elasticsearch.client.security.support.expressiondsl.RoleMapperExpression;
23+
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
27+
/**
28+
* An expression that evaluates to <code>true</code> if at least one of its children
29+
* evaluate to <code>true</code>.
30+
* An <em>any</em> expression with no children is never <code>true</code>.
31+
*/
32+
public final class AnyRoleMapperExpression extends CompositeRoleMapperExpression {
33+
34+
private AnyRoleMapperExpression(String name, RoleMapperExpression[] elements) {
35+
super(name, elements);
36+
}
37+
38+
public static Builder builder() {
39+
return new Builder();
40+
}
41+
42+
public static final class Builder {
43+
private List<RoleMapperExpression> elements = new ArrayList<>();
44+
45+
public Builder addExpression(final RoleMapperExpression expression) {
46+
assert expression != null : "expression cannot be null";
47+
elements.add(expression);
48+
return this;
49+
}
50+
51+
public AnyRoleMapperExpression build() {
52+
return new AnyRoleMapperExpression(CompositeType.ANY.getName(), elements.toArray(new RoleMapperExpression[0]));
53+
}
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.security.support.expressiondsl.expressions;
21+
22+
import org.elasticsearch.client.security.support.expressiondsl.RoleMapperExpression;
23+
import org.elasticsearch.common.xcontent.XContentBuilder;
24+
25+
import java.io.IOException;
26+
import java.util.Arrays;
27+
import java.util.Collections;
28+
import java.util.List;
29+
import java.util.Objects;
30+
31+
/**
32+
* Expression of role mapper expressions which can be combined by operators like AND, OR
33+
* <p>
34+
* Expression builder example:
35+
* <pre>
36+
* {@code
37+
* final RoleMapperExpression allExpression = AllRoleMapperExpression.builder()
38+
.addExpression(AnyRoleMapperExpression.builder()
39+
.addExpression(FieldRoleMapperExpression.ofUsername("[email protected]"))
40+
.addExpression(FieldRoleMapperExpression.ofUsername("[email protected]"))
41+
.build())
42+
.addExpression(FieldRoleMapperExpression.ofMetadata("metadata.location", "AMER"))
43+
.addExpression(new ExceptRoleMapperExpression(FieldRoleMapperExpression.ofUsername("[email protected]")))
44+
.build();
45+
* }
46+
* </pre>
47+
*/
48+
public abstract class CompositeRoleMapperExpression implements RoleMapperExpression {
49+
private final String name;
50+
private final List<RoleMapperExpression> elements;
51+
52+
CompositeRoleMapperExpression(final String name, final RoleMapperExpression... elements) {
53+
assert name != null : "field name cannot be null";
54+
assert elements != null : "at least one field expression is required";
55+
this.name = name;
56+
this.elements = Collections.unmodifiableList(Arrays.asList(elements));
57+
}
58+
59+
public String getName() {
60+
return this.getName();
61+
}
62+
63+
public List<RoleMapperExpression> getElements() {
64+
return elements;
65+
}
66+
67+
@Override
68+
public boolean equals(Object o) {
69+
if (this == o) {
70+
return true;
71+
}
72+
if (o == null || getClass() != o.getClass()) {
73+
return false;
74+
}
75+
76+
final CompositeRoleMapperExpression that = (CompositeRoleMapperExpression) o;
77+
if (Objects.equals(this.getName(), that.getName()) == false) {
78+
return false;
79+
}
80+
return Objects.equals(this.getElements(), that.getElements());
81+
}
82+
83+
@Override
84+
public int hashCode() {
85+
return Objects.hash(name, elements);
86+
}
87+
88+
@Override
89+
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
90+
builder.startObject();
91+
builder.startArray(name);
92+
for (RoleMapperExpression e : elements) {
93+
e.toXContent(builder, params);
94+
}
95+
builder.endArray();
96+
return builder.endObject();
97+
}
98+
99+
}
100+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.security.support.expressiondsl.expressions;
21+
22+
import org.elasticsearch.common.ParseField;
23+
24+
import java.util.Collections;
25+
import java.util.HashMap;
26+
import java.util.Map;
27+
28+
public enum CompositeType {
29+
30+
ANY("any"), ALL("all"), EXCEPT("except");
31+
32+
private static Map<String, CompositeType> nameToType = Collections.unmodifiableMap(initialize());
33+
private ParseField field;
34+
35+
CompositeType(String name) {
36+
this.field = new ParseField(name);
37+
}
38+
39+
public String getName() {
40+
return field.getPreferredName();
41+
}
42+
43+
public ParseField getParseField() {
44+
return field;
45+
}
46+
47+
public static CompositeType fromName(String name) {
48+
return nameToType.get(name);
49+
}
50+
51+
private static Map<String, CompositeType> initialize() {
52+
Map<String, CompositeType> map = new HashMap<>();
53+
for (CompositeType field : values()) {
54+
map.put(field.getName(), field);
55+
}
56+
return map;
57+
}
58+
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client.security.support.expressiondsl.expressions;
21+
22+
import org.elasticsearch.client.security.support.expressiondsl.RoleMapperExpression;
23+
import org.elasticsearch.common.xcontent.XContentBuilder;
24+
25+
import java.io.IOException;
26+
27+
/**
28+
* A negating expression. That is, this expression evaluates to <code>true</code> if-and-only-if
29+
* its delegate expression evaluate to <code>false</code>.
30+
* Syntactically, <em>except</em> expressions are intended to be children of <em>all</em>
31+
* expressions ({@link AllRoleMapperExpression}).
32+
*/
33+
public final class ExceptRoleMapperExpression extends CompositeRoleMapperExpression {
34+
35+
public ExceptRoleMapperExpression(final RoleMapperExpression expression) {
36+
super(CompositeType.EXCEPT.getName(), expression);
37+
}
38+
39+
@Override
40+
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException {
41+
builder.startObject();
42+
builder.field(CompositeType.EXCEPT.getName());
43+
builder.value(getElements().get(0));
44+
return builder.endObject();
45+
}
46+
47+
}

0 commit comments

Comments
 (0)