Search in sources :

Example 6 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class GetCacheEntryRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
    InternalSerializationService serializationService = mcs.getHazelcastInstance().getSerializationService();
    HazelcastInstanceCacheManager cacheManager = mcs.getHazelcastInstance().getCacheManager();
    ICache<Object, Object> cache = cacheManager.getCache(cacheName);
    CacheEntryView cacheEntry = null;
    if ("string".equals(type)) {
        cacheEntry = cache.invoke(key, ENTRY_PROCESSOR, cacheEntry);
    } else if ("long".equals(type)) {
        cacheEntry = cache.invoke(Long.valueOf(key), ENTRY_PROCESSOR, cacheEntry);
    } else if ("integer".equals(type)) {
        cacheEntry = cache.invoke(Integer.valueOf(key), ENTRY_PROCESSOR, cacheEntry);
    }
    JsonObject result = new JsonObject();
    if (cacheEntry != null) {
        Object value = serializationService.toObject(cacheEntry.getValue());
        result.add("cacheBrowse_value", value != null ? value.toString() : "null");
        result.add("cacheBrowse_class", value != null ? value.getClass().getName() : "null");
        result.add("date_cache_creation_time", Long.toString(cacheEntry.getCreationTime()));
        result.add("date_cache_expiration_time", Long.toString(cacheEntry.getExpirationTime()));
        result.add("cacheBrowse_hits", Long.toString(cacheEntry.getAccessHit()));
        result.add("date_cache_access_time", Long.toString(cacheEntry.getLastAccessTime()));
    }
    root.add("result", result);
}
Also used : HazelcastInstanceCacheManager(com.hazelcast.instance.HazelcastInstanceCacheManager) CacheEntryView(com.hazelcast.cache.CacheEntryView) JsonObject(com.eclipsesource.json.JsonObject) JsonObject(com.eclipsesource.json.JsonObject) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 7 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class DefaultSerializationServiceBuilder method build.

@Override
public InternalSerializationService build() {
    initVersions();
    if (config != null) {
        addConfigDataSerializableFactories(dataSerializableFactories, config, classLoader);
        addConfigPortableFactories(portableFactories, config, classLoader);
        classDefinitions.addAll(config.getClassDefinitions());
    }
    InputOutputFactory inputOutputFactory = createInputOutputFactory();
    InternalSerializationService ss = createSerializationService(inputOutputFactory);
    registerSerializerHooks(ss);
    if (config != null) {
        if (config.getGlobalSerializerConfig() != null) {
            GlobalSerializerConfig globalSerializerConfig = config.getGlobalSerializerConfig();
            Serializer serializer = globalSerializerConfig.getImplementation();
            if (serializer == null) {
                try {
                    serializer = ClassLoaderUtil.newInstance(classLoader, globalSerializerConfig.getClassName());
                } catch (Exception e) {
                    throw new HazelcastSerializationException(e);
                }
            }
            if (serializer instanceof HazelcastInstanceAware) {
                ((HazelcastInstanceAware) serializer).setHazelcastInstance(hazelcastInstance);
            }
            ((AbstractSerializationService) ss).registerGlobal(serializer, globalSerializerConfig.isOverrideJavaSerialization());
        }
    }
    return ss;
}
Also used : HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) InputOutputFactory(com.hazelcast.internal.serialization.InputOutputFactory) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware) GlobalSerializerConfig(com.hazelcast.config.GlobalSerializerConfig) HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) Serializer(com.hazelcast.nio.serialization.Serializer)

Example 8 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class SubscriberAccumulator method createAccumulatorHandler.

private SubscriberAccumulatorHandler createAccumulatorHandler() {
    AccumulatorInfo info = getInfo();
    boolean includeValue = info.isIncludeValue();
    InternalQueryCache queryCache = getQueryCache();
    InternalSerializationService serializationService = context.getSerializationService();
    return new SubscriberAccumulatorHandler(includeValue, queryCache, serializationService);
}
Also used : AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 9 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class AbstractInternalQueryCache method doFullValueScan.

protected void doFullValueScan(Predicate predicate, Set<V> resultingSet) {
    InternalSerializationService serializationService = this.serializationService;
    CachedQueryEntry queryEntry = new CachedQueryEntry();
    Set<Map.Entry<Data, QueryCacheRecord>> entries = recordStore.entrySet();
    for (Map.Entry<Data, QueryCacheRecord> entry : entries) {
        Data keyData = entry.getKey();
        QueryCacheRecord record = entry.getValue();
        Object value = record.getValue();
        queryEntry.init(serializationService, keyData, value, Extractors.empty());
        boolean valid = predicate.apply(queryEntry);
        if (valid) {
            Object valueObject = queryEntry.getValue();
            resultingSet.add((V) valueObject);
        }
    }
}
Also used : CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) AbstractMap(java.util.AbstractMap) IMap(com.hazelcast.core.IMap) Map(java.util.Map)

Example 10 with InternalSerializationService

use of com.hazelcast.internal.serialization.InternalSerializationService in project hazelcast by hazelcast.

the class AbstractInternalQueryCache method doFullEntryScan.

protected void doFullEntryScan(Predicate predicate, Set<Map.Entry<K, V>> resultingSet) {
    InternalSerializationService serializationService = this.serializationService;
    CachedQueryEntry queryEntry = new CachedQueryEntry();
    Set<Map.Entry<Data, QueryCacheRecord>> entries = recordStore.entrySet();
    for (Map.Entry<Data, QueryCacheRecord> entry : entries) {
        Data keyData = entry.getKey();
        QueryCacheRecord record = entry.getValue();
        Object value = record.getValue();
        queryEntry.init(serializationService, keyData, value, Extractors.empty());
        boolean valid = predicate.apply(queryEntry);
        if (valid) {
            Object keyObject = queryEntry.getKey();
            Object valueObject = queryEntry.getValue();
            Map.Entry simpleEntry = new AbstractMap.SimpleEntry(keyObject, valueObject);
            resultingSet.add(simpleEntry);
        }
    }
}
Also used : CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) QueryCacheRecord(com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord) Data(com.hazelcast.nio.serialization.Data) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) CachedQueryEntry(com.hazelcast.query.impl.CachedQueryEntry) AbstractMap(java.util.AbstractMap) IMap(com.hazelcast.core.IMap) Map(java.util.Map)

Aggregations

InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)38 QuickTest (com.hazelcast.test.annotation.QuickTest)15 Test (org.junit.Test)15 Data (com.hazelcast.nio.serialization.Data)14 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)12 Map (java.util.Map)6 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)5 IMap (com.hazelcast.core.IMap)4 QueryCacheRecord (com.hazelcast.map.impl.querycache.subscriber.record.QueryCacheRecord)4 SerializationService (com.hazelcast.spi.serialization.SerializationService)4 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)3 QueryEntry (com.hazelcast.query.impl.QueryEntry)3 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)3 SerializationConfig (com.hazelcast.config.SerializationConfig)2 PartitioningStrategy (com.hazelcast.core.PartitioningStrategy)2 TransactionalMap (com.hazelcast.core.TransactionalMap)2 NearCacheRecord (com.hazelcast.internal.nearcache.NearCacheRecord)2 DefaultNearCache (com.hazelcast.internal.nearcache.impl.DefaultNearCache)2 AbstractNearCacheRecordStore (com.hazelcast.internal.nearcache.impl.store.AbstractNearCacheRecordStore)2 SerializationServiceBuilder (com.hazelcast.internal.serialization.SerializationServiceBuilder)2