Search in sources :

Example 1 with AssignmentParamsImpl

use of org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl in project accumulo by apache.

the class TableLoadBalancer method getAssignments.

@Override
public void getAssignments(AssignmentParameters params) {
    // separate the unassigned into tables
    Map<TableId, Map<TabletId, TabletServerId>> groupedUnassigned = new HashMap<>();
    params.unassignedTablets().forEach((tid, lastTserver) -> groupedUnassigned.computeIfAbsent(tid.getTable(), k -> new HashMap<>()).put(tid, lastTserver));
    for (Entry<TableId, Map<TabletId, TabletServerId>> e : groupedUnassigned.entrySet()) {
        Map<TabletId, TabletServerId> newAssignments = new HashMap<>();
        getBalancerForTable(e.getKey()).getAssignments(new AssignmentParamsImpl(params.currentStatus(), e.getValue(), newAssignments));
        newAssignments.forEach(params::addAssignment);
    }
}
Also used : TableId(org.apache.accumulo.core.data.TableId) 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) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with AssignmentParamsImpl

use of org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl 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 3 with AssignmentParamsImpl

use of org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl 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 4 with AssignmentParamsImpl

use of org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl 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 5 with AssignmentParamsImpl

use of org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl 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)

Aggregations

AssignmentParamsImpl (org.apache.accumulo.core.manager.balancer.AssignmentParamsImpl)11 HashMap (java.util.HashMap)9 TabletId (org.apache.accumulo.core.data.TabletId)9 TabletServerId (org.apache.accumulo.core.spi.balancer.data.TabletServerId)9 Test (org.junit.jupiter.api.Test)6 ArrayList (java.util.ArrayList)3 TableId (org.apache.accumulo.core.data.TableId)3 TServerStatus (org.apache.accumulo.core.spi.balancer.data.TServerStatus)3 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 HashSet (java.util.HashSet)1 SortedMap (java.util.SortedMap)1 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)1 BalanceParamsImpl (org.apache.accumulo.core.manager.balancer.BalanceParamsImpl)1 TabletServerIdImpl (org.apache.accumulo.core.manager.balancer.TabletServerIdImpl)1 TabletMigration (org.apache.accumulo.core.spi.balancer.data.TabletMigration)1 ConfigurationImpl (org.apache.accumulo.core.util.ConfigurationImpl)1 Test (org.junit.Test)1