use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class CollectionUtilTest method testObjectToDataCollection_size.
@Test
public void testObjectToDataCollection_size() {
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
Collection<Object> list = new ArrayList<Object>();
list.add(1);
list.add("foo");
Collection<Data> dataCollection = objectToDataCollection(list, serializationService);
assertEquals(list.size(), dataCollection.size());
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class CallbackAwareClientDelegatingFutureTest method createGetRequest.
private ClientMessage createGetRequest(Integer key) {
SerializationService serializationService = client.getSerializationService();
Data keyData = serializationService.toData(key);
Data expiryPolicyData = serializationService.toData(null);
String cacheNameWithPrefix = HazelcastCacheManager.CACHE_MANAGER_PREFIX + CACHE_NAME;
return CacheGetCodec.encodeRequest(cacheNameWithPrefix, keyData, expiryPolicyData);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method canPassFilter.
private boolean canPassFilter(LocalEntryEventData localEntryEventData, EventFilter filter) {
if (filter == null || filter instanceof TrueEventFilter) {
return true;
}
NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
SerializationService serializationService = nodeEngine.getSerializationService();
Data keyData = localEntryEventData.getKeyData();
Object value = getValueOrOldValue(localEntryEventData);
QueryableEntry entry = new QueryEntry((InternalSerializationService) serializationService, keyData, value, Extractors.empty());
return filter.eval(entry);
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class CacheClearTest method testClear.
@Test
public void testClear() {
ICache<String, String> cache = createCache();
String cacheName = cache.getName();
Map<String, String> entries = createAndFillEntries();
for (Map.Entry<String, String> entry : entries.entrySet()) {
cache.put(entry.getKey(), entry.getValue());
}
// Verify that put works
for (Map.Entry<String, String> entry : entries.entrySet()) {
String key = entry.getKey();
String expectedValue = entries.get(key);
String actualValue = cache.get(key);
assertEquals(expectedValue, actualValue);
}
Node node = getNode(hazelcastInstance);
InternalPartitionService partitionService = node.getPartitionService();
SerializationService serializationService = node.getSerializationService();
// Verify that backup of put works
for (Map.Entry<String, String> entry : entries.entrySet()) {
String key = entry.getKey();
String expectedValue = entries.get(key);
Data keyData = serializationService.toData(key);
int keyPartitionId = partitionService.getPartitionId(keyData);
for (int i = 0; i < INSTANCE_COUNT; i++) {
Node n = getNode(hazelcastInstances[i]);
ICacheService cacheService = n.getNodeEngine().getService(ICacheService.SERVICE_NAME);
ICacheRecordStore recordStore = cacheService.getRecordStore("/hz/" + cacheName, keyPartitionId);
assertNotNull(recordStore);
String actualValue = serializationService.toObject(recordStore.get(keyData, null));
assertEquals(expectedValue, actualValue);
}
}
cache.clear();
// Verify that clear works
for (Map.Entry<String, String> entry : entries.entrySet()) {
String key = entry.getKey();
String actualValue = cache.get(key);
assertNull(actualValue);
}
// Verify that backup of clear works
for (Map.Entry<String, String> entry : entries.entrySet()) {
String key = entry.getKey();
Data keyData = serializationService.toData(key);
int keyPartitionId = partitionService.getPartitionId(keyData);
for (int i = 0; i < INSTANCE_COUNT; i++) {
Node n = getNode(hazelcastInstances[i]);
ICacheService cacheService = n.getNodeEngine().getService(ICacheService.SERVICE_NAME);
ICacheRecordStore recordStore = cacheService.getRecordStore("/hz/" + cacheName, keyPartitionId);
assertNotNull(recordStore);
String actualValue = serializationService.toObject(recordStore.get(keyData, null));
assertNull(actualValue);
}
}
}
use of com.hazelcast.spi.serialization.SerializationService in project hazelcast by hazelcast.
the class SetEqualsHashTest method testCollectionItem_equalsAndHash.
@Test
public void testCollectionItem_equalsAndHash() {
SerializationServiceBuilder serializationServiceBuilder = new DefaultSerializationServiceBuilder();
SerializationService build = serializationServiceBuilder.build();
Data value = build.toData(randomString());
CollectionItem firstItem = new CollectionItem(1, value);
CollectionItem secondItem = new CollectionItem(2, value);
assertTrue(firstItem.equals(secondItem));
assertEquals(firstItem.hashCode(), secondItem.hashCode());
}
Aggregations