@Override public long isReady(long tid, Master master) throws Exception { if (!Utils.getReadLock(master, bulkInfo.tableId, tid).tryLock()) return 100; if (master.onlineTabletServers().size() == 0) return 500; Tables.clearCache(master.getContext()); return Utils.reserveHdfsDirectory(master, bulkInfo.sourceDir, tid); }
private void updateAuthorizationFailures(Map<KeyExtent,SecurityErrorCode> authorizationFailures) { if (authorizationFailures.size() > 0) { // was a table deleted? HashSet<Table.ID> tableIds = new HashSet<>(); for (KeyExtent ke : authorizationFailures.keySet()) tableIds.add(ke.getTableId()); Tables.clearCache(context); for (Table.ID tableId : tableIds) if (!Tables.exists(context, tableId)) throw new TableDeletedException(tableId.canonicalID()); synchronized (this) { somethingFailed = true; mergeAuthorizationFailures(this.authorizationFailures, authorizationFailures); this.notifyAll(); } } }
public static Namespace.ID checkNamespaceId(ClientContext context, String namespaceName, TableOperation operation) throws ThriftTableOperationException { Namespace.ID namespaceId = Namespaces.lookupNamespaceId(context, namespaceName); if (namespaceId == null) { // maybe the namespace exists, but the cache was not updated yet... so try to clear the cache // and check again Tables.clearCache(context); namespaceId = Namespaces.lookupNamespaceId(context, namespaceName); if (namespaceId == null) throw new ThriftTableOperationException(null, namespaceName, operation, TableOperationExceptionType.NAMESPACE_NOTFOUND, null); } return namespaceId; }
private void checkOffline(ClientContext context) throws Exception { if (Tables.getTableState(context, tableInfo.tableID) != TableState.OFFLINE) { Tables.clearCache(context); if (Tables.getTableState(context, tableInfo.tableID) != TableState.OFFLINE) { throw new AcceptableThriftTableOperationException(tableInfo.tableID.canonicalID(), tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER, "Table is not offline"); } } }
public void mustBeOnline(final Table.ID tableId) throws ThriftTableOperationException { Tables.clearCache(context); if (!Tables.getTableState(context, tableId).equals(TableState.ONLINE)) throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online"); }
@Override public void undo(long tid, Master env) throws Exception { env.getTableManager().removeTable(tableInfo.tableId); Utils.unreserveTable(env, tableInfo.tableId, tid, true); Tables.clearCache(env.getContext()); } }
@Override public void undo(long tid, Master master) throws Exception { master.getTableManager().removeNamespace(namespaceInfo.namespaceId); Tables.clearCache(master.getContext()); Utils.unreserveNamespace(master, namespaceInfo.namespaceId, tid, true); }
/** * Lookup table ID in ZK. If not found, clears cache and tries again. */ public static Table.ID _getTableId(ClientContext context, String tableName) throws NamespaceNotFoundException, TableNotFoundException { Table.ID tableId = getNameToIdMap(context).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 clearCache(context); tableId = getNameToIdMap(context).get(tableName); if (tableId == null) { String namespace = qualify(tableName).getFirst(); if (Namespaces.getNameToIdMap(context).containsKey(namespace)) throw new TableNotFoundException(null, tableName, null); else throw new NamespaceNotFoundException(null, namespace, null); } } return tableId; }
@Override public Repo<Master> call(long tid, Master master) throws Exception { Utils.getTableNameLock().lock(); try { Utils.checkNamespaceDoesNotExist(master.getContext(), namespaceInfo.namespaceName, namespaceInfo.namespaceId, TableOperation.CREATE); TableManager.prepareNewNamespaceState(master.getContext().getZooReaderWriter(), master.getInstanceID(), namespaceInfo.namespaceId, namespaceInfo.namespaceName, NodeExistsPolicy.OVERWRITE); for (Entry<String,String> entry : namespaceInfo.props.entrySet()) NamespacePropUtil.setNamespaceProperty(master.getContext(), namespaceInfo.namespaceId, entry.getKey(), entry.getValue()); Tables.clearCache(master.getContext()); return new FinishCreateNamespace(namespaceInfo); } finally { Utils.getTableNameLock().unlock(); } }
@Override public Repo<Master> call(long tid, Master environment) throws Exception { Utils.getTableNameLock().lock(); try { // write tableName & tableId to zookeeper Utils.checkTableDoesNotExist(environment.getContext(), cloneInfo.tableName, cloneInfo.tableId, TableOperation.CLONE); environment.getTableManager().cloneTable(cloneInfo.srcTableId, cloneInfo.tableId, cloneInfo.tableName, cloneInfo.namespaceId, cloneInfo.propertiesToSet, cloneInfo.propertiesToExclude, NodeExistsPolicy.OVERWRITE); Tables.clearCache(environment.getContext()); return new CloneMetadata(cloneInfo); } finally { Utils.getTableNameLock().unlock(); } }
@Override public Repo<Master> call(long id, Master master) { // remove from zookeeper try { master.getTableManager().removeNamespace(namespaceId); } catch (Exception e) { log.error("Failed to find namespace in zookeeper", e); } Tables.clearCache(master.getContext()); // remove any permissions associated with this namespace try { AuditedSecurityOperation.getInstance(master.getContext()) .deleteNamespace(master.getContext().rpcCreds(), namespaceId); } catch (ThriftSecurityException e) { log.error("{}", e.getMessage(), e); } Utils.unreserveNamespace(master, namespaceId, id, true); log.debug("Deleted namespace " + namespaceId); return null; }
@Override public void undo(long tid, Master master) throws Exception { master.getTableManager().removeTable(tableInfo.getTableId()); Utils.unreserveTable(master, tableInfo.getTableId(), tid, true); Tables.clearCache(master.getContext()); }
@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()); }
Tables.clearCache(master.getContext()); } finally { Utils.getTableNameLock().unlock();
@Override public Repo<Master> call(long tid, Master master) throws Exception { // reserve the table name in zookeeper or fail Utils.getTableNameLock().lock(); try { // write tableName & tableId to zookeeper Utils.checkTableDoesNotExist(master.getContext(), tableInfo.getTableName(), tableInfo.getTableId(), TableOperation.CREATE); master.getTableManager().addTable(tableInfo.getTableId(), tableInfo.getNamespaceId(), tableInfo.getTableName(), NodeExistsPolicy.OVERWRITE); for (Entry<String,String> entry : tableInfo.props.entrySet()) TablePropUtil.setTableProperty(master.getContext(), tableInfo.getTableId(), entry.getKey(), entry.getValue()); Tables.clearCache(master.getContext()); return new ChooseDir(tableInfo); } finally { Utils.getTableNameLock().unlock(); } }
@Override public long isReady(long tid, Master master) throws Exception { if (!Utils.getReadLock(master, tableId, tid).tryLock()) return 100; Tables.clearCache(master.getContext()); if (Tables.getTableState(master.getContext(), tableId) == TableState.ONLINE) { long reserve1, reserve2; reserve1 = reserve2 = Utils.reserveHdfsDirectory(master, sourceDir, tid); if (reserve1 == 0) reserve2 = Utils.reserveHdfsDirectory(master, errorDir, tid); return reserve2; } else { throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, TableOperationExceptionType.OFFLINE, null); } }
@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); }
Tables.clearCache(master.getContext()); } finally { Utils.getTableNameLock().unlock();
Tables.clearCache(master.getContext()); if (tabletCount == 0 && !Tables.exists(master.getContext(), tableId)) throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null,
throw new AccumuloException(e.getMessage(), e); } finally { Tables.clearCache(context);