/** * Look for namespace ID in ZK. Fail quietly by logging and returning null. */ public static Namespace.ID lookupNamespaceId(ClientContext context, String namespaceName) { Namespace.ID id = null; try { id = getNamespaceId(context, namespaceName); } catch (NamespaceNotFoundException e) { if (log.isDebugEnabled()) log.debug("Failed to find namespace ID from name: " + namespaceName, e); } return id; }
public CloneZookeeper(CloneInfo cloneInfo, ClientContext context) throws NamespaceNotFoundException { this.cloneInfo = cloneInfo; this.cloneInfo.namespaceId = Namespaces.getNamespaceId(context, Tables.qualify(this.cloneInfo.tableName).getFirst()); }
@Override public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException, NamespaceNotEmptyException { checkArgument(namespace != null, "namespace is null"); Namespace.ID namespaceId = Namespaces.getNamespaceId(context, namespace); if (namespaceId.equals(Namespace.ID.ACCUMULO) || namespaceId.equals(Namespace.ID.DEFAULT)) { Credentials credentials = context.getCredentials(); log.debug("{} attempted to delete the {} namespace", credentials.getPrincipal(), namespaceId); throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.UNSUPPORTED_OPERATION); } if (Namespaces.getTableIds(context, namespaceId).size() > 0) { throw new NamespaceNotEmptyException(namespaceId.canonicalID(), namespace, null); } List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(namespace.getBytes(UTF_8))); Map<String,String> opts = new HashMap<>(); try { doNamespaceFateOperation(FateOperation.NAMESPACE_DELETE, args, opts, namespace); } catch (NamespaceExistsException e) { // should not happen throw new AssertionError(e); } }
@Override public Map<String,String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException { Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(context, ns); } catch (NamespaceNotFoundException e) { String why = "Could not find namespace while getting configuration."; throw new ThriftTableOperationException(null, ns, null, TableOperationExceptionType.NAMESPACE_NOTFOUND, why); } AccumuloConfiguration config = context.getServerConfFactory() .getNamespaceConfiguration(namespaceId); return conf(credentials, config); }
Namespace.ID namespaceId = Namespaces.getNamespaceId(shellState.getContext(), cl.getOptionValue(optNamespace.getOpt())); tables.addAll(Namespaces.getTableNames(shellState.getContext(), namespaceId));
tableSet.add(cl.getOptionValue(optTableName.getOpt())); } else if (cl.hasOption(optNamespace.getOpt())) { Namespace.ID namespaceId = Namespaces.getNamespaceId(shellState.getContext(), cl.getOptionValue(optNamespace.getOpt())); for (Table.ID tableId : Namespaces.getTableIds(shellState.getContext(), namespaceId)) {
@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; Table.ID currentTableId = null; if (!(shellState.getTableName() == null) && !shellState.getTableName().isEmpty()) { Namespace.ID namespaceId = Namespaces.getNamespaceId(shellState.getContext(), old); List<Table.ID> tableIds = Namespaces.getTableIds(shellState.getContext(), namespaceId); currentTableId = Tables.getTableId(shellState.getContext(), shellState.getTableName()); resetContext = tableIds.contains(currentTableId); } shellState.getAccumuloClient().namespaceOperations().rename(old, newer); if (resetContext) { shellState.setTableName(Tables.getTableName(shellState.getContext(), currentTableId)); } return 0; }
@Override public Repo<Master> call(long tid, Master env) throws Exception { // reserve the table name in zookeeper or fail Utils.getTableNameLock().lock(); try { // write tableName & tableId to zookeeper Utils.checkTableDoesNotExist(env.getContext(), tableInfo.tableName, tableInfo.tableId, TableOperation.CREATE); String namespace = Tables.qualify(tableInfo.tableName).getFirst(); Namespace.ID namespaceId = Namespaces.getNamespaceId(env.getContext(), namespace); env.getTableManager().addTable(tableInfo.tableId, namespaceId, tableInfo.tableName, NodeExistsPolicy.OVERWRITE); Tables.clearCache(env.getContext()); } finally { Utils.getTableNameLock().unlock(); } for (Entry<String,String> entry : getExportedProps(env.getFileSystem()).entrySet()) if (!TablePropUtil.setTableProperty(env.getContext(), tableInfo.tableId, entry.getKey(), entry.getValue())) { throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER, "Invalid table property " + entry.getKey()); } return new CreateImportDir(tableInfo); }
.equals(Namespaces.getNamespaceId(master.getContext(), qualifiedNewTableName.getFirst()))) throw new AcceptableThriftTableOperationException(tableId.canonicalID(), oldTableName, TableOperation.RENAME, TableOperationExceptionType.INVALID_NAME,
protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception { boolean resetContext = false; String currentTable = shellState.getTableName(); Namespace.ID namespaceId = Namespaces.getNamespaceId(shellState.getContext(), namespace); List<String> tables = Namespaces.getTableNames(shellState.getContext(), namespaceId); resetContext = tables.contains(currentTable); if (force) for (String table : shellState.getAccumuloClient().tableOperations().list()) if (table.startsWith(namespace + ".")) shellState.getAccumuloClient().tableOperations().delete(table); shellState.getAccumuloClient().namespaceOperations().delete(namespace); if (resetContext) { shellState.setTableName(""); } }
namespaceId = Namespaces.getNamespaceId(master.getContext(), Tables.qualify(tableName).getFirst()); } catch (NamespaceNotFoundException e) { Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(master.getContext(), Tables.qualify(tableName).getFirst()); } catch (NamespaceNotFoundException e) { Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(master.getContext(), Tables.qualify(tableName).getFirst()); } catch (NamespaceNotFoundException e) {