Search in sources :

Example 21 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class LiveTServerSetTest method testSessionIds.

@Test
public void testSessionIds() {
    Map<String, TServerInfo> servers = new HashMap<>();
    TServerConnection mockConn = EasyMock.createMock(TServerConnection.class);
    TServerInfo server1 = new TServerInfo(new TServerInstance(HostAndPort.fromParts("localhost", 1234), "5555"), mockConn);
    servers.put("server1", server1);
    LiveTServerSet tservers = new LiveTServerSet(EasyMock.createMock(ServerContext.class), EasyMock.createMock(Listener.class));
    assertEquals(server1.instance, tservers.find(servers, "localhost:1234"));
    assertNull(tservers.find(servers, "localhost:4321"));
    assertEquals(server1.instance, tservers.find(servers, "localhost:1234[5555]"));
    assertNull(tservers.find(servers, "localhost:1234[55755]"));
}
Also used : TServerConnection(org.apache.accumulo.server.manager.LiveTServerSet.TServerConnection) Listener(org.apache.accumulo.server.manager.LiveTServerSet.Listener) ServerContext(org.apache.accumulo.server.ServerContext) HashMap(java.util.HashMap) TServerInfo(org.apache.accumulo.server.manager.LiveTServerSet.TServerInfo) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Test(org.junit.Test)

Example 22 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class BaseHostRegexTableLoadBalancerTest method createCurrent.

protected SortedMap<TServerInstance, TabletServerStatus> createCurrent(int numTservers) {
    String base = "192.168.0.";
    TreeMap<TServerInstance, TabletServerStatus> current = new TreeMap<>();
    for (int i = 1; i <= numTservers; i++) {
        TabletServerStatus status = new TabletServerStatus();
        Map<String, TableInfo> tableMap = new HashMap<>();
        tableMap.put(FOO.getId().canonical(), new TableInfo());
        tableMap.put(BAR.getId().canonical(), new TableInfo());
        tableMap.put(BAZ.getId().canonical(), new TableInfo());
        status.setTableMap(tableMap);
        current.put(new TServerInstance(base + i + ":9997", 1), status);
    }
    // now put all of the tablets on one server
    for (Map.Entry<String, TServerInstance> entry : initialTableLocation.entrySet()) {
        TabletServerStatus status = current.get(entry.getValue());
        if (status != null) {
            String tableId = getTableOperations().tableIdMap().get(entry.getKey());
            status.getTableMap().get(tableId).setOnlineTablets(5);
        }
    }
    return current;
}
Also used : HashMap(java.util.HashMap) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 23 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class HostRegexTableLoadBalancerTest method testAllUnassigned.

@Test
public void testAllUnassigned() {
    init();
    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);
    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())) {
                fail("Assignment failure");
            }
        }
    }
    // Ensure assignments are correct
    for (Entry<KeyExtent, TServerInstance> 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) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Test(org.junit.Test)

Example 24 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class HostRegexTableLoadBalancerTest method testUnassignedWithNoDefaultPool.

@Test
public void testUnassignedWithNoDefaultPool() {
    init();
    Map<KeyExtent, TServerInstance> assignments = new HashMap<>();
    Map<KeyExtent, TServerInstance> unassigned = new HashMap<>();
    for (KeyExtent ke : tableExtents.get(BAR.getTableName())) {
        unassigned.put(ke, null);
    }
    SortedMap<TServerInstance, TabletServerStatus> current = createCurrent(15);
    // Remove the BAR tablet servers and default pool from current
    List<TServerInstance> removals = new ArrayList<>();
    for (Entry<TServerInstance, TabletServerStatus> 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 (TServerInstance r : removals) {
        current.remove(r);
    }
    this.getAssignments(Collections.unmodifiableSortedMap(current), Collections.unmodifiableMap(unassigned), assignments);
    assertEquals(unassigned.size(), assignments.size());
    // Ensure tablets are assigned in default pool
    for (Entry<KeyExtent, TServerInstance> 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) ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Example 25 with TServerInstance

use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.

the class HostRegexTableLoadBalancerTest method testPartiallyAssigned.

@Test
public void testPartiallyAssigned() {
    init();
    Map<KeyExtent, TServerInstance> assignments = new HashMap<>();
    Map<KeyExtent, TServerInstance> unassigned = new HashMap<>();
    int i = 0;
    for (List<KeyExtent> extents : tableExtents.values()) {
        for (KeyExtent ke : extents) {
            if ((i % 2) == 0) {
                unassigned.put(ke, null);
            }
            i++;
        }
    }
    this.getAssignments(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments);
    assertEquals(unassigned.size(), 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())) {
                fail("Assignment failure");
            }
        }
    }
    // Ensure assignments are correct
    for (Entry<KeyExtent, TServerInstance> 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) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) Test(org.junit.Test)

Aggregations

TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)89 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)32 ArrayList (java.util.ArrayList)31 Test (org.junit.Test)30 HashMap (java.util.HashMap)21 ServerContext (org.apache.accumulo.server.ServerContext)18 TabletLocationState (org.apache.accumulo.core.metadata.TabletLocationState)17 HostAndPort (org.apache.accumulo.core.util.HostAndPort)14 HashSet (java.util.HashSet)13 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)13 TableId (org.apache.accumulo.core.data.TableId)12 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)11 List (java.util.List)10 LiveTServerSet (org.apache.accumulo.server.manager.LiveTServerSet)10 TException (org.apache.thrift.TException)10 TreeMap (java.util.TreeMap)9 UUID (java.util.UUID)9 TreeSet (java.util.TreeSet)8 Key (org.apache.accumulo.core.data.Key)8 Value (org.apache.accumulo.core.data.Value)8