public void mustBeOnline(final String tableId) throws ThriftTableOperationException { Tables.clearCache(instance); if (!Tables.getTableState(instance, tableId).equals(TableState.ONLINE)) throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online"); }
public static String getPrintableTableInfoFromName(Instance instance, String tableName) { String tableId = null; try { tableId = getTableId(instance, tableName); } catch (TableNotFoundException e) { // handled in the string formatting } return tableId == null ? String.format("%s(?)", tableName) : String.format("%s(ID:%s)", tableName, tableId); }
private void updateAuthorizationFailures(Map<KeyExtent,SecurityErrorCode> authorizationFailures) { if (authorizationFailures.size() > 0) { // was a table deleted? HashSet<String> tableIds = new HashSet<>(); for (KeyExtent ke : authorizationFailures.keySet()) tableIds.add(ke.getTableId()); Tables.clearCache(context.getInstance()); for (String tableId : tableIds) if (!Tables.exists(context.getInstance(), tableId)) throw new TableDeletedException(tableId); synchronized (this) { somethingFailed = true; mergeAuthorizationFailures(this.authorizationFailures, authorizationFailures); this.notifyAll(); } } }
protected String checkTableId(String tableName, TableOperation operation) throws ThriftTableOperationException { String tableId = Tables.getNameToIdMap(instance).get(tableName); if (tableId == null) { // maybe the table exist, but the cache was not updated yet... so try to clear the cache and check again Tables.clearCache(instance); tableId = Tables.getNameToIdMap(instance).get(tableName); if (tableId == null) throw new ThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.NOTFOUND, null); } return tableId; }
public static List<String> getTableIds(Instance instance, String namespaceId) throws NamespaceNotFoundException { String namespace = getNamespaceName(instance, namespaceId); List<String> names = new LinkedList<>(); for (Entry<String,String> nameToId : Tables.getNameToIdMap(instance).entrySet()) if (namespace.equals(Tables.qualify(nameToId.getKey()).getFirst())) names.add(nameToId.getValue()); return names; }
String tableId = Tables.getTableId(context.getInstance(), tableName); TabletLocator tl = TabletLocator.getLocator(context, tableId); if (!Tables.exists(context.getInstance(), tableId)) throw new TableDeletedException(tableId); if (Tables.getTableState(context.getInstance(), tableId) == TableState.OFFLINE) throw new TableOfflineException(context.getInstance(), tableId);
if (!Tables.exists(instance, tableId)) throw new TableDeletedException(tableId); else if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) throw new TableOfflineException(instance, tableId);
/** * Returns the current table state (ONLINE, OFFLINE,...) of named table. * * @param tableName * the table name * @return the current table state * @throws TableNotFoundException * if table does not exist */ private TableState getTableState(String tableName) throws TableNotFoundException { String tableId = Tables.getTableId(connector.getInstance(), tableName); TableState tstate = Tables.getTableState(connector.getInstance(), tableId); log.trace("tableName: '{}': tableId {}, current state: {}", tableName, tableId, tstate); return tstate; }
if (!Tables.exists(context.getInstance(), tableId)) throw new TableNotFoundException(tableId, tableName, null); else if (Tables.getTableState(context.getInstance(), tableId) == TableState.OFFLINE) throw new TableOfflineException(context.getInstance(), tableId); continue; continue; } catch (ThriftSecurityException e) { Tables.clearCache(context.getInstance()); if (!Tables.exists(context.getInstance(), tableId)) throw new TableNotFoundException(tableId, tableName, null); throw new AccumuloSecurityException(e.user, e.code, e);
String tableState = "unknown"; try { tableName = Tables.getTableName(instance, tableId); tableState = Tables.getTableState(instance, tableId).toString(); } catch (Exception ex) { log.warn(ex, ex);
public static TableState getTableState(Instance instance, String tableId) { return getTableState(instance, tableId, false); }
private static String getTableName(Instance instance, String tableId) { if (tableId == null) return " <unknown table> "; try { String tableName = Tables.getTableName(instance, tableId); return tableName + " (" + tableId + ")"; } catch (TableNotFoundException e) { return " <unknown table> (" + tableId + ")"; } }
static void checkTableDoesNotExist(Instance instance, String tableName, String tableId, TableOperation operation) throws AcceptableThriftTableOperationException { String id = Tables.getNameToIdMap(instance).get(tableName); if (id != null && !id.equals(tableId)) throw new AcceptableThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.EXISTS, null); }
String tableId = Tables.getTableId(context.getInstance(), tableName); throw ase; } catch (Exception e) { if (!Tables.exists(context.getInstance(), tableId)) { throw new TableNotFoundException(tableId, tableName, null);
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException, NamespaceNotFoundException, NamespaceExistsException { String old = cl.getArgs()[0]; String newer = cl.getArgs()[1]; boolean resetContext = false; String currentTableId = ""; if (!(shellState.getTableName() == null) && !shellState.getTableName().isEmpty()) { String namespaceId = Namespaces.getNamespaceId(shellState.getInstance(), old); List<String> tableIds = Namespaces.getTableIds(shellState.getInstance(), namespaceId); currentTableId = Tables.getTableId(shellState.getInstance(), shellState.getTableName()); resetContext = tableIds.contains(currentTableId); } shellState.getConnector().namespaceOperations().rename(old, newer); if (resetContext) { shellState.setTableName(Tables.getTableName(shellState.getInstance(), currentTableId)); } return 0; }
@Override public void undo(long tid, Master environment) throws Exception { TableManager.getInstance().removeTable(cloneInfo.tableId); if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) Utils.unreserveNamespace(cloneInfo.namespaceId, tid, false); Utils.unreserveTable(cloneInfo.tableId, tid, true); Tables.clearCache(environment.getInstance()); }
@Override public Collection<MergeInfo> merges() { List<MergeInfo> result = new ArrayList<MergeInfo>(); for (String tableId : Tables.getIdToNameMap(instance).keySet()) { result.add(getMergeInfo(new Text(tableId))); } return result; }
private String getNamespaceIdFromTableId(TableOperation tableOp, String tableId) throws ThriftTableOperationException { String namespaceId; try { namespaceId = Tables.getNamespaceId(instance, tableId); } catch (TableNotFoundException e) { throw new ThriftTableOperationException(tableId, null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; }
protected boolean tableExists(Instance instance, String tableId) { return Tables.exists(instance, tableId); }