@Override public void init(InitializationContext ctx) { this.ctx = ctx; HotRodStoreConfiguration configuration = ctx.getConfiguration(); RemoteCacheContainer remoteCacheContainer = configuration.attributes().attribute(HotRodStoreConfiguration.REMOTE_CACHE_CONTAINER).get(); String cacheConfiguration = configuration.attributes().attribute(HotRodStoreConfiguration.CACHE_CONFIGURATION).get(); String cacheName = ctx.getCache().getName(); try { ProtocolVersion protocolVersion = remoteCacheContainer.getConfiguration().version(); // Administration support was introduced in protocol version 2.7 if (protocolVersion.compareTo(ProtocolVersion.PROTOCOL_VERSION_27) < 0) { this.remoteCache = remoteCacheContainer.getCache(cacheName, false); if (this.remoteCache == null) { throw InfinispanLogger.ROOT_LOGGER.remoteCacheMustBeDefined(protocolVersion.toString(), cacheName); } } else { InfinispanLogger.ROOT_LOGGER.remoteCacheCreated(cacheName, cacheConfiguration); this.remoteCache = remoteCacheContainer.administration().getOrCreateCache(cacheName, cacheConfiguration); } } catch (HotRodClientException ex) { throw new PersistenceException(ex); } }
private MarshalledEntry<K, V> asMarshalledEntry(Object key) { return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, (Object) null, (InternalMetadata) null); }
private Object unmarshall(byte[] bytes) { try { return this.ctx.getMarshaller().objectFromByteBuffer(bytes); } catch (IOException | ClassNotFoundException e) { throw new PersistenceException(e); } }
@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 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(); }
@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; }
this.config = ctx.getConfiguration(); ctx.getCache().getCacheConfiguration().expiration().wakeUpInterval()); marshalledEntryFactory = (MarshalledEntryFactory<K, V>)ctx.getMarshalledEntryFactory();
@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 void init(InitializationContext ctx) { this.ctx = ctx; this.configuration = ctx.getConfiguration(); this.cache = ctx.getCache(); this.marshaller = ctx.getMarshaller(); this.storeName = makeStoreName(configuration, cache); this.initCount.incrementAndGet(); this.timeService = ctx.getTimeService(); }
@Override public void init(InitializationContext initializationContext) { configuration = initializationContext.getConfiguration(); ctx = initializationContext; }
@Override public void init(InitializationContext ctx) { this.configuration = ctx.getConfiguration(); this.ctx = ctx; this.scheduler = Schedulers.from(ctx.getExecutor()); this.timeService = ctx.getTimeService(); this.semaphore = new Semaphore(Integer.MAX_VALUE, true); }
@Override public void init(InitializationContext ctx) { factory = ctx.getMarshalledEntryFactory(); timeService = ctx.getTimeService(); }
@Override public void start() { if (iceFactory == null) { iceFactory = ctx.getCache().getAdvancedCache().getComponentRegistry().getComponent(InternalEntryFactory.class); maxContentLength = configuration.maxContentLength(); this.key2StringMapper = Util.getInstance(configuration.key2StringMapper(), ctx.getCache().getAdvancedCache().getClassLoader()); this.key2StringMapper.setMarshaller(ctx.getMarshaller()); this.path = configuration.path(); try { if (configuration.appendCacheNameToPath()) { path = path + urlCodec.encode(ctx.getCache().getName()) + "/"; this.metadataHelper = Util.getInstance(configuration.metadataHelper(), ctx.getCache().getAdvancedCache().getClassLoader());
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; } }
List<Object> keys = new ArrayList<>(); long now = ctx.getTimeService().wallClockTime(); RocksIterator iterator = expiredDb.newIterator(new ReadOptions().setFillCache(false)); if (iterator != null) { if (b == null) continue; MarshalledEntry me = (MarshalledEntry) ctx.getMarshaller().objectFromByteBuffer(b);
private String sanitizedCacheName() { return ctx.getCache().getName().replaceAll("[^a-zA-Z0-9-_\\.]", "_"); }
@Override public Publisher<MarshalledEntry<K, V>> publishEntries(Predicate<? super K> filter, boolean fetchValue, boolean fetchMetadata) { return Flowable.defer(() -> { // Make sure that we update directories before we start iterating upon directories scanForUnknownDirectories(); return Flowable.fromIterable(openDirectories.values()); }) // We parallelize this since the loading below is blocking .parallel() .runOn(Schedulers.from(ctx.getExecutor())) .flatMap(dir -> { final Set<MarshalledEntry<K, V>> allInternalEntries = new HashSet<>(); dir.loadAllEntries(allInternalEntries, Integer.MAX_VALUE, ctx.getMarshaller()); return Flowable.fromIterable(allInternalEntries); }) .filter(me -> filter == null || filter.test(me.getKey())) .sequential(); }
private void addNewExpiry(MarshalledEntry entry) throws IOException { long expiry = entry.getMetadata().expiryTime(); long maxIdle = entry.getMetadata().maxIdle(); if (maxIdle > 0) { // Coding getExpiryTime() for transient entries has the risk of being a moving target // which could lead to unexpected results, hence, InternalCacheEntry calls are required expiry = maxIdle + ctx.getTimeService().wallClockTime(); } Long at = expiry; Object key = entry.getKey(); try { expiryEntryQueue.put(new ExpiryEntry(at, key)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); // Restore interruption status } }
this.config = ctx.getConfiguration(); ctx.getCache().getCacheConfiguration().expiration().wakeUpInterval()); marshalledEntryFactory = (MarshalledEntryFactory<K,V>)ctx.getMarshalledEntryFactory(); final String metricsPrefix = ctx.getCache().getName() + "."; if (config.getMetricRegistry() == null) timers = new DynamoDBTimers(metricsPrefix);
@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()); }