use of org.nustaq.reallive.impl.tablespace.TableSpaceSharding in project kontraktor by RuedigerMoeller.
the class DataClient method connect.
public IPromise connect(DataCfg config, TableSpaceActor[] shards, ServiceActor hostingService) {
this.config = config;
this.hostingService = hostingService;
this.shards = shards;
syncTableAccess = new HashMap();
tableSharding = new TableSpaceSharding(shards, key -> Math.abs(key.hashCode()) % shards.length);
tableSharding.init().await();
TableDescription[] schema = config.getSchema();
return all(schema.length, i -> {
Promise p = new Promise();
tableSharding.createOrLoadTable(schema[i]).then((r, e) -> {
if (r != null) {
syncTableAccess.put(schema[i].getName(), r);
}
p.complete(r, e);
});
return p;
});
}
use of org.nustaq.reallive.impl.tablespace.TableSpaceSharding in project kontraktor by RuedigerMoeller.
the class TableSpaceTest method simpleSharded.
@Test
public void simpleSharded() {
TableSpaceActor[] spaces = { Actors.AsActor(TableSpaceActor.class), Actors.AsActor(TableSpaceActor.class) };
for (int i = 0; i < spaces.length; i++) {
TableSpaceActor space = spaces[i];
space.init();
}
TableSpaceSharding ts = new TableSpaceSharding(spaces, key -> Math.abs(key.hashCode()) % spaces.length);
Assert.assertTrue(runSimpleTest(ts, () -> createShardedTableDescription()) == EXPECT_SIMPLECOUNT);
ts.shutDown().await();
}
use of org.nustaq.reallive.impl.tablespace.TableSpaceSharding in project kontraktor by RuedigerMoeller.
the class TableSpaceTest method simpleShardedNoServer.
@Test
public void simpleShardedNoServer() {
TableSpaceActor[] spaces = { null, null };
spaces[0] = (TableSpaceActor) new TCPConnectable(TableSpaceActor.class, "localhost", 5432).connect((disc, err) -> System.out.println("client disc " + disc + " " + err)).await();
spaces[1] = (TableSpaceActor) new TCPConnectable(TableSpaceActor.class, "localhost", 5433).connect((disc, err) -> System.out.println("client disc " + disc + " " + err)).await();
for (int i = 0; i < spaces.length; i++) {
TableSpaceActor space = spaces[i];
space.init();
}
TableSpaceSharding ts = new TableSpaceSharding(spaces, key -> Math.abs(key.hashCode()) % spaces.length);
Assert.assertTrue(runSimpleTest(ts, () -> createShardedTableDescription()) == EXPECT_SIMPLECOUNT);
ts.shutDown().await();
}
Aggregations