Search in sources :

Example 6 with TabletServerId

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());
        }
    }
}
Also used : HashMap(java.util.HashMap) TabletServerId(org.apache.accumulo.core.spi.balancer.data.TabletServerId) ArrayList(java.util.ArrayList) TServerStatus(org.apache.accumulo.core.spi.balancer.data.TServerStatus) TabletId(org.apache.accumulo.core.data.TabletId) AssignmentParamsImpl(org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl) Test(org.junit.jupiter.api.Test)

Example 7 with TabletServerId

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());
        }
    }
}
Also used : HashMap(java.util.HashMap) TabletServerId(org.apache.accumulo.core.spi.balancer.data.TabletServerId) ArrayList(java.util.ArrayList) TServerStatus(org.apache.accumulo.core.spi.balancer.data.TServerStatus) TabletId(org.apache.accumulo.core.data.TabletId) AssignmentParamsImpl(org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl) Test(org.junit.jupiter.api.Test)

Example 8 with TabletServerId

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());
}
Also used : HashMap(java.util.HashMap) TabletServerId(org.apache.accumulo.core.spi.balancer.data.TabletServerId) TabletId(org.apache.accumulo.core.data.TabletId) AssignmentParamsImpl(org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl) Test(org.junit.jupiter.api.Test)

Example 9 with TabletServerId

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());
        }
    }
}
Also used : HashMap(java.util.HashMap) TabletServerId(org.apache.accumulo.core.spi.balancer.data.TabletServerId) TabletId(org.apache.accumulo.core.data.TabletId) AssignmentParamsImpl(org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl) Test(org.junit.jupiter.api.Test)

Example 10 with TabletServerId

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());
        }
    }
}
Also used : HashMap(java.util.HashMap) TabletServerId(org.apache.accumulo.core.spi.balancer.data.TabletServerId) TabletId(org.apache.accumulo.core.data.TabletId) AssignmentParamsImpl(org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl) Test(org.junit.jupiter.api.Test)

Aggregations

TabletServerId (org.apache.accumulo.core.spi.balancer.data.TabletServerId)26 TabletId (org.apache.accumulo.core.data.TabletId)22 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)14 TabletMigration (org.apache.accumulo.core.spi.balancer.data.TabletMigration)11 AssignmentParamsImpl (org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl)10 TabletServerIdImpl (org.apache.accumulo.core.manager.balancer.TabletServerIdImpl)10 TServerStatus (org.apache.accumulo.core.spi.balancer.data.TServerStatus)10 Test (org.junit.jupiter.api.Test)10 TableId (org.apache.accumulo.core.data.TableId)8 TreeMap (java.util.TreeMap)7 BalanceParamsImpl (org.apache.accumulo.core.manager.balancer.BalanceParamsImpl)7 Map (java.util.Map)6 SortedMap (java.util.SortedMap)5 TServerStatusImpl (org.apache.accumulo.core.manager.balancer.TServerStatusImpl)4 TabletStatistics (org.apache.accumulo.core.spi.balancer.data.TabletStatistics)4 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)3 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)3 TableStatistics (org.apache.accumulo.core.spi.balancer.data.TableStatistics)3 Collections (java.util.Collections)2