Search in sources :

Example 56 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class AddOperationsTest method whenOverwritePolicy_andNoRemainingCapacity_thenBackup.

@Test
public void whenOverwritePolicy_andNoRemainingCapacity_thenBackup() throws Exception {
    for (int k = 0; k < ringbuffer.capacity(); k++) {
        ringbuffer.add("item");
    }
    Data item = serializationService.toData("newItem");
    AddOperation addOperation = new AddOperation(ringbuffer.getName(), item, OVERWRITE);
    addOperation.setNodeEngine(nodeEngine);
    addOperation.run();
    assertTrue(addOperation.shouldBackup());
    assertTrue(addOperation.shouldNotify());
    assertEquals(new Long(ringbuffer.tailSequence()), addOperation.getResponse());
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 57 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class AddOperationsTest method whenFailOverflowPolicy_andNoRemainingCapacity_thenNoBackup.

@Test
public void whenFailOverflowPolicy_andNoRemainingCapacity_thenNoBackup() throws Exception {
    for (int k = 0; k < ringbuffer.capacity(); k++) {
        ringbuffer.add("item");
    }
    Data item = serializationService.toData("newItem");
    AddOperation addOperation = new AddOperation(ringbuffer.getName(), item, FAIL);
    addOperation.setNodeEngine(nodeEngine);
    addOperation.run();
    assertFalse(addOperation.shouldBackup());
    assertFalse(addOperation.shouldNotify());
    assertEquals(new Long(-1l), addOperation.getResponse());
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 58 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class AddOperationsTest method whenFailOverflowPolicy_andRemainingCapacity_thenBackup.

@Test
public void whenFailOverflowPolicy_andRemainingCapacity_thenBackup() throws Exception {
    for (int k = 0; k < ringbuffer.capacity() - 1; k++) {
        ringbuffer.add("item");
    }
    Data item = serializationService.toData("newItem");
    AddOperation addOperation = new AddOperation(ringbuffer.getName(), item, FAIL);
    addOperation.setNodeEngine(nodeEngine);
    addOperation.run();
    assertTrue(addOperation.shouldBackup());
    assertTrue(addOperation.shouldNotify());
    assertEquals(new Long(ringbuffer.tailSequence()), addOperation.getResponse());
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 59 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class AddAllOperationTest method whenFailOverflowPolicy_andRemainingCapacity.

@Test
public void whenFailOverflowPolicy_andRemainingCapacity() throws Exception {
    for (int k = 0; k < ringbuffer.capacity() - 1; k++) {
        ringbuffer.add("item");
    }
    Data item = serializationService.toData("newItem");
    AddAllOperation addOperation = new AddAllOperation(ringbuffer.getName(), new Data[] { item }, FAIL);
    addOperation.setNodeEngine(nodeEngine);
    addOperation.run();
    assertTrue(addOperation.shouldNotify());
    assertTrue(addOperation.shouldBackup());
    assertEquals(ringbuffer.tailSequence(), addOperation.getResponse());
}
Also used : Data(com.hazelcast.nio.serialization.Data) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 60 with Data

use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.

the class ClientConnectionManagerImpl method encodeAuthenticationRequest.

private ClientMessage encodeAuthenticationRequest(boolean asOwner, SerializationService ss, byte serializationVersion, String uuid, String ownerUuid) {
    ClientMessage clientMessage;
    if (credentials.getClass().equals(UsernamePasswordCredentials.class)) {
        UsernamePasswordCredentials cr = (UsernamePasswordCredentials) credentials;
        clientMessage = ClientAuthenticationCodec.encodeRequest(cr.getUsername(), cr.getPassword(), uuid, ownerUuid, asOwner, ClientTypes.JAVA, serializationVersion, BuildInfoProvider.BUILD_INFO.getVersion());
    } else {
        Data data = ss.toData(credentials);
        clientMessage = ClientAuthenticationCustomCodec.encodeRequest(data, uuid, ownerUuid, asOwner, ClientTypes.JAVA, serializationVersion, BuildInfoProvider.BUILD_INFO.getVersion());
    }
    return clientMessage;
}
Also used : Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) UsernamePasswordCredentials(com.hazelcast.security.UsernamePasswordCredentials)

Aggregations

Data (com.hazelcast.nio.serialization.Data)773 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)140 Test (org.junit.Test)121 QuickTest (com.hazelcast.test.annotation.QuickTest)118 ParallelTest (com.hazelcast.test.annotation.ParallelTest)108 ArrayList (java.util.ArrayList)81 Map (java.util.Map)64 SerializationService (com.hazelcast.spi.serialization.SerializationService)54 HashMap (java.util.HashMap)54 NodeEngine (com.hazelcast.spi.NodeEngine)50 HashSet (java.util.HashSet)39 Address (com.hazelcast.nio.Address)28 AbstractMap (java.util.AbstractMap)28 Record (com.hazelcast.map.impl.record.Record)27 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 HeapData (com.hazelcast.internal.serialization.impl.HeapData)26 List (java.util.List)20 Future (java.util.concurrent.Future)20 CacheEventData (com.hazelcast.cache.impl.CacheEventData)19 Operation (com.hazelcast.spi.Operation)18