Search in sources :

Example 1 with CachePartitionEventData

use of com.hazelcast.cache.impl.CachePartitionEventData in project hazelcast by hazelcast.

the class CacheSerializationTest method testCachePartitionEventData.

@Test
public void testCachePartitionEventData() throws UnknownHostException {
    Address address = new Address("127.0.0.1", 5701);
    Member member = new MemberImpl(address, MemberVersion.UNKNOWN, true, false);
    CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("test", 1, member);
    CachePartitionEventData deserialized = service.toObject(cachePartitionEventData);
    assertEquals(cachePartitionEventData, deserialized);
}
Also used : CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with CachePartitionEventData

use of com.hazelcast.cache.impl.CachePartitionEventData in project hazelcast by hazelcast.

the class CachePartitionLostListenerTest method test_cachePartitionEventData_deserialization.

@Test
public void test_cachePartitionEventData_deserialization() throws IOException {
    CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("", 0, null);
    ObjectDataInput input = mock(ObjectDataInput.class);
    when(input.readUTF()).thenReturn("cacheName");
    when(input.readInt()).thenReturn(1);
    cachePartitionEventData.readData(input);
    assertEquals("cacheName", cachePartitionEventData.getName());
    assertEquals(1, cachePartitionEventData.getPartitionId());
}
Also used : CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) QuickTest(com.hazelcast.test.annotation.QuickTest) AbstractPartitionLostListenerTest(com.hazelcast.partition.AbstractPartitionLostListenerTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with CachePartitionEventData

use of com.hazelcast.cache.impl.CachePartitionEventData in project hazelcast by hazelcast.

the class InternalCachePartitionLostListenerAdapter method handleEvent.

@Override
public void handleEvent(Object eventObject) {
    final CachePartitionEventData eventData = (CachePartitionEventData) eventObject;
    final CachePartitionLostEvent event = new CachePartitionLostEvent(eventData.getName(), eventData.getMember(), CacheEventType.PARTITION_LOST.getType(), eventData.getPartitionId());
    partitionLostListener.partitionLost(event);
}
Also used : CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData)

Example 4 with CachePartitionEventData

use of com.hazelcast.cache.impl.CachePartitionEventData in project hazelcast by hazelcast.

the class CachePartitionLostListenerTest method test_cachePartitionEventData_serialization.

@Test
public void test_cachePartitionEventData_serialization() throws IOException {
    CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("cacheName", 1, null);
    ObjectDataOutput output = mock(ObjectDataOutput.class);
    cachePartitionEventData.writeData(output);
    verify(output).writeUTF("cacheName");
    verify(output).writeInt(1);
}
Also used : ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) QuickTest(com.hazelcast.test.annotation.QuickTest) AbstractPartitionLostListenerTest(com.hazelcast.partition.AbstractPartitionLostListenerTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

CachePartitionEventData (com.hazelcast.cache.impl.CachePartitionEventData)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Test (org.junit.Test)3 AbstractPartitionLostListenerTest (com.hazelcast.partition.AbstractPartitionLostListenerTest)2 Member (com.hazelcast.core.Member)1 MemberImpl (com.hazelcast.instance.MemberImpl)1 Address (com.hazelcast.nio.Address)1 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)1 ObjectDataOutput (com.hazelcast.nio.ObjectDataOutput)1