/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
// SunDATable.java: A DATable implementation that uses the IPC connection.
// Author: James Kempf
// Created On: Mon May 11 15:00:23 1998
// Last Modified By: James Kempf
// Last Modified On: Thu Mar 11 15:00:58 1999
// Update Count: 71
//
/**
* The SunDATable class uses the IPC connection to obtain DA information
* from the SA server. By convention, the SA server answers service
* requests for the service type "directory-agent.sun" and including
* a filter for the scopes formatted as:
*
* "(&(|(scopes=<scope1>)(scopes=<scope2>)(scopes=<scope3>)...)(version=2))"
*
* with a collection of URLs that fit the request. The scope of the
* request is the hostname of the local machine, which will not be
* forwarded to any DAs. The URLs contain the
* DA IP address in the host field and a list of scopes in the URL
* part in the form of an attribute value assignment, i.e.:
*
* service:directory-agent.sun:// 199.200.200.5/scopes=eng, corp, freeb
*
* useScopes list, then refreshed periodically when the
* time stamp runs out. The time stamp is determined as the minimum
* expiration time of the service URLs.
*
* @author James Kempf
*/
// The scopes identifier.
// DA version number.
// The scopes which reside on the SA only.
// The cached vector of DA equivalence classes.
// The time when the cache should be refreshed.
/**
* Construct a DATable. We get a cached table of accessable
* DAs and scopes and the SA scope names to use for querying.
*/
// Remove the common scopes from the SA scopes. This will leave
// the private, SA only scopes.
"no_sa_scopes",
new Object[0]);
// Initialize the cache. We want the scopes that can be dynamically
// discovered. If we have been configured with scopes, then
// it will be those. If not, then we want whatever we can discovery.
// we only want the default version for client side.
}
/**
* Return a hashtable of DA equivalence classes and multicast
* scopes. Multicast scopes are stored in the special hashtable
* key MULTICAST_KEY. Unicast DA equivalence classes are stored
* under the key UNICAST_KEY.
*
* @param scopes Scope list for DAs needed.
* @return Hashtable with DA addresses as keys and scopes to contact
* them with as values. Any scopes not associated with a
* DA come back stored under the key MULTICAST_KEY.
* Unicast DA equivalence classes are stored
* under the key UNICAST_KEY.
*/
throws ServiceLocationException {
// Refresh the local cache if necessary.
}
int i;
// Sort through the local cache, matching against the input parameter.
// Collect multicast scopes.
// Filter multicast scopes first. Remove any from the multicast
// scope list that are in daScopes.
// Now filter daScopes. Remove any from the daScopes that are
// not in the input scopes.
// Remove this record if there are none left.
/*
* Must decrement the index 'i' otherwise the next iteration
* around the loop will miss the element immediately after
* the element removed.
*
* WARNING: Do not use 'i' again until the loop has
* iterated as it may, after decrementing,
* be negative.
*/
i--;
continue;
}
}
// Install the unicast and multicast scopes if any.
}
}
return ret;
}
/**
* Remove a DA by address. We only remove it from the wire table
* so if it's down temporarily, we'll get it back again.
*
* @param address The host address of the DA.
* @param scopes The scopes.
* @return True if removed, false if not.
*/
// Sort through the table of equivalence classes in cache.
boolean foundit = false;
int i;
// Ignore scopes, delete if there. Scopes will always be the
// ones for which this DA is to be removed.
int j, m = daAddresses.size();
for (j = 0; j < m; j++) {
// If they are equal, remove it, exit loop.
foundit = true;
// If the cache entry is empty, remove it.
cache.removeElementAt(i);
}
break;
}
}
}
return foundit;
}
// Return a vector of DARecord equivalence classes by going out to the
// wire for them. Merge any that are in the current process'
// DAAddresses property.
throws ServiceLocationException {
// Get replies from the SA server. These will be CSrvMsg replies.
// Process reply into the vector of equivalence classes by adding to
// to those from the preconfigured DAs.
// Return vector.
return ret;
}
throws ServiceLocationException {
// Form the query.
for (i = 0; i < n; i++) {
}
// Add logical disjunction if there is more than one scope.
if (i > 1) {
}
// Add version number restriction.
if (i > 0) {
}
// Add closing paren if there were any scopes.
if (i > 0) {
}
// Create the message object. Note that if scope vector is
// empty, the query is the null string, and so all DAs
// will be returned.
// Send it down the pipe to the IPC process. It's a bad bug
// if the reply comes back as not a CSrvMsg.
// Check error code.
short errCode =
rply.getErrorCode());
throw
"loopback_error",
new Object[] {
}
}
// Process CSrvMsg reply into DA equivalence class vector
throws ServiceLocationException {
// Get the URLs.
// Process each service URL.
int i, n = serviceURLs.size();
for (i = 0; i < n; i++) {
// If the time to live is less than the current minimum,
// save it.
if (lifetime < shortTimer) {
}
// Get the host name and URL part.
// Parse URL part into scope list. Be
// sure not to include the initial `/' in the parse.
";");
while (tk.hasMoreElements()) {
// Convert to an SLP attribute.
// Depending on the attribute id, do something.
} else {
throw
"loopback_parse_error",
}
}
// Add it to the equivalence class.
}
// Reset the timestamp.
}
}