Search in sources :

Example 11 with EventDescription

use of alma.acsnc.EventDescription in project ACS by ACS-Community.

the class AdminConsumer method push_structured_event_called.

@Override
public boolean push_structured_event_called(StructuredEvent evt) {
    channelEventCount.incrementAndGet();
    //		String evtName = evt.header.fixed_header.event_name; // Normally empty, as ACSEventAdmin.py states?
    String evtTypeName = evt.header.fixed_header.event_type.type_name;
    AtomicLong typeCounter = evtCounter.get(evtTypeName);
    if (typeCounter == null) {
        synchronized (evtCounter) {
            typeCounter = evtCounter.get(evtTypeName);
            if (typeCounter == null) {
                typeCounter = new AtomicLong(0);
                evtCounter.put(evtTypeName, typeCounter);
            }
        }
    }
    typeCounter.incrementAndGet();
    //		String domainName = evt.header.fixed_header.event_type.domain_name; // Always ALMA?
    //		Any data = evt.filterable_data[0].value;
    EventDescription eDescrip = EventDescriptionHelper.extract(evt.remainder_of_body);
    //		long timeStamp = eDescrip.timestamp;
    //		String component = eDescrip.name;
    //		long count = eDescrip.count;
    Any eventAny = evt.filterable_data[0].value;
    boolean oresult = equeue.offer(new EventData(eDescrip.timestamp, eDescrip.name, eDescrip.count, evt.header.fixed_header.event_type.type_name, typeCounter.get(), channelName, eventAny));
    //		}
    if (!oresult)
        logger.severe("Couldn't queue event # " + channelEventCount.get());
    if (++totalEventCount % 100 == 0) {
        // Maybe this is redundant with the "Total rows processed" log
        logger.fine("A total of " + totalEventCount + " events have been received.");
        logger.fine("Event queue size is now: " + equeue.size() + " elements.");
    }
    // Prevent further processing of this event by the subscriber framework
    return false;
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) EventDescription(alma.acsnc.EventDescription) Any(org.omg.CORBA.Any)

Example 12 with EventDescription

use of alma.acsnc.EventDescription in project ACS by ACS-Community.

the class ArchiveSupplier method publishEvent.

/**
	 * Takes an object and tries to pack it into a CORBA Any and
	 * publish it to the event channel. 
	 * <p>
	 * The parameter <code>obj</code> can be one of the JDK classes <code>Integer</code>, <code>Long</code>, 
	 * <code>Float</code>, <code>Double</code>, <code>String</code>. 
	 * It could also be <code>null</code>, or come from an IDL-defined struct (thus implementing <code>IDLEntity</code>);
	 * at least the latter should never occur since baci properties don't have complex values. 
	 * 
	 * @param value
	 *           Value to be published.
	 * @throws AcsJException
	 *            There are an enormous amount of possibilities pertaining to why
	 *            a subclass of AcsJException would be thrown by publishEvent.
	 */
public void publishEvent(Object value) throws AcsJException {
    //the eventName consists of container named concatenated with the
    //component and property names, delimited by ':'s.
    String typeName = value.getClass().getName().substring(value.getClass().getName().lastIndexOf('.') + 1);
    String containerName = services.getName();
    String param = "no_param";
    // @TODO use real component/device name
    String device = "no_device";
    String eventName = containerName + ":" + device + ":" + param;
    // event to send
    StructuredEvent event = getCORBAEvent(typeName, eventName);
    event.remainder_of_body = services.getAdvancedContainerServices().getAny();
    // get the useful data which includes the component's name, timestamp, and event count
    long utcTime = UTCUtility.utcJavaToOmg(System.currentTimeMillis());
    EventDescription descrip = new EventDescription(containerName, utcTime, 1);
    // store all data into the structured event
    EventDescriptionHelper.insert(event.remainder_of_body, descrip);
    event.filterable_data = new Property[2];
    event.filterable_data[0] = new Property("time_stamp", anyAide.objectToCorbaAny(new Long(utcTime)));
    event.filterable_data[1] = new Property("value", anyAide.objectToCorbaAny(value));
    publishCORBAEvent(event, value);
}
Also used : StructuredEvent(org.omg.CosNotification.StructuredEvent) EventDescription(alma.acsnc.EventDescription) Property(org.omg.CosNotification.Property)

Example 13 with EventDescription

use of alma.acsnc.EventDescription in project ACS by ACS-Community.

the class InMemoryPublisher method publishEvent.

/**
	 * {@inheritDoc}
	 * <p>
	 * This method is thread-safe.
	 */
@Override
public void publishEvent(T customStruct) throws AcsJException {
    long currentOmgTime = UTCUtility.utcJavaToOmg(System.currentTimeMillis());
    EventDescription desc = new EventDescription(publisherName, currentOmgTime, count.getAndIncrement());
    nc.pushData(customStruct, desc);
}
Also used : EventDescription(alma.acsnc.EventDescription)

Example 14 with EventDescription

use of alma.acsnc.EventDescription in project ACS by ACS-Community.

the class StructuredEventCreator method createEvent.

public StructuredEvent createEvent(IDLEntity customStruct) throws AcsJException {
    // The Java class name without package becomes the name of the "event type".
    String typeName = customStruct.getClass().getName().substring(customStruct.getClass().getName().lastIndexOf('.') + 1);
    // event to send
    StructuredEvent event = getCORBAEvent(typeName, "");
    // Store the info for Exec/I&T into the event.
    // create the any
    event.remainder_of_body = m_services.getAdvancedContainerServices().getAny();
    // get the useful data which includes the component's name, timestamp, and event count (=1 here)
    EventDescription descrip = new EventDescription(m_services.getName(), alma.acs.util.UTCUtility.utcJavaToOmg(System.currentTimeMillis()), 1);
    // store the IDL struct into the structured event
    EventDescriptionHelper.insert(event.remainder_of_body, descrip);
    // preallocate one name/value pair
    event.filterable_data = new Property[1];
    event.filterable_data[0] = new Property(alma.acscommon.DEFAULTDATANAME.value, m_anyAide.complexObjectToCorbaAny(customStruct));
    return event;
}
Also used : StructuredEvent(org.omg.CosNotification.StructuredEvent) EventDescription(alma.acsnc.EventDescription) Property(org.omg.CosNotification.Property)

Example 15 with EventDescription

use of alma.acsnc.EventDescription in project ACS by ACS-Community.

the class EventSupplierImpl method initialize.

/** Sets up the SimpleSupplier.
	 * @param containerServices Services to components.
	 * @throws ComponentLifecycleException Not thrown.
	 */
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    try {
        //Instantiate our supplier
        t_block = new EventDescription("no name", 32L, 64L);
        epub = m_containerServices.createNotificationChannelPublisher(channelName, EventDescription.class);
        m_logger.info("NC Publisher for '" + channelName + "' channel created.");
    } catch (Exception e) {
        throw new ComponentLifecycleException(e);
    }
}
Also used : ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) EventDescription(alma.acsnc.EventDescription) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) AcsJException(alma.acs.exceptions.AcsJException)

Aggregations

EventDescription (alma.acsnc.EventDescription)15 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)5 AcsJException (alma.acs.exceptions.AcsJException)3 NO_IMPLEMENT (org.omg.CORBA.NO_IMPLEMENT)3 Property (org.omg.CosNotification.Property)3 StructuredEvent (org.omg.CosNotification.StructuredEvent)3 Date (java.util.Date)2 IDLEntity (org.omg.CORBA.portable.IDLEntity)2 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)1 ADMINTEST1.statusBlockEvent1 (alma.ADMINTEST1.statusBlockEvent1)1 ADMINTEST2.statusBlockEvent2 (alma.ADMINTEST2.statusBlockEvent2)1 AcsLogLevel (alma.acs.logging.AcsLogLevel)1 Callback (alma.acs.nc.AcsEventSubscriber.Callback)1 GenericCallback (alma.acs.nc.AcsEventSubscriber.GenericCallback)1 Consumer (alma.acs.nc.Consumer)1 AcsJEventSubscriptionEx (alma.acsErrTypeLifeCycle.wrappers.AcsJEventSubscriptionEx)1 AcsJPublishEventFailureEx (alma.acsncErrType.wrappers.AcsJPublishEventFailureEx)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Level (java.util.logging.Level)1