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

ACCUMULO-3948: Add Scanner classloader context #51

Closed
wants to merge 7 commits into from
Closed

ACCUMULO-3948: Add Scanner classloader context #51

wants to merge 7 commits into from

Conversation

dlmarion
Copy link
Contributor

No description provided.


@Override
public void setContext(String context) {
this.context = context;
Copy link
Contributor

Choose a reason for hiding this comment

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

A Preconditions not null check would be nice here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could, but it's not an error to pass null. The reference is initialized to null and is used successfully that way until it's set to something not null. Having said that, I don't really care one way or the other, just curious if we are forcing the user to use the api in a particular way.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking is there is no way to distinguish between a user accidentally passing null when they did not mean to and a user trying to clear the context. However if we do not accept null (users must call clearContext insead), then we can always detect the case where a user accidentally passes null and fail fast.

Copy link
Member

Choose a reason for hiding this comment

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

However if we do not accept null (users must call clearContext insead)

IMO, we either need to have clear javadoc on setContext about what a null context means or just fail on null. I'd prefer the latter since there's an explicit clearContext method. That gives us more flexibility in the future to hide behind the interface.

@dlmarion
Copy link
Contributor Author

Rat checks in core are passing for me.

@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);

/**
* Sets the name of the classloader context on this scanner
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to add some text here pointing users to the Admin manual for more info. Don't know of a way to link with a URL, but we could still say go look at section X in the admin manual for more info.

Copy link
Contributor

Choose a reason for hiding this comment

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

In addition to pointing users to admin manual, could also suggest looking at docs for relevant accumulo properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if the section number is added to the javadoc, who updates the javadoc in the future versions of the code when the manual changes? I would think that if you want to use the class loader context feature, then you have probably already read the section in the manual to understand how to configure it.

Copy link
Contributor

Choose a reason for hiding this comment

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

And if the section number is added to the javadoc, who updates the javadoc in the future versions of the code when the manual changes?

Thats a good point. We could be vauge about it and just say see the user manual for more information. Also since its not a URL, we can not run tools to check for bad links.

I would think that if you want to use the class loader context feature, then you have probably already read the section in the manual to understand how to configure it.

I think its reasonable to assume that someone will start using 1.8 w/o ever reading the user manual and notice this new method in an IDE. When they see the new method in the IDE, currently it would not have much javadocs. However there are nice docs elsewhere. It would be nice to make the user aware of those docs and help them find them. Personally I think helping guide the user in this case is better than doing nothing because of the valid concern that info pointed to may move.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, I'll add a reference

Copy link
Contributor

Choose a reason for hiding this comment

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

We could make the pointer a little more stable by using Accumulo version #. Like saying see section X in the 1.8.0 user manual.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to go with

  /**
   * Sets the name of the classloader context on this scanner. See
   * the administration chapter of the user manual for details on 
   * how to configure and use classloader contexts.
   *
   * @param classLoaderContext
   *          name of the classloader context
   * @throws NullPointerException
   *           if context is null
   * @since 1.8.0
   */
  void setClassLoaderContext(String classLoaderContext);

Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds great

Copy link
Member

Choose a reason for hiding this comment

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

Ditto! Very nice.

@keith-turner
Copy link
Contributor

Its possible to set iterators on a Condition for a ConditionalMutation. So ConditionalWriterConfig should probably have a setClassLoaderContext(...) method.

@dlmarion
Copy link
Contributor Author

This is a code path that I am not familiar with.

@keith-turner
Copy link
Contributor

This is a code path that I am not familiar with.

I can help with that if you like. I could do it as a follow in issue or a pull req to this pull req.

@dlmarion
Copy link
Contributor Author

I think I found it, running the build now.

@dlmarion
Copy link
Contributor Author

Can you point me to some tests that I need to modify?

@keith-turner
Copy link
Contributor

Can you point me to some tests that I need to modify?

There is ConditionalWriterIT. Maybe could add a test where a conditional mutaton fails w/o a context and succeeds with it.

import org.junit.Before;
import org.junit.Test;

public class ScannerContextIT extends AccumuloClusterHarness {
Copy link
Contributor

Choose a reason for hiding this comment

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

A test to ensure there is no interference might be nice. Something like the following situation.

  • Create scanner 1
  • Create scanner 2
  • Set context on scanner 1
  • verify scanner 1 scans w/ context
  • verify scanner 2 scans w/o any context.

Its not super important to have this test, it was just something I thought of. It think defends against odd leakage cases in the tablet server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this test in a commit today.

@@ -316,6 +323,7 @@ public Options getOptions() {
"time before scan should fail if no data is returned. If no unit is given assumes seconds. Units d,h,m,s,and ms are supported. e.g. 30s or 100ms");
outputFileOpt = new Option("o", "output", true, "local file to write the scan output to");
sampleOpt = new Option(null, "sample", false, "Show sample");
contextOpt = new Option("cc", "context", true, "name of the classloader context");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could add a test for this option ShellServerIT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test added

@dlmarion
Copy link
Contributor Author

Also, I added tickets 4054 and 4055 which are related to this.

@dlmarion
Copy link
Contributor Author

merged and pushed.

@dlmarion dlmarion closed this Nov 17, 2015
@dlmarion dlmarion deleted the ACCUMULO-3948 branch November 17, 2015 18:38
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

3 participants