@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, IOException, ConstraintViolationException { shellState.checkTableState(); final Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET))); final Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET)); final Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET)); if (cl.hasOption(deleteOptAuths.getOpt())) { final ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(deleteOptAuths.getOpt())); if (cl.hasOption(timestampOpt.getOpt())) { m.putDelete(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt()))); } else { m.putDelete(colf, colq, le); } } else if (cl.hasOption(timestampOpt.getOpt())) { m.putDelete(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt()))); } else { m.putDelete(colf, colq); } final BatchWriter bw = shellState.getAccumuloClient().createBatchWriter( shellState.getTableName(), new BatchWriterConfig().setMaxMemory(Math.max(m.estimatedMemoryUsed(), 1024)) .setMaxWriteThreads(1).setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS)); bw.addMutation(m); bw.close(); return 0; }
@Override public void unsuspend(Collection<TabletLocationState> tablets) throws DistributedStoreException { BatchWriter writer = createBatchWriter(); try { for (TabletLocationState tls : tablets) { if (tls.suspend != null) { continue; } Mutation m = new Mutation(tls.extent.getMetadataEntry()); SuspendingTServer.clearSuspension(m); writer.addMutation(m); } } catch (Exception ex) { throw new DistributedStoreException(ex); } finally { try { writer.close(); } catch (MutationsRejectedException e) { throw new DistributedStoreException(e); } } }
BatchWriterConfig bwConfig = new BatchWriterConfig(); bwConfig.setMaxMemory(memoryInBytes); try { Mutation copy = new Mutation(orig.getRow()); for (ColumnUpdate update : orig.getUpdates()) { long timestamp; new ColumnVisibility(update.getColumnVisibility()), timestamp); } else { copy.put(update.getColumnFamily(), update.getColumnQualifier(), new ColumnVisibility(update.getColumnVisibility()), timestamp, update.getValue()); if (bw != null) { try { bw.close(); } catch (MutationsRejectedException e) { log.error("Could not apply mutations to {}", tableName);
public static void writeMutations(final Connector connector, final String tableName, final Collection<Mutation> mutations) throws TableNotFoundException, MutationsRejectedException { final BatchWriter bw = connector.createBatchWriter(tableName, 10000l, 10000l, 4); for(final Mutation mutation : mutations) { bw.addMutation(mutation); } bw.flush(); bw.close(); } }
@Override public void delete() throws MutationsRejectedException { BatchWriter bw = null; try { bw = new BatchWriterImpl(context, tableId, bwConfig); Iterator<Entry<Key,Value>> iter = super.iterator(); while (iter.hasNext()) { Entry<Key,Value> next = iter.next(); Key k = next.getKey(); Mutation m = new Mutation(k.getRow()); m.putDelete(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp()); bw.addMutation(m); } } finally { if (bw != null) bw.close(); } }
@Override public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException { BatchWriter writer = createBatchWriter(); try { for (Assignment assignment : assignments) { Mutation m = new Mutation(assignment.tablet.getMetadataEntry()); SuspendingTServer.clearSuspension(m); assignment.server.putFutureLocation(m); writer.addMutation(m); } } catch (Exception ex) { throw new DistributedStoreException(ex); } finally { try { writer.close(); } catch (MutationsRejectedException e) { throw new DistributedStoreException(e); } } }
Master.log.info("Removing entry {}", entry); BatchWriter bw = this.master.getContext().createBatchWriter(table, new BatchWriterConfig()); Mutation m = new Mutation(entry.getKey().getRow()); m.putDelete(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier()); bw.addMutation(m); bw.close(); return;
@Override public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException { BatchWriter writer = createBatchWriter(); try { for (Assignment assignment : assignments) { Mutation m = new Mutation(assignment.tablet.getMetadataEntry()); assignment.server.putLocation(m); assignment.server.clearFutureLocation(m); SuspendingTServer.clearSuspension(m); writer.addMutation(m); } } catch (Exception ex) { throw new DistributedStoreException(ex); } finally { try { writer.close(); } catch (MutationsRejectedException e) { throw new DistributedStoreException(e); } } }
shellState.checkTableState(); final Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET))); final Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET)); final Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET)); m.put(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val); else m.put(colf, colq, le, val); } else if (cl.hasOption(timestampOpt.getOpt())) m.put(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val); else m.put(colf, colq, val); final BatchWriterConfig cfg = new BatchWriterConfig() .setMaxMemory(Math.max(m.estimatedMemoryUsed(), 1024)).setMaxWriteThreads(1) .setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS); bw.addMutation(m); try { bw.close(); } catch (MutationsRejectedException e) { final ArrayList<String> lines = new ArrayList<>();
serializedRow.getKey().getRow(), entry.getKey(), entry.getValue()); Mutation replMutation = new Mutation(buffer); replBw.addMutation(replMutation); } catch (MutationsRejectedException e) { log.error("Error writing mutations to update replication Status" replBw.close(); } catch (MutationsRejectedException e) { log.error("Error writing mutations to update replication Status"
VolumeManager fs = master.getFileSystem(); mbw = master.getContext().createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); m = new Mutation(metadataRow); TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value(absolutePath.getBytes(UTF_8))); mbw.addMutation(m); m = new Mutation(metadataRow); TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value(absolutePath.getBytes(UTF_8))); m.put(key.getColumnFamily(), cq, val); mbw.addMutation(m); break; // its the last column in the last row mbw.close();
Mutation m = new Mutation(key.getRow()); + Path.SEPARATOR + ServerConstants.TABLE_DIR + Path.SEPARATOR + tableId + Path.SEPARATOR + directory; m.put(key.getColumnFamily(), key.getColumnQualifier(), new Value(newLocation.getBytes(UTF_8))); if (log.isTraceEnabled()) { log.trace("Replacing {} with {}", oldLocation, newLocation); writer.addMutation(m); pool.submit(() -> { try { count++; writer.close(); pool.shutdown(); while (!pool.isTerminated()) {
try { for (TabletLocationState tls : tablets) { Mutation m = new Mutation(tls.extent.getMetadataEntry()); if (tls.current != null) { tls.current.clearLocation(m); LogEntry entry = new LogEntry(tls.extent, 0, tls.current.hostPort(), log.toString()); m.put(entry.getColumnFamily(), entry.getColumnQualifier(), entry.getValue()); tls.future.clearFutureLocation(m); writer.addMutation(m); } finally { try { writer.close(); } catch (MutationsRejectedException e) { throw new DistributedStoreException(e);
AccumuloClient client = this.master.getContext(); bw = client.createBatchWriter(targetSystemTable, new BatchWriterConfig()); Scanner scanner = client.createScanner(targetSystemTable, Authorizations.EMPTY); scanner.setRange(scanRange); maxLogicalTime = TabletTime.maxMetadataTime(maxLogicalTime, value.toString()); } else if (TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.hasColumns(key)) { bw.addMutation(MetadataTableUtil.createDeleteMutation(master.getContext(), range.getTableId(), entry.getValue().toString())); bw.addMutation(m); Mutation updatePrevRow = stop.getPrevRowUpdateMutation(); Master.log.debug("Setting the prevRow for last tablet: {}", stop); bw.addMutation(updatePrevRow); bw.flush(); m = new Mutation(stopRow); if (bw != null) try { bw.close(); } catch (Exception ex) { throw new AccumuloException(ex);
BatchWriter bw = client.createBatchWriter(targetSystemTable, new BatchWriterConfig()); try { deleteTablets(info, deleteRange, bw, client); } finally { bw.close(); bw = client.createBatchWriter(targetSystemTable, new BatchWriterConfig()); try { Mutation m = new Mutation(followingTablet.getMetadataEntry()); TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, KeyExtent.encodePrevEndRow(extent.getPrevEndRow())); ChoppedColumnFamily.CHOPPED_COLUMN.putDelete(m); bw.addMutation(m); bw.flush(); } finally { bw.close();
private void fillTable(Connector conn, String table) throws Exception { BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); for (String row : ROWS) { Mutation m = new Mutation(row); m.put("cf", "cq", "value"); bw.addMutation(m); } bw.close(); } }
private void writeSomeData(Connector conn, String table, int rows, int cols) throws Exception { BatchWriter bw = conn.createBatchWriter(table, new BatchWriterConfig()); for (int row = 0; row < rows; row++) { Mutation m = new Mutation(Integer.toString(row)); for (int col = 0; col < cols; col++) { String value = Integer.toString(col); m.put(value, "", value); } bw.addMutation(m); } bw.close(); }
private static void update(Connector c, Mutation m) throws TableNotFoundException, MutationsRejectedException { BatchWriter bw = c.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); bw.addMutation(m); bw.close(); }
private void writeFlush(Connector conn, String tablename, String row) throws Exception { BatchWriter bw = conn.createBatchWriter(tablename, new BatchWriterConfig()); Mutation m = new Mutation(row); m.put("", "", ""); bw.addMutation(m); bw.close(); conn.tableOperations().flush(tablename, null, null, true); }
private void writeFile(Connector conn, String tableName) throws Exception { BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig()); Mutation m = new Mutation("row"); m.put("cf", "cq", "value"); bw.addMutation(m); bw.close(); conn.tableOperations().flush(tableName, null, null, true); }