Skip to content

Conversation

@javanna
Copy link
Member

@javanna javanna commented Mar 5, 2015

While working on #6418, I found myself cleaning some things up around scripting code, which I figured would be better to isolate on a different PR, to make the fine grained settings change easier to review.

  • Added NAME constants for each script language, avoiding to repeat the same strings all over the place.
  • Simplified compile method signatures by removing a couple of variants. Note that all of these signatures are going to change again with Allow fine-grained script settings #6418 as in order to compile/execute a script the caller will need to specify which operation is attempting to execute the script, info that will be provided as an additional mandatory argument.
  • Removed double call to ScriptService#verifyDynamicScripting for every indexed or dynamic script.
  • Decreased ScriptService inner classes visibility to private (CacheKey, IndexedScript, ApplySettings)
  • Moved ScriptService inner classes to the bottom of the class, I think it makes it more readable.
  • Resolved some compiler warnings

@javanna javanna added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v1.5.0 v2.0.0-beta1 >enhancement review labels Mar 5, 2015
@dadoonet
Copy link
Contributor

dadoonet commented Mar 5, 2015

@javanna Just a reminder here for when the PR is merged to also fix :

in their es-1.x and master branches.

I believe there will be changes to port there.

I think also that some river plugins might not compile anymore (test part) as if IIRC we are doing some script tests there (couchdb, rabbitmq).

@javanna
Copy link
Member Author

javanna commented Mar 5, 2015

HI @dadoonet not sure what changes you mean that we should port there. In my mind these changes shouldn't break anything in scripting plugins, they shouldn't access the ScriptService directly. As for rivers, that might be the case, but then those compile signatures would be broken anyway for #6418 , which should be ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not something for this PR but we now have a convention of using script for inline, script_file for file and script_id for indexed scripts (using the ScriptParameterParser to maintain the consistency). Should we follow that convention here? I can see we may want to keep the inline as query but maybe we should also support script for inline? and file and id can probably be replaced with script_file and script_id?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me, patches welcome :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #9995 for this :)

@dadoonet
Copy link
Contributor

dadoonet commented Mar 5, 2015

@javanna Ignore me. I got confused by Github diff and thought you removed inner classes we are using in plugins. It's not the case. Sorry for the false alarm.

@javanna
Copy link
Member Author

javanna commented Mar 5, 2015

I think you read my mind @dadoonet I wanted to do what you feared badly :) but I went for not breaking bw comp. I will probably do that on master only later on.

@javanna javanna force-pushed the enhancement/script_service_cleanup branch from 9216e5f to 34c0c64 Compare March 5, 2015 15:48
@jpountz
Copy link
Contributor

jpountz commented Mar 6, 2015

LGTM

@javanna javanna force-pushed the enhancement/script_service_cleanup branch from 34c0c64 to 5c30425 Compare March 6, 2015 17:50
@javanna javanna removed the review label Mar 7, 2015
…#6418

- Added NAME constants for each script language, avoiding to repeat the same strings all over the place.
- Simplified `compile` method signatures by removing a couple of variants. Note that all of these signatures are going to change again with elastic#6418 as in order to compile/execute a script the caller will need to specify which operation is attempting to execute the script, info that will be provided as an additional mandatory argument.
- Removed double call to ScriptService#verifyDynamicScripting for every indexed or dynamic script.
- Decreased ScriptService inner classes visibility to private (CacheKey, IndexedScript, ApplySettings)
- Moved ScriptService inner classes to the bottom of the class, I think it makes it more readable.
- Resolved some compiler warnings

Closes elastic#9992
@javanna javanna force-pushed the enhancement/script_service_cleanup branch from 5c30425 to 521ac7f Compare March 7, 2015 09:01
@javanna javanna merged commit 521ac7f into elastic:master Mar 7, 2015
javanna added a commit that referenced this pull request Mar 7, 2015
- Added NAME constants for each script language, avoiding to repeat the same strings all over the place.
- Simplified `compile` method signatures by removing a couple of variants. Note that all of these signatures are going to change again with #6418 as in order to compile/execute a script the caller will need to specify which operation is attempting to execute the script, info that will be provided as an additional mandatory argument.
- Removed double call to ScriptService#verifyDynamicScripting for every indexed or dynamic script.
- Decreased ScriptService inner classes visibility to private (CacheKey, IndexedScript, ApplySettings)
- Moved ScriptService inner classes to the bottom of the class, I think it makes it more readable.
- Resolved some compiler warnings

Closes #9992
@dadoonet
Copy link
Contributor

@javanna It effectively breaks: See https://github.com/elastic/elasticsearch-river-couchdb/blob/master/src/main/java/org/elasticsearch/river/couchdb/CouchdbRiver.java#L145-145

The method signature changed. I need to fix that I guess. :)

We just need to change

Maps.newHashMap()

to

Maps.<String, Object>newHashMap()

dadoonet added a commit to elastic/elasticsearch-river-couchdb that referenced this pull request Mar 16, 2015
dadoonet added a commit to elastic/elasticsearch-river-couchdb that referenced this pull request Mar 16, 2015
@javanna
Copy link
Member Author

javanna commented Mar 16, 2015

Marked this as breaking. It breaks plugins that make use of scripting by depending on ScriptService (e.g. some rivers that allow to transform documents before indexing them). It doesn't break plugins that implement a scripting engine though.

@clintongormley clintongormley changed the title Scripting: cleanup ScriptService & friends in preparation for #6418 Cleanup ScriptService & friends in preparation for #6418 Jun 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants