javax.jmdns.impl.tasks.RecordReaper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmdns Show documentation
Show all versions of jmdns Show documentation
JmDNS is a Java implementation of multi-cast DNS and can be used for service registration and discovery in local area networks. JmDNS is fully compatible with Apple's Bonjour.
The project was originally started in December 2002 by Arthur van Hoff at Strangeberry.
// Copyright 2003-2005 Arthur van Hoff, Rick Blair
// Licensed under Apache License version 2.0
// Original license LGPL
package javax.jmdns.impl.tasks;
import java.util.Timer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jmdns.impl.JmDNSImpl;
import javax.jmdns.impl.constants.DNSConstants;
/**
* Periodically removes expired entries from the cache.
*/
public class RecordReaper extends DNSTask {
static Logger logger = LoggerFactory.getLogger(RecordReaper.class);
/**
* @param jmDNSImpl
*/
public RecordReaper(JmDNSImpl jmDNSImpl) {
super(jmDNSImpl);
}
/*
* (non-Javadoc)
* @see javax.jmdns.impl.tasks.DNSTask#getName()
*/
@Override
public String getName() {
return "RecordReaper(" + (this.getDns() != null ? this.getDns().getName() : "") + ")";
}
/*
* (non-Javadoc)
* @see javax.jmdns.impl.tasks.DNSTask#start(java.util.Timer)
*/
@Override
public void start(Timer timer) {
if (!this.getDns().isCanceling() && !this.getDns().isCanceled()) {
timer.schedule(this, DNSConstants.RECORD_REAPER_INTERVAL, DNSConstants.RECORD_REAPER_INTERVAL);
}
}
@Override
public void run() {
if (this.getDns().isCanceling() || this.getDns().isCanceled()) {
return;
}
logger.trace("{}.run() JmDNS reaping cache", this.getName());
// Remove expired answers from the cache
// -------------------------------------
this.getDns().cleanCache();
}
}