use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class ReplicatedMapService method prepareReplicationOperation.
@Override
public Operation prepareReplicationOperation(PartitionReplicationEvent event) {
if (nodeEngine.getLocalMember().isLiteMember()) {
return null;
}
if (event.getReplicaIndex() > 0) {
return null;
}
PartitionContainer container = partitionContainers[event.getPartitionId()];
SerializationService serializationService = nodeEngine.getSerializationService();
ReplicationOperation operation = new ReplicationOperation(serializationService, container, event.getPartitionId());
operation.setService(this);
return operation.isEmpty() ? null : operation;
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class CacheRecordStoreTestSupport method putAndSetExpiryPolicyFromRecordStore.
protected void putAndSetExpiryPolicyFromRecordStore(ICacheRecordStore cacheRecordStore, InMemoryFormat inMemoryFormat) {
SerializationService serializationService = new DefaultSerializationServiceBuilder().build();
ExpiryPolicy expiryPolicy = new TouchedExpiryPolicy(Duration.ETERNAL);
Data policyData = serializationService.toData(expiryPolicy);
for (int i = 0; i < CACHE_RECORD_COUNT; i++) {
Data keyData = serializationService.toData(i);
cacheRecordStore.put(keyData, "value-" + i, null, null, -1);
cacheRecordStore.setExpiryPolicy(Collections.singleton(keyData), policyData, null);
}
if (inMemoryFormat == InMemoryFormat.BINARY || inMemoryFormat == InMemoryFormat.NATIVE) {
for (int i = 0; i < CACHE_RECORD_COUNT; i++) {
assertTrue(Data.class.isAssignableFrom(cacheRecordStore.getExpiryPolicy(serializationService.toData(i)).getClass()));
}
} else if (inMemoryFormat == InMemoryFormat.OBJECT) {
for (int i = 0; i < CACHE_RECORD_COUNT; i++) {
assertTrue(ExpiryPolicy.class.isAssignableFrom(cacheRecordStore.getExpiryPolicy(serializationService.toData(i)).getClass()));
}
} else {
throw new IllegalArgumentException("Unsupported in-memory format: " + inMemoryFormat);
}
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class ClientCacheNearCacheInvalidationTest method setup.
@Before
public void setup() {
hazelcastFactory = new TestHazelcastFactory();
HazelcastInstance[] allMembers = new HazelcastInstance[MEMBER_COUNT];
for (int i = 0; i < MEMBER_COUNT; i++) {
// every instance should have its own getConfig() call because an existing EE test relies on this
Config config = getConfig().setProperty(CACHE_INVALIDATION_MESSAGE_BATCH_ENABLED.getName(), "false");
allMembers[i] = hazelcastFactory.newHazelcastInstance(config);
}
waitAllForSafeState(allMembers);
NearCacheConfig nearCacheConfig = getNearCacheConfig(inMemoryFormat);
ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider provider = createClientCachingProvider(client);
HazelcastServerCachingProvider memberProvider = createServerCachingProvider(allMembers[0]);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
CacheConfig<Integer, String> cacheConfig = getCacheConfig(inMemoryFormat);
ICache<Integer, String> cache = cacheManager.createCache(DEFAULT_CACHE_NAME, cacheConfig);
ICache<Integer, String> memberCache = memberCacheManager.getCache(getPrefixedCacheName(DEFAULT_CACHE_NAME, null, null));
NearCacheManager nearCacheManager = ((ClientCacheProxy) cache).getContext().getNearCacheManager(cache.getServiceName());
NearCache<Object, String> nearCache = nearCacheManager.getNearCache(cacheManager.getCacheNameWithPrefix(DEFAULT_CACHE_NAME));
SerializationService serializationService = client.getSerializationService();
invalidationListener = createInvalidationEventHandler(cache);
NearCacheTestContextBuilder<Integer, String, Object, String> builder = new NearCacheTestContextBuilder<>(nearCacheConfig, serializationService);
testContext = builder.setDataInstance(allMembers[0]).setNearCacheInstance(client).setDataAdapter(new ICacheDataStructureAdapter<>(memberCache)).setNearCacheAdapter(new ICacheDataStructureAdapter<>(cache)).setMemberCacheManager(memberCacheManager).setCacheManager(cacheManager).setNearCacheManager(nearCacheManager).setNearCache(nearCache).build();
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class PreJoinCacheConfig method writeFactories.
@Override
protected void writeFactories(ObjectDataOutput out) throws IOException {
assert (out instanceof SerializationServiceSupport) : "out must implement SerializationServiceSupport";
SerializationService serializationService = ((SerializationServiceSupport) out).getSerializationService();
IOUtil.writeData(out, cacheLoaderFactory.getSerializedValue(serializationService));
IOUtil.writeData(out, cacheWriterFactory.getSerializedValue(serializationService));
IOUtil.writeData(out, expiryPolicyFactory.getSerializedValue(serializationService));
}
use of com.hazelcast.internal.serialization.SerializationService in project hazelcast by hazelcast.
the class DefaultClientExtension method createNearCacheManager.
@Override
public NearCacheManager createNearCacheManager() {
SerializationService ss = client.getSerializationService();
TaskScheduler taskScheduler = client.getTaskScheduler();
ClassLoader classLoader = client.getClientConfig().getClassLoader();
HazelcastProperties properties = client.getProperties();
return new DefaultNearCacheManager(ss, taskScheduler, classLoader, properties);
}
Aggregations