FailoverIORInterceptorpublic class FailoverIORInterceptor extends org.omg.CORBA.LocalObject implements org.omg.PortableInterceptor.IORInterceptor, org.omg.PortableInterceptor.ORBInitializer
Fields Summary |
---|
private static Logger | _logger | private com.sun.corba.ee.spi.orb.ORB | orb | private static final String | baseMsg | private static final String | ORB_LISTENER | private List | currentAddressList | private List | previousAddressList | private List | randomizedAddressList | private List | randomizedAndMarshaledAddressList |
Methods Summary |
---|
public void | adapter_manager_state_changed(int managerId, short state)
| public void | adapter_state_changed(org.omg.PortableInterceptor.ObjectReferenceTemplate[] templates, short state)
| public void | components_established(org.omg.PortableInterceptor.IORInfo iorInfo)
| public void | destroy()
| public void | establish_components(org.omg.PortableInterceptor.IORInfo iorInfo)
try {
_logger.log(Level.FINE,
baseMsg + ".establish_components->:");
ServerRef[] servers = IIOPEndpointsInfo.getServersInCluster();
IiopListener[][] listeners = IIOPEndpointsInfo.getListenersInCluster();
currentAddressList = new ArrayList();
if (servers != null) {
for (int i = 0; i < servers.length; i++) {
String serverName = servers[i].getRef();
String hostName =
IIOPEndpointsInfo.getHostNameForServerInstance(serverName);
if (hostName==null) {
hostName = listeners[i][0].getAddress();
}
for (int j = 0; j < listeners[i].length; j++) {
String id = listeners[i][j].getId();
String port =
IIOPEndpointsInfo.getResolvedPort(listeners[i][j], serverName);
// REVISIT: Make question an official API.
if (! id.startsWith(ORB_LISTENER)) {
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO,
baseMsg + ".establish_components:"
+ " ignoring SSL ports: " +
id + " " + hostName + " " + port);
}
continue;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE,
baseMsg + ".establish_components:"
+ " adding AlternateIIOPAddressComponent"
+ " for listener id: " + id
+ " address/port: " + hostName
+ "/" + port);
}
AlternateIIOPAddressComponent address =
new AlternateIIOPAddressComponent(
hostName,
Integer.decode(port).shortValue());
currentAddressList.add(address);
}
}
}
if (previousAddressList == null) {
//
// Save the previous list for subsequent comparisons.
//
previousAddressList = new ArrayList();
// List does not define .clone and Object.clone is protected.
Iterator i = currentAddressList.iterator();
while (i.hasNext()) { previousAddressList.add(i.next()); }
//
// Randomize the list for this ORB.
// Save it in unmarshaled form for logging.
//
java.util.Collections.shuffle(currentAddressList);
randomizedAddressList = currentAddressList;
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, baseMsg
+ " first call - saving randomized alternate address list: "
+ randomizedAddressList);
}
//
// Save a marshaled version for subsequent calls.
//
randomizedAndMarshaledAddressList = new ArrayList();
i = randomizedAddressList.iterator();
while (i.hasNext()) {
AlternateIIOPAddressComponent address =
(AlternateIIOPAddressComponent) i.next();
Any any = orb.create_any();
AlternateIIOPAddressComponentHelper.insert(any, address);
byte[] data = getCodec(orb).encode_value(any);
TaggedComponent tc =
new TaggedComponent(org.omg.IOP.TAG_ALTERNATE_IIOP_ADDRESS.value,
//AlternateIIOPAddressComponent.TAG_ALTERNATE_IIOP_ADDRESS_ID,
data);
randomizedAndMarshaledAddressList.add(tc);
}
} else {
if (! currentAddressList.equals(previousAddressList)) {
throw new RuntimeException(
"Current address list: "
+ currentAddressList
+ " different from previous list: "
+ previousAddressList);
}
}
Iterator i = randomizedAndMarshaledAddressList.iterator();
while (i.hasNext()) {
iorInfo.add_ior_component((TaggedComponent) i.next());
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, baseMsg
+ " adding randomized alternate addresses: "
+ randomizedAddressList);
}
} catch (Throwable e) {
_logger.log(Level.WARNING,
"Problem in " + baseMsg + ".establish_components",
e);
/*
RuntimeException rte =
new RuntimeException("Problem in " + baseMsg + ".establish_components");
rte.initCause(e);
throw rte;
*/
} finally {
_logger.log(Level.FINE, baseMsg + ".establish_components<-:");
}
| static org.omg.IOP.Codec | getCodec(com.sun.corba.ee.spi.orb.ORB orb)
Codec result = null;
try {
CodecFactory codecFactory =
CodecFactoryHelper.narrow(
orb.resolve_initial_references("CodecFactory"));
result = codecFactory.create_codec(
new Encoding((short)ENCODING_CDR_ENCAPS.value,
(byte)1, (byte)2));
} catch (Throwable e) {
_logger.log(Level.WARNING,
"Problem in " + baseMsg + ".getCodec",
e);
}
return result;
| public java.lang.String | name()
//
// Interceptor
//
return baseMsg;
| public void | post_init(org.omg.PortableInterceptor.ORBInitInfo info)
ORB orb = ((ORBInitInfoExt)info).getORB() ;
try {
info.add_ior_interceptor(new FailoverIORInterceptor(orb));
_logger.log(Level.FINE, baseMsg + " registered.");
} catch (DuplicateName ex) {
_logger.log(Level.WARNING, "DuplicateName from " + baseMsg , ex);
/*
RuntimeException rte =
new RuntimeException("DuplicateName from " + baseMsg , ex);
rte.initCause(ex);
throw rte;
*/
}
| public void | pre_init(org.omg.PortableInterceptor.ORBInitInfo info)
|
|