Search in sources :

Example 1 with CacheRefreshConfiguration

use of org.xdi.config.oxtrust.CacheRefreshConfiguration in project oxTrust by GluuFederation.

the class ConfigureCacheRefreshAction method getOxTrustCacheRefreshConfig.

private CacheRefreshConfiguration getOxTrustCacheRefreshConfig() {
    CacheRefreshConfiguration cacheRefreshConfiguration = jsonConfigurationService.getOxTrustCacheRefreshConfiguration();
    if (cacheRefreshConfiguration == null) {
        cacheRefreshConfiguration = new CacheRefreshConfiguration();
        cacheRefreshConfiguration.setUpdateMethod(CacheRefreshUpdateMethod.COPY.getValue());
        cacheRefreshConfiguration.setSourceConfigs(new ArrayList<GluuLdapConfiguration>());
        cacheRefreshConfiguration.setInumConfig(new GluuLdapConfiguration());
        cacheRefreshConfiguration.setTargetConfig(new GluuLdapConfiguration());
        cacheRefreshConfiguration.setKeyAttributes(new ArrayList<String>(0));
        cacheRefreshConfiguration.setKeyObjectClasses(new ArrayList<String>());
        cacheRefreshConfiguration.setSourceAttributes(new ArrayList<String>());
        cacheRefreshConfiguration.setAttributeMapping(new ArrayList<CacheRefreshAttributeMapping>());
        cacheRefreshConfiguration.setDefaultInumServer(true);
    }
    this.updateMethod = CacheRefreshUpdateMethod.getByValue(cacheRefreshConfiguration.getUpdateMethod());
    this.keyAttributes = toSimpleProperties(cacheRefreshConfiguration.getKeyAttributes());
    this.keyObjectClasses = toSimpleProperties(cacheRefreshConfiguration.getKeyObjectClasses());
    this.sourceAttributes = toSimpleProperties(cacheRefreshConfiguration.getSourceAttributes());
    this.attributeMapping = toSimpleCustomProperties(cacheRefreshConfiguration.getAttributeMapping());
    return cacheRefreshConfiguration;
}
Also used : CacheRefreshConfiguration(org.xdi.config.oxtrust.CacheRefreshConfiguration) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration) CacheRefreshAttributeMapping(org.xdi.config.oxtrust.CacheRefreshAttributeMapping)

Example 2 with CacheRefreshConfiguration

use of org.xdi.config.oxtrust.CacheRefreshConfiguration in project oxTrust by GluuFederation.

the class CacheRefreshTimer method initTimer.

public void initTimer() {
    log.info("Initializing Cache Refresh Timer");
    this.isActive = new AtomicBoolean(false);
    // Clean up previous Inum cache
    CacheRefreshConfiguration cacheRefreshConfiguration = configurationFactory.getCacheRefreshConfiguration();
    if (cacheRefreshConfiguration != null) {
        String snapshotFolder = cacheRefreshConfiguration.getSnapshotFolder();
        if (StringHelper.isNotEmpty(snapshotFolder)) {
            String inumCachePath = getInumCachePath(cacheRefreshConfiguration);
            objectSerializationService.cleanup(inumCachePath);
        }
    }
    // Schedule to start cache refresh every 1 minute
    final int delay = 1 * 60;
    final int interval = DEFAULT_INTERVAL;
    timerEvent.fire(new TimerEvent(new TimerSchedule(delay, DEFAULT_INTERVAL), new CacheRefreshEvent(), Scheduled.Literal.INSTANCE));
    this.lastFinishedTime = System.currentTimeMillis();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TimerSchedule(org.xdi.service.timer.schedule.TimerSchedule) CacheRefreshConfiguration(org.xdi.config.oxtrust.CacheRefreshConfiguration) TimerEvent(org.xdi.service.timer.event.TimerEvent) CacheRefreshEvent(org.gluu.oxtrust.service.cdi.event.CacheRefreshEvent)

Example 3 with CacheRefreshConfiguration

use of org.xdi.config.oxtrust.CacheRefreshConfiguration in project oxTrust by GluuFederation.

the class CacheRefreshTimer method processInt.

public void processInt() {
    CacheRefreshConfiguration cacheRefreshConfiguration = configurationFactory.getCacheRefreshConfiguration();
    try {
        GluuAppliance currentAppliance = applianceService.getAppliance();
        if (!isStartCacheRefresh(cacheRefreshConfiguration, currentAppliance)) {
            log.debug("Starting conditions aren't reached");
            return;
        }
        processImpl(cacheRefreshConfiguration, currentAppliance);
        updateApplianceStatus(currentAppliance, System.currentTimeMillis());
        this.lastFinishedTime = System.currentTimeMillis();
    } catch (Throwable ex) {
        log.error("Exception happened while executing cache refresh synchronization", ex);
    }
}
Also used : GluuAppliance(org.gluu.oxtrust.model.GluuAppliance) CacheRefreshConfiguration(org.xdi.config.oxtrust.CacheRefreshConfiguration)

Aggregations

CacheRefreshConfiguration (org.xdi.config.oxtrust.CacheRefreshConfiguration)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)1 CacheRefreshEvent (org.gluu.oxtrust.service.cdi.event.CacheRefreshEvent)1 CacheRefreshAttributeMapping (org.xdi.config.oxtrust.CacheRefreshAttributeMapping)1 GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)1 TimerEvent (org.xdi.service.timer.event.TimerEvent)1 TimerSchedule (org.xdi.service.timer.schedule.TimerSchedule)1