@Override public void close(TaskAttemptContext attempt) throws IOException, InterruptedException { log.debug("mutations written: " + mutCount + ", values written: " + valCount); if (simulate) return; try { mtbw.close(); } catch (MutationsRejectedException e) { if (e.getSecurityErrorCodes().size() >= 0) { HashMap<String,Set<SecurityErrorCode>> tables = new HashMap<>(); for (Entry<TabletId,Set<SecurityErrorCode>> ke : e.getSecurityErrorCodes().entrySet()) { String tableId = ke.getKey().getTableId().toString(); Set<SecurityErrorCode> secCodes = tables.get(tableId); if (secCodes == null) { secCodes = new HashSet<>(); tables.put(tableId, secCodes); } secCodes.addAll(ke.getValue()); } log.error("Not authorized to write to tables : " + tables); } if (e.getConstraintViolationSummaries().size() > 0) { log.error("Constraint violations : " + e.getConstraintViolationSummaries().size()); } throw new IOException(e); } finally { client.close(); } } }
@Override public Status update(String table, String key, Map<String, ByteIterator> values) { BatchWriter bw = null; try { bw = getWriter(table); } catch (TableNotFoundException e) { System.err.println("Error opening batch writer to Accumulo table " + table); e.printStackTrace(); return Status.ERROR; } Mutation mutInsert = new Mutation(key.getBytes(UTF_8)); for (Map.Entry<String, ByteIterator> entry : values.entrySet()) { mutInsert.put(colFamBytes, entry.getKey().getBytes(UTF_8), entry.getValue().toArray()); } try { bw.addMutation(mutInsert); } catch (MutationsRejectedException e) { System.err.println("Error performing update."); e.printStackTrace(); return Status.ERROR; } return Status.BATCHED_OK; }
private void checkForFailures() throws MutationsRejectedException { if (somethingFailed) { List<ConstraintViolationSummary> cvsList = violations.asList(); HashMap<TabletId,Set<org.apache.accumulo.core.client.security.SecurityErrorCode>> af = new HashMap<>(); for (Entry<KeyExtent,Set<SecurityErrorCode>> entry : authorizationFailures.entrySet()) { HashSet<org.apache.accumulo.core.client.security.SecurityErrorCode> codes = new HashSet<>(); for (SecurityErrorCode sce : entry.getValue()) { codes.add(org.apache.accumulo.core.client.security.SecurityErrorCode.valueOf(sce.name())); } af.put(new TabletIdImpl(entry.getKey()), codes); } throw new MutationsRejectedException(context, cvsList, af, serverSideErrors, unknownErrors, lastUnknownError); } }
@Override public boolean hasNext() { if (!getScannerIterator().hasNext() || !more) { try { writer.close(); } catch (MutationsRejectedException e) { log.error(e.toString()); if (Shell.isDebuggingEnabled()) for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) log.trace(cvs.toString()); } return false; } return true; }
} catch (MutationsRejectedException e) { final ArrayList<String> lines = new ArrayList<>(); if (!e.getSecurityErrorCodes().isEmpty()) { lines.add("\tAuthorization Failures:"); for (Entry<TabletId,Set<SecurityErrorCode>> entry : e.getSecurityErrorCodes().entrySet()) { lines.add("\t\t" + entry); if (!e.getConstraintViolationSummaries().isEmpty()) { lines.add("\tConstraint Failures:"); for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) { lines.add("\t\t" + cvs); if (lines.size() == 0 || e.getUnknownExceptions() > 0) { lines.add(" " + e.getClass().getName() + " : " + e.getMessage()); if (e.getCause() != null) lines.add(" Caused by : " + e.getCause().getClass().getName() + " : " + e.getCause().getMessage());
private void checkExceptions(List<MutationsRejectedException> mres) throws MutationsRejectedException { if (mres == null || mres.isEmpty()) { return; } List<ConstraintViolationSummary> cvsList = new LinkedList<ConstraintViolationSummary>(); HashMap<KeyExtent,Set<SecurityErrorCode>> map = new HashMap<KeyExtent,Set<SecurityErrorCode>>(); Collection<String> serverSideErrors = new LinkedList<String>(); int unknownErrors = 0; for (MutationsRejectedException mre : mres) { cvsList.addAll(mre.getConstraintViolationSummaries()); map.putAll(mre.getAuthorizationFailuresMap()); serverSideErrors.addAll(mre.getErrorServers()); unknownErrors += mre.getUnknownExceptions(); } throw new MutationsRejectedException(null, cvsList, map, serverSideErrors, unknownErrors, null); }
List<ConstraintViolationSummary> cvsl = mre.getConstraintViolationSummaries();
public void close(Reporter reporter) throws IOException { LOG.debug("mutations written: {}, values written: {}", this.mutCount, this.valCount); if(!this.simulate) { try { this.mtbw.close(); } catch (MutationsRejectedException var7) { if(var7.getAuthorizationFailuresMap().size() > 0) { Map tables = new HashMap(); Map.Entry ke; Object secCodes; for(Iterator itr = var7.getAuthorizationFailuresMap().entrySet().iterator(); itr.hasNext(); ((Set)secCodes).addAll((Collection)ke.getValue())) { ke = (Map.Entry)itr.next(); secCodes = (Set)tables.get(((KeyExtent)ke.getKey()).getTableId().toString()); if(secCodes == null) { secCodes = new HashSet(); tables.put(((KeyExtent)ke.getKey()).getTableId().toString(), secCodes); } } LOG.error("Not authorized to write to tables {}", tables); } if(var7.getConstraintViolationSummaries().size() > 0) { LOG.error("Constraint violations : {}", var7.getConstraintViolationSummaries().size()); } throw new IOException(var7); } } } }
mtbw.close(); } catch (MutationsRejectedException e) { if (e.getAuthorizationFailures().size() >= 0) { HashSet<String> tables = new HashSet<>(); for (KeyExtent ke : e.getAuthorizationFailures()) { tables.add(ke.getTableId().toString()); if (!e.getConstraintViolationSummaries().isEmpty()) { log.error("Constraint violations : " + e.getConstraintViolationSummaries().size());
@Override public void close() { try { if (batchWriter != null) { batchWriter.close(); batchWriter = null; } } catch (MutationsRejectedException e) { LOG.error(e.getMessage(), e); } } }
writer.close(); } catch (MutationsRejectedException e1) { if (e1.getSecurityErrorCodes().size() > 0) throw new AccumuloSecurityException(test_user_conn.whoami(), org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode.PERMISSION_DENIED,
try{ //... } catch (MutationsRejectedException e) { Throwable c = e.getCause(); if(c instanceof MyException){ //... }else{ throw e; } }
} catch (MutationsRejectedException e) { final ArrayList<String> lines = new ArrayList<>(); if (e.getSecurityErrorCodes().isEmpty() == false) { lines.add("\tAuthorization Failures:"); for (Entry<TabletId,Set<SecurityErrorCode>> entry : e.getSecurityErrorCodes().entrySet()) { lines.add("\t\t" + entry); if (e.getConstraintViolationSummaries().isEmpty() == false) { lines.add("\tConstraint Failures:"); for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) { lines.add("\t\t" + cvs.toString()); if (lines.size() == 0 || e.getUnknownExceptions() > 0) { lines.add(" " + e.getClass().getName() + " : " + e.getMessage()); if (e.getCause() != null) lines.add(" Caused by : " + e.getCause().getClass().getName() + " : " + e.getCause().getMessage());
writer.addMutation(m); } catch (MutationsRejectedException e) { log.error(e.toString()); if (Shell.isDebuggingEnabled()) for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) log.trace(cvs.toString());
List<ConstraintViolationSummary> cvsl = mre.getConstraintViolationSummaries();
writer.close(); } catch (MutationsRejectedException e) { authFailures = e.getAuthorizationFailuresMap(); cvs = e.getConstraintViolationSummaries();
bw.close(); } catch (MutationsRejectedException e) { if (e.getAuthorizationFailures().size() > 0) { HashSet<String> tables = new HashSet<String>(); for (KeyExtent ke : e.getAuthorizationFailures()) { tables.add(ke.getTableId().toString()); if (e.getConstraintViolationSummaries().size() > 0) { System.err.println("ERROR : Constraint violations occurred : " + e.getConstraintViolationSummaries());
@Override public void purge(final RdfCloudTripleStoreConfiguration configuration) { for (final String tableName : getTables()) { try { purge(tableName, configuration.getAuths()); compact(tableName); } catch (final TableNotFoundException e) { logger.error(e.getMessage()); } catch (final MutationsRejectedException e) { logger.error(e.getMessage()); } } for(final AccumuloIndexer indexer : this.secondaryIndexers) { try { indexer.purge(configuration); } catch(final Exception e) { logger.error("Failed to purge indexer", e); } } }
fail(); } catch (MutationsRejectedException e) { assertEquals(1, e.getSecurityErrorCodes().size()); assertEquals(1, e.getSecurityErrorCodes().entrySet().iterator().next().getValue().size()); switch (e.getSecurityErrorCodes().entrySet().iterator().next().getValue().iterator().next()) { case PERMISSION_DENIED: break;
log.debug("BatchWrite " + tableName + " failed, offline"); } catch (MutationsRejectedException mre) { if (mre.getCause() instanceof TableDeletedException) log.debug("BatchWrite " + tableName + " failed, table deleted"); else if (mre.getCause() instanceof TableOfflineException) log.debug("BatchWrite " + tableName + " failed, offline"); else