use of org.nustaq.reallive.api.TableDescription 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.api.TableDescription in project kontraktor by RuedigerMoeller.
the class DefaultSessionStorage method init.
public IPromise init(Config cfg) {
Promise p = new Promise();
// FIXME: fireasync and await both
try {
String dataDir = cfg.getDataDir();
new File(dataDir).mkdirs();
IPromise _sessionId2UserKey = EmbeddedRealLive.get().createTable(new TableDescription().keyLen(64).sizeMB(cfg.getSizeSessionIdsMB()).name("sessionid2userkey").storageType(TableDescription.StorageType.PERSIST), dataDir);
IPromise _userData = EmbeddedRealLive.get().createTable(new TableDescription().keyLen(64).sizeMB(cfg.getSizeSessionIdsMB()).name("userdata").storageType(TableDescription.StorageType.PERSIST), dataDir);
Actors.all(_sessionId2UserKey, _userData).then(() -> {
sessionId2UserKey = (RealLiveTable) _sessionId2UserKey.get();
userData = (RealLiveTable) _userData.get();
p.resolve();
});
} catch (Exception e) {
Log.Warn(this, e);
return new Promise(null, e);
}
return p;
}
Aggregations