} else { Namespace.ID namespaceId = Namespace.ID.of(new String(nId, UTF_8)); if (!namespaceId.equals(Namespace.ID.DEFAULT)) { try { namespaceName = namespaceIdToNameMap.get(namespaceId);
@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); } }
.equals(Namespaces.getNamespaceId(master.getContext(), qualifiedNewTableName.getFirst()))) throw new AcceptableThriftTableOperationException(tableId.canonicalID(), oldTableName, TableOperation.RENAME, TableOperationExceptionType.INVALID_NAME,
/** * Checks if a user has a namespace permission<br> * This cannot check if a system user has permission. * * @return true if a user exists and has permission; false otherwise */ protected boolean _hasNamespacePermission(String user, Namespace.ID namespace, NamespacePermission permission, boolean useCached) throws ThriftSecurityException { if (permission == null) return false; targetUserExists(user); if (namespace.equals(Namespace.ID.ACCUMULO) && permission.equals(NamespacePermission.READ)) return true; try { if (useCached) return permHandle.hasCachedNamespacePermission(user, namespace.canonicalID(), permission); return permHandle.hasNamespacePermission(user, namespace.canonicalID(), permission); } catch (NamespaceNotFoundException e) { throw new ThriftSecurityException(user, SecurityErrorCode.NAMESPACE_DOESNT_EXIST); } }
@Override public Repo<Master> call(long tid, Master environment) { // directories are intentionally not created.... this is done because directories should be // unique // because they occupy a different namespace than normal tablet directories... also some clones // may never create files.. therefore there is no need to consume namenode space w/ directories // that are not used... tablet will create directories as needed environment.getTableManager().transitionTableState(cloneInfo.tableId, TableState.ONLINE); Utils.unreserveNamespace(environment, cloneInfo.srcNamespaceId, tid, false); if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) Utils.unreserveNamespace(environment, cloneInfo.namespaceId, tid, false); Utils.unreserveTable(environment, cloneInfo.srcTableId, tid, false); Utils.unreserveTable(environment, cloneInfo.tableId, tid, true); environment.getEventCoordinator().event("Cloned table %s from %s", cloneInfo.tableName, cloneInfo.srcTableId); LoggerFactory.getLogger(FinishCloneTable.class).debug("Cloned table " + cloneInfo.srcTableId + " " + cloneInfo.tableId + " " + cloneInfo.tableName); return null; }
@Override public void getProperties(Map<String,String> props, Predicate<String> filter) { Predicate<String> parentFilter = filter; // exclude system iterators/constraints from the system namespace // so they don't affect the metadata or root tables. if (getNamespaceId().equals(Namespace.ID.ACCUMULO)) parentFilter = key -> isIteratorOrConstraint(key) ? false : filter.test(key); getPropCacheAccessor().getProperties(props, getPath(), filter, parent, parentFilter); }
@Override public void undo(long tid, Master environment) throws Exception { environment.getTableManager().removeTable(cloneInfo.tableId); if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) Utils.unreserveNamespace(environment, cloneInfo.namespaceId, tid, false); Utils.unreserveTable(environment, cloneInfo.tableId, tid, true); Tables.clearCache(environment.getContext()); }
@Override public long isReady(long tid, Master environment) throws Exception { long val = 0; if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) val += Utils.reserveNamespace(environment, cloneInfo.namespaceId, tid, false, true, TableOperation.CLONE); val += Utils.reserveTable(environment, cloneInfo.tableId, tid, true, false, TableOperation.CLONE); return val; }
public static void checkNamespaceDoesNotExist(ServerContext context, String namespace, Namespace.ID namespaceId, TableOperation operation) throws AcceptableThriftTableOperationException { Namespace.ID n = Namespaces.lookupNamespaceId(context, namespace); if (n != null && !n.equals(namespaceId)) throw new AcceptableThriftTableOperationException(null, namespace, operation, TableOperationExceptionType.NAMESPACE_EXISTS, null); }
@Override public String get(Property property) { String key = property.getKey(); AccumuloConfiguration getParent; if (!(namespaceId.equals(Namespace.ID.ACCUMULO) && isIteratorOrConstraint(key))) { getParent = parent; } else { // ignore iterators from parent if system namespace getParent = null; } return getPropCacheAccessor().get(property, getPath(), getParent); }