Search in sources :

Example 16 with Member

use of com.hazelcast.core.Member in project hazelcast by hazelcast.

the class MapEventPublishingService method dispatchMapPartitionLostEventData.

private void dispatchMapPartitionLostEventData(MapPartitionEventData eventData, ListenerAdapter listener) {
    Member member = getMember(eventData);
    MapPartitionLostEvent event = createMapPartitionLostEventData(eventData, member);
    callListener(listener, event);
}
Also used : MapPartitionLostEvent(com.hazelcast.map.MapPartitionLostEvent) Member(com.hazelcast.core.Member)

Example 17 with Member

use of com.hazelcast.core.Member in project hazelcast by hazelcast.

the class MapEventPublishingService method dispatchMapEventData.

private void dispatchMapEventData(MapEventData mapEventData, ListenerAdapter listener) {
    Member member = getMember(mapEventData);
    MapEvent event = createMapEvent(mapEventData, member);
    callListener(listener, event);
}
Also used : MapEvent(com.hazelcast.core.MapEvent) EventPublisherHelper.createIMapEvent(com.hazelcast.map.impl.querycache.subscriber.EventPublisherHelper.createIMapEvent) BatchIMapEvent(com.hazelcast.map.impl.querycache.event.BatchIMapEvent) SingleIMapEvent(com.hazelcast.map.impl.querycache.event.SingleIMapEvent) IMapEvent(com.hazelcast.core.IMapEvent) Member(com.hazelcast.core.Member)

Example 18 with Member

use of com.hazelcast.core.Member in project hazelcast by hazelcast.

the class SimpleMultiMapTest method load.

private static void load(boolean load, ExecutorService es, final MultiMap<String, byte[]> map) {
    if (load) {
        final Member thisMember = instance.getCluster().getLocalMember();
        for (int i = 0; i < entryCount; i++) {
            final String key = String.valueOf(i);
            Partition partition = instance.getPartitionService().getPartition(key);
            if (thisMember.equals(partition.getOwner())) {
                es.execute(new Runnable() {

                    public void run() {
                        map.put(key, new byte[valueSize]);
                    }
                });
            }
        }
    }
}
Also used : Partition(com.hazelcast.core.Partition) Member(com.hazelcast.core.Member)

Example 19 with Member

use of com.hazelcast.core.Member in project hazelcast by hazelcast.

the class PartitionControlledIdTest method testObjectWithPartitionKeyAndMap.

@Test
public void testObjectWithPartitionKeyAndMap() throws Exception {
    HazelcastInstance instance = instances[0];
    IExecutorService executorServices = instance.getExecutorService("executor");
    String partitionKey = "hazelcast";
    String mapKey = "key@" + partitionKey;
    IMap map = instance.getMap("map");
    map.put(mapKey, "foobar");
    ISemaphore semaphore = instance.getSemaphore("s@" + partitionKey);
    semaphore.release();
    ContainsSemaphoreAndMapEntryTask task = new ContainsSemaphoreAndMapEntryTask(semaphore.getName(), mapKey);
    Map<Member, Future<Boolean>> futures = executorServices.submitToAllMembers(task);
    int count = 0;
    for (Future<Boolean> f : futures.values()) {
        count += f.get() ? 1 : 0;
    }
    assertEquals(1, count);
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) ISemaphore(com.hazelcast.core.ISemaphore) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 20 with Member

use of com.hazelcast.core.Member in project hazelcast by hazelcast.

the class SimpleReplicatedMapTest method load.

private void load(ExecutorService es) throws InterruptedException {
    if (!load) {
        return;
    }
    final ReplicatedMap<String, Object> map = instance.getReplicatedMap(NAMESPACE);
    final Member thisMember = instance.getCluster().getLocalMember();
    List<String> lsOwnedEntries = new LinkedList<String>();
    for (int i = 0; i < entryCount; i++) {
        final String key = String.valueOf(i);
        Partition partition = instance.getPartitionService().getPartition(key);
        if (thisMember.equals(partition.getOwner())) {
            lsOwnedEntries.add(key);
        }
    }
    final CountDownLatch latch = new CountDownLatch(lsOwnedEntries.size());
    for (final String ownedKey : lsOwnedEntries) {
        es.execute(new Runnable() {

            public void run() {
                map.put(ownedKey, createValue());
                latch.countDown();
            }
        });
    }
    latch.await();
}
Also used : Partition(com.hazelcast.core.Partition) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

Aggregations

Member (com.hazelcast.core.Member)330 Test (org.junit.Test)134 QuickTest (com.hazelcast.test.annotation.QuickTest)124 ParallelTest (com.hazelcast.test.annotation.ParallelTest)113 HazelcastInstance (com.hazelcast.core.HazelcastInstance)99 Address (com.hazelcast.nio.Address)60 IExecutorService (com.hazelcast.core.IExecutorService)57 Future (java.util.concurrent.Future)47 ArrayList (java.util.ArrayList)45 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)41 CountDownLatch (java.util.concurrent.CountDownLatch)37 Config (com.hazelcast.config.Config)35 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)26 HashMap (java.util.HashMap)26 IMap (com.hazelcast.core.IMap)24 HashSet (java.util.HashSet)21 LinkedList (java.util.LinkedList)20 OperationService (com.hazelcast.spi.OperationService)19 AssertTask (com.hazelcast.test.AssertTask)19 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)18