use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.
the class GarbageCollectWriteAheadLogsTest method deleteUnreferenceLogOnDeadServer.
@Test
public void deleteUnreferenceLogOnDeadServer() throws Exception {
AccumuloServerContext context = EasyMock.createMock(AccumuloServerContext.class);
VolumeManager fs = EasyMock.createMock(VolumeManager.class);
WalStateManager marker = EasyMock.createMock(WalStateManager.class);
LiveTServerSet tserverSet = EasyMock.createMock(LiveTServerSet.class);
Connector conn = EasyMock.createMock(Connector.class);
Scanner mscanner = EasyMock.createMock(Scanner.class);
Scanner rscanner = EasyMock.createMock(Scanner.class);
GCStatus status = new GCStatus(null, null, null, new GcCycleStats());
EasyMock.expect(tserverSet.getCurrentServers()).andReturn(Collections.singleton(server1));
EasyMock.expect(marker.getAllMarkers()).andReturn(markers2).once();
EasyMock.expect(marker.state(server2, id)).andReturn(new Pair<>(WalState.OPEN, path));
EasyMock.expect(context.getConnector()).andReturn(conn);
EasyMock.expect(conn.createScanner(ReplicationTable.NAME, Authorizations.EMPTY)).andReturn(rscanner);
rscanner.fetchColumnFamily(ReplicationSchema.StatusSection.NAME);
EasyMock.expectLastCall().once();
EasyMock.expect(rscanner.iterator()).andReturn(emptyKV);
EasyMock.expect(conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)).andReturn(mscanner);
mscanner.fetchColumnFamily(MetadataSchema.ReplicationSection.COLF);
EasyMock.expectLastCall().once();
mscanner.setRange(MetadataSchema.ReplicationSection.getRange());
EasyMock.expectLastCall().once();
EasyMock.expect(mscanner.iterator()).andReturn(emptyKV);
EasyMock.expect(fs.deleteRecursively(path)).andReturn(true).once();
marker.removeWalMarker(server2, id);
EasyMock.expectLastCall().once();
marker.forget(server2);
EasyMock.expectLastCall().once();
EasyMock.replay(context, fs, marker, tserverSet, conn, rscanner, mscanner);
GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer1List);
gc.collect(status);
EasyMock.verify(context, fs, marker, tserverSet, conn, rscanner, mscanner);
}
use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.
the class GarbageCollectWriteAheadLogsTest method testRemoveUnusedLog.
@Test
public void testRemoveUnusedLog() throws Exception {
AccumuloServerContext context = EasyMock.createMock(AccumuloServerContext.class);
VolumeManager fs = EasyMock.createMock(VolumeManager.class);
WalStateManager marker = EasyMock.createMock(WalStateManager.class);
LiveTServerSet tserverSet = EasyMock.createMock(LiveTServerSet.class);
GCStatus status = new GCStatus(null, null, null, new GcCycleStats());
EasyMock.expect(tserverSet.getCurrentServers()).andReturn(Collections.singleton(server1));
EasyMock.expect(marker.getAllMarkers()).andReturn(markers).once();
EasyMock.expect(marker.state(server1, id)).andReturn(new Pair<>(WalState.UNREFERENCED, path));
EasyMock.expect(fs.deleteRecursively(path)).andReturn(true).once();
marker.removeWalMarker(server1, id);
EasyMock.expectLastCall().once();
EasyMock.replay(context, fs, marker, tserverSet);
GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer1List) {
@Override
protected int removeReplicationEntries(Map<UUID, TServerInstance> candidates) throws IOException, KeeperException, InterruptedException {
return 0;
}
};
gc.collect(status);
EasyMock.verify(context, fs, marker, tserverSet);
}
use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.
the class HostRegexTableLoadBalancerReconfigurationTest method testConfigurationChanges.
@Test
public void testConfigurationChanges() {
init(new AccumuloServerContext(instance, factory));
Map<KeyExtent, TServerInstance> unassigned = new HashMap<>();
for (List<KeyExtent> extents : tableExtents.values()) {
for (KeyExtent ke : extents) {
unassigned.put(ke, null);
}
}
this.getAssignments(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments);
Assert.assertEquals(15, assignments.size());
// Ensure unique tservers
for (Entry<KeyExtent, TServerInstance> e : assignments.entrySet()) {
for (Entry<KeyExtent, TServerInstance> e2 : assignments.entrySet()) {
if (e.getKey().equals(e2.getKey())) {
continue;
}
if (e.getValue().equals(e2.getValue())) {
Assert.fail("Assignment failure. " + e.getKey() + " and " + e2.getKey() + " are assigned to the same host: " + e.getValue());
}
}
}
// Ensure assignments are correct
for (Entry<KeyExtent, TServerInstance> e : assignments.entrySet()) {
if (!tabletInBounds(e.getKey(), e.getValue())) {
Assert.fail("tablet not in bounds: " + e.getKey() + " -> " + e.getValue().host());
}
}
Set<KeyExtent> migrations = new HashSet<>();
List<TabletMigration> migrationsOut = new ArrayList<>();
// Wait to trigger the out of bounds check which will call our version of getOnlineTabletsForTable
UtilWaitThread.sleep(3000);
this.balance(Collections.unmodifiableSortedMap(allTabletServers), migrations, migrationsOut);
Assert.assertEquals(0, migrationsOut.size());
// Change property, simulate call by TableConfWatcher
DEFAULT_TABLE_PROPERTIES.put(HostRegexTableLoadBalancer.HOST_BALANCER_PREFIX + BAR.getTableName(), "r01.*");
this.propertiesChanged();
// Wait to trigger the out of bounds check and the repool check
UtilWaitThread.sleep(10000);
this.balance(Collections.unmodifiableSortedMap(allTabletServers), migrations, migrationsOut);
Assert.assertEquals(5, migrationsOut.size());
for (TabletMigration migration : migrationsOut) {
Assert.assertTrue(migration.newServer.host().startsWith("192.168.0.1") || migration.newServer.host().startsWith("192.168.0.2") || migration.newServer.host().startsWith("192.168.0.3") || migration.newServer.host().startsWith("192.168.0.4") || migration.newServer.host().startsWith("192.168.0.5"));
}
}
use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testAllUnassigned.
@Test
public void testAllUnassigned() {
init(new AccumuloServerContext(instance, factory));
Map<KeyExtent, TServerInstance> assignments = new HashMap<>();
Map<KeyExtent, TServerInstance> unassigned = new HashMap<>();
for (List<KeyExtent> extents : tableExtents.values()) {
for (KeyExtent ke : extents) {
unassigned.put(ke, null);
}
}
this.getAssignments(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments);
Assert.assertEquals(15, assignments.size());
// Ensure unique tservers
for (Entry<KeyExtent, TServerInstance> e : assignments.entrySet()) {
for (Entry<KeyExtent, TServerInstance> e2 : assignments.entrySet()) {
if (e.getKey().equals(e2.getKey())) {
continue;
}
if (e.getValue().equals(e2.getValue())) {
Assert.fail("Assignment failure");
}
}
}
// Ensure assignments are correct
for (Entry<KeyExtent, TServerInstance> e : assignments.entrySet()) {
if (!tabletInBounds(e.getKey(), e.getValue())) {
Assert.fail("tablet not in bounds: " + e.getKey() + " -> " + e.getValue().host());
}
}
}
use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testBalance.
@Test
public void testBalance() {
init(new AccumuloServerContext(instance, factory));
Set<KeyExtent> migrations = new HashSet<>();
List<TabletMigration> migrationsOut = new ArrayList<>();
long wait = this.balance(Collections.unmodifiableSortedMap(createCurrent(15)), migrations, migrationsOut);
Assert.assertEquals(20000, wait);
// should balance four tablets in one of the tables before reaching max
Assert.assertEquals(4, migrationsOut.size());
// now balance again passing in the new migrations
for (TabletMigration m : migrationsOut) {
migrations.add(m.tablet);
}
migrationsOut.clear();
wait = this.balance(Collections.unmodifiableSortedMap(createCurrent(15)), migrations, migrationsOut);
Assert.assertEquals(20000, wait);
// should balance four tablets in one of the other tables before reaching max
Assert.assertEquals(4, migrationsOut.size());
// now balance again passing in the new migrations
for (TabletMigration m : migrationsOut) {
migrations.add(m.tablet);
}
migrationsOut.clear();
wait = this.balance(Collections.unmodifiableSortedMap(createCurrent(15)), migrations, migrationsOut);
Assert.assertEquals(20000, wait);
// should balance four tablets in one of the other tables before reaching max
Assert.assertEquals(4, migrationsOut.size());
// now balance again passing in the new migrations
for (TabletMigration m : migrationsOut) {
migrations.add(m.tablet);
}
migrationsOut.clear();
wait = this.balance(Collections.unmodifiableSortedMap(createCurrent(15)), migrations, migrationsOut);
Assert.assertEquals(20000, wait);
// no more balancing to do
Assert.assertEquals(0, migrationsOut.size());
}
Aggregations