You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2013/06/11 21:14:48 UTC
svn commit: r1491911 - in /accumulo/branches/1.5/core: ./
src/main/java/org/apache/accumulo/core/client/mock/
src/test/java/org/apache/accumulo/core/client/mock/
Author: vines
Date: Tue Jun 11 19:14:48 2013
New Revision: 1491911
URL: http://svn.apache.org/r1491911
Log:
ACCUMULO-1505 - merging Ryan Leary's patch, with modifications to update and remove warnings
Modified:
accumulo/branches/1.5/core/ (props changed)
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
Propchange: accumulo/branches/1.5/core/
------------------------------------------------------------------------------
Merged /accumulo/branches/1.4/src/core:r1491900
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java?rev=1491911&r1=1491910&r2=1491911&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockBatchWriter.java Tue Jun 11 19:14:48 2013
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.client.
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.util.ArgumentChecker;
public class MockBatchWriter implements BatchWriter {
@@ -32,11 +33,13 @@ public class MockBatchWriter implements
@Override
public void addMutation(Mutation m) throws MutationsRejectedException {
+ ArgumentChecker.notNull(m);
acu.addMutation(tablename, m);
}
@Override
public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException {
+ ArgumentChecker.notNull(iterable);
for (Mutation m : iterable) {
acu.addMutation(tablename, m);
}
Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java?rev=1491911&r1=1491910&r2=1491911&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java (original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java Tue Jun 11 19:14:48 2013
@@ -101,6 +101,8 @@ public class MockTable {
}
synchronized void addMutation(Mutation m) {
+ if (m.size() == 0)
+ throw new IllegalArgumentException("Can not add empty mutations");
long now = System.currentTimeMillis();
mutationCount++;
for (ColumnUpdate u : m.getUpdates()) {
Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java?rev=1491911&r1=1491910&r2=1491911&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java (original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/client/mock/MockConnectorTest.java Tue Jun 11 19:14:48 2013
@@ -20,9 +20,12 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
import java.util.Random;
import org.apache.accumulo.core.Constants;
@@ -46,6 +49,7 @@ import org.apache.accumulo.core.iterator
import org.apache.accumulo.core.iterators.user.SummingCombiner;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.hadoop.io.Text;
+import org.junit.Assert;
import org.junit.Test;
public class MockConnectorTest {
@@ -94,6 +98,43 @@ public class MockConnectorTest {
}
@Test
+ public void testBadMutations() throws Exception {
+ Connector c = new MockConnector("root", new MockInstance());
+ c.tableOperations().create("test");
+ BatchWriter bw = c.createBatchWriter("test", new BatchWriterConfig().setMaxMemory(10000L).setMaxLatency(1000L, TimeUnit.MILLISECONDS).setMaxWriteThreads(4));
+
+ try {
+ bw.addMutation(null);
+ Assert.fail("addMutation should throw IAE for null mutation");
+ } catch (IllegalArgumentException iae) {}
+ try {
+ bw.addMutations(null);
+ Assert.fail("addMutations should throw IAE for null iterable");
+ } catch (IllegalArgumentException iae) {}
+
+ bw.addMutations(Collections.<Mutation>emptyList());
+
+ Mutation bad = new Mutation("bad");
+ try {
+ bw.addMutation(bad);
+ Assert.fail("addMutation should throw IAE for empty mutation");
+ } catch (IllegalArgumentException iae) {}
+
+
+ Mutation good = new Mutation("good");
+ good.put(asText(random.nextInt()), asText(random.nextInt()), new Value("good".getBytes()));
+ List<Mutation> mutations = new ArrayList<Mutation>();
+ mutations.add(good);
+ mutations.add(bad);
+ try {
+ bw.addMutations(mutations);
+ Assert.fail("addMutations should throw IAE if it contains empty mutation");
+ } catch (IllegalArgumentException iae) {}
+
+ bw.close();
+ }
+
+ @Test
public void testAggregation() throws Exception {
MockInstance mockInstance = new MockInstance();
Connector c = mockInstance.getConnector("root", new PasswordToken(""));