use of org.apache.accumulo.server.conf.NamespaceConfiguration in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testSplitCurrentByRegexUsingOverlappingPools.
@Test
public void testSplitCurrentByRegexUsingOverlappingPools() {
init(new AccumuloServerContext(instance, new TestServerConfigurationFactory(instance) {
@Override
public TableConfiguration getTableConfiguration(Table.ID tableId) {
NamespaceConfiguration defaultConf = new NamespaceConfiguration(Namespace.ID.DEFAULT, this.instance, DefaultConfiguration.getInstance());
return new TableConfiguration(instance, tableId, defaultConf) {
HashMap<String, String> tableProperties = new HashMap<>();
{
tableProperties.put(HostRegexTableLoadBalancer.HOST_BALANCER_PREFIX + FOO.getTableName(), "r.*");
tableProperties.put(HostRegexTableLoadBalancer.HOST_BALANCER_PREFIX + BAR.getTableName(), "r01.*|r02.*");
}
@Override
public String get(Property property) {
return tableProperties.get(property.name());
}
@Override
public void getProperties(Map<String, String> props, Predicate<String> filter) {
for (Entry<String, String> e : tableProperties.entrySet()) {
if (filter.test(e.getKey())) {
props.put(e.getKey(), e.getValue());
}
}
}
@Override
public long getUpdateCount() {
return 0;
}
};
}
}));
Map<String, SortedMap<TServerInstance, TabletServerStatus>> groups = this.splitCurrentByRegex(createCurrent(15));
Assert.assertEquals(2, groups.size());
Assert.assertTrue(groups.containsKey(FOO.getTableName()));
SortedMap<TServerInstance, TabletServerStatus> fooHosts = groups.get(FOO.getTableName());
Assert.assertEquals(15, fooHosts.size());
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.1:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.2:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.3:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.4:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.5:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.6:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.7:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.8:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.9:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.10:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.11:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.12:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.13:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.14:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.15:9997", 1)));
Assert.assertTrue(groups.containsKey(BAR.getTableName()));
SortedMap<TServerInstance, TabletServerStatus> barHosts = groups.get(BAR.getTableName());
Assert.assertEquals(10, barHosts.size());
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.1:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.2:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.3:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.4:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.5:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.6:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.7:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.8:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.9:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.10:9997", 1)));
}
use of org.apache.accumulo.server.conf.NamespaceConfiguration in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testSplitCurrentByRegexUsingIP.
@Test
public void testSplitCurrentByRegexUsingIP() {
init(new AccumuloServerContext(instance, new TestServerConfigurationFactory(instance) {
@Override
public synchronized AccumuloConfiguration getSystemConfiguration() {
HashMap<String, String> props = new HashMap<>();
props.put(HostRegexTableLoadBalancer.HOST_BALANCER_OOB_CHECK_KEY, "30s");
props.put(HostRegexTableLoadBalancer.HOST_BALANCER_REGEX_USING_IPS_KEY, "true");
return new ConfigurationCopy(props);
}
@Override
public TableConfiguration getTableConfiguration(Table.ID tableId) {
NamespaceConfiguration defaultConf = new NamespaceConfiguration(Namespace.ID.DEFAULT, this.instance, DefaultConfiguration.getInstance());
return new TableConfiguration(instance, tableId, defaultConf) {
HashMap<String, String> tableProperties = new HashMap<>();
{
tableProperties.put(HostRegexTableLoadBalancer.HOST_BALANCER_PREFIX + FOO.getTableName(), "192\\.168\\.0\\.[1-5]");
tableProperties.put(HostRegexTableLoadBalancer.HOST_BALANCER_PREFIX + BAR.getTableName(), "192\\.168\\.0\\.[6-9]|192\\.168\\.0\\.10");
}
@Override
public String get(Property property) {
return tableProperties.get(property.name());
}
@Override
public void getProperties(Map<String, String> props, Predicate<String> filter) {
for (Entry<String, String> e : tableProperties.entrySet()) {
if (filter.test(e.getKey())) {
props.put(e.getKey(), e.getValue());
}
}
}
@Override
public long getUpdateCount() {
return 0;
}
};
}
}));
Assert.assertTrue(isIpBasedRegex());
Map<String, SortedMap<TServerInstance, TabletServerStatus>> groups = this.splitCurrentByRegex(createCurrent(15));
Assert.assertEquals(3, groups.size());
Assert.assertTrue(groups.containsKey(FOO.getTableName()));
SortedMap<TServerInstance, TabletServerStatus> fooHosts = groups.get(FOO.getTableName());
Assert.assertEquals(5, fooHosts.size());
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.1:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.2:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.3:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.4:9997", 1)));
Assert.assertTrue(fooHosts.containsKey(new TServerInstance("192.168.0.5:9997", 1)));
Assert.assertTrue(groups.containsKey(BAR.getTableName()));
SortedMap<TServerInstance, TabletServerStatus> barHosts = groups.get(BAR.getTableName());
Assert.assertEquals(5, barHosts.size());
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.6:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.7:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.8:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.9:9997", 1)));
Assert.assertTrue(barHosts.containsKey(new TServerInstance("192.168.0.10:9997", 1)));
Assert.assertTrue(groups.containsKey(DEFAULT_POOL));
SortedMap<TServerInstance, TabletServerStatus> defHosts = groups.get(DEFAULT_POOL);
Assert.assertEquals(5, defHosts.size());
Assert.assertTrue(defHosts.containsKey(new TServerInstance("192.168.0.11:9997", 1)));
Assert.assertTrue(defHosts.containsKey(new TServerInstance("192.168.0.12:9997", 1)));
Assert.assertTrue(defHosts.containsKey(new TServerInstance("192.168.0.13:9997", 1)));
Assert.assertTrue(defHosts.containsKey(new TServerInstance("192.168.0.14:9997", 1)));
Assert.assertTrue(defHosts.containsKey(new TServerInstance("192.168.0.15:9997", 1)));
}
use of org.apache.accumulo.server.conf.NamespaceConfiguration in project accumulo by apache.
the class TableLoadBalancerTest method test.
@Test
public void test() throws Exception {
final Instance inst = EasyMock.createMock(Instance.class);
EasyMock.expect(inst.getInstanceID()).andReturn(UUID.nameUUIDFromBytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }).toString()).anyTimes();
EasyMock.expect(inst.getZooKeepers()).andReturn("10.0.0.1:1234").anyTimes();
EasyMock.expect(inst.getZooKeepersSessionTimeOut()).andReturn(30_000).anyTimes();
EasyMock.replay(inst);
ServerConfigurationFactory confFactory = new ServerConfigurationFactory(inst) {
@Override
public TableConfiguration getTableConfiguration(Table.ID tableId) {
// create a dummy namespaceConfiguration to satisfy requireNonNull in TableConfiguration constructor
NamespaceConfiguration dummyConf = new NamespaceConfiguration(null, inst, null);
return new TableConfiguration(inst, tableId, dummyConf) {
@Override
public String get(Property property) {
// fake the get table configuration so the test doesn't try to look in zookeeper for per-table classpath stuff
return DefaultConfiguration.getInstance().get(property);
}
};
}
};
String t1Id = TABLE_ID_MAP.get("t1"), t2Id = TABLE_ID_MAP.get("t2"), t3Id = TABLE_ID_MAP.get("t3");
state = new TreeMap<>();
TServerInstance svr = mkts("10.0.0.1", "0x01020304");
state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
Set<KeyExtent> migrations = Collections.emptySet();
List<TabletMigration> migrationsOut = new ArrayList<>();
TableLoadBalancer tls = new TableLoadBalancer();
tls.init(new AccumuloServerContext(inst, confFactory));
tls.balance(state, migrations, migrationsOut);
Assert.assertEquals(0, migrationsOut.size());
state.put(mkts("10.0.0.2", "0x02030405"), status());
tls = new TableLoadBalancer();
tls.init(new AccumuloServerContext(inst, confFactory));
tls.balance(state, migrations, migrationsOut);
int count = 0;
Map<Table.ID, Integer> movedByTable = new HashMap<>();
movedByTable.put(Table.ID.of(t1Id), 0);
movedByTable.put(Table.ID.of(t2Id), 0);
movedByTable.put(Table.ID.of(t3Id), 0);
for (TabletMigration migration : migrationsOut) {
if (migration.oldServer.equals(svr))
count++;
Table.ID key = migration.tablet.getTableId();
movedByTable.put(key, movedByTable.get(key) + 1);
}
Assert.assertEquals(15, count);
for (Integer moved : movedByTable.values()) {
Assert.assertEquals(5, moved.intValue());
}
}
use of org.apache.accumulo.server.conf.NamespaceConfiguration in project accumulo by apache.
the class LargestFirstMemoryManagerTest method testDeletedTable.
@Test
public void testDeletedTable() throws Exception {
final String deletedTableId = "1";
Function<Table.ID, Boolean> existenceCheck = tableId -> !deletedTableId.contentEquals(tableId.canonicalID());
LargestFirstMemoryManagerWithExistenceCheck mgr = new LargestFirstMemoryManagerWithExistenceCheck(existenceCheck);
ServerConfiguration config = new ServerConfiguration() {
ServerConfigurationFactory delegate = new ServerConfigurationFactory(inst);
@Override
public AccumuloConfiguration getSystemConfiguration() {
return DefaultConfiguration.getInstance();
}
@Override
public TableConfiguration getTableConfiguration(Table.ID tableId) {
return delegate.getTableConfiguration(tableId);
}
@Override
public NamespaceConfiguration getNamespaceConfiguration(Namespace.ID namespaceId) {
return delegate.getNamespaceConfiguration(namespaceId);
}
};
mgr.init(config);
MemoryManagementActions result;
// one tablet is really big and the other is for a nonexistent table
KeyExtent extent = new KeyExtent(Table.ID.of("2"), new Text("j"), null);
result = mgr.getMemoryManagementActions(tablets(t(extent, ZERO, ONE_GIG, 0), t(k("j"), ZERO, ONE_GIG, 0)));
assertEquals(1, result.tabletsToMinorCompact.size());
assertEquals(extent, result.tabletsToMinorCompact.get(0));
}
use of org.apache.accumulo.server.conf.NamespaceConfiguration in project accumulo by apache.
the class TableConfigurationUpdateIT method test.
@Test
public void test() throws Exception {
Connector conn = getConnector();
Instance inst = conn.getInstance();
String table = getUniqueNames(1)[0];
conn.tableOperations().create(table);
final NamespaceConfiguration defaultConf = new NamespaceConfiguration(Namespace.ID.DEFAULT, inst, DefaultConfiguration.getInstance());
// Cache invalidates 25% of the time
int randomMax = 4;
// Number of threads
int numThreads = 2;
// Number of iterations per thread
int iterations = 100000;
AccumuloConfiguration tableConf = new TableConfiguration(inst, org.apache.accumulo.core.client.impl.Table.ID.of(table), defaultConf);
long start = System.currentTimeMillis();
ExecutorService svc = Executors.newFixedThreadPool(numThreads);
CountDownLatch countDown = new CountDownLatch(numThreads);
ArrayList<Future<Exception>> futures = new ArrayList<>(numThreads);
for (int i = 0; i < numThreads; i++) {
futures.add(svc.submit(new TableConfRunner(randomMax, iterations, tableConf, countDown)));
}
svc.shutdown();
Assert.assertTrue(svc.awaitTermination(60, TimeUnit.MINUTES));
for (Future<Exception> fut : futures) {
Exception e = fut.get();
if (null != e) {
Assert.fail("Thread failed with exception " + e);
}
}
long end = System.currentTimeMillis();
log.debug("{} with {} iterations and {} threads and cache invalidates {}% took {} second(s)", tableConf, iterations, numThreads, ((1. / randomMax) * 100.), (end - start) / 1000);
}
Aggregations