mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
added a DNS-multicast discovery support.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@31053 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
d995cea432
commit
d82b85716f
3 files changed
+57
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package hudson;
|
||||
|
||||
import hudson.model.Hudson;
|
||||
|
||||
import javax.jmdns.JmDNS;
|
||||
import javax.jmdns.ServiceInfo;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Registers a DNS multi-cast service-discovery support.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
public class DNSMultiCast implements Closeable {
|
||||
private JmDNS jmdns;
|
||||
|
||||
public DNSMultiCast(Hudson hudson) {
|
||||
try {
|
||||
this.jmdns = JmDNS.create();
|
||||
|
||||
Map<String,String> props = new HashMap<String, String>();
|
||||
props.put("url",hudson.getRootUrl());
|
||||
props.put("version",Hudson.getVersion().toString());
|
||||
|
||||
TcpSlaveAgentListener tal = hudson.getTcpSlaveAgentListener();
|
||||
if (tal!=null)
|
||||
props.put("slave-port",String.valueOf(tal.getPort()));
|
||||
|
||||
jmdns.registerService(ServiceInfo.create("_hudson._tcp.local.","hudson",
|
||||
80,0,0,props));
|
||||
} catch (IOException e) {
|
||||
LOGGER.log(Level.WARNING,"Failed to advertise the service to DNS multi-cast",e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
jmdns.close();
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(DNSMultiCast.class.getName());
|
||||
}
|
||||
Reference in new issue
Block a user