2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2001 by Sun Microsystems, Inc. 2N/A * All rights reserved. 2N/A// Author: James Kempf 2N/A// Created On: Thu Sep 3 08:45:21 1998 2N/A// Last Modified By: James Kempf 2N/A// Last Modified On: Thu Jan 28 15:45:45 1999 2N/A * The ActiveDiscover does active discovery DA discovery by periodically 2N/A * sending out a SrvRqst for "service:directory-agent". Replies are 2N/A * entered into the DA table. 2N/A * @author James Kempf 2N/A // Message for active DA discovery. 2N/A // Version of protocol to use for advertisements. 2N/A // DATable where discovered DAs are recorded. 2N/A // Scopes to advertise for. 2N/A // Address on which to advertise. 2N/A // Create an active discoverer. 2N/A // Do an initial active discovery then start a thread to 2N/A // do one periodically. 2N/A // Initial sleepy time. 2N/A // Create a message for active discovery. 2N/A // Initialize preconfigured DAs. 2N/A // Do an initial round of active discovery, waiting for 2N/A // a random period first. Only do it if active 2N/A // Report that active discovery is off. 2N/A // Start the active discovery thread. 2N/A // Implement the Runnable interface for a thread to start. 2N/A // Set the Thread name. 2N/A // Sleepy time until discovery. 2N/A // If the sleep time is zero, then active discovery is turned off. 2N/A // Use the service URL maximum lifetime. 2N/A // Register ourselves at startup if we are a DA. We may not be 2N/A // listening for the active discovery message at startup 2N/A // because the listener thread goes on-line last of all. 2N/A for (i =
0; i < n; i++) {
2N/A long timestamp =
0;
// later adverts will cause replacement, 2N/A // but noforwarding because it is to us... 2N/A // Sleep, then perform active discovery or polling of preconfigured 2N/A // DAs when we awake. 2N/A // Perform active DA discovery. 2N/A // Set the previous responders list to null. Otherwise, 2N/A // the previous responders from the last time we did 2N/A // this may interfere. 2N/A // Perform the active discovery message transaction. 2N/A // Add preconfigured DAs to the DA table. Note that we poll the 2N/A // preconfigured DAs once every 9 hours to make sure they are still around. 2N/A // Go through the DA addresses, contacting them for their 2N/A // information. Better not be any SLPv1 DAs there. 2N/A for (i =
0; i < n; i++) {
2N/A // Use a TCP connection. DAs must support TCP so why not? 2N/A // Report if there's an error in configuration. 2N/A // We need to make the URL long lived if active 2N/A // discovery is off. Otherwise, we let the DA time out like all the 2N/A // Add the scopes to the configured scopes. Scopes from configured 2N/A // DAs count as configured scopes. 2N/A // Record it. Note that we don't have to forward here 2N/A // because it's the very beginning.