private void handleAccumuloException(AccumuloException e) throws org.apache.accumulo.proxy.thrift.TableNotFoundException, org.apache.accumulo.proxy.thrift.AccumuloException { if (e.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) e.getCause(); if (ttoe.type == TableOperationExceptionType.NOTFOUND) { throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(e.toString()); } } throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); }
@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().create(tableName); log.debug("Created table " + tableName); } catch (TableExistsException e) { log.debug("Create " + tableName + " failed, it exists"); } catch (AccumuloException e) { if (e.getCause() != null && e.getCause() instanceof NamespaceNotFoundException) log.debug("Create " + tableName + " failed, the namespace does not exist"); else throw e; } catch (IllegalArgumentException e) { log.debug("Create: " + e.toString()); } catch (AccumuloSecurityException e) { log.debug("Could not create table: " + e); } } }
log.debug("Clone: " + e.toString()); } catch (AccumuloException e) { Throwable cause = e.getCause(); if (cause != null && cause instanceof NamespaceNotFoundException) log.debug(
private void handleExceptionTNF(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException, TException { try { throw ex; } catch (AccumuloException e) { Throwable cause = e.getCause(); if (null != cause && TableNotFoundException.class.equals(cause.getClass())) { throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(cause.toString()); } handleAccumuloException(e); } catch (AccumuloSecurityException e) { handleAccumuloSecurityException(e); } catch (TableNotFoundException e) { throw new org.apache.accumulo.proxy.thrift.TableNotFoundException(ex.toString()); } catch (Exception e) { throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } }
private void handleExceptionNNF(Exception ex) throws org.apache.accumulo.proxy.thrift.AccumuloException, org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.NamespaceNotFoundException, TException { try { throw ex; } catch (AccumuloException e) { Throwable cause = e.getCause(); if (null != cause && NamespaceNotFoundException.class.equals(cause.getClass())) { throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(cause.toString()); } handleAccumuloException(e); } catch (AccumuloSecurityException e) { handleAccumuloSecurityException(e); } catch (NamespaceNotFoundException e) { throw new org.apache.accumulo.proxy.thrift.NamespaceNotFoundException(ex.toString()); } catch (Exception e) { throw new org.apache.accumulo.proxy.thrift.AccumuloException(e.toString()); } }
log.debug("Unable to change user permissions: " + ex.getCause()); } catch (AccumuloException ex) { Throwable cause = ex.getCause(); if (cause != null && cause instanceof ThriftTableOperationException) { ThriftTableOperationException toe = (ThriftTableOperationException) cause.getCause();
private void changeNamespaceSetting(RandomDataGenerator random, State state, Environment env, Properties props) throws Exception { // pick a random property int choice = random.nextInt(0, tableSettings.length - 1); Setting setting = tableSettings[choice]; // pick a random table SortedSet<String> namespaces = env.getConnector().namespaceOperations().list().tailSet("nspc") .headSet("nspd"); if (namespaces.isEmpty()) return; String namespace = random.nextSample(namespaces, 1)[0].toString(); // generate a random value long newValue = random.nextLong(setting.min, setting.max); state.set(LAST_NAMESPACE_SETTING, namespace + "," + choice); log.debug( "Setting " + setting.property.getKey() + " on namespace " + namespace + " to " + newValue); try { env.getConnector().namespaceOperations().setProperty(namespace, setting.property.getKey(), "" + newValue); } catch (AccumuloException ex) { if (ex.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause(); if (ttoe.type == TableOperationExceptionType.NAMESPACE_NOTFOUND) return; } throw ex; } }
private void changeTableSetting(RandomDataGenerator random, State state, Environment env, Properties props) throws Exception { // pick a random property int choice = random.nextInt(0, tableSettings.length - 1); Setting setting = tableSettings[choice]; // pick a random table SortedSet<String> tables = env.getConnector().tableOperations().list().tailSet("ctt") .headSet("ctu"); if (tables.isEmpty()) return; String table = random.nextSample(tables, 1)[0].toString(); // generate a random value long newValue = random.nextLong(setting.min, setting.max); state.set(LAST_TABLE_SETTING, table + "," + choice); log.debug("Setting " + setting.property.getKey() + " on table " + table + " to " + newValue); try { env.getConnector().tableOperations().setProperty(table, setting.property.getKey(), "" + newValue); } catch (AccumuloException ex) { if (ex.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause(); if (ttoe.type == TableOperationExceptionType.NOTFOUND) return; } throw ex; } }
break; } catch (AccumuloException e) { if (e.getCause() instanceof TableNotFoundException) { log.debug("Got TableNotFoundException, will retry"); Thread.sleep(200);
@Test public void createTableInMissingNamespace() throws Exception { String t = namespace + ".1"; assertFalse(c.namespaceOperations().exists(namespace)); assertFalse(c.tableOperations().exists(t)); try { c.tableOperations().create(t); fail(); } catch (AccumuloException e) { assertEquals(NamespaceNotFoundException.class.getName(), e.getCause().getClass().getName()); assertFalse(c.namespaceOperations().exists(namespace)); assertFalse(c.tableOperations().exists(t)); } }
property.getDefaultValue()); } catch (AccumuloException ex) { if (ex.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause(); if (ttoe.type == TableOperationExceptionType.NOTFOUND) return; property.getDefaultValue()); } catch (AccumuloException ex) { if (ex.getCause() instanceof ThriftTableOperationException) { ThriftTableOperationException ttoe = (ThriftTableOperationException) ex.getCause(); if (ttoe.type == TableOperationExceptionType.NAMESPACE_NOTFOUND) return;
fail(); } catch (AccumuloException e) { assertEquals(IllegalArgumentException.class.getName(), e.getCause().getClass().getName());
e.getCause().getClass().getName()); assertEquals(TableOperation.RENAME, ((ThriftTableOperationException) e.getCause()).getOp()); assertEquals(TableOperationExceptionType.INVALID_NAME, ((ThriftTableOperationException) e.getCause()).getType()); e.getCause().getClass().getName()); assertEquals(TableOperation.RENAME, ((ThriftTableOperationException) e.getCause()).getOp()); assertEquals(TableOperationExceptionType.INVALID_NAME, ((ThriftTableOperationException) e.getCause()).getType());
@Test public void testDeleteTable() throws Exception { String table = getUniqueNames(1)[0]; Connector conn = getConnector(); try { conn.createConditionalWriter(table, new ConditionalWriterConfig()); Assert.fail("Creating conditional writer for table that doesn't exist should fail"); } catch (TableNotFoundException e) {} conn.tableOperations().create(table); try ( ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) { conn.tableOperations().delete(table); ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq")); cm1.put("tx", "seq", "1"); cm1.put("data", "x", "a"); Result result = cw.write(cm1); try { Status status = result.getStatus(); Assert.fail("Expected exception writing conditional mutation to deleted table. Got status: " + status); } catch (AccumuloException ae) { Assert.assertEquals(TableDeletedException.class, ae.getCause().getClass()); } } }
@Test public void testOffline() throws Exception { String table = getUniqueNames(1)[0]; Connector conn = getConnector(); conn.tableOperations().create(table); try ( ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) { conn.tableOperations().offline(table, true); ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq")); cm1.put("tx", "seq", "1"); cm1.put("data", "x", "a"); Result result = cw.write(cm1); try { Status status = result.getStatus(); Assert.fail("Expected exception writing conditional mutation to offline table. Got status: " + status); } catch (AccumuloException ae) { Assert.assertEquals(TableOfflineException.class, ae.getCause().getClass()); } try { conn.createConditionalWriter(table, new ConditionalWriterConfig()); Assert.fail("Expected exception creating conditional writer to offline table"); } catch (TableOfflineException e) {} } }
fail(); } catch (AccumuloException e) { assertEquals(NamespaceNotFoundException.class.getName(), e.getCause().getClass().getName());