Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2753: Fuseki CLI arg customisation refactor #2773

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rvesse
Copy link
Member

@rvesse rvesse commented Oct 14, 2024

Refactors how the FusekiMain CLI can be customised to make it more flexible and interface driven. CLI extensions have to be statically registered prior to invoking FusekiMain but are now able to both customise the arguments available and to directly affect the FusekiServer.Builder without needing to sub-class FusekiMain

Currently some tests are broken so still a Work in Progress!

GitHub issue resolved #2753

Pull request Description:


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

Refactors how the FusekiMain CLI can be customised to make it more
flexible and interface driven.  CLI extensions have to be statically
registered prior to invoking FusekiMain but are now able to both
customise the arguments available and to directly affect the
FusekiServer.Builder without needing to sub-class FusekiMain

// ---- Port
serverConfig.port = defaultPort;
builder.port(defaultPort);
Copy link
Member Author

Choose a reason for hiding this comment

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

  • Don't set this default if a Jetty config file present

@@ -56,7 +57,7 @@
* Modules must not rely on a call to {@code serverStopped} happening.</li>
* </ul>
*/
public interface FusekiModule extends FusekiBuildCycle, FusekiStartStop, FusekiActionCycle {
public interface FusekiModule extends FusekiCliCustomiser, FusekiBuildCycle, FusekiStartStop, FusekiActionCycle {
Copy link
Member Author

Choose a reason for hiding this comment

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

  • Remove this, doesn't make sense given the CLI lifecycle

Copy link
Member

Choose a reason for hiding this comment

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

Maybe keep but return a record of three slots (DSG, label, update flag) rather than pass in ServerConfig.

Copy link
Member Author

Choose a reason for hiding this comment

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

That code was only being called from FusekiMain so made more sense (to me at least) to inline it

*
* @param fuseki Fuseki Main
*/
public default void customiseCli(FusekiMain fuseki) {
Copy link
Member

Choose a reason for hiding this comment

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

Better to return a list of ArgDecls (ArgModuleGeneral) to add? It reduces the exposed surface of FusekiMain.

* @param fuseki Fuseki Main
* @param builder Fuseki Builder
*/
public default void processCliArgs(FusekiMain fuseki, FusekiServer.Builder builder) {
Copy link
Member

Choose a reason for hiding this comment

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

Is the argument checking going to be done by the cusomization? (e.g. if arg1 , then arg2 is not allowed)

Someway to pass in the args that have been set by the earlier call?

Copy link
Member

Choose a reason for hiding this comment

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

If the server is "everythign" then one case is a customizer to influence themoduels actually run. i.e there might be args that are a "switch off" e.g.--nogeosparql -- an arg to not run a GeoSPARQL module.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the argument checking going to be done by the cusomization? (e.g. if arg1 , then arg2 is not allowed)

Someway to pass in the args that have been set by the earlier call?

That was why I was passing FusekiMain in as you can call the various contains() and getValue() methods inherited from the rest of the Jena CLI machinery

Copy link
Member Author

@rvesse rvesse Oct 15, 2024

Choose a reason for hiding this comment

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

If the server is "everything" then one case is a customizer to influence the modules actually run. i.e there might be args that are a "switch off" e.g.--nogeosparql -- an arg to not run a GeoSPARQL module.

Yeah I need to play around more with how modules interact and are configured here, it's tricky because modules aren't currently registered until after the CLI arguments are parsed which makes it somewhat circular as you can't have a module directly register its own arguments unless its explicitly registered as a customiser

Copy link
Member

Choose a reason for hiding this comment

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

A simplifying assumption is that a set FusekiCliCustomiser and a set of modules.

builder.addCliCustomisers must be before the builder calls command line processing.

There is no need to add FusekiCliCustomiser to FusekiModule for all modules.
A module can still also have FusekiCliCustomiser.

Copy link
Member

Choose a reason for hiding this comment

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

That was why I was passing FusekiMain in as you can call the various contains() and getValue() methods inherited from the rest of the Jena CLI machinery

That seems a good argument to changing FusekiMain so it does not extend CmdARQ, and instead be a FusekiMain with a command line object as a member.

I'd find it helpful to have a written description of the the flow is expected to be.

If we can make FusekiMain smaller with some clearly defined functionality in separate classes, then when there are several modules/customization they'll get what they are allowed to modifiy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ability to support custom arguments for Fuseki Servers
2 participants