@Override public LDAPStoreConfigurationBuilder withProperties(final Properties properties) { return properties(properties); }
@Override public void purge(final Executor executor, final PurgeListener<? super K> purgeListener) { Loggers.LDAP_LOG.trace("[IL0261] LDAP store: Purging {} entries", getCacheName()); executor.execute(() -> reaper.purge(purgeListener)); }
@Override public void purge(final Executor executor, final ExpirationPurgeListener<K,V> purgeListener) { Loggers.LDAP_LOG.trace("[IL0267] LDAP store: Purging {} entries", getCacheName()); executor.execute(() -> reaper.purgeExtended(purgeListener)); } }
@Override public boolean delete(final Object key) { // The CacheWriter should remove from the external storage the entry identified by the specified key. // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0252] LDAP store: Deleting {} entry with key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.deleteEntry(dn); }
@Override public boolean contains(final Object key) { // This method will be invoked by the PersistenceManager to determine if the loader contains the specified key. // The implementation should be as fast as possible, e.g. it should strive to transfer the least amount of data possible // from the external storage to perform the check. Also, if possible, make sure the field is indexed on the external storage // so that its existence can be determined as quickly as possible. // // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0250] LDAP store: Checking {} cache key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.entryExists(dn); }
@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 int size() { // Infinispan code analysis on 8.2 shows that this method is never called in practise, and // is not wired to the data / cache container API Loggers.LDAP_LOG.trace("[IL0258] LDAP store: Counting {} entries", getCacheName()); final int count = ldapConnector.countEntries(); Loggers.LDAP_LOG.trace("[IL0259] LDAP store: Counted {} {} entries", count, getCacheName()); return count; }
@Override public void clear() { Loggers.LDAP_LOG.trace("[IL0260] LDAP store: Clearing {} entries", getCacheName()); int numDeleted = ldapConnector.deleteEntries(); Loggers.LDAP_LOG.debug("[IL0254] LDAP store: Cleared {} {} entries", numDeleted, getCacheName()); }
@Override public void stop() { if (ldapConnector != null) { ldapConnector.shutdown(); Loggers.MAIN_LOG.info("[IL0205] Stopped LDAP external store connector for cache {}", getCacheName()); } super.stop(); }
@SuppressWarnings("unchecked") private K resolveKey(final Object key) { if (key instanceof byte[]) { throw new PersistenceException("Cannot resolve " + getCacheName() + " cache key from byte[], enable compatibility mode"); } return (K)key; }
@Override public LDAPStoreConfiguration create() { // This method should construct a new instance of a // LDAPStoreConfiguration object. There will be one instance // per cache. return new LDAPStoreConfiguration( purgeOnStartup, fetchPersistentState, ignoreModifications, async.create(), singletonStore.create(), preload, shared, properties); }
@Override public boolean delete(final Object key) { // The CacheWriter should remove from the external storage the entry identified by the specified key. // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0252] LDAP store: Deleting {} entry with key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.deleteEntry(dn); }
@Override public boolean contains(final Object key) { // This method will be invoked by the PersistenceManager to determine if the loader contains the specified key. // The implementation should be as fast as possible, e.g. it should strive to transfer the least amount of data possible // from the external storage to perform the check. Also, if possible, make sure the field is indexed on the external storage // so that its existence can be determined as quickly as possible. // // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0250] LDAP store: Checking {} cache key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.entryExists(dn); }
@Override public void purge(final Executor executor, final PurgeListener<? super K> purgeListener) { Loggers.LDAP_LOG.trace("[IL0261] LDAP store: Purging {} entries", getCacheName()); final AtomicInteger numPurged = new AtomicInteger(); executor.execute(() -> numPurged.set(reaper.purge(purgeListener))); Loggers.LDAP_LOG.debug("[IL0255] LDAP store: Purged {} expired {} entries", numPurged.get(), getCacheName()); } }
@Override public int size() { // Infinispan code analysis on 8.2 shows that this method is never called in practise, and // is not wired to the data / cache container API Loggers.LDAP_LOG.trace("[IL0258] LDAP store: Counting {} entries", getCacheName()); final int count = ldapConnector.countEntries(); Loggers.LDAP_LOG.trace("[IL0259] LDAP store: Counted {} {} entries", count, getCacheName()); return count; }
@Override public void clear() { Loggers.LDAP_LOG.trace("[IL0260] LDAP store: Clearing {} entries", getCacheName()); int numDeleted = ldapConnector.deleteEntries(); Loggers.LDAP_LOG.debug("[IL0254] LDAP store: Cleared {} {} entries", numDeleted, getCacheName()); }
@Override public void stop() { if (ldapConnector != null) { ldapConnector.shutdown(); Loggers.MAIN_LOG.info("[IL0205] Stopped LDAP external store connector for cache {}", getCacheName()); } super.stop(); }
@Override public LDAPStoreConfigurationBuilder withProperties(final Properties properties) { return properties(properties); }
@SuppressWarnings("unchecked") private K resolveKey(final Object key) { if (key instanceof byte[]) { throw new PersistenceException("Cannot resolve " + getCacheName() + " cache key from byte[], enable compatibility mode"); } return (K)key; }
@Override public LDAPStoreConfiguration create() { // This method should construct a new instance of a // LDAPStoreConfiguration object. There will be one instance // per cache. return new LDAPStoreConfiguration( purgeOnStartup, fetchPersistentState, ignoreModifications, async.create(), singletonStore.create(), preload, shared, properties); }