Search in sources :

Example 26 with AccumuloServerContext

use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.

the class HostRegexTableLoadBalancerTest method testAllAssigned.

@Test
public void testAllAssigned() {
    init(new AccumuloServerContext(instance, factory));
    Map<KeyExtent, TServerInstance> assignments = new HashMap<>();
    Map<KeyExtent, TServerInstance> unassigned = new HashMap<>();
    this.getAssignments(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments);
    Assert.assertEquals(0, assignments.size());
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) HashMap(java.util.HashMap) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) Test(org.junit.Test)

Example 27 with AccumuloServerContext

use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.

the class HostRegexTableLoadBalancerTest method testUnassignedWithNoTServers.

@Test
public void testUnassignedWithNoTServers() {
    init(new AccumuloServerContext(instance, factory));
    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 from current
    List<TServerInstance> removals = new ArrayList<>();
    for (Entry<TServerInstance, TabletServerStatus> e : current.entrySet()) {
        if (e.getKey().host().equals("192.168.0.6") || e.getKey().host().equals("192.168.0.7") || e.getKey().host().equals("192.168.0.8") || e.getKey().host().equals("192.168.0.9") || e.getKey().host().equals("192.168.0.10")) {
            removals.add(e.getKey());
        }
    }
    for (TServerInstance r : removals) {
        current.remove(r);
    }
    this.getAssignments(Collections.unmodifiableSortedMap(allTabletServers), Collections.unmodifiableMap(unassigned), assignments);
    Assert.assertEquals(unassigned.size(), assignments.size());
    // 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());
        }
    }
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Example 28 with AccumuloServerContext

use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.

the class TableLoadBalancerTest method test.

@Test
public void test() throws Exception {
    final Instance inst = EasyMock.createMock(Instance.class);
    EasyMock.expect(inst.getInstanceID()).andReturn(UUID.nameUUIDFromBytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }).toString()).anyTimes();
    EasyMock.expect(inst.getZooKeepers()).andReturn("10.0.0.1:1234").anyTimes();
    EasyMock.expect(inst.getZooKeepersSessionTimeOut()).andReturn(30_000).anyTimes();
    EasyMock.replay(inst);
    ServerConfigurationFactory confFactory = new ServerConfigurationFactory(inst) {

        @Override
        public TableConfiguration getTableConfiguration(Table.ID tableId) {
            // create a dummy namespaceConfiguration to satisfy requireNonNull in TableConfiguration constructor
            NamespaceConfiguration dummyConf = new NamespaceConfiguration(null, inst, null);
            return new TableConfiguration(inst, tableId, dummyConf) {

                @Override
                public String get(Property property) {
                    // fake the get table configuration so the test doesn't try to look in zookeeper for per-table classpath stuff
                    return DefaultConfiguration.getInstance().get(property);
                }
            };
        }
    };
    String t1Id = TABLE_ID_MAP.get("t1"), t2Id = TABLE_ID_MAP.get("t2"), t3Id = TABLE_ID_MAP.get("t3");
    state = new TreeMap<>();
    TServerInstance svr = mkts("10.0.0.1", "0x01020304");
    state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
    Set<KeyExtent> migrations = Collections.emptySet();
    List<TabletMigration> migrationsOut = new ArrayList<>();
    TableLoadBalancer tls = new TableLoadBalancer();
    tls.init(new AccumuloServerContext(inst, confFactory));
    tls.balance(state, migrations, migrationsOut);
    Assert.assertEquals(0, migrationsOut.size());
    state.put(mkts("10.0.0.2", "0x02030405"), status());
    tls = new TableLoadBalancer();
    tls.init(new AccumuloServerContext(inst, confFactory));
    tls.balance(state, migrations, migrationsOut);
    int count = 0;
    Map<Table.ID, Integer> movedByTable = new HashMap<>();
    movedByTable.put(Table.ID.of(t1Id), 0);
    movedByTable.put(Table.ID.of(t2Id), 0);
    movedByTable.put(Table.ID.of(t3Id), 0);
    for (TabletMigration migration : migrationsOut) {
        if (migration.oldServer.equals(svr))
            count++;
        Table.ID key = migration.tablet.getTableId();
        movedByTable.put(key, movedByTable.get(key) + 1);
    }
    Assert.assertEquals(15, count);
    for (Integer moved : movedByTable.values()) {
        Assert.assertEquals(5, moved.intValue());
    }
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Table(org.apache.accumulo.core.client.impl.Table) TabletMigration(org.apache.accumulo.server.master.state.TabletMigration) Instance(org.apache.accumulo.core.client.Instance) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) UUID(java.util.UUID) NamespaceConfiguration(org.apache.accumulo.server.conf.NamespaceConfiguration) Property(org.apache.accumulo.core.conf.Property) TableConfiguration(org.apache.accumulo.server.conf.TableConfiguration) Test(org.junit.Test)

Example 29 with AccumuloServerContext

use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.

the class TServerUtilsTest method startServer.

private ServerAddress startServer() throws Exception {
    AccumuloServerContext ctx = new AccumuloServerContext(instance, factory);
    ClientServiceHandler clientHandler = new ClientServiceHandler(ctx, null, null);
    Iface rpcProxy = RpcWrapper.service(clientHandler);
    Processor<Iface> processor = new Processor<>(rpcProxy);
    // "localhost" explicitly to make sure we can always bind to that interface (avoids DNS misconfiguration)
    String hostname = "localhost";
    return TServerUtils.startServer(ctx, hostname, Property.TSERV_CLIENTPORT, processor, "TServerUtilsTest", "TServerUtilsTestThread", Property.TSERV_PORTSEARCH, Property.TSERV_MINTHREADS, Property.TSERV_THREADCHECK, Property.GENERAL_MAX_MESSAGE_SIZE);
}
Also used : ClientServiceHandler(org.apache.accumulo.server.client.ClientServiceHandler) Iface(org.apache.accumulo.core.client.impl.thrift.ClientService.Iface) AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) Processor(org.apache.accumulo.core.client.impl.thrift.ClientService.Processor)

Example 30 with AccumuloServerContext

use of org.apache.accumulo.server.AccumuloServerContext in project accumulo by apache.

the class WrongTabletTest method main.

public static void main(String[] args) {
    final Opts opts = new Opts();
    opts.parseArgs(WrongTabletTest.class.getName(), args);
    final HostAndPort location = HostAndPort.fromString(opts.location);
    final Instance inst = opts.getInstance();
    final ServerConfigurationFactory conf = new ServerConfigurationFactory(inst);
    final ClientContext context = new AccumuloServerContext(inst, conf) {

        @Override
        public synchronized Credentials getCredentials() {
            try {
                return new Credentials(opts.getPrincipal(), opts.getToken());
            } catch (AccumuloSecurityException e) {
                throw new RuntimeException(e);
            }
        }
    };
    try {
        TabletClientService.Iface client = ThriftUtil.getTServerClient(location, context);
        Mutation mutation = new Mutation(new Text("row_0003750001"));
        mutation.putDelete(new Text("colf"), new Text("colq"));
        client.update(Tracer.traceInfo(), context.rpcCreds(), new KeyExtent(Table.ID.of("!!"), null, new Text("row_0003750000")).toThrift(), mutation.toThrift(), TDurability.DEFAULT);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : AccumuloServerContext(org.apache.accumulo.server.AccumuloServerContext) ClientOpts(org.apache.accumulo.server.cli.ClientOpts) Instance(org.apache.accumulo.core.client.Instance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) ServerConfigurationFactory(org.apache.accumulo.server.conf.ServerConfigurationFactory) Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) HostAndPort(org.apache.accumulo.core.util.HostAndPort) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) Mutation(org.apache.accumulo.core.data.Mutation) Credentials(org.apache.accumulo.core.client.impl.Credentials)

Aggregations

AccumuloServerContext (org.apache.accumulo.server.AccumuloServerContext)38 Test (org.junit.Test)20 ServerConfigurationFactory (org.apache.accumulo.server.conf.ServerConfigurationFactory)17 Instance (org.apache.accumulo.core.client.Instance)16 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)12 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)12 HashMap (java.util.HashMap)9 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)8 HdfsZooInstance (org.apache.accumulo.server.client.HdfsZooInstance)8 ArrayList (java.util.ArrayList)7 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)7 Connector (org.apache.accumulo.core.client.Connector)6 GCStatus (org.apache.accumulo.core.gc.thrift.GCStatus)6 Map (java.util.Map)5 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)5 GcCycleStats (org.apache.accumulo.core.gc.thrift.GcCycleStats)5 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)5 WalStateManager (org.apache.accumulo.server.log.WalStateManager)5 LiveTServerSet (org.apache.accumulo.server.master.LiveTServerSet)5 TabletMigration (org.apache.accumulo.server.master.state.TabletMigration)5