com.fasterxml.clustermate.service.cleanup.CleanupTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clustermate-service Show documentation
Show all versions of clustermate-service Show documentation
Building blocks for ClusterMate-based services and servers.
package com.fasterxml.clustermate.service.cleanup;
import java.util.concurrent.atomic.AtomicBoolean;
import com.fasterxml.clustermate.service.SharedServiceStuff;
import com.fasterxml.clustermate.service.Stores;
import com.fasterxml.clustermate.service.cluster.ClusterViewByServer;
import com.fasterxml.storemate.shared.TimeMaster;
public abstract class CleanupTask
{
protected TimeMaster _timeMaster;
protected AtomicBoolean _shutdown;
protected long _startupTime;
protected CleanupTask() { }
protected void init(SharedServiceStuff stuff,
Stores,?> stores,
ClusterViewByServer cluster,
AtomicBoolean shutdown)
{
_timeMaster = stuff.getTimeMaster();
_shutdown = shutdown;
}
protected boolean shouldStop()
{
return _shutdown.get();
}
protected T cleanUp() throws Exception
{
_startupTime = _timeMaster.currentTimeMillis();
return _cleanUp();
}
protected abstract T _cleanUp() throws Exception;
@Override
public String toString() {
return getClass().getName();
}
}