You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@accumulo.apache.org by dlmarion <gi...@git.apache.org> on 2015/11/10 21:54:53 UTC
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
GitHub user dlmarion opened a pull request:
https://github.com/apache/accumulo/pull/51
ACCUMULO-3948: Add Scanner classloader context
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dlmarion/accumulo ACCUMULO-3948
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/accumulo/pull/51.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #51
----
commit 11ab556858b1360f0f100184cd9391e55ccfa03a
Author: Dave Marion <dl...@apache.org>
Date: 2015-11-10T20:52:20Z
ACCUMULO-3948: Add Scanner classloader context
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156185172
I think I found it, running the build now.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion closed the pull request at:
https://github.com/apache/accumulo/pull/51
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44563977
--- Diff: core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java ---
@@ -515,7 +540,7 @@ public void initialize(InputSplit inSplit, TaskAttemptContext attempt) throws IO
if (null == authorizations) {
authorizations = getScanAuthorizations(attempt);
}
-
+ String classLoaderContext = getContext(attempt);
--- End diff --
final
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44673982
--- Diff: core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java ---
@@ -484,7 +509,7 @@ public void initialize(InputSplit inSplit, JobConf job) throws IOException {
if (null == authorizations) {
authorizations = getScanAuthorizations(job);
}
-
+ String classLoaderContext = getContext(job);
--- End diff --
Well. yes? If the variable is treated as immutable, we should always mark it as such to avoid potential errors.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44656596
--- Diff: core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java ---
@@ -484,7 +509,7 @@ public void initialize(InputSplit inSplit, JobConf job) throws IOException {
if (null == authorizations) {
authorizations = getScanAuthorizations(job);
}
-
+ String classLoaderContext = getContext(job);
--- End diff --
None of the other variables in the method have the final modifier. Are you trying to raise the bar?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156189293
> Can you point me to some tests that I need to modify?
There is [ConditionalWriterIT][1]. Maybe could add a test where a conditional mutaton fails w/o a context and succeeds with it.
[1]: https://github.com/apache/accumulo/blob/0e136c1f4276373b09d1a2e4d901c0d16809e6db/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44563918
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,28 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
+ *
+ * @param context
+ * name of the classloader context
+ * @since 1.8.0
+ */
+ void setContext(String context);
--- End diff --
Might be better to use the full "classloadContext". "Context" on its own is kind of obtuse and could overlap with other things in the future.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44685558
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
That sounds great
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44563945
--- Diff: core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java ---
@@ -484,7 +509,7 @@ public void initialize(InputSplit inSplit, JobConf job) throws IOException {
if (null == authorizations) {
authorizations = getScanAuthorizations(job);
}
-
+ String classLoaderContext = getContext(job);
--- End diff --
final?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44980676
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,31 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * 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);
--- End diff --
There are at least two ways to do this check. Do it when setClassLoader is called. Or do it when the thrift calls startScan and continueScan are made. An exception could be added to these thrift calls. How were you thinking of doing the check?
For getting server side table props you can look into the implementation of `TableOperations.getProperties()`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44978179
--- Diff: shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java ---
@@ -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");
--- End diff --
Test added
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44684629
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
Fair enough, I'll add a reference
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565748
--- Diff: test/src/test/java/org/apache/accumulo/test/functional/ValueReversingIterator.java ---
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.accumulo.core.data.ByteSequence;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.IteratorEnvironment;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.commons.lang3.ArrayUtils;
+
+public class ValueReversingIterator implements SortedKeyValueIterator<Key,Value> {
--- End diff --
Please add some javadoc outlining why it exists and what it does.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565231
--- Diff: test/pom.xml ---
@@ -226,6 +226,25 @@
</systemPropertyVariables>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <phase>pre-integration-test</phase>
--- End diff --
Might be better to just bind this to test-compile to let `mvn test -Dtest=ScannerContextIT` still work. Creating the jar won't be too much of an impact, I guess.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565413
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
+
+ private static final String CONTEXT = ScannerContextIT.class.getSimpleName();
+ private static final String CONTEXT_PROPERTY = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + CONTEXT;
+ private static final String CONTEXT_DIR = "file:///tmp";
+ private static final String CONTEXT_CLASSPATH = CONTEXT_DIR + "/Test.jar";
+ private static int ITERATIONS = 10;
+
+ @Override
+ protected int defaultTimeoutSeconds() {
+ return 2 * 60;
+ }
+
+ @Before
+ public void checkCluster() {
+ Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+ MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
+ }
+
+ @Test
+ public void test() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path srcPath = new Path(System.getProperty("user.dir") + "/target/TestIterators-tests.jar");
+ Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
+ fs.copyFromLocalFile(srcPath, dstPath);
+ // Sleep to ensure jar change gets picked up
+ UtilWaitThread.sleep(5000);
--- End diff --
5s is not enough to work around commons vfs being busted. I think we've been having success with at least 7s in accumulo-start tests.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44685382
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
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);
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44494260
--- Diff: core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java ---
@@ -244,4 +247,20 @@ public void setBatchTimeout(long timeout, TimeUnit timeUnit) {
public long getBatchTimeout(TimeUnit timeUnit) {
return timeUnit.convert(batchTimeOut, TimeUnit.MILLISECONDS);
}
+
+ @Override
+ public void setContext(String context) {
+ this.context = context;
--- End diff --
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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44680325
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
Would be nice to add some text here pointing users to the Admin manual for more info. Don't 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`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44467796
--- Diff: core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java ---
@@ -244,4 +247,20 @@ public void setBatchTimeout(long timeout, TimeUnit timeUnit) {
public long getBatchTimeout(TimeUnit timeUnit) {
return timeUnit.convert(batchTimeOut, TimeUnit.MILLISECONDS);
}
+
+ @Override
+ public void setContext(String context) {
+ this.context = context;
--- End diff --
A Preconditions not null check would be nice here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44983646
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,31 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * 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);
--- End diff --
I was looking at adding a check in Scanner.setContext() impls to fail if the context was not defined. The scanner's do not have a handle to the connection to call the *Operation classes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44700016
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
Ditto! Very nice.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565318
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
+
+ private static final String CONTEXT = ScannerContextIT.class.getSimpleName();
+ private static final String CONTEXT_PROPERTY = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + CONTEXT;
+ private static final String CONTEXT_DIR = "file:///tmp";
+ private static final String CONTEXT_CLASSPATH = CONTEXT_DIR + "/Test.jar";
+ private static int ITERATIONS = 10;
+
+ @Override
+ protected int defaultTimeoutSeconds() {
+ return 2 * 60;
+ }
+
+ @Before
+ public void checkCluster() {
+ Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+ MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
+ }
+
+ @Test
+ public void test() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path srcPath = new Path(System.getProperty("user.dir") + "/target/TestIterators-tests.jar");
--- End diff --
Building this up with File or Path (with implicitly/explicit file separators) would be nicer.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156186156
Can you point me to some tests that I need to modify?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44959931
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
--- End diff --
I added this test in a commit today.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44968062
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,31 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * 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);
--- End diff --
Can I get the server side configuration inside a ScannerImpl or TabletServerBatchReader? I don't see how, and if I did, do we want the client to get the server side configuration?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156174661
Its possible to [set iterators on a Condition][2] for a [ConditionalMutation][1]. So [ConditionalWriterConfig][3] should probably have a `setClassLoaderContext(...)` method.
[1]: https://github.com/apache/accumulo/blob/1.6.4/core/src/main/java/org/apache/accumulo/core/data/ConditionalMutation.java
[2]: https://github.com/apache/accumulo/blob/1.6.4/core/src/main/java/org/apache/accumulo/core/data/Condition.java#L173
[3]: https://github.com/apache/accumulo/blob/1.6.4/core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-157463074
merged and pushed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44697803
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
--- End diff --
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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565658
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
+
+ private static final String CONTEXT = ScannerContextIT.class.getSimpleName();
+ private static final String CONTEXT_PROPERTY = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + CONTEXT;
+ private static final String CONTEXT_DIR = "file:///tmp";
+ private static final String CONTEXT_CLASSPATH = CONTEXT_DIR + "/Test.jar";
+ private static int ITERATIONS = 10;
+
+ @Override
+ protected int defaultTimeoutSeconds() {
+ return 2 * 60;
+ }
+
+ @Before
+ public void checkCluster() {
+ Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+ MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
+ }
+
+ @Test
+ public void test() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path srcPath = new Path(System.getProperty("user.dir") + "/target/TestIterators-tests.jar");
+ Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
+ fs.copyFromLocalFile(srcPath, dstPath);
+ // Sleep to ensure jar change gets picked up
+ UtilWaitThread.sleep(5000);
+
+ try {
+ Connector c = getConnector();
+ // Set the classloader context property on the table to point to the TestIterators jar file.
+ c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
+
+ // Insert rows with the word "Test" in the value.
+ String tableName = getUniqueNames(1)[0];
+ c.tableOperations().create(tableName);
+ BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
+ bw.close();
+ // Ensure that we can get the data back
+ scanCheck(c, tableName, null, null, "Test");
+ batchCheck(c, tableName, null, null, "Test");
+
+ // This iterator is in the TestIterators jar file
+ IteratorSetting cfg = new IteratorSetting(1, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
+
+ // Check that ValueReversingIterator is not already on the classpath by not setting the context. This should fail.
+ try {
+ scanCheck(c, tableName, cfg, null, "tseT");
+ fail("This should have failed because context was not set");
+ } catch (Exception e) {
+ // Do nothing, this should fail as the classloader context is not set.
+ }
+ try {
+ batchCheck(c, tableName, cfg, null, "tseT");
+ fail("This should have failed because context was not set");
+ } catch (Exception e) {
+ // Do nothing, this should fail as the classloader context is not set.
+ }
+
+ // Ensure that the value is reversed using the iterator config and classloader context
+ scanCheck(c, tableName, cfg, CONTEXT, "tseT");
+ batchCheck(c, tableName, cfg, CONTEXT, "tseT");
+ } finally {
+ // Delete file in tmp
+ fs.delete(dstPath, true);
+ }
+
+ }
+
+ @Test
+ public void testScanContextOverridesTableContext() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
--- End diff --
This is repeated. Do it once in a before?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44563809
--- Diff: core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java ---
@@ -151,6 +153,8 @@ public static boolean getBatchFromServer(ClientContext context, Range range, Key
TabletLocation prevLoc;
Long scanID;
+ String classLoaderContext;
--- End diff --
final?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44715330
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,31 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * 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);
--- End diff --
What happens when a user sets a context that does not exists? When this happens, does the exception have an informative message that makes it easy for the user to determine what happened? Is there a test for this case?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156182996
> 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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44564725
--- Diff: server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/ScanDataSource.java ---
@@ -178,8 +178,13 @@ public boolean isCurrent() {
VisibilityFilter visFilter = new VisibilityFilter(colFilter, options.getAuthorizations(), options.getDefaultLabels());
- return iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(IteratorScope.scan, visFilter, tablet.getExtent(), tablet.getTableConfiguration(),
- options.getSsiList(), options.getSsio(), iterEnv));
+ if (null == options.getContext()) {
--- End diff --
Why not push down null handling to `IteratorUtil.loadIterators`?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156177067
This is a code path that I am not familiar with.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44564137
--- Diff: core/src/main/java/org/apache/accumulo/core/iterators/IteratorUtil.java ---
@@ -235,10 +231,26 @@ public static String findIterator(IteratorScope scope, String className, Accumul
options.putAll(entry.getValue());
}
}
+ }
+ public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(IteratorScope scope,
+ SortedKeyValueIterator<K,V> source, KeyExtent extent, AccumuloConfiguration conf, List<IterInfo> ssiList, Map<String,Map<String,String>> ssio,
+ IteratorEnvironment env, boolean useAccumuloClassLoader) throws IOException {
+ List<IterInfo> iters = new ArrayList<IterInfo>(ssiList);
+ Map<String,Map<String,String>> allOptions = new HashMap<String,Map<String,String>>();
+ parseIteratorConfiguration(scope, iters, ssio, allOptions, conf);
return loadIterators(source, iters, allOptions, env, useAccumuloClassLoader, conf.get(Property.TABLE_CLASSPATH));
}
+ public static <K extends WritableComparable<?>,V extends Writable> SortedKeyValueIterator<K,V> loadIterators(IteratorScope scope,
+ SortedKeyValueIterator<K,V> source, KeyExtent extent, AccumuloConfiguration conf, List<IterInfo> ssiList, Map<String,Map<String,String>> ssio,
+ IteratorEnvironment env, boolean useAccumuloClassLoader, String context) throws IOException {
+ List<IterInfo> iters = new ArrayList<IterInfo>(ssiList);
--- End diff --
seems duplicative to the method with the same name above.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44681496
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44563758
--- Diff: core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java ---
@@ -244,4 +247,20 @@ public void setBatchTimeout(long timeout, TimeUnit timeUnit) {
public long getBatchTimeout(TimeUnit timeUnit) {
return timeUnit.convert(batchTimeOut, TimeUnit.MILLISECONDS);
}
+
+ @Override
+ public void setContext(String context) {
+ this.context = context;
--- End diff --
> 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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44697949
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java ---
@@ -133,4 +137,39 @@ public int getMaxWriteThreads() {
public Durability getDurability() {
return durability;
}
+
+ /**
+ * 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
+ */
+ public void setClassLoaderContext(String classLoaderContext) {
+ Preconditions.checkNotNull(classLoaderContext, "context name cannot be null");
+ this.classLoaderContext = classLoaderContext;
+ }
+
+ /**
+ * Clears the current classloader context set on this scanner
+ *
+ * @since 1.8.0
+ */
+ public void clearClassLoaderContext() {
--- End diff --
AFAICT this is not used in a test. A test that scans w/ a context, clears the context, and then scans again would be nice.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44488494
--- Diff: core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java ---
@@ -244,4 +247,20 @@ public void setBatchTimeout(long timeout, TimeUnit timeUnit) {
public long getBatchTimeout(TimeUnit timeUnit) {
return timeUnit.convert(batchTimeOut, TimeUnit.MILLISECONDS);
}
+
+ @Override
+ public void setContext(String context) {
+ this.context = context;
--- End diff --
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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565049
--- Diff: server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/ScanOptions.java ---
@@ -99,4 +101,12 @@ public SamplerConfigurationImpl getSamplerConfigurationImpl() {
public long getBatchTimeOut() {
return batchTimeOut;
}
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
--- End diff --
Is this actually used anywhere? Can we just make context final?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-157171973
Also, I added tickets 4054 and 4055 which are related to this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565565
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
+
+ private static final String CONTEXT = ScannerContextIT.class.getSimpleName();
+ private static final String CONTEXT_PROPERTY = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + CONTEXT;
+ private static final String CONTEXT_DIR = "file:///tmp";
+ private static final String CONTEXT_CLASSPATH = CONTEXT_DIR + "/Test.jar";
+ private static int ITERATIONS = 10;
+
+ @Override
+ protected int defaultTimeoutSeconds() {
+ return 2 * 60;
+ }
+
+ @Before
+ public void checkCluster() {
+ Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+ MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
+ }
+
+ @Test
+ public void test() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path srcPath = new Path(System.getProperty("user.dir") + "/target/TestIterators-tests.jar");
+ Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
+ fs.copyFromLocalFile(srcPath, dstPath);
+ // Sleep to ensure jar change gets picked up
+ UtilWaitThread.sleep(5000);
+
+ try {
+ Connector c = getConnector();
+ // Set the classloader context property on the table to point to the TestIterators jar file.
+ c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
+
+ // Insert rows with the word "Test" in the value.
+ String tableName = getUniqueNames(1)[0];
+ c.tableOperations().create(tableName);
+ BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
+ bw.close();
+ // Ensure that we can get the data back
+ scanCheck(c, tableName, null, null, "Test");
+ batchCheck(c, tableName, null, null, "Test");
+
+ // This iterator is in the TestIterators jar file
+ IteratorSetting cfg = new IteratorSetting(1, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
--- End diff --
Should follow best-practices and use a reasonable priority (e.g. > 20). Would also be better to reference the `ValueReversingIterator.class` for IDEs to automatically handle potential renames in the future.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44968497
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java ---
@@ -133,4 +137,39 @@ public int getMaxWriteThreads() {
public Durability getDurability() {
return durability;
}
+
+ /**
+ * 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
+ */
+ public void setClassLoaderContext(String classLoaderContext) {
+ Preconditions.checkNotNull(classLoaderContext, "context name cannot be null");
+ this.classLoaderContext = classLoaderContext;
+ }
+
+ /**
+ * Clears the current classloader context set on this scanner
+ *
+ * @since 1.8.0
+ */
+ public void clearClassLoaderContext() {
--- End diff --
Test added.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44680723
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
In addition to pointing users to admin manual, could also suggest looking at docs for relevant accumulo properties.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44564606
--- Diff: docs/src/main/asciidoc/chapters/administration.txt ---
@@ -344,6 +344,49 @@ very sensitive to an excessive number of nodes and the sizes of the nodes. Appli
which leverage the user of custom properties should take these warnings into
consideration. There is no enforcement of these warnings via the API.
+==== Configuring the ClassLoader
+
+Accumulo loads classes from the locations specified in the +general.classpaths+ property. Additionally, Accumulo will load classes
+from the locations specified in the +general.dynamic.classpaths+ property and will monitor and reload them if they change. The reloading
+feature is useful during the development and testing of iterators as new or modified iterator classes can be deployed to Accumulo without
+having to restart the database.
+
+Accumulo also has an alternate configuration for the classloader which will allow it to load classes from remote locations. This mechanism
+uses Apache Commons VFS which enables locations such as http and hdfs to be used. This alternate configuration also uses the
++general.classpaths+ property in the same manner described above. It differs in that you need to configure the
++general.vfs.classpaths+ property instead of the +general.dynamic.classpath+ property. As in the default configuration, this alternate
+configuration will also monitor the vfs locations for changes and reload if necessary.
+
+===== ClassLoader Contexts
+
+With the addition of the VFS based classloader, we introduced the notion of classloader contexts. A context is identified
+by a name and references a set of locations from which to load classes and can be specified in the accumulo-site.xml file or added
+using the +config+ command in the shell. Below is an example for specify the app1 context in the accumulo-site.xml file:
+
+[source,xml]
+<property>
+ <name>general.vfs.context.classpath.app1</name>
+ <value>hdfs://localhost:8020/applicationA/classpath/.*.jar,file:///opt/applicationA/lib/.*.jar</value>
+ <description>Application A classpath, loads jars from HDFS and local file system</description>
+</property>
+
+The default behavior follows the Java ClassLoader contract in that classes, if they exists, are loaded from the parent classloader first.
+You can override this behavior by delegating to the parent classloader after looking in this classloader first. An example of this
+configuration is:
+
+[source,xml]
+<property>
+ <name>general.vfs.context.classpath.app1.delegation=post</name>
+ <value>hdfs://localhost:8020/applicationA/classpath/.*.jar,file:///opt/applicationA/lib/.*.jar</value>
+ <description>Application A classpath, loads jars from HDFS and local file system</description>
+</property>
+
+To use contexts in your application you can set the +table.classpath.context+ on your tables or use the +setContext()+ method on Scanner
--- End diff --
What is the "context" that would be passed to `setContext(String)`?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44564232
--- Diff: core/src/main/thrift/tabletserver.thrift ---
@@ -90,6 +90,7 @@ struct ActiveScan {
12:map<string, map<string, string>> ssio /* Server Side Iterator Options */
13:list<binary> authorizations
14:optional i64 scanId
+ 15:string context
--- End diff --
I think classloaderContext would be better. A comment here would also be nice.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44713365
--- Diff: shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java ---
@@ -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");
--- End diff --
Could add a test for this option ShellServerIT
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44565693
--- Diff: test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java ---
@@ -0,0 +1,227 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.fate.util.UtilWaitThread;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ScannerContextIT extends AccumuloClusterHarness {
+
+ private static final String CONTEXT = ScannerContextIT.class.getSimpleName();
+ private static final String CONTEXT_PROPERTY = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + CONTEXT;
+ private static final String CONTEXT_DIR = "file:///tmp";
+ private static final String CONTEXT_CLASSPATH = CONTEXT_DIR + "/Test.jar";
+ private static int ITERATIONS = 10;
+
+ @Override
+ protected int defaultTimeoutSeconds() {
+ return 2 * 60;
+ }
+
+ @Before
+ public void checkCluster() {
+ Assume.assumeThat(getClusterType(), CoreMatchers.is(ClusterType.MINI));
+ MiniAccumuloClusterImpl mac = (MiniAccumuloClusterImpl) getCluster();
+ }
+
+ @Test
+ public void test() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path srcPath = new Path(System.getProperty("user.dir") + "/target/TestIterators-tests.jar");
+ Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
+ fs.copyFromLocalFile(srcPath, dstPath);
+ // Sleep to ensure jar change gets picked up
+ UtilWaitThread.sleep(5000);
+
+ try {
+ Connector c = getConnector();
+ // Set the classloader context property on the table to point to the TestIterators jar file.
+ c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
+
+ // Insert rows with the word "Test" in the value.
+ String tableName = getUniqueNames(1)[0];
+ c.tableOperations().create(tableName);
+ BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
+ bw.close();
+ // Ensure that we can get the data back
+ scanCheck(c, tableName, null, null, "Test");
+ batchCheck(c, tableName, null, null, "Test");
+
+ // This iterator is in the TestIterators jar file
+ IteratorSetting cfg = new IteratorSetting(1, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
+
+ // Check that ValueReversingIterator is not already on the classpath by not setting the context. This should fail.
+ try {
+ scanCheck(c, tableName, cfg, null, "tseT");
+ fail("This should have failed because context was not set");
+ } catch (Exception e) {
+ // Do nothing, this should fail as the classloader context is not set.
+ }
+ try {
+ batchCheck(c, tableName, cfg, null, "tseT");
+ fail("This should have failed because context was not set");
+ } catch (Exception e) {
+ // Do nothing, this should fail as the classloader context is not set.
+ }
+
+ // Ensure that the value is reversed using the iterator config and classloader context
+ scanCheck(c, tableName, cfg, CONTEXT, "tseT");
+ batchCheck(c, tableName, cfg, CONTEXT, "tseT");
+ } finally {
+ // Delete file in tmp
+ fs.delete(dstPath, true);
+ }
+
+ }
+
+ @Test
+ public void testScanContextOverridesTableContext() throws Exception {
+ // Copy the TestIterators jar to tmp
+ FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+ Path srcPath = new Path(System.getProperty("user.dir") + "/target/TestIterators-tests.jar");
+ Path dstPath = new Path(CONTEXT_DIR + "/Test.jar");
+ fs.copyFromLocalFile(srcPath, dstPath);
+ // Sleep to ensure jar change gets picked up
+ UtilWaitThread.sleep(5000);
+
+ try {
+ Connector c = getConnector();
+ // Create two contexts FOO and ScanContextIT. The FOO context will point to a classpath
+ // that contains nothing. The ScanContextIT context will point to the TestIterators.jar
+ String tableContext = "FOO";
+ String tableContextProperty = Property.VFS_CONTEXT_CLASSPATH_PROPERTY + tableContext;
+ String tableContextDir = "file:///tmp";
+ String tableContextClasspath = tableContextDir + "/TestFoo.jar";
+ // Define both contexts
+ c.instanceOperations().setProperty(tableContextProperty, tableContextClasspath);
+ c.instanceOperations().setProperty(CONTEXT_PROPERTY, CONTEXT_CLASSPATH);
+
+ String tableName = getUniqueNames(1)[0];
+ c.tableOperations().create(tableName);
+ // Set the FOO context on the table
+ c.tableOperations().setProperty(tableName, Property.TABLE_CLASSPATH.getKey(), tableContext);
+ BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
+ bw.close();
+ scanCheck(c, tableName, null, null, "Test");
+ batchCheck(c, tableName, null, null, "Test");
+ // This iterator is in the TestIterators jar file
+ IteratorSetting cfg = new IteratorSetting(1, "reverse", "org.apache.accumulo.test.functional.ValueReversingIterator");
--- End diff --
same as above.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44684903
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by joshelser <gi...@git.apache.org>.
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r45122930
--- Diff: test/pom.xml ---
@@ -226,6 +226,25 @@
</systemPropertyVariables>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ <phase>pre-integration-test</phase>
--- End diff --
Since this wasn't addressed in the review, I'll be opening a ticket about this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by dlmarion <gi...@git.apache.org>.
Github user dlmarion commented on the pull request:
https://github.com/apache/accumulo/pull/51#issuecomment-156155683
Rat checks in core are passing for me.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] accumulo pull request: ACCUMULO-3948: Add Scanner classloader cont...
Posted by keith-turner <gi...@git.apache.org>.
Github user keith-turner commented on a diff in the pull request:
https://github.com/apache/accumulo/pull/51#discussion_r44683793
--- Diff: core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java ---
@@ -242,4 +242,30 @@
* @since 1.8.0
*/
long getBatchTimeout(TimeUnit timeUnit);
+
+ /**
+ * Sets the name of the classloader context on this scanner
--- End diff --
> 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.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---