Search in sources :

Example 1 with CacheEntryExpired

use of org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired in project indy by Commonjava.

the class ScheduleManager method expired.

@CacheEntryExpired
public void expired(CacheEntryExpiredEvent<ScheduleKey, Map> e) {
    final ScheduleKey expiredKey = e.getKey();
    final Map expiredContent = e.getValue();
    if (expiredKey != null && expiredContent != null) {
        logger.debug("EXPIRED: {}", expiredKey);
        final String type = (String) expiredContent.get(ScheduleManager.JOB_TYPE);
        final String data = (String) expiredContent.get(ScheduleManager.PAYLOAD);
        eventDispatcher.fire(new SchedulerTriggerEvent(type, data));
    }
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) CacheEntryExpired(org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired)

Example 2 with CacheEntryExpired

use of org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired in project indy by Commonjava.

the class DefaultScheduleManager method expired.

@CacheEntryExpired
public void expired(CacheEntryExpiredEvent<ScheduleKey, ScheduleValue> e) {
    if (e == null) {
        logger.error("[FATAL]The infinispan cache expired event for indy schedule manager is null.", new NullPointerException("CacheEntryExpiredEvent is null"));
        return;
    }
    if (!e.isPre()) {
        final ScheduleKey expiredKey = e.getKey();
        final ScheduleValue value = e.getValue();
        if (value == null) {
            logger.warn("The cache value for ISPN expired event of schedule expiration is null, key is {} .", expiredKey);
            return;
        }
        final Map<String, Object> expiredContent = value.getDataPayload();
        if (expiredKey != null && expiredContent != null) {
            logger.debug("EXPIRED: {}", expiredKey);
            final String type = (String) expiredContent.get(DefaultScheduleManager.JOB_TYPE);
            final String data = (String) expiredContent.get(DefaultScheduleManager.PAYLOAD);
            if (logger.isInfoEnabled() && DefaultScheduleManager.CONTENT_JOB_TYPE.equals(type)) {
                ContentExpiration expiration;
                try {
                    expiration = objectMapper.readValue(data, ContentExpiration.class);
                    final StoreKey key = expiration.getKey();
                    final String path = expiration.getPath();
                    logger.info("Expiring: {} in: {} at: {}.", path, key, new Date(System.currentTimeMillis()));
                } catch (final IOException ioe) {
                // ignore
                }
            }
            fireEvent(eventDispatcher, new SchedulerTriggerEvent(type, data));
        /*
                scheduleEventLockCache.executeCache( cache -> cache.put( expiredKey, nodeHolder.getLocalIndyNode(),
                                                                         schedulerConfig.getClusterLockExpiration(),
                                                                         TimeUnit.SECONDS ) );
*/
        }
    }
}
Also used : IOException(java.io.IOException) StoreKey(org.commonjava.indy.model.core.StoreKey) Date(java.util.Date) CacheEntryExpired(org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired)

Example 3 with CacheEntryExpired

use of org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired in project indy by Commonjava.

the class FoloExpirationWarningListener method onCacheEntryExpired.

@CacheEntryExpired
public void onCacheEntryExpired(final CacheEntryExpiredEvent<TrackedContentEntry, TrackedContentEntry> event) {
    if (event.isPre()) {
        return;
    }
    TrackedContentEntry entry = event.getKey();
    logger.warn("Tracking record entry {}:{}:{} was expired by Infinispan!", entry.getTrackingKey(), entry.getStoreKey(), entry.getPath());
}
Also used : TrackedContentEntry(org.commonjava.indy.folo.model.TrackedContentEntry) CacheEntryExpired(org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired)

Aggregations

CacheEntryExpired (org.infinispan.notifications.cachelistener.annotation.CacheEntryExpired)3 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TrackedContentEntry (org.commonjava.indy.folo.model.TrackedContentEntry)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1