-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed indexed scripts to be stored in the cluster state instead of …
…the `.scripts` index. Also added max script size soft limit for stored scripts. Closes #16651
- Loading branch information
Showing
137 changed files
with
2,389 additions
and
2,772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
.../java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.cluster.storedscripts; | ||
|
||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.action.ValidateActions.addValidationError; | ||
|
||
public class DeleteStoredScriptRequest extends AcknowledgedRequest<DeleteStoredScriptRequest> { | ||
|
||
private String id; | ||
private String scriptLang; | ||
|
||
DeleteStoredScriptRequest() { | ||
} | ||
|
||
public DeleteStoredScriptRequest(String scriptLang, String id) { | ||
this.scriptLang = scriptLang; | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if (id == null) { | ||
validationException = addValidationError("id is missing", validationException); | ||
} else if (id.contains("#")) { | ||
validationException = addValidationError("id can't contain: '#'", validationException); | ||
} | ||
if (scriptLang == null) { | ||
validationException = addValidationError("lang is missing", validationException); | ||
} else if (scriptLang.contains("#")) { | ||
validationException = addValidationError("lang can't contain: '#'", validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
public String scriptLang() { | ||
return scriptLang; | ||
} | ||
|
||
public DeleteStoredScriptRequest scriptLang(String type) { | ||
this.scriptLang = type; | ||
return this; | ||
} | ||
|
||
public String id() { | ||
return id; | ||
} | ||
|
||
public DeleteStoredScriptRequest id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
scriptLang = in.readString(); | ||
id = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(scriptLang); | ||
out.writeString(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "delete script {[" + scriptLang + "][" + id + "]}"; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...rg/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.cluster.storedscripts; | ||
|
||
import org.elasticsearch.action.support.master.AcknowledgedRequestBuilder; | ||
import org.elasticsearch.client.ElasticsearchClient; | ||
|
||
public class DeleteStoredScriptRequestBuilder extends AcknowledgedRequestBuilder<DeleteStoredScriptRequest, | ||
DeleteStoredScriptResponse, DeleteStoredScriptRequestBuilder> { | ||
|
||
public DeleteStoredScriptRequestBuilder(ElasticsearchClient client, DeleteStoredScriptAction action) { | ||
super(client, action, new DeleteStoredScriptRequest()); | ||
} | ||
|
||
public DeleteStoredScriptRequestBuilder setScriptLang(String scriptLang) { | ||
request.scriptLang(scriptLang); | ||
return this; | ||
} | ||
|
||
public DeleteStoredScriptRequestBuilder setId(String id) { | ||
request.id(id); | ||
return this; | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.cluster.storedscripts; | ||
|
||
import org.elasticsearch.action.support.master.AcknowledgedResponse; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class DeleteStoredScriptResponse extends AcknowledgedResponse { | ||
|
||
DeleteStoredScriptResponse() { | ||
} | ||
|
||
public DeleteStoredScriptResponse(boolean acknowledged) { | ||
super(acknowledged); | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
readAcknowledged(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
writeAcknowledged(out); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...ain/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.cluster.storedscripts; | ||
|
||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.ValidateActions; | ||
import org.elasticsearch.action.support.master.MasterNodeReadRequest; | ||
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class GetStoredScriptRequest extends MasterNodeReadRequest<GetStoredScriptRequest> { | ||
|
||
protected String id; | ||
protected String lang; | ||
|
||
GetStoredScriptRequest() { | ||
} | ||
|
||
public GetStoredScriptRequest(String lang, String id) { | ||
this.lang = lang; | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if (lang == null) { | ||
validationException = ValidateActions.addValidationError("lang is missing", validationException); | ||
} | ||
if (id == null) { | ||
validationException = ValidateActions.addValidationError("id is missing", validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
public GetStoredScriptRequest lang(@Nullable String type) { | ||
this.lang = type; | ||
return this; | ||
} | ||
|
||
public GetStoredScriptRequest id(String id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
|
||
public String lang() { | ||
return lang; | ||
} | ||
|
||
public String id() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
lang = in.readString(); | ||
id = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(lang); | ||
out.writeString(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "get script [" + lang + "][" + id + "]"; | ||
} | ||
} |
Oops, something went wrong.