Search in sources :

Example 1 with SourceClient

use of alma.alarmsystem.clients.SourceClient 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);
}
Also used : QueueFileHandler(alma.acs.xmlfilestore.common.QueueFileHandler) TimestampedStringQueue(alma.acs.util.stringqueue.TimestampedStringQueue) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) SourceClient(alma.alarmsystem.clients.SourceClient) File(java.io.File)

Example 2 with SourceClient

use of alma.alarmsystem.clients.SourceClient in project ACS by ACS-Community.

the class SourcePanel method initializeACS.

/**
	 * Connect to ACS and to the source NC
	 */
private void initializeACS() throws Exception {
    // Connect to ACS
    Logger logger = ClientLogManager.getAcsLogManager().getLoggerForApplication("SourcePanel", true);
    String managerLoc = System.getProperty("ACS.manager");
    if (managerLoc == null) {
        System.out.println("Java property 'ACS.manager' must be set to the corbaloc of the ACS manager!");
        System.exit(-1);
    }
    acsClient = new AdvancedComponentClient(logger, managerLoc, "SourcePanel");
    contSvcs = acsClient.getContainerServices();
    // Connect to the source channel
    sourceClient = new SourceClient(contSvcs);
}
Also used : AdvancedComponentClient(alma.acs.component.client.AdvancedComponentClient) SourceClient(alma.alarmsystem.clients.SourceClient) Logger(java.util.logging.Logger)

Example 3 with SourceClient

use of alma.alarmsystem.clients.SourceClient in project ACS by ACS-Community.

the class UserPropsTest method setUp.

/**
	 * @see extends ComponentClientTestCase
	 */
protected void setUp() throws Exception {
    super.setUp();
    categoryClient = new CategoryClient(getContainerServices());
    assertNotNull(categoryClient);
    categoryClient.connect(this);
    // Instantiate and connect the source client
    sourceClient = new SourceClient(getContainerServices());
    assertNotNull(sourceClient);
    sourceClient.addAlarmListener(this);
    sourceClient.connect();
    alarmsReceived = new Vector<Alarm>();
}
Also used : Alarm(cern.laser.client.data.Alarm) CategoryClient(alma.alarmsystem.clients.CategoryClient) SourceClient(alma.alarmsystem.clients.SourceClient)

Example 4 with SourceClient

use of alma.alarmsystem.clients.SourceClient in project ACS by ACS-Community.

the class BACITest method setUp.

/**
	 * @see alma.acs.component.client.ComponentClientTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    // Check the container services... just in case ;-)
    assertNotNull(getContainerServices());
    // Instantiate and connect the source client
    sourceClient = new SourceClient(getContainerServices());
    assertNotNull(sourceClient);
    sourceClient.addAlarmListener(this);
    sourceClient.connect();
    // Instantiate and connect the category client
    categoryClient = new CategoryClient(getContainerServices());
    assertNotNull(categoryClient);
    categoryClient.connect(this);
    // Get the component
    getTestComponent();
}
Also used : CategoryClient(alma.alarmsystem.clients.CategoryClient) SourceClient(alma.alarmsystem.clients.SourceClient)

Aggregations

SourceClient (alma.alarmsystem.clients.SourceClient)4 CategoryClient (alma.alarmsystem.clients.CategoryClient)2 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)1 AdvancedComponentClient (alma.acs.component.client.AdvancedComponentClient)1 TimestampedStringQueue (alma.acs.util.stringqueue.TimestampedStringQueue)1 QueueFileHandler (alma.acs.xmlfilestore.common.QueueFileHandler)1 Alarm (cern.laser.client.data.Alarm)1 File (java.io.File)1 Logger (java.util.logging.Logger)1