incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1202316 - in /incubator/accumulo: branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/ branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/ branches/1.4/src/core/src/main/java/org/apache/accumulo/core/c...
Date Tue, 15 Nov 2011 17:18:53 GMT
Author: billie
Date: Tue Nov 15 17:18:52 2011
New Revision: 1202316

URL: http://svn.apache.org/viewvc?rev=1202316&view=rev
Log:
ACCUMULO-53 committed changes to trunk and 1.4 branch

Added:
    incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
    incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
    incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
    incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
Tue Nov 15 17:18:52 2011
@@ -33,17 +33,22 @@ public interface ScannerBase extends Ite
   /**
    * Add a server-side scan iterator.
    * 
-   * @param iteratorClass
-   *          the fully qualified class name of the iterator to be applied at scan time
-   * @param iteratorName
-   *          a nickname for the iterator
-   * @throws IOException
-   *           if an exception occurs reading from the iterator stack
+   * @param cfg
+   *          fully specified scan-time iterator, including all options for the iterator.
Any changes to the iterator setting after this call are not propagated
+   *          to the stored iterator.
    * 
    */
   public void addScanIterator(IteratorSetting cfg);
   
   /**
+   * Remove an iterator from the list of iterators
+   * 
+   * @param iteratorName
+   *          nickname used for the iterator
+   */
+  public void removeScanIterator(String iteratorName);
+  
+  /**
    * Update the options for an iterator. Note that this does <b>not</b> change
the iterator options during a scan, it just replaces the given option on a
    * configured iterator before a scan is started.
    * 

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
Tue Nov 15 17:18:52 2011
@@ -66,7 +66,7 @@ public class ScannerOptions implements S
     
     for (IterInfo ii : serverSideIteratorList)
       if (ii.iterName.equals(si.getName()))
-        throw new RuntimeException("Iterator name is already in use " + si.getName());
+        throw new IllegalArgumentException("Iterator name is already in use " + si.getName());
     
     serverSideIteratorList.add(new IterInfo(si.getPriority(), si.getIteratorClass(), si.getName()));
     
@@ -82,6 +82,23 @@ public class ScannerOptions implements S
     opts.putAll(si.getProperties());
   }
   
+  @Override
+  public synchronized void removeScanIterator(String iteratorName) {
+    ArgumentChecker.notNull(iteratorName);
+    // if no iterators are set, we don't have it, so it is already removed
+    if (serverSideIteratorList.size() == 0)
+      return;
+    
+    for (IterInfo ii : serverSideIteratorList) {
+      if (ii.iterName.equals(iteratorName)) {
+        serverSideIteratorList.remove(ii);
+        break;
+      }
+    }
+    
+    serverSideIteratorOptions.remove(iteratorName);
+  }
+  
   /**
    * @deprecated since 1.4, use {@link #addScanIterator(IteratorSetting)}
    */

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
Tue Nov 15 17:18:52 2011
@@ -51,6 +51,7 @@ public class TabletServerBatchDeleter ex
     this.maxMemory = maxMemory;
     this.maxLatency = maxLatency;
     this.maxWriteThreads = maxWriteThreads;
+    super.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, BatchDeleter.class.getName()
+ ".NOVALUE", SortedKeyIterator.class));
   }
   
   @Override
@@ -60,7 +61,6 @@ public class TabletServerBatchDeleter ex
   
   @Override
   public void delete() throws MutationsRejectedException, TableNotFoundException {
-    super.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, BatchDeleter.class.getName()
+ ".NOVALUE", SortedKeyIterator.class));
     BatchWriter bw = null;
     try {
       bw = new BatchWriterImpl(instance, credentials, tableId, maxMemory, maxLatency, maxWriteThreads);

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
Tue Nov 15 17:18:52 2011
@@ -26,7 +26,6 @@ public class MockBatchDeleter extends Mo
   
   private final MockAccumulo acc;
   private final String tableName;
-  private final Authorizations authorizations;
   
   /**
    * Create a {@link BatchDeleter} for the specified instance on the specified table where
the writer uses the specified {@link Authorizations}.
@@ -37,7 +36,6 @@ public class MockBatchDeleter extends Mo
    */
   public MockBatchDeleter(MockAccumulo acc, String tableName, Authorizations auths) {
     super(acc.tables.get(tableName), auths);
-    this.authorizations = auths;
     this.acc = acc;
     this.tableName = tableName;
   }
@@ -47,10 +45,6 @@ public class MockBatchDeleter extends Mo
     
     BatchWriter writer = new MockBatchWriter(acc, tableName);
     try {
-      // super.setScanIterators(Integer.MAX_VALUE,
-      // SortedKeyIterator.class.getName(), BatchDeleter.class.getName()
-      // + ".NOVALUE");
-      
       Iterator<Entry<Key,Value>> iter = super.iterator();
       while (iter.hasNext()) {
         Entry<Key,Value> next = iter.next();

Added: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java?rev=1202316&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
(added)
+++ incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
Tue Nov 15 17:18:52 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.core.client.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.iterators.WholeRowIterator;
+import org.junit.Test;
+
+/**
+ * Test that scanner options are set/unset correctly
+ */
+public class ScannerOptionsTest {
+  
+  /**
+   * Test that you properly add and remove iterators from a scanner
+   * 
+   * @throws Throwable
+   */
+  @Test
+  public void testAddRemoveIterator() throws Throwable {
+    ScannerOptions options = new ScannerOptions();
+    options.addScanIterator(new IteratorSetting(1, "NAME", WholeRowIterator.class));
+    assertEquals(1, options.serverSideIteratorList.size());
+    options.removeScanIterator("NAME");
+    assertEquals(0, options.serverSideIteratorList.size());
+  }
+}

Modified: incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
(original)
+++ incubator/accumulo/branches/1.4/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
Tue Nov 15 17:18:52 2011
@@ -109,4 +109,7 @@ public class NullScanner implements Scan
     return new NullKeyValueIterator();
   }
   
+  @Override
+  public void removeScanIterator(String iteratorName) {}
+  
 }

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
Tue Nov 15 17:18:52 2011
@@ -33,17 +33,22 @@ public interface ScannerBase extends Ite
   /**
    * Add a server-side scan iterator.
    * 
-   * @param iteratorClass
-   *          the fully qualified class name of the iterator to be applied at scan time
-   * @param iteratorName
-   *          a nickname for the iterator
-   * @throws IOException
-   *           if an exception occurs reading from the iterator stack
+   * @param cfg
+   *          fully specified scan-time iterator, including all options for the iterator.
Any changes to the iterator setting after this call are not propagated
+   *          to the stored iterator.
    * 
    */
   public void addScanIterator(IteratorSetting cfg);
   
   /**
+   * Remove an iterator from the list of iterators
+   * 
+   * @param iteratorName
+   *          nickname used for the iterator
+   */
+  public void removeScanIterator(String iteratorName);
+  
+  /**
    * Update the options for an iterator. Note that this does <b>not</b> change
the iterator options during a scan, it just replaces the given option on a
    * configured iterator before a scan is started.
    * 

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
Tue Nov 15 17:18:52 2011
@@ -66,7 +66,7 @@ public class ScannerOptions implements S
     
     for (IterInfo ii : serverSideIteratorList)
       if (ii.iterName.equals(si.getName()))
-        throw new RuntimeException("Iterator name is already in use " + si.getName());
+        throw new IllegalArgumentException("Iterator name is already in use " + si.getName());
     
     serverSideIteratorList.add(new IterInfo(si.getPriority(), si.getIteratorClass(), si.getName()));
     
@@ -82,6 +82,23 @@ public class ScannerOptions implements S
     opts.putAll(si.getProperties());
   }
   
+  @Override
+  public synchronized void removeScanIterator(String iteratorName) {
+    ArgumentChecker.notNull(iteratorName);
+    // if no iterators are set, we don't have it, so it is already removed
+    if (serverSideIteratorList.size() == 0)
+      return;
+    
+    for (IterInfo ii : serverSideIteratorList) {
+      if (ii.iterName.equals(iteratorName)) {
+        serverSideIteratorList.remove(ii);
+        break;
+      }
+    }
+    
+    serverSideIteratorOptions.remove(iteratorName);
+  }
+  
   /**
    * @deprecated since 1.4, use {@link #addScanIterator(IteratorSetting)}
    */

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java
Tue Nov 15 17:18:52 2011
@@ -51,6 +51,7 @@ public class TabletServerBatchDeleter ex
     this.maxMemory = maxMemory;
     this.maxLatency = maxLatency;
     this.maxWriteThreads = maxWriteThreads;
+    super.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, BatchDeleter.class.getName()
+ ".NOVALUE", SortedKeyIterator.class));
   }
   
   @Override
@@ -60,7 +61,6 @@ public class TabletServerBatchDeleter ex
   
   @Override
   public void delete() throws MutationsRejectedException, TableNotFoundException {
-    super.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, BatchDeleter.class.getName()
+ ".NOVALUE", SortedKeyIterator.class));
     BatchWriter bw = null;
     try {
       bw = new BatchWriterImpl(instance, credentials, tableId, maxMemory, maxLatency, maxWriteThreads);

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchDeleter.java
Tue Nov 15 17:18:52 2011
@@ -26,7 +26,6 @@ public class MockBatchDeleter extends Mo
   
   private final MockAccumulo acc;
   private final String tableName;
-  private final Authorizations authorizations;
   
   /**
    * Create a {@link BatchDeleter} for the specified instance on the specified table where
the writer uses the specified {@link Authorizations}.
@@ -37,7 +36,6 @@ public class MockBatchDeleter extends Mo
    */
   public MockBatchDeleter(MockAccumulo acc, String tableName, Authorizations auths) {
     super(acc.tables.get(tableName), auths);
-    this.authorizations = auths;
     this.acc = acc;
     this.tableName = tableName;
   }
@@ -47,10 +45,6 @@ public class MockBatchDeleter extends Mo
     
     BatchWriter writer = new MockBatchWriter(acc, tableName);
     try {
-      // super.setScanIterators(Integer.MAX_VALUE,
-      // SortedKeyIterator.class.getName(), BatchDeleter.class.getName()
-      // + ".NOVALUE");
-      
       Iterator<Entry<Key,Value>> iter = super.iterator();
       while (iter.hasNext()) {
         Entry<Key,Value> next = iter.next();

Added: incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java?rev=1202316&view=auto
==============================================================================
--- incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
(added)
+++ incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerOptionsTest.java
Tue Nov 15 17:18:52 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.core.client.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.iterators.WholeRowIterator;
+import org.junit.Test;
+
+/**
+ * Test that scanner options are set/unset correctly
+ */
+public class ScannerOptionsTest {
+  
+  /**
+   * Test that you properly add and remove iterators from a scanner
+   * 
+   * @throws Throwable
+   */
+  @Test
+  public void testAddRemoveIterator() throws Throwable {
+    ScannerOptions options = new ScannerOptions();
+    options.addScanIterator(new IteratorSetting(1, "NAME", WholeRowIterator.class));
+    assertEquals(1, options.serverSideIteratorList.size());
+    options.removeScanIterator("NAME");
+    assertEquals(0, options.serverSideIteratorList.size());
+  }
+}

Modified: incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java?rev=1202316&r1=1202315&r2=1202316&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
(original)
+++ incubator/accumulo/trunk/src/server/src/main/java/org/apache/accumulo/server/monitor/servlets/trace/NullScanner.java
Tue Nov 15 17:18:52 2011
@@ -109,4 +109,7 @@ public class NullScanner implements Scan
     return new NullKeyValueIterator();
   }
   
+  @Override
+  public void removeScanIterator(String iteratorName) {}
+  
 }



Mime
View raw message