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());
}
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());
}
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());
}
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());
}
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;
}
Aggregations