All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.duracloud.mill.dup.DuplicationPolicyRefresher Maven / Gradle / Ivy

There is a newer version: 5.1.1
Show newest version
/*
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 *     http://duracloud.org/license/
 */
package org.duracloud.mill.dup;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @author Daniel Bernstein
 *	       Date: Apr 11, 2014
 */
public class DuplicationPolicyRefresher {
    private Timer timer;
    private Long policyManagerRefreshFrequencyMs;
    private DuplicationPolicyManager policyManager;
    /**
     * @param policyManagerRefreshFrequencyMs
     */
    public DuplicationPolicyRefresher(Long policyManagerRefreshFrequencyMs, DuplicationPolicyManager policyManager) {
        this.policyManagerRefreshFrequencyMs = policyManagerRefreshFrequencyMs;
        this.policyManager = policyManager;
    }

    public void init() {
        timer = new Timer();
        timer.schedule(new TimerTask(){
            /* (non-Javadoc)
             * @see java.util.TimerTask#run()
             */
            @Override
            public void run() {
                policyManager.clearPolicyCache();
            }
        }, policyManagerRefreshFrequencyMs, policyManagerRefreshFrequencyMs);        
    }
    
    public void destroy(){
        timer.cancel();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy