private MarshalledEntry<K, V> asMarshalledEntry(Object key) { return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, (Object) null, (InternalMetadata) null); }
@Override public MarshalledEntry<K, V> load(Object key) throws PersistenceException { byte[] bytes = this.remoteCache.get(this.marshall(key)); if (bytes == null) { return null; } Map.Entry<ByteBuffer, ByteBuffer> entry = this.unmarshallValue(bytes); return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, entry.getKey(), entry.getValue()); }
private MarshalledEntry<K, V> asMarshalledEntry(Object key) { return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, (Object) null, (InternalMetadata) null); }
@Override public MarshalledEntry<K, V> load(Object key) throws PersistenceException { byte[] bytes = this.remoteCache.get(this.marshall(key)); if (bytes == null) { return null; } Map.Entry<ByteBuffer, ByteBuffer> entry = this.unmarshallValue(bytes); return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, entry.getKey(), entry.getValue()); }
@Override public void init(InitializationContext ctx) { factory = ctx.getMarshalledEntryFactory(); timeService = ctx.getTimeService(); }
private MarshalledEntry<K,V> decodeEntry(Map.Entry<Key,Value> entry, Object key, boolean loadValue, boolean loadMetadata) { if (entry != null) { ByteBufferFactory bbFactory = ctx.getByteBufferFactory(); ByteBuffer buffer = ByteBuffer.wrap(entry.getValue().get(), 0, entry.getValue().getSize()); int valueSize = buffer.getInt(); int metadataSize = buffer.getInt(); org.infinispan.commons.io.ByteBuffer valueBytes = null; if (loadValue) { valueBytes = bbFactory.newByteBuffer(entry.getValue().get(), buffer.position(), valueSize); } org.infinispan.commons.io.ByteBuffer metadataBytes = null; if (metadataSize > 0 && loadMetadata) { // Skip over value if we didn't read it in. if (!loadValue) buffer.position(buffer.position() + valueSize); metadataBytes = bbFactory.newByteBuffer(entry.getValue().get(), buffer.position() + valueSize, metadataSize); } // noinspection unchecked return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, valueBytes, metadataBytes); } else { return null; } }
@Override @SuppressWarnings("unchecked") public void init(final InitializationContext ctx) { // This method will be invoked by the PersistenceManager during initialization. The InitializationContext // contains: // - this CacheLoader's configuration // - the cache to which this loader is applied. Your loader might want to use the cache's name to construct // cache-specific identifiers // - the StreamingMarshaller that needs to be used to marshall/unmarshall the entries // - a TimeService which the loader can use to determine expired entries // - a ByteBufferFactory which needs to be used to construct ByteBuffers // - a MarshalledEntryFactory which needs to be used to construct entries from the data retrieved by the loader super.init(ctx); this.config = ctx.getConfiguration(); Loggers.MAIN_LOG.info("[IL0201] LDAP store configuration properties for cache {}:", getCacheName()); config.log(); Loggers.MAIN_LOG.debug("[IL0202] Loading LDAP entry transformer class {} for cache {}...", config.ldapDirectory.entryTransformer, getCacheName()); ldapEntryTransformer = loadEntryTransformerClass(config.ldapDirectory.entryTransformer); marshalledEntryFactory = (MarshalledEntryFactory<K, V>)ctx.getMarshalledEntryFactory(); Loggers.MAIN_LOG.info("[IL0203] Initialized LDAP external store for cache {}", getCacheName()); }
@Override @SuppressWarnings("unchecked") public void init(final InitializationContext ctx) { // This method will be invoked by the PersistenceManager during initialization. The InitializationContext // contains: // - this CacheLoader's configuration // - the cache to which this loader is applied. Your loader might want to use the cache's name to construct // cache-specific identifiers // - the StreamingMarshaller that needs to be used to marshall/unmarshall the entries // - a TimeService which the loader can use to determine expired entries // - a ByteBufferFactory which needs to be used to construct ByteBuffers // - a MarshalledEntryFactory which needs to be used to construct entries from the data retrieved by the loader super.init(ctx); this.config = ctx.getConfiguration(); Loggers.MAIN_LOG.info("[IL0201] LDAP store configuration properties for cache {}:", getCacheName()); config.log(); Loggers.MAIN_LOG.debug("[IL0202] Loading LDAP entry transformer class {} for cache {}...", config.ldapDirectory.entryTransformer, getCacheName()); ldapEntryTransformer = loadEntryTransformerClass(config.ldapDirectory.entryTransformer); marshalledEntryFactory = (MarshalledEntryFactory<K, V>)ctx.getMarshalledEntryFactory(); Loggers.MAIN_LOG.info("[IL0203] Initialized LDAP external store for cache {}", getCacheName()); }
@Override public MarshalledEntry load(final Object key) { if (key instanceof IndexScopedKey) { final IndexScopedKey indexKey = (IndexScopedKey)key; DirectoryLoaderAdaptor directoryAdaptor = getDirectory(indexKey); Object value = directoryAdaptor.load(indexKey); if (value != null) { return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, value, null); } else { return null; } } else { log.cacheLoaderIgnoringKey(key); return null; } }
@Override public MarshalledEntry load(final Object key) { if (key instanceof IndexScopedKey) { final IndexScopedKey indexKey = (IndexScopedKey)key; DirectoryLoaderAdaptor directoryAdaptor = getDirectory(indexKey); Object value = directoryAdaptor.load(indexKey); if (value != null) { return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, value, null); } else { return null; } } else { log.cacheLoaderIgnoringKey(key); return null; } }
@Override public void init(InitializationContext ctx) { configuration = ctx.getConfiguration(); marshaller = ctx.getMarshaller(); marshalledEntryFactory = ctx.getMarshalledEntryFactory(); byteBufferFactory = ctx.getByteBufferFactory(); timeService = ctx.getTimeService(); maxKeyLength = configuration.maxNodeSize() - IndexNode.RESERVED_SPACE; }
@Override public MarshalledEntry load(final Object key) { if (key instanceof IndexScopedKey) { final IndexScopedKey indexKey = (IndexScopedKey)key; DirectoryLoaderAdaptor directoryAdaptor = getDirectory(indexKey); Object value = directoryAdaptor.load(indexKey); if (value != null) { return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, value, null); } else { return null; } } else { log.cacheLoaderIgnoringKey(key); return null; } }
return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, value, internalMetadata);
@Override public void init(InitializationContext ctx) { this.configuration = ctx.getConfiguration(); this.emfRegistry = ctx.getCache().getAdvancedCache().getComponentRegistry().getGlobalComponentRegistry().getComponent(EntityManagerFactoryRegistry.class); this.marshallerEntryFactory = ctx.getMarshalledEntryFactory(); this.marshaller = ctx.getMarshaller(); this.timeService = ctx.getTimeService(); this.executorService = ctx.getExecutor(); }
@Override public Flowable<MarshalledEntry<K, V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata) { Flowable<K> keyFlowable = publishKeys(filter); if (!fetchValue && !fetchMetadata) { return keyFlowable.map(k -> ctx.getMarshalledEntryFactory().newMarshalledEntry(k, (Object) null, null)); } else { return keyFlowable.map(k -> { // Technically this load will only be done synchronously but we are fine with that MarshalledEntry<K, V> entry = load(k, fetchValue, fetchMetadata); if (entry == null) { // Rxjava2 doesn't allow nulls entry = MarshalledEntryImpl.empty(); } return entry; }).filter(me -> me != MarshalledEntryImpl.empty()); } }
marshalledEntryFactory = (MarshalledEntryFactory<K, V>)ctx.getMarshalledEntryFactory();
marshalledEntryFactory = (MarshalledEntryFactory<K, V>)ctx.getMarshalledEntryFactory();
private MarshalledEntry deserialize(Object key, byte[] b, boolean fetchValue, boolean fetchMetadata) { try { if (b == null) return null; // We have to fetch metadata to tell if a key or entry is expired. Note this can be changed // after API changes fetchMetadata = true; KeyValuePair<Object, InternalMetadata> keyValuePair = (KeyValuePair<Object, InternalMetadata>) marshaller.objectFromByteBuffer(b); return ctx.getMarshalledEntryFactory().newMarshalledEntry(key, fetchValue ? keyValuePair.getKey() : null, fetchMetadata ? keyValuePair.getValue() : null); } catch (IOException e) { throw new CacheException(e); } catch (ClassNotFoundException e) { throw new CacheException(e); } }
@Override public void init(InitializationContext ctx) { this.configuration = ctx.getConfiguration(); this.cacheName = ctx.getCache().getName(); this.globalConfiguration = ctx.getCache().getCacheManager().getCacheManagerConfiguration(); this.marshalledEntryFactory = ctx.getMarshalledEntryFactory(); this.marshaller = ctx.getMarshaller(); this.timeService = ctx.getTimeService(); this.keyPartitioner = configuration.segmented() ? ctx.getKeyPartitioner() : null; this.isDistributedCache = ctx.getCache().getCacheConfiguration() != null && ctx.getCache().getCacheConfiguration().clustering().cacheMode().isDistributed(); }
marshalledEntryFactory = (MarshalledEntryFactory<K,V>)ctx.getMarshalledEntryFactory();