Methods Summary |
---|
public void | activate(int serverId)
ServerLocation location;
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized(serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
}
if (entry != null && entry.isActive()) {
if (debug)
System.out.println( "ServerManagerImpl: activate for server Id " +
serverId + " failed because server is already active. " +
"entry = " + entry ) ;
throw new ServerAlreadyActive( serverId );
}
// locate the server
try {
// We call getEntry here so that state of the entry is
// checked for validity before we actually go and locate a server
entry = getEntry(serverId);
if (debug)
System.out.println( "ServerManagerImpl: locateServer called with " +
" serverId=" + serverId + " endpointType="
+ IIOP_CLEAR_TEXT.value + " block=false" ) ;
location = locateServer(entry, IIOP_CLEAR_TEXT.value, false);
if (debug)
System.out.println( "ServerManagerImpl: activate for server Id " +
serverId + " found location " +
location.hostname + " and activated it" ) ;
} catch (NoSuchEndPoint ex) {
if (debug)
System.out.println( "ServerManagerImpl: activate for server Id " +
" threw NoSuchEndpoint exception, which was ignored" );
}
|
public void | active(int serverId, com.sun.corba.se.spi.activation.Server server)
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized (serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
if (entry == null) {
if (debug)
System.out.println( "ServerManagerImpl: active for server Id " +
serverId + " called, but no such server is registered." ) ;
throw wrapper.serverNotExpectedToRegister() ;
} else {
if (debug)
System.out.println( "ServerManagerImpl: active for server Id " +
serverId + " called. This server is now active." ) ;
entry.register(server);
}
}
|
public int[] | getActiveServers()
ServerTableEntry entry;
int[] list = null;
synchronized (serverTable) {
// unlike vectors, list is not synchronized
ArrayList servers = new ArrayList(0);
Iterator serverList = serverTable.keySet().iterator();
try {
while (serverList.hasNext()) {
Integer key = (Integer) serverList.next();
// get an entry
entry = (ServerTableEntry) serverTable.get(key);
if (entry.isValid() && entry.isActive()) {
servers.add(entry);
}
}
} catch (NoSuchElementException e) {
// all done
}
// collect the active entries
list = new int[servers.size()];
for (int i = 0; i < servers.size(); i++) {
entry = (ServerTableEntry) servers.get(i);
list[i] = entry.getServerId();
}
}
if (debug) {
StringBuffer sb = new StringBuffer() ;
for (int ctr=0; ctr<list.length; ctr++) {
sb.append( ' " ) ;
sb.append( list[ctr] ) ;
}
System.out.println( "ServerManagerImpl: getActiveServers returns" +
sb.toString() ) ;
}
return list;
|
public int | getEndpoint(java.lang.String endpointType)
return orb.getLegacyServerSocketManager()
.legacyGetTransientServerPort(endpointType);
|
private ServerTableEntry | getEntry(int serverId)
Integer key = new Integer(serverId);
ServerTableEntry entry = null ;
synchronized (serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
if (debug)
if (entry == null) {
System.out.println( "ServerManagerImpl: getEntry: " +
"no active server found." ) ;
} else {
System.out.println( "ServerManagerImpl: getEntry: " +
" active server found " + entry + "." ) ;
}
if ((entry != null) && (!entry.isValid())) {
serverTable.remove(key);
entry = null;
}
if (entry == null) {
ServerDef serverDef = repository.getServer(serverId);
entry = new ServerTableEntry( wrapper,
serverId, serverDef, initialPort, dbDirName, false, debug);
serverTable.put(key, entry);
entry.activate() ;
}
}
return entry ;
|
public java.lang.String[] | getORBNames(int serverId)
try {
ServerTableEntry entry = getEntry( serverId ) ;
return (entry.getORBList());
} catch (Exception ex) {
throw new ServerNotRegistered(serverId);
}
|
private ServerTableEntry | getRunningEntry(int serverId)
ServerTableEntry entry = getEntry( serverId ) ;
try {
// this is to see if the server has any listeners
ORBPortInfo [] serverORBAndPortList = entry.lookup(IIOP_CLEAR_TEXT.value) ;
} catch (Exception exc) {
return null ;
}
return entry;
|
public int | getServerPortForType(com.sun.corba.se.spi.activation.LocatorPackage.ServerLocationPerORB location, java.lang.String endPointType)
EndPointInfo[] listenerPorts = location.ports;
for (int i = 0; i < listenerPorts.length; i++) {
if ((listenerPorts[i].endpointType).equals(endPointType)) {
return listenerPorts[i].port;
}
}
throw new NoSuchEndPoint();
|
public void | handle(com.sun.corba.se.spi.ior.ObjectKey okey)
IOR newIOR = null;
ServerLocationPerORB location;
// we need to get the serverid and the orbid from the object key
ObjectKeyTemplate oktemp = okey.getTemplate();
int serverId = oktemp.getServerId() ;
String orbId = oktemp.getORBId() ;
try {
// get the ORBName corresponding to the orbMapid, that was
// first registered by the server
ServerTableEntry entry = getEntry( serverId ) ;
location = locateServerForORB(entry, orbId, true);
if (debug)
System.out.println( "ServerManagerImpl: handle called for server id" +
serverId + " orbid " + orbId) ;
// we received a list of ports corresponding to an ORB in a
// particular server, now retrieve the one corresponding
// to IIOP_CLEAR_TEXT, and for other created the tagged
// components to be added to the IOR
int clearPort = 0;
EndPointInfo[] listenerPorts = location.ports;
for (int i = 0; i < listenerPorts.length; i++) {
if ((listenerPorts[i].endpointType).equals(IIOP_CLEAR_TEXT.value)) {
clearPort = listenerPorts[i].port;
break;
}
}
// create a new IOR with the correct port and correct tagged
// components
IIOPAddress addr = IIOPFactories.makeIIOPAddress( orb,
location.hostname, clearPort ) ;
IIOPProfileTemplate iptemp =
IIOPFactories.makeIIOPProfileTemplate(
orb, GIOPVersion.V1_2, addr ) ;
if (GIOPVersion.V1_2.supportsIORIIOPProfileComponents()) {
iptemp.add(IIOPFactories.makeCodeSetsComponent(orb));
iptemp.add(IIOPFactories.makeMaxStreamFormatVersionComponent());
}
IORTemplate iortemp = IORFactories.makeIORTemplate(oktemp) ;
iortemp.add( iptemp ) ;
newIOR = iortemp.makeIOR(orb, "IDL:org/omg/CORBA/Object:1.0",
okey.getId() );
} catch (Exception e) {
throw wrapper.errorInBadServerIdHandler( e ) ;
}
if (debug)
System.out.println( "ServerManagerImpl: handle " +
"throws ForwardException" ) ;
try {
// This delay is required in case of Server is activated or
// re-activated the first time. Server needs some time before
// handling all the requests.
// (Talk to Ken to see whether there is a better way of doing this).
Thread.sleep( serverStartupDelay );
} catch ( Exception e ) {
System.out.println( "Exception = " + e );
e.printStackTrace();
}
throw new ForwardException(orb, newIOR);
|
public void | install(int serverId)
ServerTableEntry entry = getRunningEntry( serverId ) ;
if (entry != null) {
repository.install( serverId ) ;
entry.install() ;
}
|
public com.sun.corba.se.spi.activation.LocatorPackage.ServerLocation | locateServer(int serverId, java.lang.String endpointType)
ServerTableEntry entry = getEntry( serverId ) ;
if (debug)
System.out.println( "ServerManagerImpl: locateServer called with " +
" serverId=" + serverId + " endpointType=" +
endpointType + " block=true" ) ;
// passing in entry to eliminate multiple lookups for
// the same entry in some cases
return locateServer(entry, endpointType, true);
|
private com.sun.corba.se.spi.activation.LocatorPackage.ServerLocation | locateServer(ServerTableEntry entry, java.lang.String endpointType, boolean block)
ServerLocation location = new ServerLocation() ;
// if server location is desired, then wait for the server
// to register back, then return location
ORBPortInfo [] serverORBAndPortList;
if (block) {
try {
serverORBAndPortList = entry.lookup(endpointType);
} catch (Exception ex) {
if (debug)
System.out.println( "ServerManagerImpl: locateServer: " +
"server held down" ) ;
throw new ServerHeldDown( entry.getServerId() );
}
String host =
orb.getLegacyServerSocketManager()
.legacyGetEndpoint(LegacyServerSocketEndPointInfo.DEFAULT_ENDPOINT).getHostName();
location.hostname = host ;
int listLength;
if (serverORBAndPortList != null) {
listLength = serverORBAndPortList.length;
} else {
listLength = 0;
}
location.ports = new ORBPortInfo[listLength];
for (int i = 0; i < listLength; i++) {
location.ports[i] = new ORBPortInfo(serverORBAndPortList[i].orbId,
serverORBAndPortList[i].port) ;
if (debug)
System.out.println( "ServerManagerImpl: locateServer: " +
"server located at location " +
location.hostname + " ORBid " +
serverORBAndPortList[i].orbId +
" Port " + serverORBAndPortList[i].port) ;
}
}
return location;
|
public com.sun.corba.se.spi.activation.LocatorPackage.ServerLocationPerORB | locateServerForORB(int serverId, java.lang.String orbId)This method is used to obtain the registered ports for an ORB.
This is useful for custom Bad server ID handlers in ORBD.
ServerTableEntry entry = getEntry( serverId ) ;
// passing in entry to eliminate multiple lookups for
// the same entry in some cases
if (debug)
System.out.println( "ServerManagerImpl: locateServerForORB called with " +
" serverId=" + serverId + " orbId=" + orbId +
" block=true" ) ;
return locateServerForORB(entry, orbId, true);
|
private com.sun.corba.se.spi.activation.LocatorPackage.ServerLocationPerORB | locateServerForORB(ServerTableEntry entry, java.lang.String orbId, boolean block)
ServerLocationPerORB location = new ServerLocationPerORB() ;
// if server location is desired, then wait for the server
// to register back, then return location
EndPointInfo [] endpointInfoList;
if (block) {
try {
endpointInfoList = entry.lookupForORB(orbId);
} catch (InvalidORBid ex) {
throw ex;
} catch (Exception ex) {
if (debug)
System.out.println( "ServerManagerImpl: locateServerForORB: " +
"server held down" ) ;
throw new ServerHeldDown( entry.getServerId() );
}
String host =
orb.getLegacyServerSocketManager()
.legacyGetEndpoint(LegacyServerSocketEndPointInfo.DEFAULT_ENDPOINT).getHostName();
location.hostname = host ;
int listLength;
if (endpointInfoList != null) {
listLength = endpointInfoList.length;
} else {
listLength = 0;
}
location.ports = new EndPointInfo[listLength];
for (int i = 0; i < listLength; i++) {
location.ports[i] = new EndPointInfo(endpointInfoList[i].endpointType,
endpointInfoList[i].port) ;
if (debug)
System.out.println( "ServerManagerImpl: locateServer: " +
"server located at location " +
location.hostname + " endpointType " +
endpointInfoList[i].endpointType +
" Port " + endpointInfoList[i].port) ;
}
}
return location;
|
public void | registerEndpoints(int serverId, java.lang.String orbId, com.sun.corba.se.spi.activation.EndPointInfo[] endpointList)
// orbId is ignored for now
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized (serverTable) {
entry = (ServerTableEntry) serverTable.get(key);
if (entry == null) {
if (debug)
System.out.println(
"ServerManagerImpl: registerEndpoint for server Id " +
serverId + " called, but no such server is registered." ) ;
throw wrapper.serverNotExpectedToRegister() ;
} else {
if (debug)
System.out.println(
"ServerManagerImpl: registerEndpoints for server Id " +
serverId + " called. This server is now active." ) ;
entry.registerPorts( orbId, endpointList );
}
}
|
public void | shutdown(int serverId)
ServerTableEntry entry;
Integer key = new Integer(serverId);
synchronized(serverTable) {
entry = (ServerTableEntry) serverTable.remove(key);
if (entry == null) {
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " throws ServerNotActive." ) ;
throw new ServerNotActive( serverId );
}
try {
entry.destroy();
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " completed." ) ;
} catch (Exception e) {
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " threw exception " + e ) ;
}
}
|
public void | uninstall(int serverId)
ServerTableEntry entry =
(ServerTableEntry) serverTable.get( new Integer(serverId) );
if (entry != null) {
entry =
(ServerTableEntry) serverTable.remove(new Integer(serverId));
if (entry == null) {
if (debug)
System.out.println( "ServerManagerImpl: shutdown for server Id " +
serverId + " throws ServerNotActive." ) ;
throw new ServerHeldDown( serverId );
}
entry.uninstall();
}
|