http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java index 981c81a..0c378d4 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java +++ b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java @@ -37,7 +37,9 @@ import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.CompactionStrategyConfig; import org.apache.accumulo.core.client.admin.TimeType; import org.apache.accumulo.core.client.impl.CompactionStrategyConfigUtil; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.TableOperationsImpl; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode; @@ -103,7 +105,7 @@ class FateServiceHandler implements FateService.Iface { TableOperation tableOp = TableOperation.CREATE; String namespace = validateNamespaceArgument(arguments.get(0), tableOp, null); - if (!master.security.canCreateNamespace(c, namespace)) + if (!master.security.canCreateNamespace(c)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); master.fate.seedTransaction(opid, new TraceRepo<>(new CreateNamespace(c.getPrincipal(), namespace, options)), autoCleanup); @@ -114,7 +116,7 @@ class FateServiceHandler implements FateService.Iface { String oldName = validateNamespaceArgument(arguments.get(0), tableOp, Namespaces.NOT_DEFAULT.and(Namespaces.NOT_ACCUMULO)); String newName = validateNamespaceArgument(arguments.get(1), tableOp, null); - String namespaceId = ClientServiceHandler.checkNamespaceId(master.getInstance(), oldName, tableOp); + Namespace.ID namespaceId = ClientServiceHandler.checkNamespaceId(master.getInstance(), oldName, tableOp); if (!master.security.canRenameNamespace(c, namespaceId, oldName, newName)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); @@ -125,7 +127,7 @@ class FateServiceHandler implements FateService.Iface { TableOperation tableOp = TableOperation.DELETE; String namespace = validateNamespaceArgument(arguments.get(0), tableOp, Namespaces.NOT_DEFAULT.and(Namespaces.NOT_ACCUMULO)); - String namespaceId = ClientServiceHandler.checkNamespaceId(master.getInstance(), namespace, tableOp); + Namespace.ID namespaceId = ClientServiceHandler.checkNamespaceId(master.getInstance(), namespace, tableOp); if (!master.security.canDeleteNamespace(c, namespaceId)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); @@ -137,7 +139,7 @@ class FateServiceHandler implements FateService.Iface { String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); TimeType timeType = TimeType.valueOf(ByteBufferUtil.toString(arguments.get(1))); - String namespaceId; + Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(master.getInstance(), Tables.qualify(tableName).getFirst()); @@ -171,8 +173,8 @@ class FateServiceHandler implements FateService.Iface { }); - String tableId = ClientServiceHandler.checkTableId(master.getInstance(), oldTableName, tableOp); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), oldTableName, tableOp); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canRename; try { @@ -195,9 +197,9 @@ class FateServiceHandler implements FateService.Iface { } case TABLE_CLONE: { TableOperation tableOp = TableOperation.CLONE; - String srcTableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID); + Table.ID srcTableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID); String tableName = validateTableNameArgument(arguments.get(1), tableOp, NOT_SYSTEM); - String namespaceId; + Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(master.getInstance(), Tables.qualify(tableName).getFirst()); } catch (NamespaceNotFoundException e) { @@ -242,8 +244,8 @@ class FateServiceHandler implements FateService.Iface { TableOperation tableOp = TableOperation.DELETE; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); - final String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + final Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canDeleteTable; try { @@ -260,8 +262,8 @@ class FateServiceHandler implements FateService.Iface { } case TABLE_ONLINE: { TableOperation tableOp = TableOperation.ONLINE; - final String tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + final Table.ID tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canOnlineOfflineTable; try { @@ -279,8 +281,8 @@ class FateServiceHandler implements FateService.Iface { } case TABLE_OFFLINE: { TableOperation tableOp = TableOperation.OFFLINE; - final String tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + final Table.ID tableId = validateTableIdArgument(arguments.get(0), tableOp, NOT_ROOT_ID); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canOnlineOfflineTable; try { @@ -302,8 +304,8 @@ class FateServiceHandler implements FateService.Iface { Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); - final String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + final Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canMerge; try { @@ -326,8 +328,8 @@ class FateServiceHandler implements FateService.Iface { Text startRow = ByteBufferUtil.toText(arguments.get(1)); Text endRow = ByteBufferUtil.toText(arguments.get(2)); - final String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + final Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canDeleteRange; try { @@ -350,8 +352,8 @@ class FateServiceHandler implements FateService.Iface { String failDir = ByteBufferUtil.toString(arguments.get(2)); boolean setTime = Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(3))); - final String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + final Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canBulkImport; try { @@ -370,12 +372,12 @@ class FateServiceHandler implements FateService.Iface { } case TABLE_COMPACT: { TableOperation tableOp = TableOperation.COMPACT; - String tableId = validateTableIdArgument(arguments.get(0), tableOp, null); + Table.ID tableId = validateTableIdArgument(arguments.get(0), tableOp, null); byte[] startRow = ByteBufferUtil.toBytes(arguments.get(1)); byte[] endRow = ByteBufferUtil.toBytes(arguments.get(2)); List<IteratorSetting> iterators = IteratorUtil.decodeIteratorSettings(ByteBufferUtil.toBytes(arguments.get(3))); CompactionStrategyConfig compactionStrategy = CompactionStrategyConfigUtil.decode(ByteBufferUtil.toBytes(arguments.get(4))); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canCompact; try { @@ -394,8 +396,8 @@ class FateServiceHandler implements FateService.Iface { } case TABLE_CANCEL_COMPACT: { TableOperation tableOp = TableOperation.COMPACT_CANCEL; - String tableId = validateTableIdArgument(arguments.get(0), tableOp, null); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + Table.ID tableId = validateTableIdArgument(arguments.get(0), tableOp, null); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canCancelCompact; try { @@ -415,7 +417,7 @@ class FateServiceHandler implements FateService.Iface { TableOperation tableOp = TableOperation.IMPORT; String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); String exportDir = ByteBufferUtil.toString(arguments.get(1)); - String namespaceId; + Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(master.getInstance(), Tables.qualify(tableName).getFirst()); } catch (NamespaceNotFoundException e) { @@ -441,8 +443,8 @@ class FateServiceHandler implements FateService.Iface { String tableName = validateTableNameArgument(arguments.get(0), tableOp, NOT_SYSTEM); String exportDir = ByteBufferUtil.toString(arguments.get(1)); - String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); - String namespaceId = getNamespaceIdFromTableId(tableOp, tableId); + Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp); + Namespace.ID namespaceId = getNamespaceIdFromTableId(tableOp, tableId); final boolean canExport; try { @@ -463,12 +465,12 @@ class FateServiceHandler implements FateService.Iface { } } - private String getNamespaceIdFromTableId(TableOperation tableOp, String tableId) throws ThriftTableOperationException { - String namespaceId; + private Namespace.ID getNamespaceIdFromTableId(TableOperation tableOp, Table.ID tableId) throws ThriftTableOperationException { + Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(master.getInstance(), tableId); } catch (TableNotFoundException e) { - throw new ThriftTableOperationException(tableId, null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); + throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; } @@ -491,11 +493,11 @@ class FateServiceHandler implements FateService.Iface { * @throws ThriftTableOperationException * Thrown if {@code e} was thrown because {@link SecurityErrorCode#TABLE_DOESNT_EXIST} */ - private void throwIfTableMissingSecurityException(ThriftSecurityException e, String tableId, String tableName, TableOperation op) + private void throwIfTableMissingSecurityException(ThriftSecurityException e, Table.ID tableId, String tableName, TableOperation op) throws ThriftTableOperationException { // ACCUMULO-3135 Table can be deleted after we get table ID but before we can check permission if (e.isSetCode() && SecurityErrorCode.TABLE_DOESNT_EXIST == e.getCode()) { - throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.NOTFOUND, "Table no longer exists"); + throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.NOTFOUND, "Table no longer exists"); } } @@ -536,15 +538,15 @@ class FateServiceHandler implements FateService.Iface { } // Verify table name arguments are valid, and match any additional restrictions - private String validateTableIdArgument(ByteBuffer tableIdArg, TableOperation op, Validator<String> userValidator) throws ThriftTableOperationException { - String tableId = tableIdArg == null ? null : ByteBufferUtil.toString(tableIdArg); + private Table.ID validateTableIdArgument(ByteBuffer tableIdArg, TableOperation op, Validator<Table.ID> userValidator) throws ThriftTableOperationException { + Table.ID tableId = tableIdArg == null ? null : ByteBufferUtil.toTableId(tableIdArg); try { return VALID_ID.and(userValidator).validate(tableId); } catch (IllegalArgumentException e) { String why = e.getMessage(); // Information provided by a client should generate a user-level exception, not a system-level warning. log.debug(why); - throw new ThriftTableOperationException(tableId, null, op, TableOperationExceptionType.INVALID_NAME, why); + throw new ThriftTableOperationException(tableId.canonicalID(), null, op, TableOperationExceptionType.INVALID_NAME, why); } }
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/Master.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java index 379b955..a18473b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/Master.java +++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java @@ -47,7 +47,9 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.ThriftTransportPool; import org.apache.accumulo.core.client.impl.thrift.TableOperation; @@ -388,11 +390,11 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List // create initial namespaces String namespaces = ZooUtil.getRoot(getInstance()) + Constants.ZNAMESPACES; zoo.putPersistentData(namespaces, new byte[0], NodeExistsPolicy.SKIP); - for (Pair<String,String> namespace : Iterables.concat( + for (Pair<String,Namespace.ID> namespace : Iterables.concat( Collections.singleton(new Pair<>(Namespaces.ACCUMULO_NAMESPACE, Namespaces.ACCUMULO_NAMESPACE_ID)), Collections.singleton(new Pair<>(Namespaces.DEFAULT_NAMESPACE, Namespaces.DEFAULT_NAMESPACE_ID)))) { String ns = namespace.getFirst(); - String id = namespace.getSecond(); + Namespace.ID id = namespace.getSecond(); log.debug("Upgrade creating namespace \"" + ns + "\" (ID: " + id + ")"); if (!Namespaces.exists(getInstance(), id)) TableManager.prepareNewNamespaceState(getInstance().getInstanceID(), id, ns, NodeExistsPolicy.SKIP); @@ -414,11 +416,11 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List // put existing tables in the correct namespaces String tables = ZooUtil.getRoot(getInstance()) + Constants.ZTABLES; for (String tableId : zoo.getChildren(tables)) { - String targetNamespace = (MetadataTable.ID.equals(tableId) || RootTable.ID.equals(tableId)) ? Namespaces.ACCUMULO_NAMESPACE_ID + Namespace.ID targetNamespace = (MetadataTable.ID.canonicalID().equals(tableId) || RootTable.ID.canonicalID().equals(tableId)) ? Namespaces.ACCUMULO_NAMESPACE_ID : Namespaces.DEFAULT_NAMESPACE_ID; log.debug("Upgrade moving table " + new String(zoo.getData(tables + "/" + tableId + Constants.ZTABLE_NAME, null), UTF_8) + " (ID: " + tableId + ") into namespace with ID " + targetNamespace); - zoo.putPersistentData(tables + "/" + tableId + Constants.ZTABLE_NAMESPACE, targetNamespace.getBytes(UTF_8), NodeExistsPolicy.SKIP); + zoo.putPersistentData(tables + "/" + tableId + Constants.ZTABLE_NAMESPACE, targetNamespace.getUtf8(), NodeExistsPolicy.SKIP); } // rename metadata table @@ -519,7 +521,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List } } - private int assignedOrHosted(String tableId) { + private int assignedOrHosted(Table.ID tableId) { int result = 0; for (TabletGroupWatcher watcher : watchers) { TableCounts count = watcher.getStats(tableId); @@ -560,8 +562,8 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List // Count offline tablets for online tables for (TabletGroupWatcher watcher : watchers) { TableManager manager = TableManager.getInstance(); - for (Entry<String,TableCounts> entry : watcher.getStats().entrySet()) { - String tableId = entry.getKey(); + for (Entry<Table.ID,TableCounts> entry : watcher.getStats().entrySet()) { + Table.ID tableId = entry.getKey(); TableCounts counts = entry.getValue(); TableState tableState = manager.getTableState(tableId); if (tableState != null && tableState.equals(TableState.ONLINE)) { @@ -590,10 +592,10 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List return result; } - public void mustBeOnline(final String tableId) throws ThriftTableOperationException { + public void mustBeOnline(final Table.ID tableId) throws ThriftTableOperationException { Tables.clearCache(getInstance()); if (!Tables.getTableState(getInstance(), tableId).equals(TableState.ONLINE)) - throw new ThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online"); + throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.MERGE, TableOperationExceptionType.OFFLINE, "table is not online"); } public Master(Instance instance, ServerConfigurationFactory config, VolumeManager fs, String hostname) throws IOException { @@ -650,7 +652,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List return tserverSet.getConnection(server); } - public MergeInfo getMergeInfo(String tableId) { + public MergeInfo getMergeInfo(Table.ID tableId) { synchronized (mergeLock) { try { String path = ZooUtil.getRoot(getInstance().getInstanceID()) + Constants.ZTABLES + "/" + tableId + "/merge"; @@ -693,7 +695,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List nextEvent.event("Merge state of %s set to %s", info.getExtent(), state); } - public void clearMergeState(String tableId) throws IOException, KeeperException, InterruptedException { + public void clearMergeState(Table.ID tableId) throws IOException, KeeperException, InterruptedException { synchronized (mergeLock) { String path = ZooUtil.getRoot(getInstance().getInstanceID()) + Constants.ZTABLES + "/" + tableId + "/merge"; ZooReaderWriter.getInstance().recursiveDelete(path, NodeMissingPolicy.SKIP); @@ -731,7 +733,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List return true; } - public void clearMigrations(String tableId) { + public void clearMigrations(Table.ID tableId) { synchronized (migrations) { Iterator<KeyExtent> iterator = migrations.keySet().iterator(); while (iterator.hasNext()) { @@ -886,7 +888,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List */ private void cleanupOfflineMigrations() { TableManager manager = TableManager.getInstance(); - for (String tableId : Tables.getIdToNameMap(getInstance()).keySet()) { + for (Table.ID tableId : Tables.getIdToNameMap(getInstance()).keySet()) { TableState state = manager.getTableState(tableId); if (TableState.OFFLINE == state) { clearMigrations(tableId); @@ -1525,7 +1527,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List } @Override - public void stateChanged(String tableId, TableState state) { + public void stateChanged(Table.ID tableId, TableState state) { nextEvent.event("Table state in zookeeper changed for %s to %s", tableId, state); if (TableState.OFFLINE == state) { clearMigrations(tableId); @@ -1533,14 +1535,14 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List } @Override - public void initialize(Map<String,TableState> tableIdToStateMap) {} + public void initialize(Map<Table.ID,TableState> tableIdToStateMap) {} @Override public void sessionExpired() {} @Override - public Set<String> onlineTables() { - Set<String> result = new HashSet<>(); + public Set<Table.ID> onlineTables() { + Set<Table.ID> result = new HashSet<>(); if (getMasterState() != MasterState.NORMAL) { if (getMasterState() != MasterState.UNLOAD_METADATA_TABLETS) result.add(MetadataTable.ID); @@ -1550,7 +1552,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List } TableManager manager = TableManager.getInstance(); - for (String tableId : Tables.getIdToNameMap(getInstance()).keySet()) { + for (Table.ID tableId : Tables.getIdToNameMap(getInstance()).keySet()) { TableState state = manager.getTableState(tableId); if (state != null) { if (state == TableState.ONLINE) @@ -1568,7 +1570,7 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List @Override public Collection<MergeInfo> merges() { List<MergeInfo> result = new ArrayList<>(); - for (String tableId : Tables.getIdToNameMap(getInstance()).keySet()) { + for (Table.ID tableId : Tables.getIdToNameMap(getInstance()).keySet()) { result.add(getMergeInfo(tableId)); } return result; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java index 2497a44..e98064b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java +++ b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java @@ -41,6 +41,8 @@ import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.DelegationTokenConfig; import org.apache.accumulo.core.client.impl.AuthenticationTokenIdentifier; import org.apache.accumulo.core.client.impl.DelegationTokenConfigSerializer; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode; import org.apache.accumulo.core.client.impl.thrift.TableOperation; @@ -111,8 +113,9 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma } @Override - public long initiateFlush(TInfo tinfo, TCredentials c, String tableId) throws ThriftSecurityException, ThriftTableOperationException { - String namespaceId = getNamespaceIdFromTableId(TableOperation.FLUSH, tableId); + public long initiateFlush(TInfo tinfo, TCredentials c, String tableIdStr) throws ThriftSecurityException, ThriftTableOperationException { + Table.ID tableId = new Table.ID(tableIdStr); + Namespace.ID namespaceId = getNamespaceIdFromTableId(TableOperation.FLUSH, tableId); master.security.canFlush(c, tableId, namespaceId); String zTablePath = Constants.ZROOT + "/" + master.getInstance().getInstanceID() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_FLUSH_ID; @@ -129,22 +132,24 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma } }); } catch (NoNodeException nne) { - throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH, TableOperationExceptionType.NOTFOUND, null); + throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.FLUSH, TableOperationExceptionType.NOTFOUND, null); } catch (Exception e) { Master.log.warn("{}", e.getMessage(), e); - throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH, TableOperationExceptionType.OTHER, null); + throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.FLUSH, TableOperationExceptionType.OTHER, null); } return Long.parseLong(new String(fid)); } @Override - public void waitForFlush(TInfo tinfo, TCredentials c, String tableId, ByteBuffer startRow, ByteBuffer endRow, long flushID, long maxLoops) + public void waitForFlush(TInfo tinfo, TCredentials c, String tableIdStr, ByteBuffer startRow, ByteBuffer endRow, long flushID, long maxLoops) throws ThriftSecurityException, ThriftTableOperationException { - String namespaceId = getNamespaceIdFromTableId(TableOperation.FLUSH, tableId); + Table.ID tableId = new Table.ID(tableIdStr); + Namespace.ID namespaceId = getNamespaceIdFromTableId(TableOperation.FLUSH, tableId); master.security.canFlush(c, tableId, namespaceId); if (endRow != null && startRow != null && ByteBufferUtil.toText(startRow).compareTo(ByteBufferUtil.toText(endRow)) >= 0) - throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH, TableOperationExceptionType.BAD_RANGE, "start row must be less than end row"); + throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.FLUSH, TableOperationExceptionType.BAD_RANGE, + "start row must be less than end row"); Set<TServerInstance> serversToFlush = new HashSet<>(master.tserverSet.getCurrentServers()); @@ -237,7 +242,7 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma // TODO detect case of table offline AND tablets w/ logs? - ACCUMULO-1296 if (tabletCount == 0 && !Tables.exists(master.getInstance(), tableId)) - throw new ThriftTableOperationException(tableId, null, TableOperation.FLUSH, TableOperationExceptionType.NOTFOUND, null); + throw new ThriftTableOperationException(tableId.canonicalID(), null, TableOperation.FLUSH, TableOperationExceptionType.NOTFOUND, null); } catch (AccumuloException e) { Master.log.debug("Failed to scan " + MetadataTable.NAME + " table to wait for flush " + tableId, e); @@ -254,12 +259,12 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma } - private String getNamespaceIdFromTableId(TableOperation tableOp, String tableId) throws ThriftTableOperationException { - String namespaceId; + private Namespace.ID getNamespaceIdFromTableId(TableOperation tableOp, Table.ID tableId) throws ThriftTableOperationException { + Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(master.getInstance(), tableId); } catch (TableNotFoundException e) { - throw new ThriftTableOperationException(tableId, null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); + throw new ThriftTableOperationException(tableId.canonicalID(), null, tableOp, TableOperationExceptionType.NOTFOUND, e.getMessage()); } return namespaceId; } @@ -412,7 +417,7 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma private void alterNamespaceProperty(TCredentials c, String namespace, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException { - String namespaceId = null; + Namespace.ID namespaceId = null; namespaceId = ClientServiceHandler.checkNamespaceId(master.getInstance(), namespace, op); if (!master.security.canAlterNamespace(c, namespaceId)) @@ -426,19 +431,20 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma } } catch (KeeperException.NoNodeException e) { // race condition... namespace no longer exists? This call will throw an exception if the namespace was deleted: - ClientServiceHandler.checkNamespaceId(master.getInstance(), namespaceId, op); + ClientServiceHandler.checkNamespaceId(master.getInstance(), namespace, op); log.info("Error altering namespace property", e); - throw new ThriftTableOperationException(namespaceId, namespace, op, TableOperationExceptionType.OTHER, "Problem altering namespaceproperty"); + throw new ThriftTableOperationException(namespaceId.canonicalID(), namespace, op, TableOperationExceptionType.OTHER, "Problem altering namespaceproperty"); } catch (Exception e) { log.error("Problem altering namespace property", e); - throw new ThriftTableOperationException(namespaceId, namespace, op, TableOperationExceptionType.OTHER, "Problem altering namespace property"); + throw new ThriftTableOperationException(namespaceId.canonicalID(), namespace, op, TableOperationExceptionType.OTHER, + "Problem altering namespace property"); } } private void alterTableProperty(TCredentials c, String tableName, String property, String value, TableOperation op) throws ThriftSecurityException, ThriftTableOperationException { - final String tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, op); - String namespaceId = getNamespaceIdFromTableId(op, tableId); + final Table.ID tableId = ClientServiceHandler.checkTableId(master.getInstance(), tableName, op); + Namespace.ID namespaceId = getNamespaceIdFromTableId(op, tableId); if (!master.security.canAlterTable(c, tableId, namespaceId)) throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); @@ -452,10 +458,10 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma // race condition... table no longer exists? This call will throw an exception if the table was deleted: ClientServiceHandler.checkTableId(master.getInstance(), tableName, op); log.info("Error altering table property", e); - throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); + throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } catch (Exception e) { log.error("Problem altering table property", e); - throw new ThriftTableOperationException(tableId, tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); + throw new ThriftTableOperationException(tableId.canonicalID(), tableName, op, TableOperationExceptionType.OTHER, "Problem altering table property"); } } @@ -517,7 +523,7 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma throw new RuntimeException("Failed to obtain connector", e); } - final Text tableId = new Text(getTableId(master.getInstance(), tableName)); + final Text tableId = new Text(getTableId(master.getInstance(), tableName).getUtf8()); drainLog.trace("Waiting for {} to be replicated for {}", logsToWatch, tableId); @@ -555,7 +561,7 @@ public class MasterClientServiceHandler extends FateServiceHandler implements Ma } } - protected String getTableId(Instance instance, String tableName) throws ThriftTableOperationException { + protected Table.ID getTableId(Instance instance, String tableName) throws ThriftTableOperationException { return ClientServiceHandler.checkTableId(instance, tableName, null); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java index 34dc1e2..b356241 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java +++ b/server/master/src/main/java/org/apache/accumulo/master/TabletGroupWatcher.java @@ -45,6 +45,7 @@ import org.apache.accumulo.core.client.MutationsRejectedException; import org.apache.accumulo.core.client.RowIterator; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; @@ -121,7 +122,7 @@ abstract class TabletGroupWatcher extends Daemon { /** Should this {@code TabletGroupWatcher} suspend tablets? */ abstract boolean canSuspendTablets(); - Map<String,TableCounts> getStats() { + Map<Table.ID,TableCounts> getStats() { return stats.getLast(); } @@ -130,7 +131,7 @@ abstract class TabletGroupWatcher extends Daemon { return masterState; } - TableCounts getStats(String tableId) { + TableCounts getStats(Table.ID tableId) { return stats.getLast(tableId); } @@ -156,8 +157,8 @@ abstract class TabletGroupWatcher extends Daemon { int unloaded = 0; ClosableIterator<TabletLocationState> iter = null; try { - Map<String,MergeStats> mergeStatsCache = new HashMap<>(); - Map<String,MergeStats> currentMerges = new HashMap<>(); + Map<Table.ID,MergeStats> mergeStatsCache = new HashMap<>(); + Map<Table.ID,MergeStats> currentMerges = new HashMap<>(); for (MergeInfo merge : master.merges()) { if (merge.getExtent() != null) { currentMerges.put(merge.getExtent().getTableId(), new MergeStats(merge)); @@ -219,7 +220,7 @@ abstract class TabletGroupWatcher extends Daemon { unloaded = 0; eventListener.waitForEvents(Master.TIME_TO_WAIT_BETWEEN_SCANS); } - String tableId = tls.extent.getTableId(); + Table.ID tableId = tls.extent.getTableId(); TableConfiguration tableConf = this.master.getConfigurationFactory().getTableConfiguration(tableId); MergeStats mergeStats = mergeStatsCache.get(tableId); @@ -534,7 +535,7 @@ abstract class TabletGroupWatcher extends Daemon { } } - private void updateMergeState(Map<String,MergeStats> mergeStatsCache) { + private void updateMergeState(Map<Table.ID,MergeStats> mergeStatsCache) { for (MergeStats stats : mergeStatsCache.values()) { try { MergeState update = stats.nextMergeState(this.master.getConnector(), this.master); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/replication/FinishedWorkUpdater.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/FinishedWorkUpdater.java b/server/master/src/main/java/org/apache/accumulo/master/replication/FinishedWorkUpdater.java index e394b57..500b176 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/FinishedWorkUpdater.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/FinishedWorkUpdater.java @@ -28,6 +28,7 @@ import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.MutationsRejectedException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; @@ -95,7 +96,7 @@ public class FinishedWorkUpdater implements Runnable { log.debug("Processing work progress for {} with {} columns", serializedRow.getKey().getRow(), wholeRow.size()); - Map<String,Long> tableIdToProgress = new HashMap<>(); + Map<Table.ID,Long> tableIdToProgress = new HashMap<>(); boolean error = false; Text buffer = new Text(); @@ -128,7 +129,7 @@ public class FinishedWorkUpdater implements Runnable { } // Update the replication table for each source table we found work records for - for (Entry<String,Long> entry : tableIdToProgress.entrySet()) { + for (Entry<Table.ID,Long> entry : tableIdToProgress.entrySet()) { // If the progress is 0, then no one has replicated anything, and we don't need to update anything if (0 == entry.getValue()) { continue; @@ -145,7 +146,7 @@ public class FinishedWorkUpdater implements Runnable { Value serializedUpdatedStatus = ProtobufUtil.toValue(updatedStatus); // Pull the sourceTableId into a Text - String srcTableId = entry.getKey(); + Table.ID srcTableId = entry.getKey(); // Make the mutation StatusSection.add(replMutation, srcTableId, serializedUpdatedStatus); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecords.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecords.java b/server/master/src/main/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecords.java index e286371..68f7d96 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecords.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/RemoveCompleteReplicationRecords.java @@ -30,6 +30,7 @@ import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.MutationsRejectedException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; @@ -148,7 +149,7 @@ public class RemoveCompleteReplicationRecords implements Runnable { } Mutation m = new Mutation(row); - Map<String,Long> tableToTimeCreated = new HashMap<>(); + Map<Table.ID,Long> tableToTimeCreated = new HashMap<>(); for (Entry<Key,Value> entry : columns.entrySet()) { Status status = null; try { @@ -171,9 +172,9 @@ public class RemoveCompleteReplicationRecords implements Runnable { m.putDelete(colf, colq); - String tableId; + Table.ID tableId; if (StatusSection.NAME.equals(colf)) { - tableId = colq.toString(); + tableId = new Table.ID(colq.toString()); } else if (WorkSection.NAME.equals(colf)) { ReplicationTarget target = ReplicationTarget.from(colq); tableId = target.getSourceTableId(); @@ -195,10 +196,10 @@ public class RemoveCompleteReplicationRecords implements Runnable { List<Mutation> mutations = new ArrayList<>(); mutations.add(m); - for (Entry<String,Long> entry : tableToTimeCreated.entrySet()) { + for (Entry<Table.ID,Long> entry : tableToTimeCreated.entrySet()) { log.info("Removing order mutation for table {} at {} for {}", entry.getKey(), entry.getValue(), row.toString()); Mutation orderMutation = OrderSection.createMutation(row.toString(), entry.getValue()); - orderMutation.putDelete(OrderSection.NAME, new Text(entry.getKey())); + orderMutation.putDelete(OrderSection.NAME, new Text(entry.getKey().getUtf8())); mutations.add(orderMutation); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java b/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java index f24da7e..705c110 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/SequentialWorkAssigner.java @@ -97,7 +97,7 @@ public class SequentialWorkAssigner extends DistributedWorkQueueWorkAssigner { Entry<String,ReplicationTarget> entry = DistributedWorkQueueWorkAssignerHelper.fromQueueKey(work); String filename = entry.getKey(); String peerName = entry.getValue().getPeerName(); - String sourceTableId = entry.getValue().getSourceTableId(); + String sourceTableId = entry.getValue().getSourceTableId().canonicalID(); log.debug("In progress replication of {} from table with ID {} to peer {}", filename, sourceTableId, peerName); @@ -158,7 +158,7 @@ public class SequentialWorkAssigner extends DistributedWorkQueueWorkAssigner { return true; } - String queuedWork = queuedWorkForPeer.get(target.getSourceTableId()); + String queuedWork = queuedWorkForPeer.get(target.getSourceTableId().canonicalID()); // If we have no work for the local table to the given peer, submit some! return null == queuedWork; @@ -173,11 +173,11 @@ public class SequentialWorkAssigner extends DistributedWorkQueueWorkAssigner { this.queuedWorkByPeerName.put(target.getPeerName(), workForPeer); } - String queuedWork = workForPeer.get(target.getSourceTableId()); + String queuedWork = workForPeer.get(target.getSourceTableId().canonicalID()); if (null == queuedWork) { try { workQueue.addWork(queueKey, path.toString()); - workForPeer.put(target.getSourceTableId(), queueKey); + workForPeer.put(target.getSourceTableId().canonicalID(), queueKey); } catch (KeeperException | InterruptedException e) { log.warn("Could not queue work for {} to {}", path, target, e); return false; @@ -200,7 +200,7 @@ public class SequentialWorkAssigner extends DistributedWorkQueueWorkAssigner { return Collections.emptySet(); } - String queuedWork = queuedWorkForPeer.get(target.getSourceTableId()); + String queuedWork = queuedWorkForPeer.get(target.getSourceTableId().canonicalID()); if (null == queuedWork) { return Collections.emptySet(); } else { @@ -216,9 +216,9 @@ public class SequentialWorkAssigner extends DistributedWorkQueueWorkAssigner { return; } - String queuedWork = queuedWorkForPeer.get(target.getSourceTableId()); + String queuedWork = queuedWorkForPeer.get(target.getSourceTableId().canonicalID()); if (queuedWork.equals(queueKey)) { - queuedWorkForPeer.remove(target.getSourceTableId()); + queuedWorkForPeer.remove(target.getSourceTableId().canonicalID()); } else { log.warn("removeQueuedWork called on {} with differing queueKeys, expected {} but was {}", target, queueKey, queuedWork); return; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java b/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java index 4a0ed52..7a41619 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/StatusMaker.java @@ -26,6 +26,7 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.MutationsRejectedException; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Value; @@ -106,7 +107,7 @@ public class StatusMaker { } // Extract the useful bits from the status key MetadataSchema.ReplicationSection.getFile(entry.getKey(), file); - String tableId = MetadataSchema.ReplicationSection.getTableId(entry.getKey()); + Table.ID tableId = MetadataSchema.ReplicationSection.getTableId(entry.getKey()); Status status; try { @@ -158,10 +159,10 @@ public class StatusMaker { /** * Create a status record in the replication table */ - protected boolean addStatusRecord(Text file, String tableId, Value v) { + protected boolean addStatusRecord(Text file, Table.ID tableId, Value v) { try { Mutation m = new Mutation(file); - m.put(StatusSection.NAME, new Text(tableId), v); + m.put(StatusSection.NAME, new Text(tableId.getUtf8()), v); try { replicationWriter.addMutation(m); @@ -194,7 +195,7 @@ public class StatusMaker { * @param value * Serialized version of the Status msg */ - protected boolean addOrderRecord(Text file, String tableId, Status stat, Value value) { + protected boolean addOrderRecord(Text file, Table.ID tableId, Status stat, Value value) { try { if (!stat.hasCreatedTime()) { log.error("Status record ({}) for {} in table {} was written to metadata table which lacked createdTime", ProtobufUtil.toString(stat), file, tableId); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java index bd9bd65..3e2dc1c 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java +++ b/server/master/src/main/java/org/apache/accumulo/master/replication/WorkMaker.java @@ -25,6 +25,7 @@ import org.apache.accumulo.core.client.BatchWriter; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.MutationsRejectedException; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; @@ -93,7 +94,7 @@ public class WorkMaker { for (Entry<Key,Value> entry : s) { // Extract the useful bits from the status key ReplicationSchema.StatusSection.getFile(entry.getKey(), file); - String tableId = ReplicationSchema.StatusSection.getTableId(entry.getKey()); + Table.ID tableId = ReplicationSchema.StatusSection.getTableId(entry.getKey()); log.debug("Processing replication status record for " + file + " on table " + tableId); Status status; @@ -168,7 +169,7 @@ public class WorkMaker { return StatusUtil.isWorkRequired(status); } - protected void addWorkRecord(Text file, Value v, Map<String,String> targets, String sourceTableId) { + protected void addWorkRecord(Text file, Value v, Map<String,String> targets, Table.ID sourceTableId) { log.info("Adding work records for " + file + " to targets " + targets); try { Mutation m = new Mutation(file); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/state/MergeStats.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/state/MergeStats.java b/server/master/src/main/java/org/apache/accumulo/master/state/MergeStats.java index 4cb858c..0f40698 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/state/MergeStats.java +++ b/server/master/src/main/java/org/apache/accumulo/master/state/MergeStats.java @@ -24,6 +24,7 @@ import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; @@ -185,7 +186,7 @@ public class MergeStats { if (start == null) { start = new Text(); } - String tableId = extent.getTableId(); + Table.ID tableId = extent.getTableId(); Text first = KeyExtent.getMetadataEntry(tableId, start); Range range = new Range(first, false, null, true); scanner.setRange(range.clip(MetadataSchema.TabletsSection.getRange())); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/state/TableStats.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/state/TableStats.java b/server/master/src/main/java/org/apache/accumulo/master/state/TableStats.java index 931df12..0c9f456 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/state/TableStats.java +++ b/server/master/src/main/java/org/apache/accumulo/master/state/TableStats.java @@ -19,12 +19,13 @@ package org.apache.accumulo.master.state; import java.util.HashMap; import java.util.Map; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.master.thrift.MasterState; import org.apache.accumulo.server.master.state.TabletState; public class TableStats { - private Map<String,TableCounts> last = new HashMap<>(); - private Map<String,TableCounts> next; + private Map<Table.ID,TableCounts> last = new HashMap<>(); + private Map<Table.ID,TableCounts> next; private long startScan = 0; private long endScan = 0; private MasterState state; @@ -34,7 +35,7 @@ public class TableStats { startScan = System.currentTimeMillis(); } - public synchronized void update(String tableId, TabletState state) { + public synchronized void update(Table.ID tableId, TabletState state) { TableCounts counts = next.get(tableId); if (counts == null) { counts = new TableCounts(); @@ -50,7 +51,7 @@ public class TableStats { this.state = state; } - public synchronized Map<String,TableCounts> getLast() { + public synchronized Map<Table.ID,TableCounts> getLast() { return last; } @@ -58,7 +59,7 @@ public class TableStats { return state; } - public synchronized TableCounts getLast(String tableId) { + public synchronized TableCounts getLast(Table.ID tableId) { TableCounts result = last.get(tableId); if (result == null) return new TableCounts(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java index 622690c..60d9c16 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java @@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; @@ -76,12 +77,12 @@ public class BulkImport extends MasterRepo { private static final Logger log = LoggerFactory.getLogger(BulkImport.class); - private String tableId; + private Table.ID tableId; private String sourceDir; private String errorDir; private boolean setTime; - public BulkImport(String tableId, String sourceDir, String errorDir, boolean setTime) { + public BulkImport(Table.ID tableId, String sourceDir, String errorDir, boolean setTime) { this.tableId = tableId; this.sourceDir = sourceDir; this.errorDir = errorDir; @@ -101,7 +102,7 @@ public class BulkImport extends MasterRepo { reserve2 = Utils.reserveHdfsDirectory(errorDir, tid); return reserve2; } else { - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.OFFLINE, null); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, TableOperationExceptionType.OFFLINE, null); } } @@ -122,14 +123,14 @@ public class BulkImport extends MasterRepo { // ignored } if (errorStatus == null) - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, - errorDir + " does not exist"); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, + TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir + " does not exist"); if (!errorStatus.isDirectory()) - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, - errorDir + " is not a directory"); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, + TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir + " is not a directory"); if (fs.listStatus(errorPath).length != 0) - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, - errorDir + " is not empty"); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, + TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, errorDir + " is not empty"); ZooArbitrator.start(Constants.BULK_ARBITRATOR_TYPE, tid); master.updateBulkImportStatus(sourceDir, BulkImportState.MOVING); @@ -140,12 +141,12 @@ public class BulkImport extends MasterRepo { return new LoadFiles(tableId, sourceDir, bulkDir, errorDir, setTime); } catch (IOException ex) { log.error("error preparing the bulk import directory", ex); - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_INPUT_DIRECTORY, - sourceDir + ": " + ex); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT, + TableOperationExceptionType.BULK_BAD_INPUT_DIRECTORY, sourceDir + ": " + ex); } } - private Path createNewBulkDir(VolumeManager fs, String tableId) throws IOException { + private Path createNewBulkDir(VolumeManager fs, Table.ID tableId) throws IOException { Path tempPath = fs.matchingFileSystem(new Path(sourceDir), ServerConstants.getTablesDirs()); if (tempPath == null) throw new IOException(sourceDir + " is not in a volume configured for Accumulo"); @@ -176,7 +177,7 @@ public class BulkImport extends MasterRepo { } } - private String prepareBulkImport(Master master, final VolumeManager fs, String dir, String tableId) throws Exception { + private String prepareBulkImport(Master master, final VolumeManager fs, String dir, Table.ID tableId) throws Exception { final Path bulkDir = createNewBulkDir(fs, tableId); MetadataTableUtil.addBulkLoadInProgressFlag(master, "/" + bulkDir.getParent().getName() + "/" + bulkDir.getName()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java index 73d67b1..1fa5888 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java @@ -19,6 +19,8 @@ package org.apache.accumulo.master.tableOps; import static java.nio.charset.StandardCharsets.UTF_8; import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; @@ -29,10 +31,10 @@ import org.apache.accumulo.server.zookeeper.ZooReaderWriter; public class CancelCompactions extends MasterRepo { private static final long serialVersionUID = 1L; - private String tableId; - private String namespaceId; + private Table.ID tableId; + private Namespace.ID namespaceId; - public CancelCompactions(String namespaceId, String tableId) { + public CancelCompactions(Namespace.ID namespaceId, Table.ID tableId) { this.tableId = tableId; this.namespaceId = namespaceId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChangeTableState.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChangeTableState.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChangeTableState.java index a99fcf7..94a7d4e 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChangeTableState.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChangeTableState.java @@ -16,6 +16,8 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.fate.Repo; @@ -26,11 +28,11 @@ import org.slf4j.LoggerFactory; public class ChangeTableState extends MasterRepo { private static final long serialVersionUID = 1L; - private String tableId; - private String namespaceId; + private Table.ID tableId; + private Namespace.ID namespaceId; private TableOperation top; - public ChangeTableState(String namespaceId, String tableId, TableOperation top) { + public ChangeTableState(Namespace.ID namespaceId, Table.ID tableId, TableOperation top) { this.tableId = tableId; this.namespaceId = namespaceId; this.top = top; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java index 6685eaf..45df864 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java @@ -25,6 +25,8 @@ import org.apache.accumulo.core.client.BatchScanner; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.conf.AccumuloConfiguration; @@ -61,7 +63,8 @@ class CleanUp extends MasterRepo { private static final long serialVersionUID = 1L; - private String tableId, namespaceId; + private Table.ID tableId; + private Namespace.ID namespaceId; private long creationTime; @@ -76,7 +79,7 @@ class CleanUp extends MasterRepo { } - public CleanUp(String tableId, String namespaceId) { + public CleanUp(Table.ID tableId, Namespace.ID namespaceId) { this.tableId = tableId; this.namespaceId = namespaceId; creationTime = System.currentTimeMillis(); @@ -174,7 +177,7 @@ class CleanUp extends MasterRepo { if (archiveFiles) { archiveFile(fs, dir, tableId); } else { - fs.deleteRecursively(new Path(dir, tableId)); + fs.deleteRecursively(new Path(dir, tableId.canonicalID())); } } } catch (IOException e) { @@ -212,8 +215,8 @@ class CleanUp extends MasterRepo { return null; } - protected void archiveFile(VolumeManager fs, String dir, String tableId) throws IOException { - Path tableDirectory = new Path(dir, tableId); + protected void archiveFile(VolumeManager fs, String dir, Table.ID tableId) throws IOException { + Path tableDirectory = new Path(dir, tableId.canonicalID()); Volume v = fs.getVolumeByPath(tableDirectory); String basePath = v.getBasePath(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUpBulkImport.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUpBulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUpBulkImport.java index fef327d..099008f 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUpBulkImport.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUpBulkImport.java @@ -18,6 +18,7 @@ package org.apache.accumulo.master.tableOps; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.master.thrift.BulkImportState; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -33,12 +34,12 @@ class CleanUpBulkImport extends MasterRepo { private static final Logger log = LoggerFactory.getLogger(CleanUpBulkImport.class); - private String tableId; + private Table.ID tableId; private String source; private String bulk; private String error; - public CleanUpBulkImport(String tableId, String source, String bulk, String error) { + public CleanUpBulkImport(Table.ID tableId, String source, String bulk, String error) { this.tableId = tableId; this.source = source; this.bulk = bulk; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java index 96ff954..46e910e 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java @@ -16,6 +16,9 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; + import java.io.Serializable; import java.util.Map; import java.util.Set; @@ -24,11 +27,11 @@ class CloneInfo implements Serializable { private static final long serialVersionUID = 1L; - String srcTableId; + Table.ID srcTableId; String tableName; - String tableId; - String namespaceId; - String srcNamespaceId; + Table.ID tableId; + Namespace.ID namespaceId; + Namespace.ID srcNamespaceId; Map<String,String> propertiesToSet; Set<String> propertiesToExclude; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java index f9e0e81..04b55e2 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java @@ -19,6 +19,8 @@ package org.apache.accumulo.master.tableOps; import java.util.Map; import java.util.Set; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -28,7 +30,8 @@ public class CloneTable extends MasterRepo { private static final long serialVersionUID = 1L; private CloneInfo cloneInfo; - public CloneTable(String user, String namespaceId, String srcTableId, String tableName, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) { + public CloneTable(String user, Namespace.ID namespaceId, Table.ID srcTableId, String tableName, Map<String,String> propertiesToSet, + Set<String> propertiesToExclude) { cloneInfo = new CloneInfo(); cloneInfo.user = user; cloneInfo.srcTableId = srcTableId; @@ -50,7 +53,7 @@ public class CloneTable extends MasterRepo { Utils.idLock.lock(); try { - cloneInfo.tableId = Utils.getNextTableId(cloneInfo.tableName, environment.getInstance()); + cloneInfo.tableId = Utils.getNextTableId(cloneInfo.tableName, environment.getInstance(), Table.ID.class); return new ClonePermissions(cloneInfo); } finally { Utils.idLock.unlock(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java index 5fc37ec..4375ee7 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java @@ -26,6 +26,8 @@ import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.admin.CompactionStrategyConfig; import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException; import org.apache.accumulo.core.client.impl.CompactionStrategyConfigUtil; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.fate.Repo; @@ -45,13 +47,13 @@ public class CompactRange extends MasterRepo { private static final Logger log = LoggerFactory.getLogger(CompactRange.class); private static final long serialVersionUID = 1L; - private final String tableId; - private final String namespaceId; + private final Table.ID tableId; + private final Namespace.ID namespaceId; private byte[] startRow; private byte[] endRow; private byte[] config; - public CompactRange(String namespaceId, String tableId, byte[] startRow, byte[] endRow, List<IteratorSetting> iterators, + public CompactRange(Namespace.ID namespaceId, Table.ID tableId, byte[] startRow, byte[] endRow, List<IteratorSetting> iterators, CompactionStrategyConfig compactionStrategy) throws AcceptableThriftTableOperationException { requireNonNull(namespaceId, "Invalid argument: null namespaceId"); @@ -71,7 +73,7 @@ public class CompactRange extends MasterRepo { } if (this.startRow != null && this.endRow != null && new Text(startRow).compareTo(new Text(endRow)) >= 0) - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.BAD_RANGE, + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.BAD_RANGE, "start row must be less than end row"); } @@ -105,7 +107,7 @@ public class CompactRange extends MasterRepo { log.debug("txidString : " + txidString); log.debug("tokens[" + i + "] : " + tokens[i]); - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, "Another compaction with iterators and/or a compaction strategy is running"); } @@ -125,12 +127,12 @@ public class CompactRange extends MasterRepo { return new CompactionDriver(Long.parseLong(new String(cid, UTF_8).split(",")[0]), namespaceId, tableId, startRow, endRow); } catch (NoNodeException nne) { - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.NOTFOUND, null); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.NOTFOUND, null); } } - static void removeIterators(Master environment, final long txid, String tableId) throws Exception { + static void removeIterators(Master environment, final long txid, Table.ID tableId) throws Exception { String zTablePath = Constants.ZROOT + "/" + environment.getInstance().getInstanceID() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_COMPACT_ID; IZooReaderWriter zoo = ZooReaderWriter.getInstance(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java index bfecdd5..37c02ca 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java @@ -27,6 +27,8 @@ import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.RowIterator; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; @@ -56,12 +58,12 @@ class CompactionDriver extends MasterRepo { private static final long serialVersionUID = 1L; private long compactId; - private final String tableId; - private final String namespaceId; + private final Table.ID tableId; + private final Namespace.ID namespaceId; private byte[] startRow; private byte[] endRow; - public CompactionDriver(long compactId, String namespaceId, String tableId, byte[] startRow, byte[] endRow) { + public CompactionDriver(long compactId, Namespace.ID namespaceId, Table.ID tableId, byte[] startRow, byte[] endRow) { this.compactId = compactId; this.tableId = tableId; this.namespaceId = namespaceId; @@ -78,7 +80,8 @@ class CompactionDriver extends MasterRepo { if (Long.parseLong(new String(zoo.getData(zCancelID, null))) >= compactId) { // compaction was canceled - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, "Compaction canceled"); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.OTHER, + "Compaction canceled"); } MapCounter<TServerInstance> serversToFlush = new MapCounter<>(); @@ -141,10 +144,10 @@ class CompactionDriver extends MasterRepo { Instance instance = master.getInstance(); Tables.clearCache(instance); if (tabletCount == 0 && !Tables.exists(instance, tableId)) - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.NOTFOUND, null); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.NOTFOUND, null); if (serversToFlush.size() == 0 && Tables.getTableState(instance, tableId) == TableState.OFFLINE) - throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.COMPACT, TableOperationExceptionType.OFFLINE, null); + throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.COMPACT, TableOperationExceptionType.OFFLINE, null); if (tabletsToWaitFor == 0) return 0; @@ -153,7 +156,7 @@ class CompactionDriver extends MasterRepo { try { final TServerConnection server = master.getConnection(tsi); if (server != null) - server.compact(master.getMasterLock(), tableId, startRow, endRow); + server.compact(master.getMasterLock(), tableId.canonicalID(), startRow, endRow); } catch (TException ex) { LoggerFactory.getLogger(CompactionDriver.class).error(ex.toString()); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompleteBulkImport.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompleteBulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompleteBulkImport.java index 3fe6d6c..bcfadd5 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompleteBulkImport.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompleteBulkImport.java @@ -17,6 +17,7 @@ package org.apache.accumulo.master.tableOps; import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; import org.apache.accumulo.server.zookeeper.TransactionWatcher.ZooArbitrator; @@ -25,12 +26,12 @@ class CompleteBulkImport extends MasterRepo { private static final long serialVersionUID = 1L; - private String tableId; + private Table.ID tableId; private String source; private String bulk; private String error; - public CompleteBulkImport(String tableId, String source, String bulk, String error) { + public CompleteBulkImport(Table.ID tableId, String source, String bulk, String error) { this.tableId = tableId; this.source = source; this.bulk = bulk; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CopyFailed.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CopyFailed.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CopyFailed.java index 2f71907..a69c369 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CopyFailed.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CopyFailed.java @@ -29,6 +29,7 @@ import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.data.impl.KeyExtent; @@ -53,12 +54,12 @@ class CopyFailed extends MasterRepo { private static final long serialVersionUID = 1L; - private String tableId; + private Table.ID tableId; private String source; private String bulk; private String error; - public CopyFailed(String tableId, String source, String bulk, String error) { + public CopyFailed(Table.ID tableId, String source, String bulk, String error) { this.tableId = tableId; this.source = source; this.bulk = bulk; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java index 0dfe2e1..3e7d62a 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java @@ -52,7 +52,7 @@ class CreateImportDir extends MasterRepo { throw new IOException(tableInfo.exportDir + " is not in a volume configured for Accumulo"); } log.info("Chose base table directory of " + base); - Path directory = new Path(base, tableInfo.tableId); + Path directory = new Path(base, tableInfo.tableId.canonicalID()); Path newBulkDir = new Path(directory, Constants.BULK_PREFIX + namer.getNextName()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java index b01fbcc..26ad897 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java @@ -18,6 +18,7 @@ package org.apache.accumulo.master.tableOps; import java.util.Map; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -42,7 +43,7 @@ public class CreateNamespace extends MasterRepo { public Repo<Master> call(long tid, Master master) throws Exception { Utils.idLock.lock(); try { - namespaceInfo.namespaceId = Utils.getNextTableId(namespaceInfo.namespaceName, master.getInstance()); + namespaceInfo.namespaceId = Utils.getNextTableId(namespaceInfo.namespaceName, master.getInstance(), Namespace.ID.class); return new SetupNamespacePermissions(namespaceInfo); } finally { Utils.idLock.unlock(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java index ea2e395..dcd9191 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java @@ -19,6 +19,8 @@ package org.apache.accumulo.master.tableOps; import java.util.Map; import org.apache.accumulo.core.client.admin.TimeType; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -29,7 +31,7 @@ public class CreateTable extends MasterRepo { private TableInfo tableInfo; - public CreateTable(String user, String tableName, TimeType timeType, Map<String,String> props, String namespaceId) { + public CreateTable(String user, String tableName, TimeType timeType, Map<String,String> props, Namespace.ID namespaceId) { tableInfo = new TableInfo(); tableInfo.tableName = tableName; tableInfo.timeType = TabletTime.getTimeID(timeType); @@ -54,7 +56,7 @@ public class CreateTable extends MasterRepo { Utils.idLock.lock(); try { - tableInfo.tableId = Utils.getNextTableId(tableInfo.tableName, master.getInstance()); + tableInfo.tableId = Utils.getNextTableId(tableInfo.tableName, master.getInstance(), Table.ID.class); return new SetupPermissions(tableInfo); } finally { Utils.idLock.unlock(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java index f84671e..922e419 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java @@ -16,6 +16,7 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -24,9 +25,9 @@ public class DeleteNamespace extends MasterRepo { private static final long serialVersionUID = 1L; - private String namespaceId; + private Namespace.ID namespaceId; - public DeleteNamespace(String namespaceId) { + public DeleteNamespace(Namespace.ID namespaceId) { this.namespaceId = namespaceId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java index 34d2772..c3ca2c9 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java @@ -16,6 +16,8 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.fate.Repo; @@ -26,10 +28,10 @@ public class DeleteTable extends MasterRepo { private static final long serialVersionUID = 1L; - private String tableId; - private String namespaceId; + private Table.ID tableId; + private Namespace.ID namespaceId; - public DeleteTable(String namespaceId, String tableId) { + public DeleteTable(Namespace.ID namespaceId, Table.ID tableId) { this.namespaceId = namespaceId; this.tableId = tableId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java index 3e86488..fcefbfd 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java @@ -16,6 +16,9 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; + import java.io.Serializable; class ExportInfo implements Serializable { @@ -23,7 +26,7 @@ class ExportInfo implements Serializable { private static final long serialVersionUID = 1L; public String tableName; - public String tableID; + public Table.ID tableID; public String exportDir; - public String namespaceID; + public Namespace.ID namespaceID; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java index 9dd4800..10549f8 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java @@ -16,6 +16,8 @@ */ package org.apache.accumulo.master.tableOps; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -26,7 +28,7 @@ public class ExportTable extends MasterRepo { private final ExportInfo tableInfo; - public ExportTable(String namespaceId, String tableName, String tableId, String exportDir) throws ThriftTableOperationException { + public ExportTable(Namespace.ID namespaceId, String tableName, Table.ID tableId, String exportDir) throws ThriftTableOperationException { tableInfo = new ExportInfo(); tableInfo.tableName = tableName; tableInfo.exportDir = exportDir;
