Package org.apache.cloudstack.framework.events

Examples of org.apache.cloudstack.framework.events.Event


        // if account has been deleted, this might be called during cleanup of resources and results in null pointer
        if (account == null)
            return;

        Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
                resourceType, resourceUUID);

        Map<String, String> eventDescription = new HashMap<String, String>();
        eventDescription.put("account", account.getUuid());
        eventDescription.put("zone", dc.getUuid());
        eventDescription.put("event", usageEventType);
        eventDescription.put("resource", resourceType);
        eventDescription.put("id", resourceUUID);
        event.setDescription(eventDescription);

        try {
            _eventBus.publish(event);
        } catch (EventBusException e) {
            s_logger.warn("Failed to publish usage event on the the event bus.");
View Full Code Here


        // if an invalid zone is passed in, create event without zone UUID
        String zoneUuid = null;
        if (dc != null)
            zoneUuid = dc.getUuid();

        Event event = new Event(Name, EventCategory.USAGE_EVENT.getName(), usageEventType, resourceType, resourceUUID);

        Map<String, String> eventDescription = new HashMap<String, String>();
        eventDescription.put("account", account.getUuid());
        eventDescription.put("zone", zoneUuid);
        eventDescription.put("event", usageEventType);
        eventDescription.put("resource", resourceType);
        eventDescription.put("id", resourceUUID);

        String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
        eventDescription.put("eventDateTime", eventDate);

        event.setDescription(eventDescription);

        try {
            s_eventBus.publish(event);
        } catch (EventBusException e) {
            s_logger.warn("Failed to publish usage event on the the event bus.");
View Full Code Here

                        String eventSource = getEventSourceFromRoutingKey(routingKey);
                        String eventCategory = getEventCategoryFromRoutingKey(routingKey);
                        String eventType = getEventTypeFromRoutingKey(routingKey);
                        String resourceType = getResourceTypeFromRoutingKey(routingKey);
                        String resourceUUID = getResourceUUIDFromRoutingKey(routingKey);
                        Event event = new Event(eventSource, eventCategory, eventType, resourceType, resourceUUID);
                        event.setDescription(new String(body));

                        // deliver the event to call back object provided by subscriber
                        subscriber.onEvent(event);
                    }
                }
View Full Code Here

                                    String eventType = getEventTypeFromRoutingKey(routingKey);
                                    String resourceType = getResourceTypeFromRoutingKey(routingKey);
                                    String resourceUUID = getResourceUUIDFromRoutingKey(routingKey);

                                    // create event object from the message details obtained from AMQP server
                                    Event event = new Event(eventSource, eventCategory, eventType, resourceType, resourceUUID);
                                    event.setDescription(new String(body));

                                    // deliver the event to call back object provided by subscriber
                                    subscriber.onEvent(event);
                                }
                            }
View Full Code Here

    @Test
    public void testPublish() throws Exception {
        EventTopic topic = mock(EventTopic.class);
        EventSubscriber subscriber = mock(EventSubscriber.class);
        Event event = mock(Event.class);

        InMemoryEventBus bus = new InMemoryEventBus();

        UUID uuid = bus.subscribe(topic, subscriber);
        assertNotNull(uuid);
View Full Code Here

    }

    @Test
    public void testPublishEmpty() throws Exception {
        EventSubscriber subscriber = mock(EventSubscriber.class);
        Event event = mock(Event.class);

        InMemoryEventBus bus = new InMemoryEventBus();
        bus.publish(event);

        verify(subscriber, times(0)).onEvent(event);
View Full Code Here

        // if an invalid zone is passed in, create event without zone UUID
        String zoneUuid = null;
        if (dc != null)
            zoneUuid = dc.getUuid();

        Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
                resourceType, resourceUUID);

        Map<String, String> eventDescription = new HashMap<String, String>();
        eventDescription.put("account", account.getUuid());
        eventDescription.put("zone", zoneUuid);
        eventDescription.put("event", usageEventType);
        eventDescription.put("resource", resourceType);
        eventDescription.put("id", resourceUUID);
        event.setDescription(eventDescription);

        try {
            _eventBus.publish(event);
        } catch (EventBusException e) {
            s_logger.warn("Failed to publish usage event on the the event bus.");
View Full Code Here

        // if account has been deleted, this might be called during cleanup of resources and results in null pointer
        if (account == null)
            return;

        Event event = new Event(Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
                resourceType, resourceUUID);

        Map<String, String> eventDescription = new HashMap<String, String>();
        eventDescription.put("account", account.getUuid());
        eventDescription.put("zone", dc.getUuid());
        eventDescription.put("event", usageEventType);
        eventDescription.put("resource", resourceType);
        eventDescription.put("id", resourceUUID);

        String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
        eventDescription.put("eventDateTime", eventDate);

        event.setDescription(eventDescription);

        try {
            _eventBus.publish(event);
        } catch (EventBusException e) {
            s_logger.warn("Failed to publish usage event on the the event bus.");
View Full Code Here

        }

        Account account = _accountDao.findById(accountId);
        DataCenterVO dc = _dcDao.findById(zoneId);

        Event event = new Event(ManagementServer.Name, EventCategory.USAGE_EVENT.getName(), usageEventType,
                resourceType, resourceUUID);

        Map<String, String> eventDescription = new HashMap<String, String>();
        eventDescription.put("account", account.getUuid());
        eventDescription.put("zone", dc.getUuid());
        eventDescription.put("event", usageEventType);
        eventDescription.put("resource", resourceType);
        eventDescription.put("id", resourceUUID);
        event.setDescription(eventDescription);

        try {
            _eventBus.publish(event);
        } catch (EventBusException e) {
            s_logger.warn("Failed to publish usage event on the the event bus.");
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.framework.events.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.