Skip to content

Commit cb7e92b

Browse files
committed
start work on the groovy plugin
1 parent 913bc2f commit cb7e92b

Some content is hidden

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

44 files changed

+1886
-245
lines changed

.idea/dictionaries/kimchy.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/plugin-groovy.iml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ explodedDistLibDir = new File(explodedDistDir, 'lib')
1818
explodedDistBinDir = new File(explodedDistDir, 'bin')
1919
explodedDistConfigDir = new File(explodedDistDir, 'config')
2020

21+
//mavenRepoUrl = "file://localhost/" + projectDir.absolutePath + "/build/maven/repository"
22+
//mavenSnapshotRepoUrl = "file://localhost/" + projectDir.absolutePath + "/build/maven/snapshotRepository"
23+
mavenRepoUrl = "http://oss.sonatype.org/service/local/staging/deploy/maven2/"
24+
mavenSnapshotRepoUrl = "http://oss.sonatype.org/content/repositories/snapshots"
25+
mavenRepoUser = "kimchy"
26+
mavenRepoPass = System.getenv("REPO_PASS")
2127

2228
allprojects {
2329
group = 'org.elasticsearch'

modules/elasticsearch/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,12 @@ artifacts {
9797

9898
uploadArchives {
9999
repositories.mavenDeployer {
100-
// repository(url: "file://localhost/" + rootProject.projectDir.absolutePath + "/build/maven/repository")
101-
// snapshotRepository(url: "file://localhost/" + rootProject.projectDir.absolutePath + "/build/maven/snapshotRepository")
102-
103100
configuration = configurations.deployerJars
104-
repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") {
105-
authentication(userName: "kimchy", password: System.getenv("REPO_PASS"))
101+
repository(url: rootProject.mavenRepoUrl) {
102+
authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
106103
}
107-
snapshotRepository(url: "http://oss.sonatype.org/content/repositories/snapshots") {
108-
authentication(userName: "kimchy", password: System.getenv("REPO_PASS"))
104+
snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
105+
authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
109106
}
110107

111108
pom.project {

modules/elasticsearch/src/main/java/org/elasticsearch/action/ActionListener.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@
2020
package org.elasticsearch.action;
2121

2222
/**
23-
* @author kimchy (Shay Banon)
23+
* A listener for action responses or failures.
24+
*
25+
* @author kimchy (shay.banon)
2426
*/
2527
public interface ActionListener<Response> {
2628

29+
/**
30+
* A response handler.
31+
*/
2732
void onResponse(Response response);
2833

34+
/**
35+
* A failure handler.
36+
*/
2937
void onFailure(Throwable e);
3038
}

modules/elasticsearch/src/main/java/org/elasticsearch/action/ActionRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.util.io.stream.Streamable;
2323

2424
/**
25-
* @author kimchy (Shay Banon)
25+
* @author kimchy (shay.banon)
2626
*/
2727
public interface ActionRequest extends Streamable {
2828

modules/elasticsearch/src/main/java/org/elasticsearch/action/ActionResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.elasticsearch.util.io.stream.Streamable;
2323

2424
/**
25-
* @author kimchy (Shay Banon)
25+
* @author kimchy (shay.banon)
2626
*/
2727
public interface ActionResponse extends Streamable {
2828
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to Elastic Search and Shay Banon under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. Elastic Search licenses this
6+
* file to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. 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.action;
21+
22+
/**
23+
* An {@link ActionFuture} that listeners can be added to.
24+
*
25+
* @author kimchy (shay.banon)
26+
*/
27+
public interface ListenableActionFuture<T> extends ActionFuture<T> {
28+
29+
/**
30+
* Add an action listener to be invoked when a response has received.
31+
*/
32+
void addListener(final ActionListener<T> listener);
33+
34+
/**
35+
* Add an action listener (runnable) to be invoked when a response has received.
36+
*/
37+
void addListener(final Runnable listener);
38+
}

modules/elasticsearch/src/main/java/org/elasticsearch/action/delete/DeleteResponse.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,41 @@ public String index() {
5858
return this.index;
5959
}
6060

61+
/**
62+
* The index the document was deleted from.
63+
*/
64+
public String getIndex() {
65+
return index;
66+
}
67+
6168
/**
6269
* The type of the document deleted.
6370
*/
6471
public String type() {
6572
return this.type;
6673
}
6774

75+
/**
76+
* The type of the document deleted.
77+
*/
78+
public String getType() {
79+
return type;
80+
}
81+
6882
/**
6983
* The id of the document deleted.
7084
*/
7185
public String id() {
7286
return this.id;
7387
}
7488

89+
/**
90+
* The id of the document deleted.
91+
*/
92+
public String getId() {
93+
return id;
94+
}
95+
7596
@Override public void readFrom(StreamInput in) throws IOException {
7697
index = in.readUTF();
7798
id = in.readUTF();

modules/elasticsearch/src/main/java/org/elasticsearch/action/get/GetField.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ public String name() {
5050
return name;
5151
}
5252

53+
public String getName() {
54+
return name;
55+
}
56+
5357
public List<Object> values() {
5458
return values;
5559
}
5660

61+
public List<Object> getValues() {
62+
return values;
63+
}
64+
5765
@Override public Iterator<Object> iterator() {
5866
return values.iterator();
5967
}

modules/elasticsearch/src/main/java/org/elasticsearch/action/get/GetResponse.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class GetResponse implements ActionResponse, Streamable, Iterable<GetFiel
5555

5656
private Map<String, GetField> fields;
5757

58+
private Map<String, Object> sourceAsMap;
59+
5860
private byte[] source;
5961

6062
GetResponse() {
@@ -79,27 +81,55 @@ public boolean exists() {
7981
return exists;
8082
}
8183

84+
/**
85+
* Does the document exists.
86+
*/
87+
public boolean isExists() {
88+
return exists;
89+
}
90+
8291
/**
8392
* The index the document was fetched from.
8493
*/
8594
public String index() {
8695
return this.index;
8796
}
8897

98+
/**
99+
* The index the document was fetched from.
100+
*/
101+
public String getIndex() {
102+
return index;
103+
}
104+
89105
/**
90106
* The type of the document.
91107
*/
92108
public String type() {
93109
return type;
94110
}
95111

112+
/**
113+
* The type of the document.
114+
*/
115+
public String getType() {
116+
return type;
117+
}
118+
96119
/**
97120
* The id of the document.
98121
*/
99122
public String id() {
100123
return id;
101124
}
102125

126+
/**
127+
* The id of the document.
128+
*/
129+
public String getId() {
130+
return id;
131+
}
132+
103133
/**
104134
* The source of the document if exists.
105135
*/
@@ -125,17 +155,29 @@ public Map<String, Object> sourceAsMap() throws ElasticSearchParseException {
125155
if (source == null) {
126156
return null;
127157
}
158+
if (sourceAsMap != null) {
159+
return sourceAsMap;
160+
}
128161
try {
129-
return defaultObjectMapper().readValue(source, 0, source.length, Map.class);
162+
sourceAsMap = defaultObjectMapper().readValue(source, 0, source.length, Map.class);
163+
return sourceAsMap;
130164
} catch (Exception e) {
131165
throw new ElasticSearchParseException("Failed to parse source to map", e);
132166
}
133167
}
134168

169+
public Map<String, Object> getSource() {
170+
return sourceAsMap();
171+
}
172+
135173
public Map<String, GetField> fields() {
136174
return this.fields;
137175
}
138176

177+
public Map<String, GetField> getFields() {
178+
return fields;
179+
}
180+
139181
public GetField field(String name) {
140182
return fields.get(name);
141183
}

modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public static OpType fromId(byte id) {
104104
private byte[] source;
105105
private OpType opType = OpType.INDEX;
106106

107+
public IndexRequest() {
108+
}
109+
107110
/**
108111
* Constructs a new index request against the specific index. The {@link #type(String)},
109112
* {@link #id(String)} and {@link #source(byte[])} must be set.
@@ -127,9 +130,6 @@ public IndexRequest(String index, String type, String id, byte[] source) {
127130
this.source = source;
128131
}
129132

130-
IndexRequest() {
131-
}
132-
133133
@Override public ActionRequestValidationException validate() {
134134
ActionRequestValidationException validationException = super.validate();
135135
if (type == null) {

modules/elasticsearch/src/main/java/org/elasticsearch/action/index/IndexResponse.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,41 @@ public String index() {
5858
return this.index;
5959
}
6060

61+
/**
62+
* The index the document was indexed into.
63+
*/
64+
public String getIndex() {
65+
return index;
66+
}
67+
6168
/**
6269
* The type of the document indexed.
6370
*/
6471
public String type() {
6572
return this.type;
6673
}
6774

75+
/**
76+
* The type of the document indexed.
77+
*/
78+
public String getType() {
79+
return type;
80+
}
81+
6882
/**
6983
* The id of the document indexed.
7084
*/
7185
public String id() {
7286
return this.id;
7387
}
7488

89+
/**
90+
* The id of the document indexed.
91+
*/
92+
public String getId() {
93+
return id;
94+
}
95+
7596
@Override public void readFrom(StreamInput in) throws IOException {
7697
index = in.readUTF();
7798
id = in.readUTF();

0 commit comments

Comments
 (0)