use of org.omg.CORBA.ORB in project ACS by ACS-Community.
the class ManagerImplSerializationTest method testContainerDie.
public void testContainerDie() throws Throwable {
// should be something else then deafault because
// the default is in use by the Manager
Properties table = new Properties();
table.put("OAPort", "12121");
// new ORB instance
ORB ourOrb = ORB.init(new String[0], table);
try {
POA rootPOA = POAHelper.narrow(ourOrb.resolve_initial_references("RootPOA"));
// activate POA
POAManager manager = rootPOA.the_POAManager();
manager.activate();
} catch (Exception e) {
e.printStackTrace();
}
ContainerProxyImpl activator = new ContainerProxyImpl(clientName);
si.ijs.maci.ClientInfo clientInfo = manager.login(activator._this(ourOrb));
if (clientInfo == null || clientInfo.h == 0)
fail("Unable to login to manager");
// just destroy its ORB
ourOrb.shutdown(true);
// get object as it is stored in recovery store
ManagerImpl newManager = (ManagerImpl) deserializeManager(new ManagerImpl());
HandleDataStore activators = newManager.getContainers();
// the client now is still in stored data
assertEquals(activators.first(), 1);
newManager.initialize(null, null, null, null, null);
// now wait for timer task to remove client
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
// since the client died the menager automaticaly log it out
activators = newManager.getClients();
// not any more
assertEquals(activators.first(), 0);
}
use of org.omg.CORBA.ORB in project ACS by ACS-Community.
the class ManagerImplSerializationTest method testClientDie.
public void testClientDie() {
// should be something else then deafault because
// the default is in use by the Manager
Properties table = new Properties();
table.put("OAPort", "12121");
// new ORB instance
ORB ourOrb = ORB.init(new String[0], table);
try {
POA rootPOA = POAHelper.narrow(ourOrb.resolve_initial_references("RootPOA"));
// activate POA
POAManager manager = rootPOA.the_POAManager();
manager.activate();
} catch (Exception e) {
e.printStackTrace();
}
ClientProxyImpl client = new ClientProxyImpl(clientName, myManager.getManagerEngine().getLogger());
client.login(ourOrb, manager);
// just destroy its ORB
ourOrb.shutdown(true);
// get object as it is stored in recovery store
ManagerImpl newManager = (ManagerImpl) deserializeManager(new ManagerImpl());
HandleDataStore clients = newManager.getClients();
// the client now is still in stored data
assertEquals(clients.first(), 1);
newManager.initialize(null, null, null, null, null);
// now wait for timer task to remove client
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
// since the client died the menager automaticaly log it out
clients = newManager.getClients();
// not any more
assertEquals(clients.first(), 0);
}
use of org.omg.CORBA.ORB in project ACS by ACS-Community.
the class HibernateServer method run.
public void run(String[] args) {
String iorFileName = null;
final AcsLogger sharedLogger = AcsLoggerHelper.getInstance().getSharedLogger();
try {
Properties properties = System.getProperties();
// default is JDK ORB
boolean useJacORB = false;
boolean profiler = false;
int portNumber = Integer.parseInt(ACSPorts.getCDBPort());
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-OAport") || args[i].equals("-OAPort")) {
if (i < args.length - 1) {
portNumber = Integer.valueOf(args[++i]).intValue();
}
}
if (args[i].equals("-OAIAddr")) {
if (i < args.length - 1) {
properties.put("OAIAddr", args[++i]);
}
}
if (args[i].equals("-orbacus")) {
sharedLogger.log(AcsLogLevel.NOTICE, "ORBacus is no longer supported, switching to JacORB.");
//System.err.println(
// "ORBacus is no longer supported, switching to JacORB.");
useJacORB = true;
}
if (args[i].equals("-jacorb")) {
useJacORB = true;
}
if (args[i].equals("-profiler")) {
profiler = true;
}
if (args[i].equals("-o")) {
if (i < args.length - 1) {
iorFileName = args[++i];
} else {
iorFileName = "DAL.ior";
}
}
}
if (useJacORB) {
if (Integer.getInteger("ACS.logstdout", 4) < 4) {
sharedLogger.log(AcsLogLevel.INFO, "DALfs will use JacORB ORB");
}
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");
// port
properties.put("OAPort", Integer.toString(portNumber));
// ORB implementation name
properties.put("jacorb.implname", "ORB");
/*
* by setting the following property, the ORB will
* accept client requests targeted at the object with
* key "CDB", so more readable corbaloc URLs
* can be used
*/
properties.put("jacorb.orb.objectKeyMap.CDB", "ORB/dalPOA/CDB");
} else {
properties.put("com.sun.CORBA.POA.ORBPersistentServerPort", Integer.toString(portNumber));
}
// create and initialize the ORB
ORB orb = ORB.init(args, properties);
// activate profiling
if (orb instanceof AcsProfilingORB) {
// This profiler will log ORB resource statistics every 10 seconds,
// and will print every callback to requestStarted / requestFinished to stdout if the "-profiler" option is set (see above)
final boolean printIndividualCalls = profiler;
AcsORBProfiler orbProfiler = new AcsORBProfilerImplBase(sharedLogger) {
{
if (printIndividualCalls) {
debugRequestStarted = true;
debugRequestFinished = true;
}
}
};
((AcsProfilingORB) orb).registerAcsORBProfiler(orbProfiler);
}
// get reference to rootpoa & activate the POAManager
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
/* create a user defined poa for the naming contexts */
org.omg.CORBA.Policy[] policies = new org.omg.CORBA.Policy[2];
policies[0] = rootpoa.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID);
if (useJacORB)
policies[1] = rootpoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT);
else
policies[1] = rootpoa.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
POA dalpoa = rootpoa.create_POA("dalPOA", rootpoa.the_POAManager(), policies);
for (int i = 0; i < policies.length; i++) policies[i].destroy();
rootpoa.the_POAManager().activate();
// create servant and register it with the ORB
//DALImpl DALImpl = new DALImpl(args, orb, dalpoa);
//org.omg.PortableServer.Servant servant = new WDALImpl(args, orb, dalpoa);
org.omg.PortableServer.Servant servant = new HibernateWDALImpl(args, orb, dalpoa, sharedLogger);
//create object id
byte[] id = { 'C', 'D', 'B' };
//activate object
dalpoa.activate_object_with_id(id, servant);
// get object reference from the servant
org.omg.CORBA.Object ref = dalpoa.servant_to_reference(servant);
jdal = WDALHelper.narrow(ref);
// try to bind it in IOR
if (useJacORB) {
// nothing to do here
} else {
((com.sun.corba.se.internal.Interceptors.PIORB) orb).register_initial_reference("CDB", rootpoa.servant_to_reference(servant));
}
// register in name service if available
try {
// get the root naming context
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// Bind the object reference in naming
NameComponent nc = new NameComponent("CDB", "");
NameComponent[] path = { nc };
ncRef.rebind(path, jdal);
} catch (Exception e1) {
sharedLogger.log(AcsLogLevel.NOTICE, "JDAL is NOT registered in the name service because of: " + e1);
}
if (Integer.getInteger("ACS.logstdout", 4) < 4) {
sharedLogger.log(AcsLogLevel.INFO, "JDAL is listening on " + ACSPorts.getIP() + ":" + portNumber + "/CDB");
}
// recover (notify) clients
if (servant instanceof Recoverer) {
((Recoverer) servant).recoverClients();
}
if (iorFileName != null) {
// write the object reference to a file
PrintWriter iorFile = new PrintWriter(new FileWriter(iorFileName));
iorFile.println(orb.object_to_string(jdal));
iorFile.close();
}
sharedLogger.log(AcsLogLevel.INFO, "JDAL is ready and waiting ...");
// GCH 2006-11-13
// Here we put also a println to be sure that the message
// ALWAYS appears on standart output, also if the logging level
// is put higher than INFO.
// This is needed because the ACS startup scripts wait for this message
// to declare complete the startup of the CDB.
System.out.println("JDAL is ready and waiting ...");
// wait for invocations from clients
orb.run();
sharedLogger.log(AcsLogLevel.INFO, "JDAL exiting ORB loop ...");
} catch (Exception e) {
sharedLogger.log(AcsLogLevel.SEVERE, "Top level exception ", e);
}
}
use of org.omg.CORBA.ORB in project ACS by ACS-Community.
the class CDBChecker method checkIdlTypes.
/**
* This method check if the idl types on CDB are available
*
*/
protected void checkIdlTypes() {
//first check if IR is available
org.omg.CORBA.Object repRef = null;
ORB orb = org.omg.CORBA.ORB.init(new String[0], null);
String IRloc = props.getProperty(IR_CORBALOC);
try {
repRef = orb.string_to_object(IRloc);
} catch (Exception e) {
System.out.println("[Error] - Interface repository is not running, no check will be done.");
}
rep = RepositoryHelper.narrow(repRef);
//iterate trough all idlTypes
//done in parseElement
}
use of org.omg.CORBA.ORB in project ACS by ACS-Community.
the class RemoteLoggingTest method initRemoteLogging.
///////////////////////////////////////////////////////////
////////////////// Helper methods ///////////////////
///////////////////////////////////////////////////////////
/**
* Calls {@linkplain ClientLogManagerStandalone#initRemoteLogging(ORB, Manager, int, boolean)}
* with appropriate dummy parameters.
* @param clm The instance to call initRemoteLogging on.
* @return true if simulated remote logging was initialized successfully
*/
private boolean initRemoteLogging(ClientLogManagerStandalone clm) {
// An unconfigured ORB will do, just needed to produce Any objects for sending remote logs.
// There is however the ugly side effect that the constructor org.jacorb.orb.ORBSingleton
// will use slf4j and thus call ClientLogManager#getAcsLogManager, so that we have another
// instance of ClientLogManager in addition to our ClientLogManagerStandalone instance.
ORB orb = ORB.init();
// will only be used for != null check.
Manager managerDummy = new _ManagerStub();
return clm.initRemoteLogging(orb, managerDummy, 1, true);
}
Aggregations