use of org.apache.accumulo.core.spi.balancer.data.TabletServerId in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testUnassignedWithNoDefaultPool.
@Test
public void testUnassignedWithNoDefaultPool() {
init(DEFAULT_TABLE_PROPERTIES);
Map<TabletId, TabletServerId> assignments = new HashMap<>();
Map<TabletId, TabletServerId> unassigned = new HashMap<>();
for (TabletId tabletId : tableTablets.get(BAR.getTableName())) {
unassigned.put(tabletId, null);
}
SortedMap<TabletServerId, TServerStatus> current = createCurrent(15);
// Remove the BAR tablet servers and default pool from current
List<TabletServerId> removals = new ArrayList<>();
for (Entry<TabletServerId, TServerStatus> e : current.entrySet()) {
if (e.getKey().getHost().equals("192.168.0.6") || e.getKey().getHost().equals("192.168.0.7") || e.getKey().getHost().equals("192.168.0.8") || e.getKey().getHost().equals("192.168.0.9") || e.getKey().getHost().equals("192.168.0.10") || e.getKey().getHost().equals("192.168.0.11") || e.getKey().getHost().equals("192.168.0.12") || e.getKey().getHost().equals("192.168.0.13") || e.getKey().getHost().equals("192.168.0.14") || e.getKey().getHost().equals("192.168.0.15")) {
removals.add(e.getKey());
}
}
for (TabletServerId r : removals) {
current.remove(r);
}
this.getAssignments(new AssignmentParamsImpl(Collections.unmodifiableSortedMap(current), Collections.unmodifiableMap(unassigned), assignments));
assertEquals(unassigned.size(), assignments.size());
// Ensure tablets are assigned in default pool
for (Entry<TabletId, TabletServerId> e : assignments.entrySet()) {
if (tabletInBounds(e.getKey(), e.getValue())) {
fail("tablet unexpectedly in bounds: " + e.getKey() + " -> " + e.getValue().getHost());
}
}
}
use of org.apache.accumulo.core.spi.balancer.data.TabletServerId in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testUnassignedWithNoTServers.
@Test
public void testUnassignedWithNoTServers() {
init(DEFAULT_TABLE_PROPERTIES);
Map<TabletId, TabletServerId> assignments = new HashMap<>();
Map<TabletId, TabletServerId> unassigned = new HashMap<>();
for (TabletId tabletId : tableTablets.get(BAR.getTableName())) {
unassigned.put(tabletId, null);
}
SortedMap<TabletServerId, TServerStatus> current = createCurrent(15);
// Remove the BAR tablet servers from current
List<TabletServerId> removals = new ArrayList<>();
for (Entry<TabletServerId, TServerStatus> e : current.entrySet()) {
if (e.getKey().getHost().equals("192.168.0.6") || e.getKey().getHost().equals("192.168.0.7") || e.getKey().getHost().equals("192.168.0.8") || e.getKey().getHost().equals("192.168.0.9") || e.getKey().getHost().equals("192.168.0.10")) {
removals.add(e.getKey());
}
}
for (TabletServerId r : removals) {
current.remove(r);
}
this.getAssignments(new AssignmentParamsImpl(Collections.unmodifiableSortedMap(current), Collections.unmodifiableMap(unassigned), assignments));
assertEquals(unassigned.size(), assignments.size());
// Ensure tablets are assigned in default pool
for (Entry<TabletId, TabletServerId> e : assignments.entrySet()) {
if (tabletInBounds(e.getKey(), e.getValue())) {
fail("tablet unexpectedly in bounds: " + e.getKey() + " -> " + e.getValue().getHost());
}
}
}
use of org.apache.accumulo.core.spi.balancer.data.TabletServerId in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testAllAssigned.
@Test
public void testAllAssigned() {
init(DEFAULT_TABLE_PROPERTIES);
Map<TabletId, TabletServerId> assignments = new HashMap<>();
this.getAssignments(new AssignmentParamsImpl(Collections.unmodifiableSortedMap(allTabletServers), Map.of(), assignments));
assertEquals(0, assignments.size());
}
use of org.apache.accumulo.core.spi.balancer.data.TabletServerId in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testAllUnassigned.
@Test
public void testAllUnassigned() {
init(DEFAULT_TABLE_PROPERTIES);
Map<TabletId, TabletServerId> assignments = new HashMap<>();
Map<TabletId, TabletServerId> unassigned = new HashMap<>();
for (List<TabletId> extents : tableTablets.values()) {
for (TabletId tabletId : extents) {
unassigned.put(tabletId, null);
}
}
this.getAssignments(new AssignmentParamsImpl(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments));
assertEquals(15, assignments.size());
// Ensure unique tservers
for (Entry<TabletId, TabletServerId> e : assignments.entrySet()) {
for (Entry<TabletId, TabletServerId> e2 : assignments.entrySet()) {
if (e.getKey().equals(e2.getKey())) {
continue;
}
if (e.getValue().equals(e2.getValue())) {
fail("Assignment failure");
}
}
}
// Ensure assignments are correct
for (Entry<TabletId, TabletServerId> e : assignments.entrySet()) {
if (!tabletInBounds(e.getKey(), e.getValue())) {
fail("tablet not in bounds: " + e.getKey() + " -> " + e.getValue().getHost());
}
}
}
use of org.apache.accumulo.core.spi.balancer.data.TabletServerId in project accumulo by apache.
the class HostRegexTableLoadBalancerTest method testPartiallyAssigned.
@Test
public void testPartiallyAssigned() {
init(DEFAULT_TABLE_PROPERTIES);
Map<TabletId, TabletServerId> assignments = new HashMap<>();
Map<TabletId, TabletServerId> unassigned = new HashMap<>();
int i = 0;
for (List<TabletId> tablets : tableTablets.values()) {
for (TabletId tabletId : tablets) {
if ((i % 2) == 0) {
unassigned.put(tabletId, null);
}
i++;
}
}
this.getAssignments(new AssignmentParamsImpl(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments));
assertEquals(unassigned.size(), assignments.size());
// Ensure unique tservers
for (Entry<TabletId, TabletServerId> e : assignments.entrySet()) {
for (Entry<TabletId, TabletServerId> e2 : assignments.entrySet()) {
if (e.getKey().equals(e2.getKey())) {
continue;
}
if (e.getValue().equals(e2.getValue())) {
fail("Assignment failure");
}
}
}
// Ensure assignments are correct
for (Entry<TabletId, TabletServerId> e : assignments.entrySet()) {
if (!tabletInBounds(e.getKey(), e.getValue())) {
fail("tablet not in bounds: " + e.getKey() + " -> " + e.getValue().getHost());
}
}
}
Aggregations