Search in sources :

Example 1 with ShardFunc

use of org.nustaq.reallive.impl.actors.ShardFunc in project kontraktor by RuedigerMoeller.

the class Basic method testActorShard.

@Test
public void testActorShard() throws InterruptedException {
    RealLiveTableActor[] rls = new RealLiveTableActor[8];
    for (int i = 0; i < rls.length; i++) {
        rls[i] = Actors.AsActor(RealLiveTableActor.class);
        rls[i].init(() -> new OffHeapRecordStorage(32, 500 / rls.length, 700_000 / rls.length), null);
    }
    ShardFunc sfunc = key -> Math.abs(key.hashCode()) % rls.length;
    TableSharding sharding = new TableSharding(sfunc, rls, null);
    TA ta = Actors.AsActor(TA.class);
    // while( System.currentTimeMillis() != 0)
    {
        ta.runTest(sharding).await(50009);
    }
    ta.stop();
    sharding.stop();
}
Also used : IntStream(java.util.stream.IntStream) org.nustaq.reallive.api(org.nustaq.reallive.api) TableSpaceActor(org.nustaq.reallive.impl.tablespace.TableSpaceActor) Iterator(java.util.Iterator) Test(org.junit.Test) Promise(org.nustaq.kontraktor.Promise) PromiseLatch(org.nustaq.kontraktor.util.PromiseLatch) TableSharding(org.nustaq.reallive.impl.actors.TableSharding) org.nustaq.reallive.impl.storage(org.nustaq.reallive.impl.storage) MapRecord(org.nustaq.reallive.records.MapRecord) IPromise(org.nustaq.kontraktor.IPromise) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) org.nustaq.reallive.impl(org.nustaq.reallive.impl) Map(java.util.Map) Actor(org.nustaq.kontraktor.Actor) Actors(org.nustaq.kontraktor.Actors) ShardFunc(org.nustaq.reallive.impl.actors.ShardFunc) RealLiveTableActor(org.nustaq.reallive.impl.actors.RealLiveTableActor) ShardFunc(org.nustaq.reallive.impl.actors.ShardFunc) TableSharding(org.nustaq.reallive.impl.actors.TableSharding) RealLiveTableActor(org.nustaq.reallive.impl.actors.RealLiveTableActor) Test(org.junit.Test)

Aggregations

Iterator (java.util.Iterator)1 Map (java.util.Map)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IntStream (java.util.stream.IntStream)1 Test (org.junit.Test)1 Actor (org.nustaq.kontraktor.Actor)1 Actors (org.nustaq.kontraktor.Actors)1 IPromise (org.nustaq.kontraktor.IPromise)1 Promise (org.nustaq.kontraktor.Promise)1 PromiseLatch (org.nustaq.kontraktor.util.PromiseLatch)1 org.nustaq.reallive.api (org.nustaq.reallive.api)1 org.nustaq.reallive.impl (org.nustaq.reallive.impl)1 RealLiveTableActor (org.nustaq.reallive.impl.actors.RealLiveTableActor)1 ShardFunc (org.nustaq.reallive.impl.actors.ShardFunc)1 TableSharding (org.nustaq.reallive.impl.actors.TableSharding)1 org.nustaq.reallive.impl.storage (org.nustaq.reallive.impl.storage)1 TableSpaceActor (org.nustaq.reallive.impl.tablespace.TableSpaceActor)1 MapRecord (org.nustaq.reallive.records.MapRecord)1