use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class ControllerImpl method initialize.
//////////////////////////////////////
///////// ComponentLifecycle /////////
//////////////////////////////////////
@Override
public void initialize(ContainerServices inContainerServices) throws ComponentLifecycleException {
super.initialize(inContainerServices);
try {
String[] componentNames = getConfiguredBlobberCompNames();
if (componentNames.length == 0) {
throw new ComponentLifecycleException("No blobbers (" + BLOBBER_IDL_TYPE + ") found in the CDB. At least one must be configured.");
}
for (String componentName : componentNames) {
try {
blobberList.createBlobberInfo(componentName);
} catch (AcsJIllegalArgumentEx ex) {
m_logger.warning("Failed to process blobber component name '" + componentName + "', which apparently is a duplicate.");
}
}
m_logger.info("The following configured blobber components were found: " + blobberList.getBlobberNames(false) + ". Blobbers will be requested later on demand.");
} catch (AcsJContainerServicesEx e) {
throw new ComponentLifecycleException(e);
}
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class XmlFileStoreAlarmImpl method initialize.
/**
* Life cycle
* @see alma.acs.component.ComponentLifecycle#initialize()
*/
@Override
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
cs = containerServices;
m_logger = cs.getLogger();
// Prepare the queue
String folderPath = System.getProperty(XmlFileStoreAlarmImpl.LOGDIR_PROPNAME, XmlFileStoreAlarmImpl.DEFAULLOGDIR);
File f = new File(folderPath);
if (!f.exists()) {
f.mkdirs();
}
int fileMax = Integer.getInteger(XmlFileStoreAlarmImpl.MAXNUMBEROFFILES_PROPNAME, XmlFileStoreAlarmImpl.DEFAULTMAXNUMBEROFFILES);
int fileSizeLimit = Integer.getInteger(XmlFileStoreAlarmImpl.MAXFILESIZE_PROPNAME, XmlFileStoreAlarmImpl.DEFAULTMAXFILESIZE);
if (fileMax < 1 || fileSizeLimit < 100000) {
StringBuilder str = new StringBuilder(XmlFileStoreAlarmImpl.MAXNUMBEROFFILES_PROPNAME);
str.append(" must be greater then 1 and ");
str.append(XmlFileStoreAlarmImpl.MAXFILESIZE_PROPNAME);
str.append(" must be greater then 100000");
throw new ComponentLifecycleException(str.toString());
}
StringBuilder str = new StringBuilder("Will save alarms files in : ");
str.append(folderPath);
str.append(" (max log file size: ");
str.append(fileSizeLimit);
str.append(", max # log files: ");
str.append(fileMax);
str.append(')');
m_logger.info(str.toString());
QueueFileHandler qFileHandler;
try {
qFileHandler = new QueueFileHandler(cs, folderPath, fileMax, fileSizeLimit, "alarmSources", "AlarmsLogger");
} catch (Throwable t) {
throw new ComponentLifecycleException("Could not create the queue file handler", t);
}
queue = new TimestampedStringQueue(qFileHandler, "<source-timestamp>");
queue.start();
// Connects to the alarm source NC
try {
alarmSourceClient = new SourceClient(cs);
alarmSourceClient.connect();
} catch (Throwable t) {
throw new ComponentLifecycleException("Could not connect to alarm source NC", t);
}
alarmSourceClient.addAlarmListener(this);
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class XmlFileStoreLoggerImpl method connectToLoggingChannel.
/**
*
* @param logFilePath
* @param fileMax
* @param fileSizeLimit
* @throws ComponentLifecycleException
*/
private void connectToLoggingChannel(String logFilePath, int fileMax, int fileSizeLimit) throws ComponentLifecycleException {
try {
// connect to LoggingChannel
QueueFileHandler queueFileHandler = new QueueFileHandler(cs, logFilePath, fileMax, fileSizeLimit, "log", "Logging");
engine = new LCEngine(queueFileHandler);
engine.connect(cs.getAdvancedContainerServices().getORB(), null);
engine.enableAutoReconnection(true);
} catch (Throwable e) {
m_logger.severe("Could not initialize connection to logging channel.");
cs.getAlarmSource().setAlarm("Logging", cs.getName(), 2, true);
throw new ComponentLifecycleException(e);
}
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class EventConsumerImpl method initialize.
/**
* Sets up the {@link Consumer}.
* <p>
* {@inheritDoc}
*/
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
m_logger.info("initialize() called...");
try {
//subscribe to real channel and name
m_consumer = new Consumer("blar", m_containerServices);
m_consumer.addSubscription(EventDescription.class, this);
// m_consumer.addSubscription(NestedFridgeEventSeqHolder.class, this);
m_logger.info("Subscribed to 'EventDescription' " + /*and 'NestedFridgeEventSeqHolder'*/
" types of events on channel 'blar'");
//try to add a subscription to the same type
try {
m_consumer.addSubscription(EventDescription.class, this);
throw new ComponentLifecycleException("subscription to the same type should fail!");
} catch (ComponentLifecycleException e) {
throw e;
} catch (Exception e) {
//good, expected this.
m_logger.info("Good... attempt to subscribe twice to the same event type failed with " + e.getClass().getName());
}
//add a subscription to something that exists but we will never actually receive
try {
m_consumer.addSubscription(alma.acstime.Epoch.class, this);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Bad...cannot subscribe to multiple events types.");
// @TODO: throw exception. Perhaps move these checks to separate functional method to be called by test client.
}
//add a subscription to something that exists but there is no receive method implemented for.
try {
m_consumer.addSubscription(org.omg.CosNotification.StructuredEvent.class, this);
System.out.println("If you'return reading this message, addSubscription is broken!");
// @TODO: throw exception. Perhaps move these checks to separate functional method to be called by test client.
} catch (Exception e) {
System.out.println("Good...cannot subscribe to events where the receive method has not been implemented");
}
//try to add a bad filter
try {
if (m_consumer.addFilter(EventDescription.class, "hope to god this filter doesn't work") != -1) {
System.out.println("If you're reading this message, stupid API allows subscribing to bad filters!");
}
} catch (alma.acs.exceptions.AcsJException e) {
System.out.println("Good...cannot add a bad filter: " + e.getMessage());
}
//test the helper
if (m_consumer.getHelper() == null) {
System.out.println("Damn helper was null!");
}
//test offer_change
m_consumer.offer_change(new org.omg.CosNotification.EventType[] {}, new org.omg.CosNotification.EventType[] {});
//test disconnect_structured_push_consumer
m_consumer.disconnect_structured_push_consumer();
//start receiving events
m_consumer.consumerReady();
//test suspend
m_consumer.suspend();
//test resume
m_consumer.resume();
m_logger.info("Waiting for events...");
} catch (ComponentLifecycleException e) {
throw e;
} catch (Exception e) {
throw new ComponentLifecycleException(e);
}
}
use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.
the class EventConsumerImpl method initialize.
/**
* Sets up the {@link Consumer}.
* <p>
* {@inheritDoc}
*/
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
super.initialize(containerServices);
m_logger.info("initialize() called...");
try {
//subscribe to real channel and name
m_consumer = new Consumer("blarIL", m_containerServices);
m_consumer.addSubscription(EventDescription.class, this);
//try to add a subscription to the same type
try {
m_consumer.addSubscription(EventDescription.class, this);
} catch (Exception e) {
//good, expected this.
}
//add a subscription to something that exists but we will never actually receive
try {
m_consumer.addSubscription(alma.acstime.Epoch.class, this);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Bad...cannot subscribe to multiple events types.");
}
//add a subscription to something that exists but there is no receive method implemented for.
try {
m_consumer.addSubscription(org.omg.CosNotification.StructuredEvent.class, this);
System.out.println("If you'return reading this message, addSubscription is broken!");
} catch (Exception e) {
System.out.println("Good...cannot subscribe to events where the receive method has not been implemented");
}
//try to add a bad filter
try {
if (m_consumer.addFilter(EventDescription.class, "hope to god this filter doesn't work") != -1) {
System.out.println("If you're reading this message, stupid API allows subscribing to bad filters!");
}
} catch (alma.acs.exceptions.AcsJException e) {
System.out.println("Good...cannot add a bad filter: " + e.getMessage());
}
//test the helper
if (m_consumer.getHelper() == null) {
System.out.println("Damn helper was null!");
}
//test offer_change
m_consumer.offer_change(new org.omg.CosNotification.EventType[] {}, new org.omg.CosNotification.EventType[] {});
//test disconnect_structured_push_consumer
m_consumer.disconnect_structured_push_consumer();
//start receiving events
m_consumer.consumerReady();
//test suspend
m_consumer.suspend();
//test resume
m_consumer.resume();
System.out.println("Waiting for events...consumer");
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations