use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AcsManagerProxy method findManager.
/**
* Finds the Manger using the supplied <code>managerLoc</code>.
*
* If the manager can't be found, this method enters a loop and tries again after every 3 seconds.
* The number of iterations of the loop is bounded by <code>attempts</code>.
*
* @param managerLoc the corbaloc string that uniquely identifies the manager
* as a CORBA service.
* @param attempts The number of attempts to contact the manager (0 means forever).
* If 0, this method will only return when it has successfully contacted the manager service;
* if greater then 0, this method will simply throw a <code>AcsJContainerServicesEx</code>
* if it fails to resolve the manager.
* @throws AcsJContainerEx if anything goes wrong.
*/
private synchronized void findManager(String managerLoc, int attempts) throws AcsJContainerEx {
if (attempts < 0) {
throw new IllegalArgumentException("Invalid number of attempts to contact the manager: " + attempts);
}
int currentAttempt = attempts;
do {
if (m_shuttingDown) {
//
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo("Abandoned because we are shutting down.");
throw ex;
}
try {
org.omg.CORBA.Object object = m_orb.string_to_object(m_managerLoc);
m_logger.finest("manager corbaloc '" + managerLoc + "' resolved.");
m_manager = ManagerHelper.narrow(object);
if (m_manager == null) {
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo("received null reference to ACS Manager.");
throw ex;
}
m_logger.finest("manager narrow successful.");
// Set attempts=1 and currentAttempt=0 to exit the loop
attempts = 1;
currentAttempt = 0;
} catch (Throwable thr) {
String msg = "Failed to obtain the manager reference from the corbaloc '" + m_managerLoc + "'. ";
if (attempts == 0 || currentAttempt > 0) {
m_logger.log(Level.INFO, msg + "Will keep trying.");
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
// nada
}
} else {
m_logger.log(Level.WARNING, msg + thr.getMessage());
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo(msg);
throw ex;
}
}
currentAttempt = (attempts == 0) ? 0 : currentAttempt - 1;
} while (attempts == 0 || currentAttempt > 0);
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AcsManagerProxy method loginToManager.
/**
* Logs in to the Manager.
* Only to be called from within this class (see connectorThread), when the
*
* @param attempts The number of attempts to contact the manager (0 means forever)
* used for the call to {@link #findManager(String, int)}
* @throws AcsJContainerServicesEx
*/
private synchronized void loginToManager(int attempts) throws AcsJContainerEx {
if (m_shuttingDown) {
String msg = "call to loginToManager(..) fails while shutting down.";
m_logger.fine(msg);
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo(msg);
throw ex;
}
if (isLoggedIn(false)) {
m_logger.info("login to Manager requested while being logged in - will first log out...");
logoutFromManager();
}
if (m_manager == null) {
m_logger.fine("manager reference not yet available in method loginToManager; " + "will try to find the manager first...");
findManager(m_managerLoc, attempts);
}
try {
// login
ClientInfo ci = m_manager.login(m_managerClient);
if (ci == null) {
throw new NullPointerException("received null from manager.login()");
}
if (ci.h <= 0) {
AcsJContainerEx ex = new AcsJContainerEx();
ex.setContextInfo("Got invalid handle from manager login: " + ci.h);
throw ex;
}
m_mgrHandle = ci.h;
} catch (Throwable thr) {
m_mgrHandle = 0;
String msg = "Failed to login to manager.";
m_logger.log(Level.WARNING, msg);
AcsJContainerEx ex = new AcsJContainerEx(thr);
ex.setContextInfo(msg);
throw ex;
}
m_logger.fine("Manager login done, handle '" + m_mgrHandle + "' obtained.");
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class ManagerContainerServices method checkOffShootPOA.
/**
* Creates the shared offshoot poa on demand
*/
public void checkOffShootPOA() throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
final String offshootPoaName = "offshootPoa";
synchronized (clientPOA) {
try {
// can we reuse it?
offshootPoa = clientPOA.find_POA(offshootPoaName, false);
} catch (AdapterNonExistent e) {
logger.finest("will have to create offshoot POA");
if (offshootPolicies == null) {
offshootPolicies = new Policy[4];
offshootPolicies[0] = clientPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
offshootPolicies[1] = clientPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
offshootPolicies[2] = clientPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
offshootPolicies[3] = clientPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
}
try {
offshootPoa = clientPOA.create_POA(offshootPoaName, clientPOA.the_POAManager(), offshootPolicies);
logger.finest("successfully created offshoot POA");
} catch (InvalidPolicy ex) {
AcsJContainerEx ex2 = new AcsJContainerEx(ex);
ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
throw ex2;
} catch (AdapterAlreadyExists ex) {
// we sync on componentPOA, so this should never happen
throw new AcsJUnexpectedExceptionEx(ex);
}
}
}
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class AlarmSystemContainerServices method getPOAForOffshoots.
public POA getPOAForOffshoots(POA componentPOA) throws AcsJContainerEx, AcsJUnexpectedExceptionEx {
final String offshootPoaName = "offshootPoa";
POA offshootPoa = null;
synchronized (componentPOA) {
try {
// can we reuse it?
offshootPoa = componentPOA.find_POA(offshootPoaName, false);
} catch (AdapterNonExistent e) {
logger.finest("will have to create offshoot POA");
if (m_offshootPolicies == null) {
m_offshootPolicies = new Policy[4];
m_offshootPolicies[0] = componentPOA.create_id_assignment_policy(IdAssignmentPolicyValue.SYSTEM_ID);
m_offshootPolicies[1] = componentPOA.create_lifespan_policy(LifespanPolicyValue.TRANSIENT);
m_offshootPolicies[2] = componentPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY);
m_offshootPolicies[3] = componentPOA.create_servant_retention_policy(ServantRetentionPolicyValue.RETAIN);
}
try {
offshootPoa = componentPOA.create_POA(offshootPoaName, alSysCorbaServer.getRootPOA().the_POAManager(), m_offshootPolicies);
logger.finest("successfully created offshoot POA");
} catch (InvalidPolicy ex) {
AcsJContainerEx ex2 = new AcsJContainerEx(ex);
ex2.setContextInfo("Attempted to create offshoot POA with invalid policies.");
throw ex2;
} catch (AdapterAlreadyExists ex) {
// we sync on componentPOA, so this should never happen
throw new AcsJUnexpectedExceptionEx(ex);
}
}
}
return offshootPoa;
}
use of alma.JavaContainerError.wrappers.AcsJContainerEx in project ACS by ACS-Community.
the class DataPrinter method startSample.
/**
* Starts the sampling, connecting to ACS Manager and the Sampling Manager.
* @throws CouldntAccessComponentEx Component wasn't available at the time.
* @throws TypeNotSupportedEx Sampling Manager specific exception. Some types are currently not supported in acssamp.
* @throws CouldntAccessPropertyEx
*/
public void startSample() throws CouldntAccessComponentEx, TypeNotSupportedEx, CouldntAccessPropertyEx, SamplingManagerException {
samp = new Sampler();
synchronized (this) {
System.out.println("Initialization:" + initializations);
if (initializations == 0) {
try {
spinUp(SampTool.NAME, ssg.MAN_NAME);
} catch (AcsInformationException e) {
System.out.print(e.getMessage());
System.exit(-1);
} catch (SamplingManagerException e) {
System.out.print(e.getMessage());
System.exit(-1);
} catch (AcsJContainerEx e) {
System.out.println(e.getMessage());
System.exit(-1);
}
}
initializations++;
}
try {
SamplingManagerUITool.startSample(new SampDetail(component, property, (long) this.frequency, reportRate));
} catch (alma.ACSErrTypeCommon.CouldntAccessComponentEx e) {
setComponentAvailable(false, "Cannot access component implementation");
throw e;
} catch (alma.ACSErrTypeCommon.TypeNotSupportedEx e) {
setComponentAvailable(false, "Type not supported");
throw e;
} catch (CouldntAccessPropertyEx e) {
setComponentAvailable(false, "Cannot access the property");
throw e;
} catch (SamplingManagerException e) {
setComponentAvailable(false, e.getMessage());
throw e;
}
samp.start();
}
Aggregations