Watcher: Removing unused upgradeSource boolean in watch parsing (elastic/elasticsearch#4202)
This seems to be a leftover from elastic/elasticsearch#4162 However the boolean parameters is completely unused already and can be removed. Original commit: elastic/x-pack-elasticsearch@3371b089d6
This commit is contained in:
parent
ace1a7e6af
commit
946d943868
|
@ -233,15 +233,11 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
|||
}
|
||||
|
||||
public Watch parse(String name, boolean includeStatus, BytesReference source) throws IOException {
|
||||
return parse(name, includeStatus, false, source, new DateTime(clock.millis(), UTC), false);
|
||||
}
|
||||
|
||||
public Watch parse(String name, boolean includeStatus, BytesReference source, boolean upgradeSource) throws IOException {
|
||||
return parse(name, includeStatus, false, source, new DateTime(clock.millis(), UTC), upgradeSource);
|
||||
return parse(name, includeStatus, false, source, new DateTime(clock.millis(), UTC));
|
||||
}
|
||||
|
||||
public Watch parse(String name, boolean includeStatus, BytesReference source, DateTime now) throws IOException {
|
||||
return parse(name, includeStatus, false, source, now, false);
|
||||
return parse(name, includeStatus, false, source, now);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,11 +253,10 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
|||
* @see org.elasticsearch.xpack.watcher.WatcherService#putWatch(String, BytesReference, boolean)
|
||||
*/
|
||||
public Watch parseWithSecrets(String id, boolean includeStatus, BytesReference source, DateTime now) throws IOException {
|
||||
return parse(id, includeStatus, true, source, now, false);
|
||||
return parse(id, includeStatus, true, source, now);
|
||||
}
|
||||
|
||||
private Watch parse(String id, boolean includeStatus, boolean withSecrets, BytesReference source, DateTime now,
|
||||
boolean upgradeSource) throws IOException {
|
||||
private Watch parse(String id, boolean includeStatus, boolean withSecrets, BytesReference source, DateTime now) throws IOException {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("parsing watch [{}] ", source.utf8ToString());
|
||||
}
|
||||
|
@ -269,7 +264,7 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
|||
try {
|
||||
parser = new WatcherXContentParser(createParser(source), new HaltedClock(now), withSecrets ? cryptoService : null);
|
||||
parser.nextToken();
|
||||
return parse(id, includeStatus, parser, upgradeSource);
|
||||
return parse(id, includeStatus, parser);
|
||||
} catch (IOException ioe) {
|
||||
throw ioException("could not parse watch [{}]", ioe, id);
|
||||
} finally {
|
||||
|
@ -279,7 +274,7 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
|||
}
|
||||
}
|
||||
|
||||
public Watch parse(String id, boolean includeStatus, XContentParser parser, boolean upgradeWatchSource) throws IOException {
|
||||
public Watch parse(String id, boolean includeStatus, XContentParser parser) throws IOException {
|
||||
Trigger trigger = null;
|
||||
ExecutableInput input = defaultInput;
|
||||
Condition condition = defaultCondition;
|
||||
|
|
|
@ -301,7 +301,7 @@ public class WatchStore extends AbstractComponent {
|
|||
for (SearchHit hit : response.getHits()) {
|
||||
String id = hit.getId();
|
||||
try {
|
||||
Watch watch = watchParser.parse(id, true, hit.getSourceRef(), true);
|
||||
Watch watch = watchParser.parse(id, true, hit.getSourceRef());
|
||||
watch.status().version(hit.version());
|
||||
watch.version(hit.version());
|
||||
watches.put(id, watch);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.watch;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
|
@ -220,10 +219,10 @@ public class WatchStoreTests extends ESTestCase {
|
|||
when(watch3.status()).thenReturn(status);
|
||||
Watch watch4 = mock(Watch.class);
|
||||
when(watch4.status()).thenReturn(status);
|
||||
when(parser.parse("_id1", true, source, true)).thenReturn(watch1);
|
||||
when(parser.parse("_id2", true, source, true)).thenReturn(watch2);
|
||||
when(parser.parse("_id3", true, source, true)).thenReturn(watch3);
|
||||
when(parser.parse("_id4", true, source, true)).thenReturn(watch4);
|
||||
when(parser.parse("_id1", true, source)).thenReturn(watch1);
|
||||
when(parser.parse("_id2", true, source)).thenReturn(watch2);
|
||||
when(parser.parse("_id3", true, source)).thenReturn(watch3);
|
||||
when(parser.parse("_id4", true, source)).thenReturn(watch4);
|
||||
|
||||
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 0));
|
||||
|
||||
|
@ -302,7 +301,7 @@ public class WatchStoreTests extends ESTestCase {
|
|||
};
|
||||
when(watch.transform()).thenReturn(randomFrom(testTransform, null));
|
||||
|
||||
when(parser.parse("_id" + i, true, source, true)).thenReturn(watch);
|
||||
when(parser.parse("_id" + i, true, source)).thenReturn(watch);
|
||||
}
|
||||
|
||||
SearchResponse searchResponse = mockSearchResponse(1, 1, hitCount, hits.toArray(new InternalSearchHit[] {}));
|
||||
|
@ -364,7 +363,7 @@ public class WatchStoreTests extends ESTestCase {
|
|||
Watch watch = mock(Watch.class);
|
||||
WatchStatus status = mock(WatchStatus.class);
|
||||
when(watch.status()).thenReturn(status);
|
||||
when(parser.parse("_id1", true, source, true)).thenReturn(watch);
|
||||
when(parser.parse("_id1", true, source)).thenReturn(watch);
|
||||
|
||||
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 0));
|
||||
|
||||
|
@ -408,17 +407,17 @@ public class WatchStoreTests extends ESTestCase {
|
|||
when(clientProxy.refresh(any(RefreshRequest.class))).thenReturn(refreshResponse);
|
||||
|
||||
BytesReference source = new BytesArray("{}");
|
||||
InternalSearchHit hit1 = new InternalSearchHit(0, "_id1", new Text("type"), Collections.<String, SearchHitField>emptyMap());
|
||||
InternalSearchHit hit1 = new InternalSearchHit(0, "_id1", new Text("type"), Collections.emptyMap());
|
||||
hit1.sourceRef(source);
|
||||
InternalSearchHit hit2 = new InternalSearchHit(1, "_id2", new Text("type"), Collections.<String, SearchHitField>emptyMap());
|
||||
InternalSearchHit hit2 = new InternalSearchHit(1, "_id2", new Text("type"), Collections.emptyMap());
|
||||
hit2.sourceRef(source);
|
||||
SearchResponse searchResponse1 = mockSearchResponse(1, 1, 2, hit1, hit2);
|
||||
|
||||
when(clientProxy.search(any(SearchRequest.class), any(TimeValue.class))).thenReturn(searchResponse1);
|
||||
|
||||
InternalSearchHit hit3 = new InternalSearchHit(2, "_id3", new Text("type"), Collections.<String, SearchHitField>emptyMap());
|
||||
InternalSearchHit hit3 = new InternalSearchHit(2, "_id3", new Text("type"), Collections.emptyMap());
|
||||
hit3.sourceRef(source);
|
||||
InternalSearchHit hit4 = new InternalSearchHit(3, "_id4", new Text("type"), Collections.<String, SearchHitField>emptyMap());
|
||||
InternalSearchHit hit4 = new InternalSearchHit(3, "_id4", new Text("type"), Collections.emptyMap());
|
||||
hit4.sourceRef(source);
|
||||
SearchResponse searchResponse2 = mockSearchResponse(1, 1, 2, hit3, hit4);
|
||||
SearchResponse searchResponse3 = mockSearchResponse(1, 1, 2);
|
||||
|
@ -433,10 +432,10 @@ public class WatchStoreTests extends ESTestCase {
|
|||
when(watch3.status()).thenReturn(status);
|
||||
Watch watch4 = mock(Watch.class);
|
||||
when(watch4.status()).thenReturn(status);
|
||||
when(parser.parse("_id1", true, source, true)).thenReturn(watch1);
|
||||
when(parser.parse("_id2", true, source, true)).thenReturn(watch2);
|
||||
when(parser.parse("_id3", true, source, true)).thenReturn(watch3);
|
||||
when(parser.parse("_id4", true, source, true)).thenReturn(watch4);
|
||||
when(parser.parse("_id1", true, source)).thenReturn(watch1);
|
||||
when(parser.parse("_id2", true, source)).thenReturn(watch2);
|
||||
when(parser.parse("_id3", true, source)).thenReturn(watch3);
|
||||
when(parser.parse("_id4", true, source)).thenReturn(watch4);
|
||||
|
||||
when(clientProxy.clearScroll(anyString())).thenReturn(new ClearScrollResponse(true, 0));
|
||||
|
||||
|
@ -526,5 +525,4 @@ public class WatchStoreTests extends ESTestCase {
|
|||
when(searchResponse.getHits()).thenReturn(internalSearchHits);
|
||||
return searchResponse;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.elasticsearch.indices.query.IndicesQueriesRegistry;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.script.ScriptSettings;
|
||||
import org.elasticsearch.search.SearchRequestParsers;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||
|
@ -342,13 +341,6 @@ public class WatchTests extends ESTestCase {
|
|||
WatcherSearchTemplateRequest request = ((SearchInput) watch.input().input()).getRequest();
|
||||
SearchRequest searchRequest = searchTemplateService.toSearchRequest(request);
|
||||
assertThat(((ScriptQueryBuilder) searchRequest.source().query()).script().getLang(), equalTo(Script.DEFAULT_SCRIPT_LANG));
|
||||
|
||||
// parse in legacy mode:
|
||||
watch = watchParser.parse("_id", false, builder.bytes(), true);
|
||||
assertThat(((ScriptCondition) watch.condition()).getScript().getLang(), equalTo("painless"));
|
||||
request = ((SearchInput) watch.input().input()).getRequest();
|
||||
searchRequest = searchTemplateService.toSearchRequest(request);
|
||||
assertThat(((ScriptQueryBuilder) searchRequest.source().query()).script().getLang(), equalTo("painless"));
|
||||
}
|
||||
|
||||
private static Schedule randomSchedule() {
|
||||
|
|
Loading…
Reference in New Issue