Skip to content

Commit b7422ad

Browse files
author
Tom May
committed
Move nasty ActionFuture casts from LruNodeClient to LruNodeManager which
has the nasty code that requires them.
1 parent a7272d1 commit b7422ad

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

plugins/client/lru/src/main/java/org/elasticsearch/client/node/lru/LruIndexManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ public interface IndexOperation {
3535
public void perform();
3636
}
3737

38-
public interface AsyncIndexOperation {
39-
public ActionFuture<? extends ActionResponse> perform();
38+
public interface AsyncIndexOperation<T> {
39+
public ActionFuture<T> perform();
4040
}
4141

4242

43-
public ActionFuture<? extends ActionResponse> ensureOpen(final String index, AsyncIndexOperation op) {
44-
return ensureOpenAndPerform(new String[]{index},op);
43+
public <T> ActionFuture<T> ensureOpen(final String index, AsyncIndexOperation<T> op) {
44+
return (ActionFuture<T>)ensureOpenAndPerform(new String[]{index},op);
4545
}
4646

47-
public ActionFuture<? extends ActionResponse> ensureOpen(final String [] indices, AsyncIndexOperation op) {
48-
return ensureOpenAndPerform(indices,op);
47+
public <T> ActionFuture<T> ensureOpen(final String [] indices, AsyncIndexOperation<T> op) {
48+
return (ActionFuture<T>)ensureOpenAndPerform(indices,op);
4949
}
5050

5151
public void ensureOpen(final String index, IndexOperation op) {

plugins/client/lru/src/main/java/org/elasticsearch/client/node/lru/LruNodeClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void perform() {
8080

8181
@Override public ActionFuture<DeleteResponse> delete(final DeleteRequest request) {
8282
logger.debug("delete");
83-
return (ActionFuture<DeleteResponse>)lru.ensureOpen(request.index(), new LruIndexManager.AsyncIndexOperation() {
83+
return lru.ensureOpen(request.index(), new LruIndexManager.AsyncIndexOperation<DeleteResponse>() {
8484
public ActionFuture<DeleteResponse> perform() {
8585
return LruNodeClient.super.delete(request);
8686
}
@@ -98,7 +98,7 @@ public void perform() {
9898

9999
@Override public ActionFuture<BulkResponse> bulk(final BulkRequest request) {
100100
logger.debug("bulk");
101-
return (ActionFuture<BulkResponse>)lru.ensureOpen(getIndices(request), new LruIndexManager.AsyncIndexOperation() {
101+
return lru.ensureOpen(getIndices(request), new LruIndexManager.AsyncIndexOperation<BulkResponse>() {
102102
public ActionFuture<BulkResponse> perform() {
103103
return LruNodeClient.super.bulk(request);
104104
}
@@ -118,7 +118,7 @@ public void perform() {
118118

119119
@Override public ActionFuture<DeleteByQueryResponse> deleteByQuery(final DeleteByQueryRequest request) {
120120
logger.debug("deleteByQuery");
121-
return (ActionFuture<DeleteByQueryResponse>)lru.ensureOpen(request.indices(), new LruIndexManager.AsyncIndexOperation() {
121+
return lru.ensureOpen(request.indices(), new LruIndexManager.AsyncIndexOperation<DeleteByQueryResponse>() {
122122
public ActionFuture<DeleteByQueryResponse> perform() {
123123
return LruNodeClient.super.deleteByQuery(request);
124124
}
@@ -136,7 +136,7 @@ public void perform() {
136136

137137
@Override public ActionFuture<GetResponse> get(final GetRequest request) {
138138
logger.debug("get");
139-
return (ActionFuture<GetResponse>)lru.ensureOpen(request.index(), new LruIndexManager.AsyncIndexOperation() {
139+
return lru.ensureOpen(request.index(), new LruIndexManager.AsyncIndexOperation<GetResponse>() {
140140
public ActionFuture<GetResponse> perform() {
141141
return LruNodeClient.super.get(request);
142142
}
@@ -155,7 +155,7 @@ public void perform() {
155155

156156
@Override public ActionFuture<CountResponse> count(final CountRequest request) {
157157
logger.debug("count");
158-
return (ActionFuture<CountResponse>)lru.ensureOpen(request.indices(), new LruIndexManager.AsyncIndexOperation() {
158+
return lru.ensureOpen(request.indices(), new LruIndexManager.AsyncIndexOperation<CountResponse>() {
159159
public ActionFuture<CountResponse> perform() {
160160
return LruNodeClient.super.count(request);
161161
}
@@ -174,7 +174,7 @@ public void perform() {
174174

175175
@Override public ActionFuture<SearchResponse> search(final SearchRequest request) {
176176
logger.debug("search");
177-
return (ActionFuture<SearchResponse>)lru.ensureOpen(request.indices(), new LruIndexManager.AsyncIndexOperation() {
177+
return lru.ensureOpen(request.indices(), new LruIndexManager.AsyncIndexOperation<SearchResponse>() {
178178
public ActionFuture<SearchResponse> perform() {
179179
return LruNodeClient.super.search(request);
180180
}
@@ -202,7 +202,7 @@ public void perform() {
202202

203203
@Override public ActionFuture<SearchResponse> moreLikeThis(final MoreLikeThisRequest request) {
204204
logger.debug("moreLikeThis");
205-
return (ActionFuture<SearchResponse>)lru.ensureOpen(request.index(), new LruIndexManager.AsyncIndexOperation() {
205+
return lru.ensureOpen(request.index(), new LruIndexManager.AsyncIndexOperation<SearchResponse>() {
206206
public ActionFuture<SearchResponse> perform() {
207207
return LruNodeClient.super.moreLikeThis(request);
208208
}

0 commit comments

Comments
 (0)