use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class SimpleSupplierConsumerClient method createPublisherAndSubscriber.
public void createPublisherAndSubscriber() {
try {
m_client = new ComponentClient(m_logger, System.getProperty("ACS.manager"), "SimpleSupplierConsumerClient");
//m_subscriber = m_client.getContainerServices().createNotificationChannelSubscriber(CHANNEL_NAME, EventDescription.class);
//m_subscriber.addSubscription(this);
m_publisher = m_client.getContainerServices().createNotificationChannelPublisher(CHANNEL_NAME, IDLEntity.class);
} catch (AcsJContainerServicesEx e) {
// Silently ignore the errors
} catch (AcsJException e) {
// Shouldn't happen
} catch (Exception e) {
e.printStackTrace();
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class MasterComponentImplBase method initialize.
/******************* [ Lifecycle implementations ] *******************/
/**
* Master component subclasses must call <code>super.initialize()</code> if they override this method!
* @see alma.acs.component.ComponentLifecycle#initialize(alma.acs.container.ContainerServices)
*/
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
subsysComponentMonitor = new SubsysResourceMonitor(m_logger, containerServices.getThreadFactory(), 10);
try {
ROstringSeqImpl currentStateHierarchyImpl = new ROstringSeqImpl("currentStateHierarchy", this);
m_currentStateHierarchyDataAccess = currentStateHierarchyImpl.getDataAccess();
ROstringSeqPOATie currentStateHierarchyTie = new ROstringSeqPOATie(currentStateHierarchyImpl);
m_currentStateHierarchy = ROstringSeqHelper.narrow(this.registerProperty(currentStateHierarchyImpl, currentStateHierarchyTie));
} catch (Throwable th) {
throw new ComponentLifecycleException("Failed to create ACS property for nested component states.", th);
}
AlmaSubsystemActions actionHandler = getActionHandler();
if (actionHandler == null) {
throw new ComponentLifecycleException("Action handler was null. Check implementation of method getActionHandler in concrete master component implementation class.");
}
m_stateMachine = new AlmaSubsystemContext(actionHandler, m_logger, m_containerServices.getThreadFactory());
m_stateMachine.addAcsStateChangeListener(this);
if (StateChangeNotificationChecker.monitorStateChangeNotification) {
try {
stateChangeNotificationChecker = new StateChangeNotificationChecker(m_logger);
stateChangeNotificationChecker.createMonitor(m_currentStateHierarchy, m_containerServices);
m_logger.info("Running in state change notification test mode: All externally visible state changes will be compared with the internally triggered changes.");
} catch (Exception e) {
m_logger.log(Level.WARNING, "Master component " + name() + " failed to monitor its state change notification although this was requested by the property '" + StateChangeNotificationChecker.PROPERTYNAME + "'.", e);
}
}
try {
updateStateHierarchy();
} catch (AcsJException e) {
throw new ComponentLifecycleException("failed to initialize state property", e);
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class EventModel method getArchiveConsumer.
/**
* TODO: Call this from mouse menu of Archiving NC instead of in the beginning.
* (It used to be called once a minute from a thread of the event list / archiving list parts.)
*
* Creates on demand an ArchiveConsumer and stores its reference in field {@link #archiveConsumer}.
*/
private synchronized void getArchiveConsumer() {
if (archiveConsumer == null) {
try {
archiveConsumer = new ArchiveConsumer(new ArchiveReceiver(archQueue), cs, nctx);
archiveConsumer.startReceivingEvents();
m_logger.info("Subscribed to monitoring/archiving events.");
} catch (AcsJException ex) {
m_logger.log(Level.WARNING, "Failed to subcribe to monitoring/archiving events.", ex);
}
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class AnyAide method complexObjectToCorbaAny.
/**
* Converts a complex CORBA-based object to a CORBA any.
*
* @param obj
* A complex CORBA-based object such as a user-defined IDL struct.
* @return A CORBA any containing obj.
* @throws AcsJException
* if any problem occurs with the conversion.
*/
public Any complexObjectToCorbaAny(IDLEntity obj) throws AcsJException {
if (obj == null) {
Throwable cause = new Throwable("Method arg 'obj' was null");
throw new AcsJBadParameterEx(cause);
}
Any retVal = m_containerServices.getAdvancedContainerServices().getAny();
// ------
Class structHelperClass = null;
// actually looks like a CORBA type.
try {
// This is the CORBA helper class which is capable of inserting/extracting data from CORBA Anys.
structHelperClass = Class.forName(obj.getClass().getName() + "Helper");
} catch (Exception e) {
// If what's above fails...then the developer has specified a native Java
// class which has nothing to do with CORBA.
String msg = "The non-CORBA class '" + obj.getClass().getName() + "' cannot be converted to a CORBA Any.";
Throwable cause = new Throwable(msg);
m_logger.warning(msg);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotFoundEx(cause);
}
try {
// get at the static insert method defined for all IDL structures and sequences.
// TODO: Cache it in a struct - method map, perhaps using weak references.
Method insert = structHelperClass.getMethod("insert", new Class[] { Any.class, obj.getClass() });
// arguments to insert method are just the newly created Any and the
// IDL struct instance passed to this method.
Object[] args = { retVal, obj };
insert.invoke(null, args);
return retVal;
} catch (NoSuchMethodException e) {
// we got a Helper class, but it seems to be not the CORBA-generated kind
Throwable cause = new Throwable("Class '" + structHelperClass.getName() + "' associated with the given object of type '" + obj.getClass().getName() + "' is incompatiable with CORBA: " + e.getMessage());
throw new AcsJBadParameterEx(cause);
} catch (java.lang.reflect.InvocationTargetException e) {
Throwable realEx = e.getCause();
String reason = "Failed to insert the given CORBA object into a CORBA Any: the helper class insert method threw an exception.";
m_logger.log(Level.FINE, reason, realEx);
Throwable cause = new Throwable(reason + realEx.getMessage());
// todo: NC-specific exception type
throw new alma.ACSErrTypeJavaNative.wrappers.AcsJJavaLangEx(cause);
} catch (Throwable thr) {
String reason = "Failed to insert the given CORBA object into a CORBA Any.";
m_logger.log(Level.FINE, reason, thr);
Throwable cause = new Throwable(reason + thr.getMessage());
throw new AcsJUnexpectedExceptionEx(cause);
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class ChannelProperties method getCDBAdminProps.
// //////////////////////////////////////////////////////////////////////////
/**
* Given a channel name that exists in the ACS CDB
* ($ACS_CDB/CDB/MACI/Channels/channelName/channelName.xml), this function
* returns the channels administrative properties in their CORBA format.
*
* @param channelName
* name of the channel found in $ACS_CDB/CDB/MACI/Channels
* @return channel's admin properties
* @throws AcsJException
* if the channel's CDB entry is corrupted in any way
*/
public Property[] getCDBAdminProps(String channelName) throws AcsJException {
// use this object to get at channel information from the CDB
DAO tempDAO = null;
try {
tempDAO = m_services.getCDB().get_DAO_Servant("MACI/Channels/" + channelName);
} catch (alma.cdbErrType.CDBXMLErrorEx e) {
m_logger.log(Level.WARNING, "Bad CDB entry found for '" + channelName + "' channel");
throw new alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx(e);
} catch (alma.cdbErrType.CDBRecordDoesNotExistEx e) {
m_logger.log(Level.WARNING, "No CDB entry found for '" + channelName + "' channel");
throw new alma.ACSErrTypeCommon.wrappers.AcsJFileNotFoundEx(e);
} catch (AcsJContainerServicesEx e) {
m_logger.log(Level.WARNING, "CDB unavailable");
throw new alma.ACSErrTypeCommon.wrappers.AcsJNoResourcesEx(e);
}
// MaxQueueLength - TAO 1.1 had a queque of ~5 events. TAO 1.3 allows an
// infinite amount of events to be stored. 20 seems like
// a reasonable default.
Any maxQLAny = m_services.getAdvancedContainerServices().getAny();
try {
maxQLAny.insert_long(tempDAO.get_long("MaxQueueLength"));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property maxQL = new Property(MaxQueueLength.value, maxQLAny);
// MaxConsumers - ///////////////////////////////////////////////////////
Any maxConsumersAny = m_services.getAdvancedContainerServices().getAny();
try {
maxConsumersAny.insert_long(tempDAO.get_long("MaxConsumers"));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property maxConsumers = new Property(MaxConsumers.value, maxConsumersAny);
// MaxSuppliers - ///////////////////////////////////////////////////////
Any maxSuppliersAny = m_services.getAdvancedContainerServices().getAny();
try {
maxSuppliersAny.insert_long(tempDAO.get_long("MaxSuppliers"));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property maxSuppliers = new Property(MaxSuppliers.value, maxSuppliersAny);
// RejectNewEvents - if the queque is full, suppliers get exceptions when
// trying to push events onto the channel.
Any rejectNEAny = m_services.getAdvancedContainerServices().getAny();
boolean tBool = true;
try {
if (tempDAO.get_string("RejectNewEvents").equals("false")) {
tBool = false;
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
rejectNEAny.insert_boolean(tBool);
Property rejectNE = new Property(RejectNewEvents.value, rejectNEAny);
Property[] adminProps = { maxQL, maxConsumers, maxSuppliers, rejectNE };
return adminProps;
}
Aggregations