Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6EA419258 for ; Wed, 9 Jan 2013 16:32:17 +0000 (UTC) Received: (qmail 67152 invoked by uid 500); 9 Jan 2013 16:32:17 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 67119 invoked by uid 500); 9 Jan 2013 16:32:17 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 67105 invoked by uid 99); 9 Jan 2013 16:32:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jan 2013 16:32:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jan 2013 16:32:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5F25523889BB; Wed, 9 Jan 2013 16:31:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1430938 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/client/mock/ test/java/org/apache/accumulo/core/client/mock/ Date: Wed, 09 Jan 2013 16:31:53 -0000 To: commits@accumulo.apache.org From: ecn@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130109163153.5F25523889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ecn Date: Wed Jan 9 16:31:52 2013 New Revision: 1430938 URL: http://svn.apache.org/viewvc?rev=1430938&view=rev Log: ACCUMULO-843 implement deleteRows in MockAccumulo, fake locality groups, ignore merge requests Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java?rev=1430938&r1=1430937&r2=1430938&view=diff ============================================================================== --- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java (original) +++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java Wed Jan 9 16:31:52 2013 @@ -20,9 +20,11 @@ import java.util.Collection; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.Map.Entry; import java.util.SortedMap; import java.util.SortedSet; +import java.util.TreeMap; import java.util.TreeSet; import java.util.concurrent.ConcurrentSkipListMap; @@ -86,6 +88,7 @@ public class MockTable { Map> userPermissions = new HashMap>(); private TimeType timeType; SortedSet splits = new TreeSet(); + Map> localityGroups = new TreeMap>(); MockTable(boolean limitVersion, TimeType timeType) { this.timeType = timeType; @@ -122,4 +125,11 @@ public class MockTable { public Collection getSplits() { return splits; } + + public void setLocalityGroups(Map> groups) { + localityGroups = groups; + } + public Map> getLocalityGroups() { + return localityGroups; + } } Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java?rev=1430938&r1=1430937&r2=1430938&view=diff ============================================================================== --- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java (original) +++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java Wed Jan 9 16:31:52 2013 @@ -40,6 +40,7 @@ import org.apache.accumulo.core.client.a import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.data.PartialKey; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.file.FileOperations; @@ -155,17 +156,23 @@ public class MockTableOperations extends @Override public void setLocalityGroups(String tableName, Map> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); + acu.tables.get(tableName).setLocalityGroups(groups); } @Override public Map> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); + return acu.tables.get(tableName).getLocalityGroups(); } @Override public Set splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); return Collections.singleton(range); } @@ -262,15 +269,20 @@ public class MockTableOperations extends @Override public void offline(String tableName) throws AccumuloSecurityException, AccumuloException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new AccumuloException(tableName + " does not exists"); } @Override - public void online(String tableName) throws AccumuloSecurityException, AccumuloException {} + public void online(String tableName) throws AccumuloSecurityException, AccumuloException { + if (!exists(tableName)) + throw new AccumuloException(tableName + " does not exists"); + } @Override public void clearLocatorCache(String tableName) throws TableNotFoundException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); } @Override @@ -284,24 +296,31 @@ public class MockTableOperations extends @Override public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { - throw new NotImplementedException(); - } + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); +} @Override public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); + MockTable t = acu.tables.get(tableName); + Set keep = new TreeSet(t.table.tailMap(new Key(start)).headMap(new Key(end)).keySet()); + t.table.keySet().removeAll(keep); } @Override public void compact(String tableName, Text start, Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException, AccumuloException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); } @Override public void compact(String tableName, Text start, Text end, List iterators, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException, AccumuloException { - throw new NotImplementedException(); + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); } @Override @@ -312,8 +331,9 @@ public class MockTableOperations extends @Override public void flush(String tableName, Text start, Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { - throw new NotImplementedException(); - } + if (!exists(tableName)) + throw new TableNotFoundException(tableName, tableName, ""); + } @Override public Text getMaxRow(String tableName, Authorizations auths, Text startRow, boolean startInclusive, Text endRow, boolean endInclusive) Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java?rev=1430938&r1=1430937&r2=1430938&view=diff ============================================================================== --- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java (original) +++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java Wed Jan 9 16:31:52 2013 @@ -58,6 +58,7 @@ import org.apache.accumulo.core.util.Pai import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.Text; import org.junit.Assert; import org.junit.Test; @@ -249,7 +250,7 @@ public class MockTableOperationsTest { testFiles.importPath.toString(), testFiles.failurePath.toString(), false); } - + @Test(expected = IOException.class) public void testFailsWithNonEmptyFailureDirectory() throws Throwable { Instance instance = new MockInstance("foo"); @@ -264,4 +265,26 @@ public class MockTableOperationsTest { false); } + @Test + public void testDeleteRows() throws Exception { + Instance instance = new MockInstance("rows"); + Connector connector = instance.getConnector("user", "foo"); + TableOperations to = connector.tableOperations(); + to.create("test"); + BatchWriter bw = connector.createBatchWriter("test", new BatchWriterConfig()); + for (int r = 0; r < 20; r++) { + Mutation m = new Mutation("" + r); + for (int c = 0; c < 5; c++) { + m.put(new Text("cf"), new Text("" + c), new Value(("" + c).getBytes())); + } + bw.addMutation(m); + } + bw.flush(); + to.deleteRows("test", new Text("1"), new Text("2")); + Scanner s = connector.createScanner("test", Constants.NO_AUTHS); + for (Entry entry : s) { + Assert.assertTrue(entry.getKey().getRow().toString().charAt(0) != '1'); + } + } + }