http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/iterators/IteratorUtilTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/IteratorUtilTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/IteratorUtilTest.java index db30847..03c2208 100644 --- a/core/src/test/java/org/apache/accumulo/core/iterators/IteratorUtilTest.java +++ b/core/src/test/java/org/apache/accumulo/core/iterators/IteratorUtilTest.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationCopy; import org.apache.accumulo.core.conf.Property; @@ -138,7 +139,7 @@ public class IteratorUtilTest { SortedMapIterator source = new SortedMapIterator(tm); - SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent("tab", null, null), conf, + SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent(new Table.ID("tab"), null, null), conf, new DefaultIteratorEnvironment(conf)); iter.seek(new Range(), EMPTY_COL_FAMS, false); @@ -170,7 +171,7 @@ public class IteratorUtilTest { SortedMapIterator source = new SortedMapIterator(tm); - SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.majc, source, new KeyExtent("tab", null, null), conf, + SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.majc, source, new KeyExtent(new Table.ID("tab"), null, null), conf, new DefaultIteratorEnvironment(conf)); iter.seek(new Range(), EMPTY_COL_FAMS, false); @@ -206,7 +207,7 @@ public class IteratorUtilTest { conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".addIter", "2," + AddingIter.class.getName()); conf.set(Property.TABLE_ITERATOR_PREFIX + IteratorScope.minc.name() + ".sqIter", "1," + SquaringIter.class.getName()); - SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent("tab", null, null), conf, + SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent(new Table.ID("tab"), null, null), conf, new DefaultIteratorEnvironment(conf)); iter.seek(new Range(), EMPTY_COL_FAMS, false); @@ -242,7 +243,7 @@ public class IteratorUtilTest { SortedMapIterator source = new SortedMapIterator(tm); - SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent("tab", null, null), conf, + SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent(new Table.ID("tab"), null, null), conf, new DefaultIteratorEnvironment(conf)); iter.seek(new Range(), EMPTY_COL_FAMS, false); @@ -278,7 +279,7 @@ public class IteratorUtilTest { SortedMapIterator source = new SortedMapIterator(tm); - SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent("tab", null, null), conf, + SortedKeyValueIterator<Key,Value> iter = IteratorUtil.loadIterators(IteratorScope.minc, source, new KeyExtent(new Table.ID("tab"), null, null), conf, new DefaultIteratorEnvironment(conf)); iter.seek(new Range(), EMPTY_COL_FAMS, false);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/iterators/system/MultiIteratorTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/system/MultiIteratorTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/system/MultiIteratorTest.java index b2de6cb..d38ea27 100644 --- a/core/src/test/java/org/apache/accumulo/core/iterators/system/MultiIteratorTest.java +++ b/core/src/test/java/org/apache/accumulo/core/iterators/system/MultiIteratorTest.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.List; import java.util.TreeMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; @@ -344,7 +345,7 @@ public class MultiIteratorTest extends TestCase { List<SortedKeyValueIterator<Key,Value>> skvil = new ArrayList<>(1); skvil.add(new SortedMapIterator(tm1)); - KeyExtent extent = new KeyExtent("tablename", newRow(1), newRow(0)); + KeyExtent extent = new KeyExtent(new Table.ID("tablename"), newRow(1), newRow(0)); MultiIterator mi = new MultiIterator(skvil, extent); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/metadata/MetadataServicerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/metadata/MetadataServicerTest.java b/core/src/test/java/org/apache/accumulo/core/metadata/MetadataServicerTest.java index 0a0a940..6f3316f 100644 --- a/core/src/test/java/org/apache/accumulo/core/metadata/MetadataServicerTest.java +++ b/core/src/test/java/org/apache/accumulo/core/metadata/MetadataServicerTest.java @@ -31,6 +31,7 @@ import org.apache.accumulo.core.client.TableExistsException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.client.impl.ClientContext; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.replication.ReplicationTable; import org.easymock.EasyMock; import org.junit.BeforeClass; @@ -39,16 +40,16 @@ import org.junit.Test; public class MetadataServicerTest { private static final String userTableName = "tableName"; - private static final String userTableId = "tableId"; + private static final Table.ID userTableId = new Table.ID("tableId"); private static ClientContext context; @BeforeClass public static void setupContext() throws Exception { HashMap<String,String> tableNameToIdMap = new HashMap<>(); - tableNameToIdMap.put(RootTable.NAME, RootTable.ID); - tableNameToIdMap.put(MetadataTable.NAME, MetadataTable.ID); - tableNameToIdMap.put(ReplicationTable.NAME, ReplicationTable.ID); - tableNameToIdMap.put(userTableName, userTableId); + tableNameToIdMap.put(RootTable.NAME, RootTable.ID.canonicalID()); + tableNameToIdMap.put(MetadataTable.NAME, MetadataTable.ID.canonicalID()); + tableNameToIdMap.put(ReplicationTable.NAME, ReplicationTable.ID.canonicalID()); + tableNameToIdMap.put(userTableName, userTableId.canonicalID()); context = EasyMock.createMock(ClientContext.class); Connector conn = EasyMock.createMock(Connector.class); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/replication/ReplicationConfigurationUtilTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/replication/ReplicationConfigurationUtilTest.java b/core/src/test/java/org/apache/accumulo/core/replication/ReplicationConfigurationUtilTest.java index 6d87005..ee92f5d 100644 --- a/core/src/test/java/org/apache/accumulo/core/replication/ReplicationConfigurationUtilTest.java +++ b/core/src/test/java/org/apache/accumulo/core/replication/ReplicationConfigurationUtilTest.java @@ -19,6 +19,7 @@ package org.apache.accumulo.core.replication; import java.util.HashMap; import java.util.Map; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationCopy; import org.apache.accumulo.core.conf.Property; @@ -72,13 +73,13 @@ public class ReplicationConfigurationUtilTest { @Test public void regularTable() { - KeyExtent extent = new KeyExtent("1", new Text("b"), new Text("a")); + KeyExtent extent = new KeyExtent(new Table.ID("1"), new Text("b"), new Text("a")); Assert.assertTrue("Table should be replicated", ReplicationConfigurationUtil.isEnabled(extent, conf)); } @Test public void regularNonEnabledTable() { - KeyExtent extent = new KeyExtent("1", new Text("b"), new Text("a")); + KeyExtent extent = new KeyExtent(new Table.ID("1"), new Text("b"), new Text("a")); Assert.assertFalse("Table should not be replicated", ReplicationConfigurationUtil.isEnabled(extent, new ConfigurationCopy(new HashMap<String,String>()))); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/replication/ReplicationSchemaTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/replication/ReplicationSchemaTest.java b/core/src/test/java/org/apache/accumulo/core/replication/ReplicationSchemaTest.java index ca5eaa4..08274ef 100644 --- a/core/src/test/java/org/apache/accumulo/core/replication/ReplicationSchemaTest.java +++ b/core/src/test/java/org/apache/accumulo/core/replication/ReplicationSchemaTest.java @@ -16,6 +16,7 @@ */ package org.apache.accumulo.core.replication; +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.replication.ReplicationSchema.OrderSection; @@ -61,15 +62,15 @@ public class ReplicationSchemaTest { @Test public void extractTableId() { - String tableId = "1"; - Key k = new Key(new Text("foo"), StatusSection.NAME, new Text(tableId)); + Table.ID tableId = new Table.ID("1"); + Key k = new Key(new Text("foo"), StatusSection.NAME, new Text(tableId.getUtf8())); Assert.assertEquals(tableId, StatusSection.getTableId(k)); } @Test public void extractTableIdUsingText() { - String tableId = "1"; - Key k = new Key(new Text("foo"), StatusSection.NAME, new Text(tableId)); + Table.ID tableId = new Table.ID("1"); + Key k = new Key(new Text("foo"), StatusSection.NAME, new Text(tableId.getUtf8())); Assert.assertEquals(tableId, StatusSection.getTableId(k)); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/replication/ReplicationTargetTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/replication/ReplicationTargetTest.java b/core/src/test/java/org/apache/accumulo/core/replication/ReplicationTargetTest.java index 88e6304..c2c8b84 100644 --- a/core/src/test/java/org/apache/accumulo/core/replication/ReplicationTargetTest.java +++ b/core/src/test/java/org/apache/accumulo/core/replication/ReplicationTargetTest.java @@ -16,6 +16,7 @@ */ package org.apache.accumulo.core.replication; +import org.apache.accumulo.core.client.impl.Table; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.io.Text; @@ -29,18 +30,18 @@ public class ReplicationTargetTest { @Test public void properEquality() { - ReplicationTarget expected1 = new ReplicationTarget("foo", "bar", "1"); + ReplicationTarget expected1 = new ReplicationTarget("foo", "bar", new Table.ID("1")); - Assert.assertEquals(expected1, new ReplicationTarget("foo", "bar", "1")); - Assert.assertNotEquals(expected1, new ReplicationTarget("foo", "foo", "1")); - Assert.assertNotEquals(expected1, new ReplicationTarget("bar", "bar", "1")); - Assert.assertNotEquals(expected1, new ReplicationTarget(null, "bar", "1")); - Assert.assertNotEquals(expected1, new ReplicationTarget("foo", null, "1")); + Assert.assertEquals(expected1, new ReplicationTarget("foo", "bar", new Table.ID("1"))); + Assert.assertNotEquals(expected1, new ReplicationTarget("foo", "foo", new Table.ID("1"))); + Assert.assertNotEquals(expected1, new ReplicationTarget("bar", "bar", new Table.ID("1"))); + Assert.assertNotEquals(expected1, new ReplicationTarget(null, "bar", new Table.ID("1"))); + Assert.assertNotEquals(expected1, new ReplicationTarget("foo", null, new Table.ID("1"))); } @Test public void writableOut() throws Exception { - ReplicationTarget expected = new ReplicationTarget("foo", "bar", "1"); + ReplicationTarget expected = new ReplicationTarget("foo", "bar", new Table.ID("1")); DataOutputBuffer buffer = new DataOutputBuffer(); expected.write(buffer); @@ -64,7 +65,7 @@ public class ReplicationTargetTest { @Test public void staticFromTextHelper() throws Exception { - ReplicationTarget expected = new ReplicationTarget("foo", "bar", "1"); + ReplicationTarget expected = new ReplicationTarget("foo", "bar", new Table.ID("1")); DataOutputBuffer buffer = new DataOutputBuffer(); expected.write(buffer); Text t = new Text(); @@ -75,7 +76,7 @@ public class ReplicationTargetTest { @Test public void staticToTextHelper() throws Exception { - ReplicationTarget expected = new ReplicationTarget("foo", "bar", "1"); + ReplicationTarget expected = new ReplicationTarget("foo", "bar", new Table.ID("1")); DataOutputBuffer buffer = new DataOutputBuffer(); expected.write(buffer); Text t = new Text(); @@ -86,7 +87,7 @@ public class ReplicationTargetTest { @Test public void staticFromStringHelper() throws Exception { - ReplicationTarget expected = new ReplicationTarget("foo", "bar", "1"); + ReplicationTarget expected = new ReplicationTarget("foo", "bar", new Table.ID("1")); DataOutputBuffer buffer = new DataOutputBuffer(); expected.write(buffer); Text t = new Text(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/util/MergeTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/util/MergeTest.java b/core/src/test/java/org/apache/accumulo/core/util/MergeTest.java index b7804f6..7a0773e 100644 --- a/core/src/test/java/org/apache/accumulo/core/util/MergeTest.java +++ b/core/src/test/java/org/apache/accumulo/core/util/MergeTest.java @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.List; import org.apache.accumulo.core.client.Connector; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.util.Merge.Size; import org.apache.hadoop.io.Text; @@ -43,7 +44,7 @@ public class MergeTest { end = null; else end = new Text(String.format("%05d", tablets.size())); - KeyExtent extent = new KeyExtent("table", end, start); + KeyExtent extent = new KeyExtent(new Table.ID("table"), end, start); start = end; tablets.add(new Size(extent, size)); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java ---------------------------------------------------------------------- diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java index b1f3d0e..ece2377 100644 --- a/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImplTest.java @@ -115,8 +115,8 @@ public class MiniAccumuloClusterImplTest { Assert.assertTrue("master state should be valid.", validStates.contains(stats.state)); Assert.assertTrue("master goal state should be in " + validGoals + ". is " + stats.goalState, validGoals.contains(stats.goalState)); Assert.assertNotNull("should have a table map.", stats.tableMap); - Assert.assertTrue("root table should exist in " + stats.tableMap.keySet(), stats.tableMap.keySet().contains(RootTable.ID)); - Assert.assertTrue("meta table should exist in " + stats.tableMap.keySet(), stats.tableMap.keySet().contains(MetadataTable.ID)); + Assert.assertTrue("root table should exist in " + stats.tableMap.keySet(), stats.tableMap.keySet().contains(RootTable.ID.canonicalID())); + Assert.assertTrue("meta table should exist in " + stats.tableMap.keySet(), stats.tableMap.keySet().contains(MetadataTable.ID.canonicalID())); Assert.assertTrue("our test table should exist in " + stats.tableMap.keySet(), stats.tableMap.keySet().contains(testTableID)); Assert.assertNotNull("there should be tservers.", stats.tServerInfo); Assert.assertEquals(NUM_TSERVERS, stats.tServerInfo.size()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java index c9af520..e5ed823 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java +++ b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java @@ -38,6 +38,7 @@ import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.impl.ClientContext; import org.apache.accumulo.core.client.impl.ServerClient; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.TabletLocator; import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation; import org.apache.accumulo.core.client.impl.Translator; @@ -129,7 +130,7 @@ public class BulkImporter { final Map<Path,List<KeyExtent>> completeFailures = Collections.synchronizedSortedMap(new TreeMap<Path,List<KeyExtent>>()); ClientService.Client client = null; - final TabletLocator locator = TabletLocator.getLocator(context, tableId); + final TabletLocator locator = TabletLocator.getLocator(context, new Table.ID(tableId)); try { final Map<Path,List<TabletLocation>> assignments = Collections.synchronizedSortedMap(new TreeMap<Path,List<TabletLocation>>()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java index 134a804..343cfc4 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java +++ b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java @@ -35,7 +35,9 @@ import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.NamespaceNotFoundException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.impl.Credentials; +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.thrift.ClientService; import org.apache.accumulo.core.client.impl.thrift.ConfigurationType; @@ -88,7 +90,7 @@ public class ClientServiceHandler implements ClientService.Iface { this.security = AuditedSecurityOperation.getInstance(context); } - public static String checkTableId(Instance instance, String tableName, TableOperation operation) throws ThriftTableOperationException { + public static Table.ID checkTableId(Instance instance, String tableName, TableOperation operation) throws ThriftTableOperationException { TableOperationExceptionType reason = null; try { return Tables._getTableId(instance, tableName); @@ -100,14 +102,14 @@ public class ClientServiceHandler implements ClientService.Iface { throw new ThriftTableOperationException(null, tableName, operation, reason, null); } - public static String checkNamespaceId(Instance instance, String namespace, TableOperation operation) throws ThriftTableOperationException { - String namespaceId = Namespaces.getNameToIdMap(instance).get(namespace); + public static Namespace.ID checkNamespaceId(Instance instance, String namespaceName, TableOperation operation) throws ThriftTableOperationException { + Namespace.ID namespaceId = Namespaces.lookupNamespaceId(instance, 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(instance); - namespaceId = Namespaces.getNameToIdMap(instance).get(namespace); + namespaceId = Namespaces.lookupNamespaceId(instance, namespaceName); if (namespaceId == null) - throw new ThriftTableOperationException(null, namespace, operation, TableOperationExceptionType.NAMESPACE_NOTFOUND, null); + throw new ThriftTableOperationException(null, namespaceName, operation, TableOperationExceptionType.NAMESPACE_NOTFOUND, null); } return namespaceId; } @@ -199,8 +201,8 @@ public class ClientServiceHandler implements ClientService.Iface { @Override public void grantTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException { - String tableId = checkTableId(instance, tableName, TableOperation.PERMISSION); - String namespaceId; + Table.ID tableId = checkTableId(instance, tableName, TableOperation.PERMISSION); + Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(instance, tableId); } catch (TableNotFoundException e) { @@ -213,7 +215,7 @@ public class ClientServiceHandler implements ClientService.Iface { @Override public void grantNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte permission) throws ThriftSecurityException, ThriftTableOperationException { - String namespaceId = checkNamespaceId(instance, ns, TableOperation.PERMISSION); + Namespace.ID namespaceId = checkNamespaceId(instance, ns, TableOperation.PERMISSION); security.grantNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(permission)); } @@ -224,8 +226,8 @@ public class ClientServiceHandler implements ClientService.Iface { @Override public void revokeTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte permission) throws TException { - String tableId = checkTableId(instance, tableName, TableOperation.PERMISSION); - String namespaceId; + Table.ID tableId = checkTableId(instance, tableName, TableOperation.PERMISSION); + Namespace.ID namespaceId; try { namespaceId = Tables.getNamespaceId(instance, tableId); } catch (TableNotFoundException e) { @@ -243,21 +245,21 @@ public class ClientServiceHandler implements ClientService.Iface { @Override public boolean hasTablePermission(TInfo tinfo, TCredentials credentials, String user, String tableName, byte tblPerm) throws ThriftSecurityException, ThriftTableOperationException { - String tableId = checkTableId(instance, tableName, TableOperation.PERMISSION); + Table.ID tableId = checkTableId(instance, tableName, TableOperation.PERMISSION); return security.hasTablePermission(credentials, user, tableId, TablePermission.getPermissionById(tblPerm)); } @Override public boolean hasNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte perm) throws ThriftSecurityException, ThriftTableOperationException { - String namespaceId = checkNamespaceId(instance, ns, TableOperation.PERMISSION); + Namespace.ID namespaceId = checkNamespaceId(instance, ns, TableOperation.PERMISSION); return security.hasNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(perm)); } @Override public void revokeNamespacePermission(TInfo tinfo, TCredentials credentials, String user, String ns, byte permission) throws ThriftSecurityException, ThriftTableOperationException { - String namespaceId = checkNamespaceId(instance, ns, TableOperation.PERMISSION); + Namespace.ID namespaceId = checkNamespaceId(instance, ns, TableOperation.PERMISSION); security.revokeNamespacePermission(credentials, user, namespaceId, NamespacePermission.getPermissionById(permission)); } @@ -295,7 +297,7 @@ public class ClientServiceHandler implements ClientService.Iface { @Override public Map<String,String> getTableConfiguration(TInfo tinfo, TCredentials credentials, String tableName) throws TException, ThriftTableOperationException { - String tableId = checkTableId(instance, tableName, null); + Table.ID tableId = checkTableId(instance, tableName, null); AccumuloConfiguration config = context.getServerConfigurationFactory().getTableConfiguration(tableId); return conf(credentials, config); } @@ -364,7 +366,7 @@ public class ClientServiceHandler implements ClientService.Iface { security.authenticateUser(credentials, credentials); - String tableId = checkTableId(instance, tableName, null); + Table.ID tableId = checkTableId(instance, tableName, null); ClassLoader loader = getClass().getClassLoader(); Class<?> shouldMatch; @@ -398,7 +400,7 @@ public class ClientServiceHandler implements ClientService.Iface { security.authenticateUser(credentials, credentials); - String namespaceId = checkNamespaceId(instance, ns, null); + Namespace.ID namespaceId = checkNamespaceId(instance, ns, null); ClassLoader loader = getClass().getClassLoader(); Class<?> shouldMatch; @@ -433,9 +435,9 @@ public class ClientServiceHandler implements ClientService.Iface { for (String table : tables) { // ensure that table table exists - String tableId = checkTableId(instance, table, null); - tableIds.add(tableId); - String namespaceId = Tables.getNamespaceId(instance, tableId); + Table.ID tableId = checkTableId(instance, table, null); + tableIds.add(tableId.canonicalID()); + Namespace.ID namespaceId = Tables.getNamespaceId(instance, tableId); if (!security.canScan(credentials, tableId, namespaceId)) throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED); } @@ -462,7 +464,7 @@ public class ClientServiceHandler implements ClientService.Iface { @Override public Map<String,String> getNamespaceConfiguration(TInfo tinfo, TCredentials credentials, String ns) throws ThriftTableOperationException, TException { - String namespaceId; + Namespace.ID namespaceId; try { namespaceId = Namespaces.getNamespaceId(instance, ns); } catch (NamespaceNotFoundException e) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java index 71cc0a2..22969e5 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfWatcher.java @@ -18,6 +18,7 @@ package org.apache.accumulo.server.conf; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -54,24 +55,25 @@ class NamespaceConfWatcher implements Watcher { if (log.isTraceEnabled()) log.trace("WatchedEvent : " + toString(event)); - String namespaceId = null; + String namespaceIdStr = null; String key = null; if (path != null) { if (path.startsWith(namespacesPrefix)) { - namespaceId = path.substring(namespacesPrefixLength); - if (namespaceId.contains("/")) { - namespaceId = namespaceId.substring(0, namespaceId.indexOf('/')); - if (path.startsWith(namespacesPrefix + namespaceId + Constants.ZNAMESPACE_CONF + "/")) - key = path.substring((namespacesPrefix + namespaceId + Constants.ZNAMESPACE_CONF + "/").length()); + namespaceIdStr = path.substring(namespacesPrefixLength); + if (namespaceIdStr.contains("/")) { + namespaceIdStr = namespaceIdStr.substring(0, namespaceIdStr.indexOf('/')); + if (path.startsWith(namespacesPrefix + namespaceIdStr + Constants.ZNAMESPACE_CONF + "/")) + key = path.substring((namespacesPrefix + namespaceIdStr + Constants.ZNAMESPACE_CONF + "/").length()); } } - if (namespaceId == null) { + if (namespaceIdStr == null) { log.warn("Zookeeper told me about a path I was not watching: " + path + ", event " + toString(event)); return; } } + Namespace.ID namespaceId = new Namespace.ID(namespaceIdStr); switch (event.getType()) { case NodeDataChanged: http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java index bbd1354..63f6fa7 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java @@ -21,6 +21,7 @@ import java.util.function.Predicate; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Namespaces; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationObserver; @@ -40,11 +41,11 @@ public class NamespaceConfiguration extends ObservableConfiguration { private final AccumuloConfiguration parent; private ZooCachePropertyAccessor propCacheAccessor = null; - protected String namespaceId = null; + protected Namespace.ID namespaceId = null; protected Instance inst = null; private ZooCacheFactory zcf = new ZooCacheFactory(); - public NamespaceConfiguration(String namespaceId, Instance inst, AccumuloConfiguration parent) { + public NamespaceConfiguration(Namespace.ID namespaceId, Instance inst, AccumuloConfiguration parent) { this.inst = inst; this.parent = parent; this.namespaceId = namespaceId; @@ -66,7 +67,7 @@ public class NamespaceConfiguration extends ObservableConfiguration { private synchronized ZooCachePropertyAccessor getPropCacheAccessor() { if (propCacheAccessor == null) { synchronized (propCaches) { - PropCacheKey key = new PropCacheKey(inst.getInstanceID(), namespaceId); + PropCacheKey key = new PropCacheKey(inst.getInstanceID(), namespaceId.canonicalID()); ZooCache propCache = propCaches.get(key); if (propCache == null) { propCache = zcf.getZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new NamespaceConfWatcher(inst)); @@ -106,7 +107,7 @@ public class NamespaceConfiguration extends ObservableConfiguration { getPropCacheAccessor().getProperties(props, getPath(), filter, parent, parentFilter); } - protected String getNamespaceId() { + protected Namespace.ID getNamespaceId() { return namespaceId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java index 8417713..22e3890 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java @@ -16,13 +16,15 @@ */ package org.apache.accumulo.server.conf; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.AccumuloConfiguration; public abstract class ServerConfiguration { - abstract public TableConfiguration getTableConfiguration(String tableId); + abstract public TableConfiguration getTableConfiguration(Table.ID tableId); - abstract public NamespaceConfiguration getNamespaceConfiguration(String namespaceId); + abstract public NamespaceConfiguration getNamespaceConfiguration(Namespace.ID namespaceId); abstract public AccumuloConfiguration getSystemConfiguration(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java index a5d20ea..3cdde40 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java @@ -20,6 +20,8 @@ import java.util.HashMap; import java.util.Map; import org.apache.accumulo.core.client.Instance; +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.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigSanityCheck; @@ -32,9 +34,9 @@ import org.apache.accumulo.fate.zookeeper.ZooCacheFactory; */ public class ServerConfigurationFactory extends ServerConfiguration { - private static final Map<String,Map<String,TableConfiguration>> tableConfigs = new HashMap<>(1); - private static final Map<String,Map<String,NamespaceConfiguration>> namespaceConfigs = new HashMap<>(1); - private static final Map<String,Map<String,NamespaceConfiguration>> tableParentConfigs = new HashMap<>(1); + private static final Map<String,Map<Table.ID,TableConfiguration>> tableConfigs = new HashMap<>(1); + private static final Map<String,Map<Namespace.ID,NamespaceConfiguration>> namespaceConfigs = new HashMap<>(1); + private static final Map<String,Map<Table.ID,NamespaceConfiguration>> tableParentConfigs = new HashMap<>(1); private static void addInstanceToCaches(String iid) { synchronized (tableConfigs) { @@ -48,13 +50,13 @@ public class ServerConfigurationFactory extends ServerConfiguration { } } - static boolean removeCachedTableConfiguration(String instanceId, String tableId) { + static boolean removeCachedTableConfiguration(String instanceId, Table.ID tableId) { synchronized (tableConfigs) { return tableConfigs.get(instanceId).remove(tableId) != null; } } - static boolean removeCachedNamespaceConfiguration(String instanceId, String namespaceId) { + static boolean removeCachedNamespaceConfiguration(String instanceId, Namespace.ID namespaceId) { synchronized (namespaceConfigs) { return namespaceConfigs.get(instanceId).remove(namespaceId) != null; } @@ -74,7 +76,7 @@ public class ServerConfigurationFactory extends ServerConfiguration { static void expireAllTableObservers() { synchronized (tableConfigs) { - for (Map<String,TableConfiguration> instanceMap : tableConfigs.values()) { + for (Map<Table.ID,TableConfiguration> instanceMap : tableConfigs.values()) { for (TableConfiguration c : instanceMap.values()) { c.expireAllObservers(); } @@ -123,7 +125,7 @@ public class ServerConfigurationFactory extends ServerConfiguration { } @Override - public TableConfiguration getTableConfiguration(String tableId) { + public TableConfiguration getTableConfiguration(Table.ID tableId) { TableConfiguration conf; synchronized (tableConfigs) { conf = tableConfigs.get(instanceID).get(tableId); @@ -140,7 +142,7 @@ public class ServerConfigurationFactory extends ServerConfiguration { conf = new TableConfiguration(instance, tableId, getNamespaceConfigurationForTable(tableId)); ConfigSanityCheck.validate(conf); synchronized (tableConfigs) { - Map<String,TableConfiguration> configs = tableConfigs.get(instanceID); + Map<Table.ID,TableConfiguration> configs = tableConfigs.get(instanceID); TableConfiguration existingConf = configs.get(tableId); if (null == existingConf) { // Configuration doesn't exist yet @@ -154,7 +156,7 @@ public class ServerConfigurationFactory extends ServerConfiguration { return conf; } - public NamespaceConfiguration getNamespaceConfigurationForTable(String tableId) { + public NamespaceConfiguration getNamespaceConfigurationForTable(Table.ID tableId) { NamespaceConfiguration conf; synchronized (tableParentConfigs) { conf = tableParentConfigs.get(instanceID).get(tableId); @@ -173,7 +175,7 @@ public class ServerConfigurationFactory extends ServerConfiguration { } @Override - public NamespaceConfiguration getNamespaceConfiguration(String namespaceId) { + public NamespaceConfiguration getNamespaceConfiguration(Namespace.ID namespaceId) { NamespaceConfiguration conf; // can't hold the lock during the construction and validation of the config, // which may result in creating multiple objects for the same id, but that's ok. http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfWatcher.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfWatcher.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfWatcher.java index 2c1c9a5..f7ffe62 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfWatcher.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfWatcher.java @@ -18,6 +18,7 @@ package org.apache.accumulo.server.conf; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.log4j.Level; import org.apache.log4j.Logger; @@ -52,24 +53,25 @@ class TableConfWatcher implements Watcher { if (log.isTraceEnabled()) log.trace("WatchedEvent : " + toString(event)); - String tableId = null; + String tableIdString = null; String key = null; if (path != null) { if (path.startsWith(tablesPrefix)) { - tableId = path.substring(tablesPrefix.length()); - if (tableId.contains("/")) { - tableId = tableId.substring(0, tableId.indexOf('/')); - if (path.startsWith(tablesPrefix + tableId + Constants.ZTABLE_CONF + "/")) - key = path.substring((tablesPrefix + tableId + Constants.ZTABLE_CONF + "/").length()); + tableIdString = path.substring(tablesPrefix.length()); + if (tableIdString.contains("/")) { + tableIdString = tableIdString.substring(0, tableIdString.indexOf('/')); + if (path.startsWith(tablesPrefix + tableIdString + Constants.ZTABLE_CONF + "/")) + key = path.substring((tablesPrefix + tableIdString + Constants.ZTABLE_CONF + "/").length()); } } - if (tableId == null) { + if (tableIdString == null) { log.warn("Zookeeper told me about a path I was not watching: " + path + ", event " + toString(event)); return; } } + Table.ID tableId = new Table.ID(tableIdString); switch (event.getType()) { case NodeDataChanged: http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java index 568594a..ef503c0 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java @@ -23,6 +23,7 @@ import java.util.function.Predicate; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.ConfigurationObserver; import org.apache.accumulo.core.conf.ObservableConfiguration; import org.apache.accumulo.core.conf.Property; @@ -43,9 +44,9 @@ public class TableConfiguration extends ObservableConfiguration { private final NamespaceConfiguration parent; private ZooCacheFactory zcf = new ZooCacheFactory(); - private final String tableId; + private final Table.ID tableId; - public TableConfiguration(Instance instance, String tableId, NamespaceConfiguration parent) { + public TableConfiguration(Instance instance, Table.ID tableId, NamespaceConfiguration parent) { this.instance = requireNonNull(instance); this.tableId = requireNonNull(tableId); this.parent = requireNonNull(parent); @@ -58,7 +59,7 @@ public class TableConfiguration extends ObservableConfiguration { private synchronized ZooCachePropertyAccessor getPropCacheAccessor() { if (propCacheAccessor == null) { synchronized (propCaches) { - PropCacheKey key = new PropCacheKey(instance.getInstanceID(), tableId); + PropCacheKey key = new PropCacheKey(instance.getInstanceID(), tableId.canonicalID()); ZooCache propCache = propCaches.get(key); if (propCache == null) { propCache = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), new TableConfWatcher(instance)); @@ -105,7 +106,7 @@ public class TableConfiguration extends ObservableConfiguration { getPropCacheAccessor().getProperties(props, getPath(), filter, parent, null); } - public String getTableId() { + public Table.ID getTableId() { return tableId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java index 70649be..c55483f 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java @@ -18,6 +18,8 @@ package org.apache.accumulo.server.conf; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.TableNotFoundException; +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.conf.AccumuloConfiguration; @@ -26,16 +28,16 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration; */ public class TableParentConfiguration extends NamespaceConfiguration { - private String tableId; + private Table.ID tableId; - public TableParentConfiguration(String tableId, Instance inst, AccumuloConfiguration parent) { + public TableParentConfiguration(Table.ID tableId, Instance inst, AccumuloConfiguration parent) { super(null, inst, parent); this.tableId = tableId; this.namespaceId = getNamespaceId(); } @Override - protected String getNamespaceId() { + protected Namespace.ID getNamespaceId() { try { return Tables.getNamespaceId(inst, tableId); } catch (TableNotFoundException e) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java b/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java index 98f8c3f..060615c 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java +++ b/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java @@ -149,7 +149,7 @@ public class MetadataConstraints implements Constraint { } // ensure row is not less than Constants.METADATA_TABLE_ID - if (new Text(row).compareTo(new Text(MetadataTable.ID)) < 0) { + if (new Text(row).compareTo(new Text(MetadataTable.ID.getUtf8())) < 0) { violations = addViolation(violations, 5); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java b/server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java index 594a0a2..4a57100 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java +++ b/server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java @@ -18,6 +18,7 @@ package org.apache.accumulo.server.fs; import java.util.concurrent.ConcurrentHashMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.server.client.HdfsZooInstance; import org.apache.accumulo.server.conf.ServerConfigurationFactory; @@ -32,7 +33,7 @@ public class PerTableVolumeChooser implements VolumeChooser { private final VolumeChooser fallbackVolumeChooser = new RandomVolumeChooser(); // TODO Add hint of expected size to construction, see ACCUMULO-3410 /* Track VolumeChooser instances so they can keep state. */ - private final ConcurrentHashMap<String,VolumeChooser> tableSpecificChooser = new ConcurrentHashMap<>(); + private final ConcurrentHashMap<Table.ID,VolumeChooser> tableSpecificChooser = new ConcurrentHashMap<>(); // TODO has to be lazily initialized currently because of the reliance on HdfsZooInstance. see ACCUMULO-3411 private volatile ServerConfigurationFactory serverConfs; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java index a096854..b6886ba 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java +++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeChooserEnvironment.java @@ -17,14 +17,15 @@ package org.apache.accumulo.server.fs; import java.util.Optional; +import org.apache.accumulo.core.client.impl.Table; public class VolumeChooserEnvironment { - private final Optional<String> tableId; + private final Optional<Table.ID> tableId; // scope is meant for non-table identifiers private String scope; - public VolumeChooserEnvironment(Optional<String> tableId) { + public VolumeChooserEnvironment(Optional<Table.ID> tableId) { this.tableId = tableId; } @@ -32,7 +33,7 @@ public class VolumeChooserEnvironment { return tableId.isPresent(); } - public String getTableId() { + public Table.ID getTableId() { return tableId.get(); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java index 7b72829..d5727ac 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java +++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java @@ -19,6 +19,7 @@ package org.apache.accumulo.server.fs; import java.io.IOException; import java.util.Collection; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.volume.Volume; import org.apache.accumulo.server.ServerConstants; @@ -151,7 +152,7 @@ public interface VolumeManager { // Convert a file or directory metadata reference into a path Path getFullPath(Key key); - Path getFullPath(String tableId, String path); + Path getFullPath(Table.ID tableId, String path); // Given a filename, figure out the qualified path given multiple namespaces Path getFullPath(FileType fileType, String fileName) throws IOException; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java index e38bf77..e19cd36 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java +++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java @@ -28,6 +28,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.conf.Property; @@ -373,7 +374,7 @@ public class VolumeManagerImpl implements VolumeManager { // TODO sanity check col fam String relPath = key.getColumnQualifierData().toString(); byte[] tableId = KeyExtent.tableOfMetadataRow(key.getRow()); - return getFullPath(new String(tableId), relPath); + return getFullPath(new Table.ID(new String(tableId)), relPath); } @Override @@ -400,7 +401,7 @@ public class VolumeManagerImpl implements VolumeManager { } @Override - public Path getFullPath(String tableId, String path) { + public Path getFullPath(Table.ID tableId, String path) { if (path.contains(":")) return new Path(path); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java index 212dc6b..cdd2ccd 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java +++ b/server/base/src/main/java/org/apache/accumulo/server/init/Initialize.java @@ -42,6 +42,7 @@ import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.IteratorSetting.Column; import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.DefaultConfiguration; @@ -451,11 +452,12 @@ public class Initialize implements KeywordExecutable { } private static class Tablet { - String tableId, dir; + Table.ID tableId; + String dir; Text prevEndRow, endRow; String[] files; - Tablet(String tableId, String dir, Text prevEndRow, Text endRow, String... files) { + Tablet(Table.ID tableId, String dir, Text prevEndRow, Text endRow, String... files) { this.tableId = tableId; this.dir = dir; this.prevEndRow = prevEndRow; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java b/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java index 7d1d6e1..c7dd897 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/LiveTServerSet.java @@ -28,6 +28,7 @@ import java.util.Set; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.impl.ClientContext; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.TabletServerStatus; @@ -149,10 +150,10 @@ public class LiveTServerSet implements Watcher { } } - public void flush(ZooLock lock, String tableId, byte[] startRow, byte[] endRow) throws TException { + public void flush(ZooLock lock, Table.ID tableId, byte[] startRow, byte[] endRow) throws TException { TabletClientService.Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), address, context); try { - client.flush(Tracer.traceInfo(), context.rpcCreds(), lockString(lock), tableId, startRow == null ? null : ByteBuffer.wrap(startRow), + client.flush(Tracer.traceInfo(), context.rpcCreds(), lockString(lock), tableId.canonicalID(), startRow == null ? null : ByteBuffer.wrap(startRow), endRow == null ? null : ByteBuffer.wrap(endRow)); } finally { ThriftUtil.returnClient(client); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java index 1f421bc..bd16d9b 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancer.java @@ -25,6 +25,7 @@ import java.util.Random; import java.util.Set; import java.util.SortedMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.TableInfo; @@ -129,10 +130,11 @@ public class ChaoticLoadBalancer extends TabletBalancer { for (Entry<TServerInstance,TabletServerStatus> e : current.entrySet()) { for (String tableId : e.getValue().getTableMap().keySet()) { - if (!moveMetadata && MetadataTable.ID.equals(tableId)) + Table.ID id = new Table.ID(tableId); + if (!moveMetadata && MetadataTable.ID.equals(id)) continue; try { - for (TabletStats ts : getOnlineTabletsForTable(e.getKey(), tableId)) { + for (TabletStats ts : getOnlineTabletsForTable(e.getKey(), id)) { KeyExtent ke = new KeyExtent(ts.extent); int index = r.nextInt(underCapacityTServer.size()); TServerInstance dest = underCapacityTServer.get(index); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java index f288832..4c85521 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancer.java @@ -27,6 +27,7 @@ import java.util.Objects; import java.util.Set; import java.util.SortedMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.TableInfo; import org.apache.accumulo.core.master.thrift.TabletServerStatus; @@ -42,13 +43,13 @@ public class DefaultLoadBalancer extends TabletBalancer { Iterator<TServerInstance> assignments; // if tableToBalance is set, then only balance the given table - String tableToBalance = null; + Table.ID tableToBalance = null; public DefaultLoadBalancer() { } - public DefaultLoadBalancer(String table) { + public DefaultLoadBalancer(Table.ID table) { tableToBalance = table; } @@ -123,7 +124,7 @@ public class DefaultLoadBalancer extends TabletBalancer { if (current.size() < 2) { return false; } - final Map<String,Map<KeyExtent,TabletStats>> donerTabletStats = new HashMap<>(); + final Map<Table.ID,Map<KeyExtent,TabletStats>> donerTabletStats = new HashMap<>(); // Sort by total number of online tablets, per server int total = 0; @@ -135,7 +136,7 @@ public class DefaultLoadBalancer extends TabletBalancer { /** * The check below was on entry.getKey(), but that resolves to a tabletserver not a tablename. Believe it should be e.getKey() which is a tablename */ - if (tableToBalance == null || tableToBalance.equals(e.getKey())) + if (tableToBalance == null || tableToBalance.canonicalID().equals(e.getKey())) serverTotal += e.getValue().onlineTablets; } } @@ -195,26 +196,26 @@ public class DefaultLoadBalancer extends TabletBalancer { /** * Select a tablet based on differences between table loads; if the loads are even, use the busiest table */ - List<TabletMigration> move(ServerCounts tooMuch, ServerCounts tooLittle, int count, Map<String,Map<KeyExtent,TabletStats>> donerTabletStats) { + List<TabletMigration> move(ServerCounts tooMuch, ServerCounts tooLittle, int count, Map<Table.ID,Map<KeyExtent,TabletStats>> donerTabletStats) { List<TabletMigration> result = new ArrayList<>(); if (count == 0) return result; // Copy counts so we can update them as we propose migrations - Map<String,Integer> tooMuchMap = tabletCountsPerTable(tooMuch.status); - Map<String,Integer> tooLittleMap = tabletCountsPerTable(tooLittle.status); + Map<Table.ID,Integer> tooMuchMap = tabletCountsPerTable(tooMuch.status); + Map<Table.ID,Integer> tooLittleMap = tabletCountsPerTable(tooLittle.status); for (int i = 0; i < count; i++) { - String table; + Table.ID table; Integer tooLittleCount; if (tableToBalance == null) { // find a table to migrate // look for an uneven table count int biggestDifference = 0; - String biggestDifferenceTable = null; - for (Entry<String,Integer> tableEntry : tooMuchMap.entrySet()) { - String tableID = tableEntry.getKey(); + Table.ID biggestDifferenceTable = null; + for (Entry<Table.ID,Integer> tableEntry : tooMuchMap.entrySet()) { + Table.ID tableID = tableEntry.getKey(); if (tooLittleMap.get(tableID) == null) tooLittleMap.put(tableID, 0); int diff = tableEntry.getValue() - tooLittleMap.get(tableID); @@ -270,12 +271,12 @@ public class DefaultLoadBalancer extends TabletBalancer { return result; } - static Map<String,Integer> tabletCountsPerTable(TabletServerStatus status) { - Map<String,Integer> result = new HashMap<>(); + static Map<Table.ID,Integer> tabletCountsPerTable(TabletServerStatus status) { + Map<Table.ID,Integer> result = new HashMap<>(); if (status != null && status.tableMap != null) { Map<String,TableInfo> tableMap = status.tableMap; for (Entry<String,TableInfo> entry : tableMap.entrySet()) { - result.put(entry.getKey(), entry.getValue().onlineTablets); + result.put(new Table.ID(entry.getKey()), entry.getValue().onlineTablets); } } return result; @@ -295,15 +296,15 @@ public class DefaultLoadBalancer extends TabletBalancer { } // define what it means for a tablet to be busy - private static String busiest(Map<String,TableInfo> tables) { - String result = null; + private static Table.ID busiest(Map<String,TableInfo> tables) { + Table.ID result = null; double busiest = Double.NEGATIVE_INFINITY; for (Entry<String,TableInfo> entry : tables.entrySet()) { TableInfo info = entry.getValue(); double busy = info.ingestRate + info.queryRate; if (busy > busiest) { busiest = busy; - result = entry.getKey(); + result = new Table.ID(entry.getKey()); } } return result; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java index f412658..fd15ddd 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/GroupBalancer.java @@ -110,7 +110,7 @@ public abstract class GroupBalancer extends TabletBalancer { } for (KeyExtent keyExtent : migrations) { - if (keyExtent.getTableId().equals(tableId)) { + if (keyExtent.getTableId().canonicalID().equals(tableId)) { return false; } } @@ -774,7 +774,7 @@ public abstract class GroupBalancer extends TabletBalancer { Scanner scanner = new IsolatedScanner(context.getConnector().createScanner(MetadataTable.NAME, Authorizations.EMPTY)); scanner.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME); MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner); - scanner.setRange(MetadataSchema.TabletsSection.getRange(tableId)); + scanner.setRange(MetadataSchema.TabletsSection.getRange(new org.apache.accumulo.core.client.impl.Table.ID(tableId))); RowIterator rowIter = new RowIterator(scanner); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java index cc1c015..945efd0 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java @@ -32,6 +32,7 @@ import java.util.TreeMap; import java.util.regex.Pattern; import org.apache.accumulo.core.client.admin.TableOperations; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.ConfigurationObserver; import org.apache.accumulo.core.conf.ConfigurationTypeHelper; import org.apache.accumulo.core.conf.Property; @@ -79,7 +80,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con protected long oobCheckMillis = ConfigurationTypeHelper.getTimeInMillis(HOST_BALANCER_OOB_DEFAULT); - private Map<String,String> tableIdToTableName = null; + private Map<Table.ID,String> tableIdToTableName = null; private Map<String,Pattern> poolNameToRegexPattern = null; private volatile long lastOOBCheck = System.currentTimeMillis(); private boolean isIpBasedRegex = false; @@ -179,9 +180,10 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con tableIdToTableName = new HashMap<>(); poolNameToRegexPattern = new HashMap<>(); for (Entry<String,String> table : t.tableIdMap().entrySet()) { - tableIdToTableName.put(table.getValue(), table.getKey()); - conf.getTableConfiguration(table.getValue()).addObserver(this); - Map<String,String> customProps = conf.getTableConfiguration(table.getValue()).getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); + Table.ID tableId = new Table.ID(table.getValue()); + tableIdToTableName.put(tableId, table.getKey()); + conf.getTableConfiguration(tableId).addObserver(this); + Map<String,String> customProps = conf.getTableConfiguration(tableId).getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); if (null != customProps && customProps.size() > 0) { for (Entry<String,String> customProp : customProps.entrySet()) { if (customProp.getKey().startsWith(HOST_BALANCER_PREFIX)) { @@ -221,7 +223,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con return buf.toString(); } - public Map<String,String> getTableIdToTableName() { + public Map<Table.ID,String> getTableIdToTableName() { return tableIdToTableName; } @@ -253,7 +255,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con Map<String,SortedMap<TServerInstance,TabletServerStatus>> pools = splitCurrentByRegex(current); // group the unassigned into tables - Map<String,Map<KeyExtent,TServerInstance>> groupedUnassigned = new HashMap<>(); + Map<Table.ID,Map<KeyExtent,TServerInstance>> groupedUnassigned = new HashMap<>(); for (Entry<KeyExtent,TServerInstance> e : unassigned.entrySet()) { Map<KeyExtent,TServerInstance> tableUnassigned = groupedUnassigned.get(e.getKey().getTableId()); if (tableUnassigned == null) { @@ -263,7 +265,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con tableUnassigned.put(e.getKey(), e.getValue()); } // Send a view of the current servers to the tables tablet balancer - for (Entry<String,Map<KeyExtent,TServerInstance>> e : groupedUnassigned.entrySet()) { + for (Entry<Table.ID,Map<KeyExtent,TServerInstance>> e : groupedUnassigned.entrySet()) { Map<KeyExtent,TServerInstance> newAssignments = new HashMap<>(); String tableName = tableIdToTableName.get(e.getKey()); String poolName = getPoolNameForTable(tableName); @@ -311,7 +313,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con continue; } try { - List<TabletStats> outOfBoundsTablets = getOnlineTabletsForTable(e.getKey(), tid); + List<TabletStats> outOfBoundsTablets = getOnlineTabletsForTable(e.getKey(), new Table.ID(tid)); if (null == outOfBoundsTablets) { continue; } @@ -362,7 +364,8 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con } for (String s : tableIdMap.values()) { - String tableName = tableIdToTableName.get(s); + Table.ID tableId = new Table.ID(s); + String tableName = tableIdToTableName.get(tableId); String regexTableName = getPoolNameForTable(tableName); SortedMap<TServerInstance,TabletServerStatus> currentView = currentGrouped.get(regexTableName); if (null == currentView) { @@ -370,7 +373,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer implements Con continue; } ArrayList<TabletMigration> newMigrations = new ArrayList<>(); - getBalancerForTable(s).balance(currentView, migrations, newMigrations); + getBalancerForTable(tableId).balance(currentView, migrations, newMigrations); migrationsOut.addAll(newMigrations); if (migrationsOut.size() > this.maxTServerMigrations) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/RegexGroupBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/RegexGroupBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/RegexGroupBalancer.java index ec8908b..54c76aa 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/RegexGroupBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/RegexGroupBalancer.java @@ -22,6 +22,7 @@ import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.ConfigurationTypeHelper; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.impl.KeyExtent; @@ -57,7 +58,7 @@ public class RegexGroupBalancer extends GroupBalancer { @Override protected long getWaitTime() { - Map<String,String> customProps = context.getServerConfigurationFactory().getTableConfiguration(tableId) + Map<String,String> customProps = context.getServerConfigurationFactory().getTableConfiguration(new Table.ID(tableId)) .getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); if (customProps.containsKey(WAIT_TIME_PROPERTY)) { return ConfigurationTypeHelper.getTimeInMillis(customProps.get(WAIT_TIME_PROPERTY)); @@ -69,7 +70,7 @@ public class RegexGroupBalancer extends GroupBalancer { @Override protected Function<KeyExtent,String> getPartitioner() { - Map<String,String> customProps = context.getServerConfigurationFactory().getTableConfiguration(tableId) + Map<String,String> customProps = context.getServerConfigurationFactory().getTableConfiguration(new Table.ID(tableId)) .getAllPropertiesWithPrefix(Property.TABLE_ARBITRARY_PROP_PREFIX); String regex = customProps.get(REGEX_PROPERTY); final String defaultGroup = customProps.get(DEFAUT_GROUP_PROPERTY); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java index dedf2a2..2b4b552 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TableLoadBalancer.java @@ -28,6 +28,7 @@ import java.util.SortedMap; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.admin.TableOperations; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.state.tables.TableState; @@ -43,21 +44,21 @@ public class TableLoadBalancer extends TabletBalancer { private static final Logger log = LoggerFactory.getLogger(TableLoadBalancer.class); - Map<String,TabletBalancer> perTableBalancers = new HashMap<>(); + Map<Table.ID,TabletBalancer> perTableBalancers = new HashMap<>(); - private TabletBalancer constructNewBalancerForTable(String clazzName, String table) throws Exception { + private TabletBalancer constructNewBalancerForTable(String clazzName, Table.ID tableId) throws Exception { String context = null; - context = this.context.getServerConfigurationFactory().getTableConfiguration(table).get(Property.TABLE_CLASSPATH); + context = this.context.getServerConfigurationFactory().getTableConfiguration(tableId).get(Property.TABLE_CLASSPATH); Class<? extends TabletBalancer> clazz; if (context != null && !context.equals("")) clazz = AccumuloVFSClassLoader.getContextManager().loadClass(context, clazzName, TabletBalancer.class); else clazz = AccumuloVFSClassLoader.loadClass(clazzName, TabletBalancer.class); - Constructor<? extends TabletBalancer> constructor = clazz.getConstructor(String.class); - return constructor.newInstance(table); + Constructor<? extends TabletBalancer> constructor = clazz.getConstructor(Table.ID.class); + return constructor.newInstance(tableId); } - protected String getLoadBalancerClassNameForTable(String table) { + protected String getLoadBalancerClassNameForTable(Table.ID table) { TableState tableState = TableManager.getInstance().getTableState(table); if (tableState == null) return null; @@ -66,10 +67,10 @@ public class TableLoadBalancer extends TabletBalancer { return null; } - protected TabletBalancer getBalancerForTable(String table) { - TabletBalancer balancer = perTableBalancers.get(table); + protected TabletBalancer getBalancerForTable(Table.ID tableId) { + TabletBalancer balancer = perTableBalancers.get(tableId); - String clazzName = getLoadBalancerClassNameForTable(table); + String clazzName = getLoadBalancerClassNameForTable(tableId); if (clazzName == null) clazzName = DefaultLoadBalancer.class.getName(); @@ -78,32 +79,32 @@ public class TableLoadBalancer extends TabletBalancer { // the balancer class for this table does not match the class specified in the configuration try { // attempt to construct a balancer with the specified class - TabletBalancer newBalancer = constructNewBalancerForTable(clazzName, table); + TabletBalancer newBalancer = constructNewBalancerForTable(clazzName, tableId); if (newBalancer != null) { balancer = newBalancer; - perTableBalancers.put(table, balancer); + perTableBalancers.put(tableId, balancer); balancer.init(this.context); } - log.info("Loaded new class " + clazzName + " for table " + table); + log.info("Loaded new class " + clazzName + " for table " + tableId); } catch (Exception e) { - log.warn("Failed to load table balancer class " + clazzName + " for table " + table, e); + log.warn("Failed to load table balancer class " + clazzName + " for table " + tableId, e); } } } if (balancer == null) { try { - balancer = constructNewBalancerForTable(clazzName, table); - log.info("Loaded class " + clazzName + " for table " + table); + balancer = constructNewBalancerForTable(clazzName, tableId); + log.info("Loaded class " + clazzName + " for table " + tableId); } catch (Exception e) { - log.warn("Failed to load table balancer class " + clazzName + " for table " + table, e); + log.warn("Failed to load table balancer class " + clazzName + " for table " + tableId, e); } if (balancer == null) { - log.info("Using balancer " + DefaultLoadBalancer.class.getName() + " for table " + table); - balancer = new DefaultLoadBalancer(table); + log.info("Using balancer " + DefaultLoadBalancer.class.getName() + " for table " + tableId); + balancer = new DefaultLoadBalancer(tableId); } - perTableBalancers.put(table, balancer); + perTableBalancers.put(tableId, balancer); balancer.init(this.context); } return balancer; @@ -113,7 +114,7 @@ public class TableLoadBalancer extends TabletBalancer { public void getAssignments(SortedMap<TServerInstance,TabletServerStatus> current, Map<KeyExtent,TServerInstance> unassigned, Map<KeyExtent,TServerInstance> assignments) { // separate the unassigned into tables - Map<String,Map<KeyExtent,TServerInstance>> groupedUnassigned = new HashMap<>(); + Map<Table.ID,Map<KeyExtent,TServerInstance>> groupedUnassigned = new HashMap<>(); for (Entry<KeyExtent,TServerInstance> e : unassigned.entrySet()) { Map<KeyExtent,TServerInstance> tableUnassigned = groupedUnassigned.get(e.getKey().getTableId()); if (tableUnassigned == null) { @@ -122,7 +123,7 @@ public class TableLoadBalancer extends TabletBalancer { } tableUnassigned.put(e.getKey(), e.getValue()); } - for (Entry<String,Map<KeyExtent,TServerInstance>> e : groupedUnassigned.entrySet()) { + for (Entry<Table.ID,Map<KeyExtent,TServerInstance>> e : groupedUnassigned.entrySet()) { Map<KeyExtent,TServerInstance> newAssignments = new HashMap<>(); getBalancerForTable(e.getKey()).getAssignments(current, e.getValue(), newAssignments); assignments.putAll(newAssignments); @@ -152,7 +153,7 @@ public class TableLoadBalancer extends TabletBalancer { return minBalanceTime; for (String s : t.tableIdMap().values()) { ArrayList<TabletMigration> newMigrations = new ArrayList<>(); - long tableBalanceTime = getBalancerForTable(s).balance(current, migrations, newMigrations); + long tableBalanceTime = getBalancerForTable(new Table.ID(s)).balance(current, migrations, newMigrations); if (tableBalanceTime < minBalanceTime) minBalanceTime = tableBalanceTime; migrationsOut.addAll(newMigrations); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java index 81ebe7a..00372fa 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/TabletBalancer.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Set; import java.util.SortedMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.data.impl.KeyExtent; @@ -204,11 +205,11 @@ public abstract class TabletBalancer { * @throws TException * any other problem */ - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID tableId) throws ThriftSecurityException, TException { log.debug("Scanning tablet server " + tserver + " for table " + tableId); Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), tserver.getLocation(), context); try { - return client.getTabletStats(Tracer.traceInfo(), context.rpcCreds(), tableId); + return client.getTabletStats(Tracer.traceInfo(), context.rpcCreds(), tableId.canonicalID()); } catch (TTransportException e) { log.error("Unable to connect to " + tserver + ": " + e); } finally { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/state/CurrentState.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/CurrentState.java b/server/base/src/main/java/org/apache/accumulo/server/master/state/CurrentState.java index c7f8b5d..e0bc4fb 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/state/CurrentState.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/CurrentState.java @@ -19,12 +19,13 @@ package org.apache.accumulo.server.master.state; import java.util.Collection; import java.util.Set; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.MasterState; public interface CurrentState { - Set<String> onlineTables(); + Set<Table.ID> onlineTables(); Set<TServerInstance> onlineTabletServers(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java b/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java index c0dca50..8f372b3 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java +++ b/server/base/src/main/java/org/apache/accumulo/server/master/state/TabletStateChangeIterator.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import org.apache.accumulo.core.client.IteratorSetting; +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; @@ -58,7 +59,7 @@ public class TabletStateChangeIterator extends SkippingIterator { private Set<TServerInstance> current; private Set<String> onlineTables; - private Map<String,MergeInfo> merges; + private Map<Table.ID,MergeInfo> merges; private boolean debug = false; private Set<KeyExtent> migrations; private MasterState masterState = MasterState.NORMAL; @@ -130,11 +131,11 @@ public class TabletStateChangeIterator extends SkippingIterator { return result; } - private Map<String,MergeInfo> parseMerges(String merges) { + private Map<Table.ID,MergeInfo> parseMerges(String merges) { if (merges == null) return null; try { - Map<String,MergeInfo> result = new HashMap<>(); + Map<Table.ID,MergeInfo> result = new HashMap<>(); DataInputBuffer buffer = new DataInputBuffer(); byte[] data = Base64.getDecoder().decode(merges); buffer.reset(data, data.length); @@ -179,7 +180,7 @@ public class TabletStateChangeIterator extends SkippingIterator { } // is the table supposed to be online or offline? - boolean shouldBeOnline = onlineTables.contains(tls.extent.getTableId()); + boolean shouldBeOnline = onlineTables.contains(tls.extent.getTableId().canonicalID()); if (debug) { log.debug(tls.extent + " is " + tls.getState(current) + " and should be " + (shouldBeOnline ? "on" : "off") + "line"); @@ -221,7 +222,7 @@ public class TabletStateChangeIterator extends SkippingIterator { } } - public static void setOnlineTables(IteratorSetting cfg, Set<String> onlineTables) { + public static void setOnlineTables(IteratorSetting cfg, Set<Table.ID> onlineTables) { if (onlineTables != null) cfg.addOption(TABLES_OPTION, Joiner.on(",").join(onlineTables)); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java index 8685034..532c791 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java +++ b/server/base/src/main/java/org/apache/accumulo/server/problems/ProblemReport.java @@ -29,6 +29,7 @@ import java.util.Map.Entry; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +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; @@ -44,14 +45,14 @@ import org.apache.hadoop.io.Text; import org.apache.zookeeper.KeeperException; public class ProblemReport { - private String tableId; + private Table.ID tableId; private ProblemType problemType; private String resource; private String exception; private String server; private long creationTime; - public ProblemReport(String tableId, ProblemType problemType, String resource, String server, Throwable e, long creationTime) { + public ProblemReport(Table.ID tableId, ProblemType problemType, String resource, String server, Throwable e, long creationTime) { requireNonNull(tableId, "tableId is null"); requireNonNull(problemType, "problemType is null"); requireNonNull(resource, "resource is null"); @@ -76,15 +77,15 @@ public class ProblemReport { this.creationTime = creationTime; } - public ProblemReport(String tableId, ProblemType problemType, String resource, String server, Throwable e) { + public ProblemReport(Table.ID tableId, ProblemType problemType, String resource, String server, Throwable e) { this(tableId, problemType, resource, server, e, System.currentTimeMillis()); } - public ProblemReport(String tableId, ProblemType problemType, String resource, Throwable e) { + public ProblemReport(Table.ID tableId, ProblemType problemType, String resource, Throwable e) { this(tableId, problemType, resource, null, e); } - private ProblemReport(String table, ProblemType problemType, String resource, byte enc[]) throws IOException { + private ProblemReport(Table.ID table, ProblemType problemType, String resource, byte enc[]) throws IOException { requireNonNull(table, "table is null"); requireNonNull(problemType, "problemType is null"); requireNonNull(resource, "resource is null"); @@ -168,7 +169,7 @@ public class ProblemReport { private String getZPath(Instance instance) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); - dos.writeUTF(getTableName()); + dos.writeUTF(getTableId().canonicalID()); dos.writeUTF(getProblemType().name()); dos.writeUTF(getResource()); dos.close(); @@ -188,7 +189,7 @@ public class ProblemReport { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); DataInputStream dis = new DataInputStream(bais); - String tableId = dis.readUTF(); + Table.ID tableId = new Table.ID(dis.readUTF()); String problemType = dis.readUTF(); String resource = dis.readUTF(); @@ -200,14 +201,14 @@ public class ProblemReport { } public static ProblemReport decodeMetadataEntry(Entry<Key,Value> entry) throws IOException { - String tableId = entry.getKey().getRow().toString().substring("~err_".length()); + Table.ID tableId = new Table.ID(entry.getKey().getRow().toString().substring("~err_".length())); String problemType = entry.getKey().getColumnFamily().toString(); String resource = entry.getKey().getColumnQualifier().toString(); return new ProblemReport(tableId, ProblemType.valueOf(problemType), resource, entry.getValue().get()); } - public String getTableName() { + public Table.ID getTableId() { return tableId; }
