jmark99 commented on a change in pull request #1771:
URL: https://github.com/apache/accumulo/pull/1771#discussion_r519931835
##########
File path:
shell/src/main/java/org/apache/accumulo/shell/commands/InsertCommand.java
##########
@@ -63,81 +64,96 @@ protected long getTimeout(final CommandLine cl) {
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));
- final Value val = new Value(cl.getArgs()[3].getBytes(Shell.CHARSET));
-
- if (cl.hasOption(insertOptAuths.getOpt())) {
- final ColumnVisibility le = new
ColumnVisibility(cl.getOptionValue(insertOptAuths.getOpt()));
- Shell.log.debug("Authorization label will be set to: {}", le);
-
- if (cl.hasOption(timestampOpt.getOpt()))
- 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);
- if (cl.hasOption(durabilityOption.getOpt())) {
- String userDurability = cl.getOptionValue(durabilityOption.getOpt());
- switch (userDurability) {
- case "sync":
- cfg.setDurability(Durability.SYNC);
- break;
- case "flush":
- cfg.setDurability(Durability.FLUSH);
- break;
- case "none":
- cfg.setDurability(Durability.NONE);
- break;
- case "log":
- cfg.setDurability(Durability.NONE);
- break;
- default:
- throw new IllegalArgumentException("Unknown durability: " +
userDurability);
- }
- }
- final BatchWriter bw =
-
shellState.getAccumuloClient().createBatchWriter(shellState.getTableName(),
cfg);
- bw.addMutation(m);
+ String initialTable = null;
try {
- bw.close();
- } catch (MutationsRejectedException e) {
- final ArrayList<String> lines = new ArrayList<>();
- if (!e.getSecurityErrorCodes().isEmpty()) {
- lines.add("\tAuthorization Failures:");
+ if (cl.hasOption(tableNameOption.getOpt())) {
+ initialTable = shellState.getTableName();
+ shellState.setTableName(cl.getOptionValue(tableNameOption.getOpt()));
Review comment:
Thanks for pointing that out @ctubbsii. I've updated the code to use a
temp variable and left the shellstate as is.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]