use of org.apache.accumulo.core.data.Mutation in project accumulo by apache.
the class PluginIT method checkIterator.
@Test
public void checkIterator() throws IOException, AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
String tableName = "checkIterator";
connector.tableOperations().create(tableName);
BatchWriter bw = connector.createBatchWriter(tableName, new BatchWriterConfig());
Mutation m = new Mutation("ROW1");
m.put("allowed", "CQ1", "V1");
m.put("denied", "CQ2", "V2");
m.put("allowed", "CQ3", "V3");
bw.addMutation(m);
m = new Mutation("ROW2");
m.put("allowed", "CQ1", "V1");
m.put("denied", "CQ2", "V2");
m.put("allowed", "CQ3", "V3");
bw.addMutation(m);
bw.close();
// check filter
Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
IteratorSetting is = new IteratorSetting(5, CustomFilter.class);
scanner.addScanIterator(is);
int count = 0;
for (Entry<Key, Value> entry : scanner) {
count++;
assertEquals("allowed", entry.getKey().getColumnFamily().toString());
}
assertEquals(4, count);
// check filter negated
scanner.clearScanIterators();
CustomFilter.setNegate(is, true);
scanner.addScanIterator(is);
count = 0;
for (Entry<Key, Value> entry : scanner) {
count++;
assertEquals("denied", entry.getKey().getColumnFamily().toString());
}
assertEquals(2, count);
assertTrue(new File("target/accumulo-maven-plugin/" + instance.getInstanceName() + "/testCheckIteratorPassed").createNewFile());
}
use of org.apache.accumulo.core.data.Mutation in project accumulo by apache.
the class DeleterFormatter method next.
/**
* @return null, because the iteration will provide prompts and handle deletes internally.
*/
@Override
public String next() {
Entry<Key, Value> next = getScannerIterator().next();
Key key = next.getKey();
Mutation m = new Mutation(key.getRow());
String entryStr = formatEntry(next, isDoTimestamps());
boolean delete = force;
try {
if (!force) {
shellState.getReader().flush();
String line = shellState.getReader().readLine("Delete { " + entryStr + " } ? ");
more = line != null;
delete = line != null && (line.equalsIgnoreCase("y") || line.equalsIgnoreCase("yes"));
}
if (delete) {
m.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibility()), key.getTimestamp());
try {
writer.addMutation(m);
} catch (MutationsRejectedException e) {
log.error(e.toString());
if (Shell.isDebuggingEnabled())
for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) log.trace(cvs.toString());
}
}
shellState.getReader().print(String.format("[%s] %s%n", delete ? "DELETED" : "SKIPPED", entryStr));
} catch (IOException e) {
log.error("Cannot write to console", e);
throw new RuntimeException(e);
}
return null;
}
use of org.apache.accumulo.core.data.Mutation in project accumulo by apache.
the class SimpleGarbageCollector method putMarkerDeleteMutation.
private static void putMarkerDeleteMutation(final String delete, final BatchWriter writer) throws MutationsRejectedException {
Mutation m = new Mutation(MetadataSchema.DeletesSection.getRowPrefix() + delete);
m.putDelete(EMPTY_TEXT, EMPTY_TEXT);
writer.addMutation(m);
}
use of org.apache.accumulo.core.data.Mutation in project accumulo by apache.
the class CloseWriteAheadLogReferences method closeWal.
/**
* Write a closed {@link Status} mutation for the given {@link Key} using the provided {@link BatchWriter}
*
* @param bw
* BatchWriter
* @param k
* Key to create close mutation from
*/
protected void closeWal(BatchWriter bw, Key k) throws MutationsRejectedException {
log.debug("Closing unreferenced WAL ({}) in metadata table", k.toStringNoTruncate());
Mutation m = new Mutation(k.getRow());
m.put(k.getColumnFamily(), k.getColumnQualifier(), StatusUtil.fileClosedValue());
bw.addMutation(m);
}
use of org.apache.accumulo.core.data.Mutation in project accumulo by apache.
the class LogicalTimeTest method testSetUpdateTimes.
@Test
public void testSetUpdateTimes() {
List<Mutation> ms = new java.util.ArrayList<>();
ServerMutation m = createMock(ServerMutation.class);
ServerMutation m2 = createMock(ServerMutation.class);
m.setSystemTimestamp(1235L);
replay(m);
m2.setSystemTimestamp(1236L);
replay(m2);
ms.add(m);
ms.add(m2);
long currTime = ltime.setUpdateTimes(ms);
assertEquals(TIME + 2L, currTime);
verify(m);
verify(m2);
}
Aggregations