@Override public String next() { String tserver = iter.next(); try { instanceOps.ping(tserver); } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } return tserver + " OK"; }
private static int ping(ClientContext context, List<String> args) { InstanceOperations io = context.instanceOperations(); if (args.size() == 0) { args = io.getTabletServers(); } int unreachable = 0; for (String tserver : args) { try { io.ping(tserver); System.out.println(tserver + " OK"); } catch (AccumuloException ae) { System.out.println(tserver + " FAILED (" + ae.getMessage() + ")"); unreachable++; } } System.out.printf("\n%d of %d tablet servers unreachable\n\n", unreachable, args.size()); return unreachable; }
@Override public void createUser(String principal, AuthenticationToken token) throws AccumuloSecurityException { try { if (!(token instanceof PasswordToken)) throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN); PasswordToken pt = (PasswordToken) token; constructUser(principal, ZKSecurityTool.createPass(pt.getPassword())); } catch (KeeperException e) { if (e.code().equals(KeeperException.Code.NODEEXISTS)) throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_EXISTS, e); throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e); } }
@Override public void changePassword(String principal, AuthenticationToken token) throws AccumuloSecurityException { if (!(token instanceof PasswordToken)) throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN); PasswordToken pt = (PasswordToken) token; if (userExists(principal)) { try { synchronized (zooCache) { zooCache.clear(ZKUserPath + "/" + principal); context.getZooReaderWriter().putPrivatePersistentData(ZKUserPath + "/" + principal, ZKSecurityTool.createPass(pt.getPassword()), NodeExistsPolicy.OVERWRITE); } } catch (KeeperException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e); } } else // user doesn't exist throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST); }
} catch (AccumuloException e) { Shell.log .warn(e.getMessage() + " while setting visibility constraint, but table was created");
throw e; } catch (AccumuloException e) { error = "exception from tablet loc " + e.getMessage(); if (!error.equals(lastError)) log.debug("{}", error);
System.exit(rc); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); System.exit(1); } catch (AccumuloSecurityException e) {
@Override public String next() { String tserver = iter.next(); try { instanceOps.ping(tserver); } catch (AccumuloException e) { return tserver + " ERROR " + e.getMessage(); } return tserver + " OK"; }
@Override public void run() { HashSet<Path> uniqMapFiles = new HashSet<Path>(); for (List<PathSize> mapFiles : assignmentsPerTablet.values()) for (PathSize ps : mapFiles) uniqMapFiles.add(ps.path); log.debug("Assigning " + uniqMapFiles.size() + " map files to " + assignmentsPerTablet.size() + " tablets at " + location); try { List<KeyExtent> failures = assignMapFiles(credentials, location, assignmentsPerTablet); handleFailures(failures, "Not Serving Tablet"); } catch (AccumuloException e) { handleFailures(assignmentsPerTablet.keySet(), e.getMessage()); } catch (AccumuloSecurityException e) { handleFailures(assignmentsPerTablet.keySet(), e.getMessage()); } }
@Override public void run() { HashSet<Path> uniqMapFiles = new HashSet<>(); for (List<PathSize> mapFiles : assignmentsPerTablet.values()) for (PathSize ps : mapFiles) uniqMapFiles.add(ps.path); log.debug("Assigning " + uniqMapFiles.size() + " map files to " + assignmentsPerTablet.size() + " tablets at " + location); try { List<KeyExtent> failures = assignMapFiles(context, location, assignmentsPerTablet); handleFailures(failures, "Not Serving Tablet"); } catch (AccumuloException e) { handleFailures(assignmentsPerTablet.keySet(), e.getMessage()); } catch (AccumuloSecurityException e) { handleFailures(assignmentsPerTablet.keySet(), e.getMessage()); } }
private static int ping(ClientContext context, List<String> args) throws AccumuloException, AccumuloSecurityException { InstanceOperations io = context.getConnector().instanceOperations(); if (args.size() == 0) { args = io.getTabletServers(); } int unreachable = 0; for (String tserver : args) { try { io.ping(tserver); System.out.println(tserver + " OK"); } catch (AccumuloException ae) { System.out.println(tserver + " FAILED (" + ae.getMessage() + ")"); unreachable++; } } System.out.printf("\n%d of %d tablet servers unreachable\n\n", unreachable, args.size()); return unreachable; }
@Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { conn.tableOperations().offline(tableName, rand.nextBoolean()); log.debug("Offlined " + tableName); sleepUninterruptibly(rand.nextInt(200), TimeUnit.MILLISECONDS); conn.tableOperations().online(tableName, rand.nextBoolean()); log.debug("Onlined " + tableName); } catch (TableNotFoundException tne) { log.debug("offline or online failed " + tableName + ", doesnt exist"); } catch (AccumuloException ae) { if (ae.getMessage().startsWith("Unexpected table state")) { log.debug("offline or online failed " + tableName + ", unexpected table state"); } else { throw ae; } } } }
public static void update(Writer t, ZooLock zooLock, Mutation m) { if (zooLock != null) putLockID(zooLock, m); while (true) { try { t.update(m); return; } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); } catch (AccumuloSecurityException e) { log.error("{}", e.getMessage(), e); } catch (ConstraintViolationException e) { log.error("{}", e.getMessage(), e); // retrying when a CVE occurs is probably futile and can cause problems, see ACCUMULO-3096 throw new RuntimeException(e); } catch (TableNotFoundException e) { log.error("{}", e.getMessage(), e); } sleepUninterruptibly(1, TimeUnit.SECONDS); } }
@Override public void initializeSecurity(TCredentials credentials, String principal, byte[] token) throws AccumuloSecurityException { try { // remove old settings from zookeeper first, if any IZooReaderWriter zoo = ZooReaderWriter.getInstance(); synchronized (zooCache) { zooCache.clear(); if (zoo.exists(ZKUserPath)) { zoo.recursiveDelete(ZKUserPath, NodeMissingPolicy.SKIP); log.info("Removed " + ZKUserPath + "/" + " from zookeeper"); } // prep parent node of users with root username zoo.putPersistentData(ZKUserPath, principal.getBytes(UTF_8), NodeExistsPolicy.FAIL); constructUser(principal, ZKSecurityTool.createPass(token)); } } catch (KeeperException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } }
@Override public void dropAndDestroy() throws RyaDAOException { for (final String tableName : getTables()) { try { if (tableName != null) { drop(tableName); } } catch (final AccumuloSecurityException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final AccumuloException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final TableNotFoundException e) { logger.warn(e.getMessage()); } } destroy(); for(final AccumuloIndexer indexer : this.secondaryIndexers) { try { indexer.dropAndDestroy(); } catch(final Exception e) { logger.error("Failed to drop and destroy indexer", e); } } }
@Override public void createUser(String principal, AuthenticationToken token) throws AccumuloSecurityException { try { if (!(token instanceof PasswordToken)) throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN); PasswordToken pt = (PasswordToken) token; constructUser(principal, ZKSecurityTool.createPass(pt.getPassword())); } catch (KeeperException e) { if (e.code().equals(KeeperException.Code.NODEEXISTS)) throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_EXISTS, e); throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e); } }
@Override public void dropAndDestroy() throws RyaDAOException { for (final String tableName : getTables()) { try { if (tableName != null) { drop(tableName); } } catch (final AccumuloSecurityException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final AccumuloException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final TableNotFoundException e) { logger.warn(e.getMessage()); } } destroy(); for(final AccumuloIndexer indexer : this.secondaryIndexers) { try { indexer.dropAndDestroy(); } catch(final Exception e) { logger.error("Failed to drop and destroy indexer", e); } } }
@Override public void changePassword(String principal, AuthenticationToken token) throws AccumuloSecurityException { if (!(token instanceof PasswordToken)) throw new AccumuloSecurityException(principal, SecurityErrorCode.INVALID_TOKEN); PasswordToken pt = (PasswordToken) token; if (userExists(principal)) { try { synchronized (zooCache) { zooCache.clear(ZKUserPath + "/" + principal); ZooReaderWriter.getInstance().putPrivatePersistentData(ZKUserPath + "/" + principal, ZKSecurityTool.createPass(pt.getPassword()), NodeExistsPolicy.OVERWRITE); } } catch (KeeperException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.CONNECTION_ERROR, e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); throw new RuntimeException(e); } catch (AccumuloException e) { log.error("{}", e.getMessage(), e); throw new AccumuloSecurityException(principal, SecurityErrorCode.DEFAULT_SECURITY_ERROR, e); } } else // user doesn't exist throw new AccumuloSecurityException(principal, SecurityErrorCode.USER_DOESNT_EXIST); }
/** * This method completes the setup process and was redundant in all but of the tests. * * @param bucketsToUse * - the array of buckets to use */ private void completeSetup(Integer[] bucketsToUse) { try { deleteFile(fileName); aiad = new AccumuloIndexAgeDisplay(mockInstance, tableName, columns, userName, password, bucketsToUse); aiad.extractDataFromAccumulo(); aiad.logAgeSummary(); aiad.createAccumuloShellScript(fileName); } catch (AccumuloException ae) { log.error("Accumlo exception from our mock instance."); log.error(ae.getMessage()); } catch (AccumuloSecurityException ase) { log.error("Accumulo security exception from our mock instance"); log.error(ase.getMessage()); } }
/** * A test verifying the buckets are sorted in reverse order. */ @Test public void sortBucketsInReverseOrderTest() { Assert.assertNotNull(mockInstance); try { aiad = new AccumuloIndexAgeDisplay(mockInstance, tableName, columns, userName, password, new Integer[0]); aiad.setBuckets(null); Integer[] expected = {180, 90, 60, 30, 14, 7, 2}; Integer[] actual = aiad.getBuckets(); Assert.assertArrayEquals(expected, actual); Integer[] useExpectedWithTooSmallNumber = {1, 2, 3, 4, 5}; expected = new Integer[] {5, 4, 3, 2}; aiad.setBuckets(useExpectedWithTooSmallNumber); actual = aiad.getBuckets(); Assert.assertArrayEquals(expected, actual); } catch (AccumuloException ae) { log.error("Accumlo exception from our mock instance."); log.error(ae.getMessage()); } catch (AccumuloSecurityException ase) { log.error("Accumulo security exception from our mock instance"); log.error(ase.getMessage()); } }