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

portable way to get the files to stage from current classloader #4514

Conversation

rmannibucau
Copy link
Contributor

follow up PR of #4497 to share the idea in a concrete way

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

…lassloader + ensuring the right classloader is used
Copy link
Member

@lukecwik lukecwik left a comment

Choose a reason for hiding this comment

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

As a heads up, most of the files we have use two spaces for indentation and not 4.

throw new IllegalArgumentException("Unsupported entry: " + url.toExternalForm());
}

private static String decode(String fileName) {
Copy link
Member

Choose a reason for hiding this comment

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

Use an implementation that already exists instead of re-implementing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anyone you are thinking about? Dont think we want xbean here (another shady dep)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From memory the rule was not 100% the same but can need to be checked, makes years now

public final class Classloaders {
private static final ClassLoader SYSTEM = ClassLoader.getSystemClassLoader();

public static Stream<File> toFiles(final ClassLoader classLoader) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

Lets hide all this logic and make it private within PipelineResources.

.map(Classloaders::toFile);
}

private static boolean isSystemParent(final ClassLoader classLoader) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: rename to isAncestorOfSystemClassLoader


/**
* Allows to configure how the staging files are selected.
* TODO: allow to select in parent classloaders as well as current one.
Copy link
Member

Choose a reason for hiding this comment

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

Add a comment around the order in which the filters are applied.

*/
@Description("Include regex for file staging.")
String getClassLoaderIncludeFilter();
void setClassLoaderIncludeFilter(String value);
Copy link
Member

Choose a reason for hiding this comment

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

Should we just accept a list to start since its likely people will want to be able to specify more then one include and exclude instead of writing a giant regex or filter?

* when staging the classloader.
* The regex is applied on the file name.
*/
@Description("Include regex for file staging.")
Copy link
Member

Choose a reason for hiding this comment

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

Be explicit in this description since this appears in the output of --help.
Ditto on the exclude filter.


/**
* Allows to configure how the staging files are selected.
* TODO: allow to select in parent classloaders as well as current one.
Copy link
Member

Choose a reason for hiding this comment

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

The TODO should really be in PipelineResources.


PipelineResources.detectClassPathResourcesToStage(classLoader);
})) {
assertEquals(0, PipelineResources.detectClassPathResourcesToStage(null, classLoader).size());
Copy link
Member

Choose a reason for hiding this comment

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

This should continue to throw, we don't want to silently ignore parts of the classpath we don't understand. Would rather make this limitation be explicit for users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont but this url is invalid and ignored by the classloader. We still fail if the url is not jar or file.

@lukecwik
Copy link
Member

I brought this discussion back to the dev@ to choose between PR/4497 or PR/4514 or support both.

@stale
Copy link

stale bot commented Jun 7, 2018

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 7, 2018
@stale
Copy link

stale bot commented Jun 14, 2018

This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@stale stale bot closed this Jun 14, 2018
@kennknowles kennknowles added stale and removed wontfix labels Jun 25, 2018
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.

3 participants