Package com.iplanet.services.naming
Class WebtopNaming
- java.lang.Object
-
- com.iplanet.services.naming.WebtopNaming
-
public class WebtopNaming extends Object
TheWebtopNamingclass is used to get URLs for various services such as session, profile, logging etc. The lookup is based on the service name and the host name. The Naming Service shall contain URLs for all services on all servers. For instance, two machines might host session services. The Naming Service profile may look like the following:host1.session.URL="http://host1:8080/SessionServlet" host2.session.URL="https://host2:9090/SessionServlet"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWebtopNaming.SiteMonitorTheSiteMonitorclass is used to monitor the health status of all the sites.static interfaceWebtopNaming.SiteStatusCheckThe interfaceSiteStatusCheckprovides method that will be used by SiteMonitor to check each site is alive.
-
Field Summary
Fields Modifier and Type Field Description protected static DebugdebugThe debug instance.static StringNAMING_SERVICEThe unique identifier for the Naming Service.static StringNODE_SEPARATORThe delimiter used to separate server IDs in the service attribute.
-
Constructor Summary
Constructors Constructor Description WebtopNaming()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intconfigMonitoring()Provides the Monitoring Agent site and server related information.static Collection<String>getAllServerIDs()Returns all server IDs.static StringgetAMServerID()Returns the server ID.static List<String>getBaseURLs()The idea behind this function is to returns the base URLs of the OpenAM instances, without any of the extras that getServiceAllURLs provides - i.e. we don't want a specific service, we just want the base URL.static StringgetLBCookieValue(String serverid)Returns the lbCookieValue corresponding to the server ID.static StringgetLocalServer()Returns local server name from naming table.static String[]getNamingServiceURL()Returns a list of the naming service urls.static URLgetNotificationURL()Returns the URL of the notification service on the local host.static Set<String>getPlatformServerList()Returns the platform server list.static Set<String>getPlatformServerList(boolean update)Returns the platform server list.static StringgetSecondarySites(String serverid)Returns the String representation of the separator delimited secondary site list.static StringgetSecondarySites(String protocol, String host, String port, String uri)Returns the String representation of the separator delimited secondary site list.static StringgetServerFromID(String serverID)Returns the server URL based on the server ID.static StringgetServerID(String protocol, String host, String port, String uri)Returns the server ID that is there in the platform server list for a corresponding server.static StringgetServerID(String protocol, String host, String port, String uri, boolean updatetbl)Returns the server ID that is there in the platform server list for a corresponding server.static VectorgetServiceAllURLs(String service)Returns all the URLs of the specified service based on the servers in platform server list.static StringgetServiceClass(String service)Returns the class of the specified service.static URLgetServiceURL(String service, String protocol, String host, String port, boolean validate)Returns the URL of the specified service on the specified host.static URLgetServiceURL(String service, String protocol, String host, String port, String uri)Returns the URL of the specified service on the specified host.static URLgetServiceURL(String service, String protocol, String host, String port, String uri, boolean validate)Returns the URL of the specified service on the specified host.static URLgetServiceURL(String service, URL url, boolean validate)Returns the URL of the specified service on the specified host.static SessionIDCorrectorgetSessionIDCorrector()When server/site configuration changes, Sessions issued against the previous configuration will be out of date and refer to an invalid configuration.static StringgetSiteID(String serverid)Returns the unique identifier of the site which the given server instance belongs to.static StringgetSiteID(String protocol, String host, String port, String uri)Returns the unique identifier of the site which the given server instance belongs to.static StringgetSiteIdByName(String siteName)static StringgetSiteNameById(String siteId)static Set<String>getSiteNodes(String serverid)Returns all the node ID for the site.static StringgetURI(URL url)Returns the uri of the specified URL.static voidinitialize()static booleanisSecondarySite(String secondarySiteID)Tells whether the provided ID belongs to a secondary site or not.static booleanisServer(String serverID)Tells whether the provided ID belongs to a server or not.static booleanisServerMode()Determines whether WebtopNaming code runs in the core server mode or in the client SDK run-time mode.static booleanisSite(String siteID)Tells whether the provided ID belongs to a site or not.static booleanisSiteEnabled(String serverid)Determines whether Site is enabled for the given server ID.static booleanisSiteEnabled(String protocol, String host, String port, String uri)Determines whether Site is enabled for the given server instance.static StringmapSiteToServer(SessionID sid)Return the mapped server URL if there is a site.static URLmapSiteToServer(String protocol, String host, String port, String uri)static voidremoveFailedSite(String server)Removes a server from the available site list.static voidremoveFailedSite(URL url)Removes a server from the available site list.static voidupdateNamingTable()Triggers the update of the NamingTable by examining the contents ofNamingServicefor the naming information.
-
-
-
Field Detail
-
NAMING_SERVICE
public static final String NAMING_SERVICE
The unique identifier for the Naming Service.- See Also:
- Constant Field Values
-
NODE_SEPARATOR
public static final String NODE_SEPARATOR
The delimiter used to separate server IDs in the service attribute.- See Also:
- Constant Field Values
-
debug
protected static Debug debug
The debug instance.
-
-
Method Detail
-
initialize
public static void initialize()
-
isServerMode
public static boolean isServerMode()
Determines whether WebtopNaming code runs in the core server mode or in the client SDK run-time mode.- Returns:
truerunning in the core server mode,falseotherwise
-
isServer
public static boolean isServer(String serverID)
Tells whether the provided ID belongs to a server or not.- Parameters:
serverID- The ID that needs to be checked.- Returns:
trueif the ID corresponds to a server.
-
isSite
public static boolean isSite(String siteID)
Tells whether the provided ID belongs to a site or not.- Parameters:
siteID- The ID that needs to be checked.- Returns:
trueif the ID corresponds to a site.
-
isSecondarySite
public static boolean isSecondarySite(String secondarySiteID)
Tells whether the provided ID belongs to a secondary site or not.- Parameters:
secondarySiteID- The ID that needs to be checked.- Returns:
trueif the ID corresponds to a secondary site.
-
isSiteEnabled
public static boolean isSiteEnabled(String protocol, String host, String port, String uri) throws Exception
Determines whether Site is enabled for the given server instance.- Parameters:
protocol- protocol of the server instancehost- host of the server instanceport- port of the server instanceuri- uri of the server instance- Returns:
trueif Site is enabled,falseotherwise- Throws:
Exception- if server entry is not found or there is any other run-time error
-
isSiteEnabled
public static boolean isSiteEnabled(String serverid) throws Exception
Determines whether Site is enabled for the given server ID.- Parameters:
serverid- server ID- Returns:
trueif Site is enabled,falseotherwise- Throws:
Exception- if the given server ID is null
-
getAMServerID
public static String getAMServerID() throws ServerEntryNotFoundException
Returns the server ID.- Returns:
- Server ID
- Throws:
ServerEntryNotFoundException- if the Naming Service can not find that server entry
-
getServiceURL
public static URL getServiceURL(String service, String protocol, String host, String port, String uri) throws URLNotFoundException
Returns the URL of the specified service on the specified host.- Parameters:
service- the name of the service.protocol- the service protocolhost- the service host nameport- the service listening porturi- the deployment uri- Returns:
- the URL of the specified service on the specified host.
- Throws:
URLNotFoundException- if the Naming Service can not find a URL for a specified service
-
getServiceURL
public static URL getServiceURL(String service, URL url, boolean validate) throws URLNotFoundException
Returns the URL of the specified service on the specified host.- Parameters:
service- the name of the service.url- the deployment URI.validate- a boolean value indicate whether or not to validate the protocol, host and port of the server- Returns:
- the URL of the specified service on the specified host.
- Throws:
URLNotFoundException- if the Naming Service can not find a URL for a specified service
-
getServiceURL
public static URL getServiceURL(String service, String protocol, String host, String port, boolean validate) throws URLNotFoundException
Returns the URL of the specified service on the specified host.- Parameters:
service- the name of the service.protocol- the service protocol.host- the service host name.port- the ervice listening port.validate- a boolean value indicate whether or not to validate the protocol, host and port of the server- Returns:
- the URL of the specified service on the specified host.
- Throws:
URLNotFoundException- if the Naming Service can not find a URL for a specified service
-
mapSiteToServer
public static URL mapSiteToServer(String protocol, String host, String port, String uri) throws URLNotFoundException
- Throws:
URLNotFoundException
-
mapSiteToServer
public static String mapSiteToServer(SessionID sid) throws URLNotFoundException
Return the mapped server URL if there is a site. Otherwise, return the server URL from the session.- Parameters:
sid- the session- Returns:
- the site URL
- Throws:
URLNotFoundException
-
getServiceURL
public static URL getServiceURL(String service, String protocol, String host, String port, String uri, boolean validate) throws URLNotFoundException
Returns the URL of the specified service on the specified host.- Parameters:
service- name of the service.protocol- service protocol.host- service host name.port- service listening port.uri- the deployment uri.validate- a boolean value indicate whether or not to validate the protocol, host and port of the server.- Returns:
- the URL of the specified service on the specified host.
- Throws:
URLNotFoundException- if the Naming Service can not find a URL for a specified service
-
getServiceAllURLs
public static Vector getServiceAllURLs(String service) throws URLNotFoundException
Returns all the URLs of the specified service based on the servers in platform server list.- Parameters:
service- the name of the service.- Returns:
- the URL of the specified service on the specified host.
- Throws:
URLNotFoundException- if the Naming Service can not find a URL for a specified service
-
getBaseURLs
public static List<String> getBaseURLs() throws URLNotFoundException
The idea behind this function is to returns the base URLs of the OpenAM instances, without any of the extras that getServiceAllURLs provides - i.e. we don't want a specific service, we just want the base URL.- Returns:
- the URLs of the OpenAM instances we can contact.
- Throws:
URLNotFoundException- if the Naming Service cannot find a URL for a specified service
-
getPlatformServerList
public static Set<String> getPlatformServerList() throws Exception
Returns the platform server list. Note: Calling this method would dont cause performance impact, as it involves xml request over the wire.- Returns:
- platform server list
- Throws:
Exception- if an error occurs when updating the naming table
-
getPlatformServerList
public static Set<String> getPlatformServerList(boolean update) throws Exception
Returns the platform server list.- Parameters:
update- a boolean flag indicating whether a refresh of the naming profile is needed.- Returns:
- platform server list
- Throws:
Exception- if an error occurs when updating the nameing table
-
getLocalServer
public static String getLocalServer()
Returns local server name from naming table.- Returns:
- server name opensso is deployed.
-
getServerID
public static String getServerID(String protocol, String host, String port, String uri) throws ServerEntryNotFoundException
Returns the server ID that is there in the platform server list for a corresponding server.- Parameters:
protocol- procotol of the server instancehost- host of the server instanceport- port of the server instanceuri- uri of the server instance- Returns:
- Server ID
- Throws:
ServerEntryNotFoundException- if the Naming Service can not find that server entry
-
getServerID
public static String getServerID(String protocol, String host, String port, String uri, boolean updatetbl) throws ServerEntryNotFoundException
Returns the server ID that is there in the platform server list for a corresponding server.- Parameters:
protocol- procotol of the server instancehost- host of the server instanceport- port of the server instanceuri- uri of the server instanceupdatetbl- a boolean flag indicating whether a refresh of the naming profile is needed.- Returns:
- Server ID
- Throws:
ServerEntryNotFoundException- if the Naming Service can not find that server entry
-
getServerFromID
public static String getServerFromID(String serverID) throws ServerEntryNotFoundException
Returns the server URL based on the server ID.- Parameters:
serverID- Server ID- Returns:
- server URL
- Throws:
ServerEntryNotFoundException- if the Naming Service can not find that server entry
-
getAllServerIDs
public static Collection<String> getAllServerIDs() throws Exception
Returns all server IDs.- Returns:
- all server IDs.
- Throws:
Exception- if an error occurs when updating the nameing table
-
getLBCookieValue
public static String getLBCookieValue(String serverid)
Returns the lbCookieValue corresponding to the server ID.- Parameters:
serverid- the server id- Returns:
- the LB cookie value corresponding to server ID
-
getSiteID
public static String getSiteID(String protocol, String host, String port, String uri) throws ServerEntryNotFoundException
Returns the unique identifier of the site which the given server instance belongs to.- Parameters:
protocol- procotol of the server instancehost- host of the server instanceport- port of the server instanceuri- uri of the server instance- Returns:
- Site ID
- Throws:
ServerEntryNotFoundException- if the Naming Service can not find that server entry
-
getSiteID
public static String getSiteID(String serverid)
Returns the unique identifier of the site which the given server instance belongs to.- Parameters:
serverid- server ID- Returns:
- Site ID or null if the Server ID is not known.
-
getSecondarySites
public static String getSecondarySites(String protocol, String host, String port, String uri) throws ServerEntryNotFoundException
Returns the String representation of the separator delimited secondary site list.- Parameters:
protocol- procotol of the server instancehost- host of the server instanceport- port of the server instanceuri- uri of the server instance- Returns:
- the secondary site list
- Throws:
ServerEntryNotFoundException- if the Naming Service can not find that server entry
-
getSecondarySites
public static String getSecondarySites(String serverid)
Returns the String representation of the separator delimited secondary site list.- Parameters:
serverid- server ID- Returns:
- the secondary site list
-
getSiteNodes
public static Set<String> getSiteNodes(String serverid) throws Exception
Returns all the node ID for the site.- Parameters:
serverid- one of server IDs within the site, it can also be the loab balancer's ID- Returns:
- HashSet has all the node is for the site.
- Throws:
Exception- if an error occurs when updating the nameing table
-
getServiceClass
public static String getServiceClass(String service) throws ClassNotFoundException
Returns the class of the specified service.- Parameters:
service- the name of the service.- Returns:
- The class name of the specified service.
- Throws:
ClassNotFoundException- if no definition for the class with the specified name could be found.
-
getNotificationURL
public static URL getNotificationURL() throws URLNotFoundException
Returns the URL of the notification service on the local host.- Returns:
- the notification URL
- Throws:
URLNotFoundException- if the Naming Service can not find a URL for a specified service
-
updateNamingTable
public static void updateNamingTable() throws ExceptionTriggers the update of the NamingTable by examining the contents ofNamingServicefor the naming information. Assembles this int a table of Servers and Sites that make up the platform.- Throws:
Exception- If there was an error processing naming information.
-
getNamingServiceURL
public static String[] getNamingServiceURL() throws Exception
Returns a list of the naming service urls.- Returns:
- a String array of naming service urls.
- Throws:
Exception- if there is no configured url or there is an error when trying to get the urls
-
removeFailedSite
public static void removeFailedSite(String server)
Removes a server from the available site list.- Parameters:
server- theStringto parse as a URL of the server to be removed from the site list
-
removeFailedSite
public static void removeFailedSite(URL url)
Removes a server from the available site list.- Parameters:
url- url of the server to be removed from the site list
-
getURI
public static String getURI(URL url)
Returns the uri of the specified URL.- Parameters:
url- the URL that includes uri.- Returns:
- a uri of the specified
URL.
-
configMonitoring
public static int configMonitoring()
Provides the Monitoring Agent site and server related information.- Returns:
- 0 (zero) if all information collected and provided successfully; -1 if server protocol, hostname, port or URI is null; -2 if not serverMode, or Monitoring Agent already running -3 if unable to get the ServerID
-
getSessionIDCorrector
public static SessionIDCorrector getSessionIDCorrector()
When server/site configuration changes, Sessions issued against the previous configuration will be out of date and refer to an invalid configuration. SessionIDCorrector can compensate for these changes.- Returns:
- Null if WebtopNaming has not been configured, otherwise the instance of SessionIDCorrector associated with the WebtopNaming configuration.
-
-