You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by bi...@apache.org on 2012/01/09 16:29:36 UTC
svn commit: r1229205 - in /incubator/accumulo/branches/1.4/src/core/src:
main/java/org/apache/accumulo/core/client/admin/
main/java/org/apache/accumulo/core/client/mock/
test/java/org/apache/accumulo/core/client/admin/
test/java/org/apache/accumulo/cor...
Author: billie
Date: Mon Jan 9 15:29:35 2012
New Revision: 1229205
URL: http://svn.apache.org/viewvc?rev=1229205&view=rev
Log:
ACCUMULO-217 employed more TableNotFound / TableExists Exceptions in TableOperations
Added:
incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java (with props)
Modified:
incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java
incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java?rev=1229205&r1=1229204&r2=1229205&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java (original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java Mon Jan 9 15:29:35 2012
@@ -48,6 +48,8 @@ public abstract class TableOperationsHel
@Override
public void removeIterator(String tableName, String name, EnumSet<IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException,
TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(null, tableName, null);
Map<String,String> copy = new HashMap<String,String>();
for (Entry<String,String> property : this.getProperties(tableName)) {
copy.put(property.getKey(), property.getValue());
@@ -64,6 +66,8 @@ public abstract class TableOperationsHel
@Override
public IteratorSetting getIteratorSetting(String tableName, String name, IteratorScope scope) throws AccumuloSecurityException, AccumuloException,
TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(null, tableName, null);
int priority = -1;
String classname = null;
Map<String,String> settings = new HashMap<String,String>();
@@ -90,6 +94,8 @@ public abstract class TableOperationsHel
@Override
public Set<String> listIterators(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(null, tableName, null);
Set<String> result = new HashSet<String>();
Set<String> lifecycles = new HashSet<String>();
for (IteratorScope scope : IteratorScope.values())
@@ -107,6 +113,8 @@ public abstract class TableOperationsHel
@Override
public void checkIteratorConflicts(String tableName, IteratorSetting setting) throws AccumuloException, TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(null, tableName, null);
for (IteratorScope scope : setting.getScopes()) {
String scopeStr = String.format("%s%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase());
String nameStr = String.format("%s.%s", scopeStr, setting.getName());
Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java?rev=1229205&r1=1229204&r2=1229205&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java (original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java Mon Jan 9 15:29:35 2012
@@ -82,6 +82,8 @@ public class MockTableOperations extends
if (!tableName.matches(Constants.VALID_TABLE_NAME_REGEX)) {
throw new IllegalArgumentException();
}
+ if (exists(tableName))
+ throw new TableExistsException(tableName, tableName, "");
acu.createTable(username, tableName, versioningIter, timeType);
}
@@ -91,30 +93,42 @@ public class MockTableOperations extends
@Override
public void addAggregators(String tableName, List<? extends PerColumnIteratorConfig> aggregators) throws AccumuloSecurityException, TableNotFoundException,
AccumuloException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(tableName, tableName, "");
acu.addAggregators(tableName, aggregators);
}
@Override
- public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {}
+ public void addSplits(String tableName, SortedSet<Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
+ throw new NotImplementedException();
+ }
@Override
- public Collection<Text> getSplits(String tableName) {
+ public Collection<Text> getSplits(String tableName) throws TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(tableName, tableName, "");
return Collections.emptyList();
}
@Override
- public Collection<Text> getSplits(String tableName, int maxSplits) {
- return Collections.emptyList();
+ public Collection<Text> getSplits(String tableName, int maxSplits) throws TableNotFoundException {
+ return getSplits(tableName);
}
@Override
public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(tableName, tableName, "");
acu.tables.remove(tableName);
}
@Override
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException,
TableExistsException {
+ if (!exists(oldTableName))
+ throw new TableNotFoundException(oldTableName, oldTableName, "");
+ if (exists(newTableName))
+ throw new TableExistsException(newTableName, newTableName, "");
MockTable t = acu.tables.remove(oldTableName);
acu.tables.put(newTableName, t);
}
@@ -134,15 +148,19 @@ public class MockTableOperations extends
@Override
public Iterable<Entry<String,String>> getProperties(String tableName) throws TableNotFoundException {
+ if (!exists(tableName))
+ throw new TableNotFoundException(tableName, tableName, "");
return acu.tables.get(tableName).settings.entrySet();
}
@Override
- public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {}
+ public void setLocalityGroups(String tableName, Map<String,Set<Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+ throw new NotImplementedException();
+ }
@Override
public Map<String,Set<Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException {
- return null;
+ throw new NotImplementedException();
}
@Override
@@ -164,13 +182,17 @@ public class MockTableOperations extends
}
@Override
- public void offline(String tableName) throws AccumuloSecurityException, AccumuloException {}
+ public void offline(String tableName) throws AccumuloSecurityException, AccumuloException {
+ throw new NotImplementedException();
+ }
@Override
public void online(String tableName) throws AccumuloSecurityException, AccumuloException {}
@Override
- public void clearLocatorCache(String tableName) throws TableNotFoundException {}
+ public void clearLocatorCache(String tableName) throws TableNotFoundException {
+ throw new NotImplementedException();
+ }
@Override
public Map<String,String> tableIdMap() {
Modified: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java?rev=1229205&r1=1229204&r2=1229205&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java (original)
+++ incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java Mon Jan 9 15:29:35 2012
@@ -55,7 +55,7 @@ public class TableOperationsHelperTest {
@Override
public boolean exists(String tableName) {
- return false;
+ return true;
}
@Override
Added: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java?rev=1229205&view=auto
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java (added)
+++ incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java Mon Jan 9 15:29:35 2012
@@ -0,0 +1,85 @@
+/**
+ * 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.mock;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MockTableOperationsTest {
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testTableNotFound() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
+ Instance instance = new MockInstance("topstest");
+ Connector conn = instance.getConnector("user", "pass");
+ String t = "tableName";
+ try {
+ conn.tableOperations().addAggregators(t, null);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().attachIterator(t, null);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().checkIteratorConflicts(t, null);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().delete(t);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().getIteratorSetting(t, null, null);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().getProperties(t);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().getSplits(t);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().listIterators(t);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().removeIterator(t, null, null);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ try {
+ conn.tableOperations().rename(t, t);
+ Assert.fail();
+ } catch (TableNotFoundException e) {}
+ conn.tableOperations().create(t);
+ try {
+ conn.tableOperations().create(t);
+ Assert.fail();
+ } catch (TableExistsException e) {}
+ try {
+ conn.tableOperations().rename(t, t);
+ Assert.fail();
+ } catch (TableExistsException e) {}
+ }
+}
Propchange: incubator/accumulo/branches/1.4/src/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
------------------------------------------------------------------------------
svn:eol-style = native