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

Separating digdag-guice-rs-server from digdag-server #316

Merged
merged 8 commits into from Oct 3, 2016
Merged

Conversation

frsyuki
Copy link
Member

@frsyuki frsyuki commented Sep 29, 2016

Besides moving of code, there're some interface changes for isolation:

  • digdag-core: BackgroundExecutor interface (=threads that should shutdown before stopping HTTP handlers Graceful shutdown of HTTP server and worker threads #182) is changed to @PreStop annotation. Current code still has BackgroundExecutor interface that has only one method annotated with @PreStop to minimize change of code. Some refactoring may be necessary later.
  • digdag-server: ServerConfig interface extends UndertowServerConfig interface (nothing changed actually though)
  • digdag-core: DigdagEmbed.Bootstrap has a method to return org.embulk.guice.Bootstrap rather than Injector so that UndertowBootstrap can add modules before creating injector. I think that DigdagEmbed.Bootstrap should extend org.embulk.guice.Bootstrap but it's a refactoring that may happen later.
  • digdag-server: Writing ServerRuntimeInfo file is moved to a @PostStart handler (ServerRuntimeInfoWriter).
  • digdag-cli: cli.Sched and cli.Server create ServerBootstrap instance rather than passing ServerBootstrap.class. This is because UndertowServer takes an instance that implements new shared ServerBootstrap interface.

@frsyuki frsyuki changed the title [WIP] Separating digdag-guice-rs-server from digdag-server Separating digdag-guice-rs-server from digdag-server Sep 29, 2016
@frsyuki
Copy link
Member Author

frsyuki commented Sep 29, 2016

nice, worked. dependency conflicts were the last beast. According to ./gradlew classpath result, final dependencies are consistent excepting guice-bootstrap.

$ diff classpath.txt classpath-master.txt  -u
--- classpath.txt       2016-09-29 16:26:48.000000000 -0700
+++ classpath-master.txt        2016-09-29 16:27:00.000000000 -0700
@@ -19,19 +19,17 @@
 commons-io-2.1.jar
 commons-logging-1.2.jar
 cron4j-2.2.5.jar
-digdag-cli-0.8.16-SNAPSHOT.jar
-digdag-client-0.8.16-SNAPSHOT.jar
-digdag-core-0.8.16-SNAPSHOT.jar
-digdag-guice-rs-0.8.16-SNAPSHOT.jar
-digdag-guice-rs-server-0.8.16-SNAPSHOT.jar
-digdag-guice-rs-server-undertow-0.8.16-SNAPSHOT.jar
-digdag-plugin-utils-0.8.16-SNAPSHOT.jar
-digdag-server-0.8.16-SNAPSHOT.jar
-digdag-spi-0.8.16-SNAPSHOT.jar
-digdag-standards-0.8.16-SNAPSHOT.jar
+digdag-cli-0.8.17-SNAPSHOT.jar
+digdag-client-0.8.17-SNAPSHOT.jar
+digdag-core-0.8.17-SNAPSHOT.jar
+digdag-guice-rs-0.8.17-SNAPSHOT.jar
+digdag-plugin-utils-0.8.17-SNAPSHOT.jar
+digdag-server-0.8.17-SNAPSHOT.jar
+digdag-spi-0.8.17-SNAPSHOT.jar
+digdag-standards-0.8.17-SNAPSHOT.jar
 guava-19.0.jar
 guice-4.0.jar
-guice-bootstrap-0.2.1.jar
+guice-bootstrap-0.1.0.jar
 guice-multibindings-4.0.jar
 h2-1.4.192.jar
 hamcrest-core-1.1.jar

@danielnorberg are you comfortable to merge this? It might be better to separate digdag-guice-rs-* (and embulk guice-bootstrap) to another repository and make them stabilized in the future once digdag doesn't need frequent changes in them.

public RevisionAutoReloaderStarter(Config systemConfig, ProjectArchiveLoader projectLoader, ConfigFactory cf, RevisionAutoReloader autoReloader)
{
this.projectDirName = systemConfig.get(SYSTEM_CONFIG_AUTO_LOAD_LOCAL_PROJECT_KEY, String.class);
this.overwriteParams = cf.fromJsonString(systemConfig.get(SYSTEM_CONFIG_LOCAL_OVERWRITE_PARAMS, String.class));
Copy link
Contributor

Choose a reason for hiding this comment

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

s/overwrite/override

Copy link
Member Author

Choose a reason for hiding this comment

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

oh ok...overwriteParams is used a lot in digdag's code (especially digdag-cli but also some in digdag-core such as ProjectArchiveLoader).
should all of them be replaced?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably. But maybe that can be a different PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok. I'll do that in another PR.

compile 'org.embulk:guice-bootstrap:0.1.0'
compile 'com.fasterxml.jackson.module:jackson-module-guice:2.6.7'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.6.7'
// this dependency is here only to override dependency confliction of
Copy link
Contributor

Choose a reason for hiding this comment

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

s/confliction/conflict

Copy link
Member Author

@frsyuki frsyuki Sep 30, 2016

Choose a reason for hiding this comment

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

oops!

@@ -20,25 +21,33 @@
@JsonSerialize(as = ImmutableServerConfig.class)
@JsonDeserialize(as = ImmutableServerConfig.class)
public interface ServerConfig
extends UndertowServerConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the fact that digdag server uses undertow be part of the public interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that it's hard to abstract configuration parameters of different HTTP server implementations. Some of them are generic but not all of them. More control is more important than abstraction here in my opinion. Then if we change implementation from Undertow to something else, users will need to change config file anyways. So I think it is OK to expose "Undertow" here.
And more over, although ServerConfig is a public interface, it's not digdag-spi. In my understanding, digdag-server package is an implementation detail of digdag.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@danielnorberg
Copy link
Contributor

Remind me, what's the purpose of this PR? Is it just refactoring to improve design/code structure?

On a related note, how come we have such a bespoke http server setup instead of using something more standard like dropwizard?

@frsyuki
Copy link
Member Author

frsyuki commented Sep 30, 2016

This PR is code structure refactoring so that initialization code of Undertow becomes reusable.
Using this setup instead of Dropwizard, Spring boot, or full-stack Java EE including JPA is my preference for simplicity and better understanding of the entire behavior over abstracted magic.
Because I don't have much experience on web API development, having smaller number of external dependencies was also good to make working code as quick as possible. I took ideas from Presto because I'm familiar to its code much more. I still don't feel immediate needs for dignified frameworks honestly.

I think it is ok to separate digdag-server from digdag-cli. Then dependency issues will be smaller. Digdag's server code is based-on JAX-RS. So, migrating to Java EE frameworks seems possible although Spring boot seems more work to adopt. KumuluzEE, Dropwizard, Payara (Micro), Restlet, TomEE, etc.

@danielnorberg
Copy link
Contributor

danielnorberg commented Oct 3, 2016

What is the intended user of the undertow initialization code? Some other part of digdag or another project?

If the intent is for the undertow initialization code to become a library reusable by other projects, then perhaps it should be broken out into a separate project without the name digdag? That can be future work in a separate PR though.

I'm comfortable with merging this if you are. 👍

@frsyuki
Copy link
Member Author

frsyuki commented Oct 3, 2016

plazmadb-server is an user: https://github.com/treasure-data/plazmadb/pull/55

Having another repository is good but I'm expecting more changes. It's easier to test changes if code is in this repository. Once digdag doesn't need frequent changes, we can move them.

@frsyuki frsyuki merged commit 4f65bb8 into master Oct 3, 2016
@frsyuki frsyuki deleted the server-module branch October 3, 2016 22:29
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.

None yet

2 participants