Method from org.apache.openejb.server.discovery.MulticastDiscoveryAgent Detail: |
public long getExponentialBackoff() {
return exponentialBackoff;
}
|
public String getGroup() {
return group;
}
|
public long getHeartRate() {
return heartRate;
}
|
public String getHost() {
return host;
}
|
public String getIP() {
return host;
}
|
public int getMaxMissedHeartbeats() {
return maxMissedHeartbeats;
}
|
public int getMaxReconnectAttempts() {
return maxReconnectAttempts;
}
|
public long getMaxReconnectDelay() {
return maxReconnectDelay;
}
|
public String getName() {
return "multicast";
}
|
public int getPort() {
return port;
}
|
public long getReconnectDelay() {
return reconnectDelay;
}
|
public int getTimeToLive() {
return timeToLive;
}
|
public void init(Properties props) throws Exception {
host = props.getProperty("bind", host);
group = props.getProperty("group", group);
groupPrefix = group + ":";
Options options = new Options(props);
port = options.get("port", port);
heartRate = options.get("heart_rate", heartRate);
maxMissedHeartbeats = options.get("max_missed_heartbeats", maxMissedHeartbeats);
loopbackMode = options.get("loopback_mode", loopbackMode);
reconnectDelay = options.get("reconnect_delay", reconnectDelay);
maxReconnectDelay = options.get("max_reconnect_delay", reconnectDelay);
maxReconnectAttempts = options.get("max_reconnect_attempts", maxReconnectAttempts);
exponentialBackoff = options.get("exponential_backoff", exponentialBackoff);
useExponentialBackOff = (exponentialBackoff > 1);
}
|
public boolean isLoopbackMode() {
return loopbackMode;
}
|
public static void main(String[] args) throws Exception {
}
|
public void registerService(URI serviceUri) throws IOException {
Service service = new Service(serviceUri);
this.registeredServices.put(service.broadcastString, service);
this.listener.fireServiceAddedEvent(serviceUri);
}
|
public void reportFailed(URI serviceUri) throws IOException {
listener.reportFailed(serviceUri);
}
|
public void service(Socket socket) throws ServiceException, IOException {
}
|
public void service(InputStream in,
OutputStream out) throws ServiceException, IOException {
}
|
public void setDiscoveryListener(DiscoveryListener listener) {
this.listener.setDiscoveryListener(listener);
}
|
public void setExponentialBackoff(long exponentialBackoff) {
this.exponentialBackoff = exponentialBackoff;
this.useExponentialBackOff = (exponentialBackoff > 1);
}
|
public void setGroup(String group) {
this.group = group;
groupPrefix = group + ":";
}
|
public void setHeartRate(long heartRate) {
this.heartRate = heartRate;
}
|
public void setHost(String host) {
this.host = host;
}
|
public void setLoopbackMode(boolean loopbackMode) {
this.loopbackMode = loopbackMode;
}
|
public void setMaxMissedHeartbeats(int maxMissedHeartbeats) {
this.maxMissedHeartbeats = maxMissedHeartbeats;
}
|
public void setMaxReconnectAttempts(int maxReconnectAttempts) {
this.maxReconnectAttempts = maxReconnectAttempts;
}
|
public void setMaxReconnectDelay(long maxReconnectDelay) {
this.maxReconnectDelay = maxReconnectDelay;
}
|
public void setReconnectDelay(long reconnectDelay) {
this.reconnectDelay = reconnectDelay;
}
|
public void setTimeToLive(int timeToLive) {
this.timeToLive = timeToLive;
}
|
public void start() throws ServiceException {
try {
if (started.compareAndSet(false, true)) {
InetAddress inetAddress = InetAddress.getByName(host);
this.address = new InetSocketAddress(inetAddress, port);
multicast = new MulticastSocket(port);
multicast.setLoopbackMode(loopbackMode);
multicast.setTimeToLive(timeToLive);
multicast.joinGroup(inetAddress);
multicast.setSoTimeout((int) heartRate);
Thread listenerThread = new Thread(listener);
listenerThread.setName("MulticastDiscovery: Listener");
listenerThread.setDaemon(true);
listenerThread.start();
Broadcaster broadcaster = new Broadcaster();
Timer timer = new Timer("MulticastDiscovery: Broadcaster", true);
timer.scheduleAtFixedRate(broadcaster, 0, heartRate);
}
} catch (Exception e) {
throw new ServiceException(e);
}
}
start the discovery agent |
public void stop() throws ServiceException {
if (started.compareAndSet(true, false)) {
multicast.close();
}
}
|
public void unregisterService(URI serviceUri) throws IOException {
Service service = new Service(serviceUri);
this.registeredServices.remove(service.broadcastString);
this.listener.fireServiceRemovedEvent(serviceUri);
}
|