/* (c) Copyright 2011 Telefonica, I+D. Printed in Spain (Europe). All Righ Reserved. The copyright to the software program(s) is property of Telefonica I+D. The program(s) may be used and or copied only with the express written consent of Telefonica I+D or in accordance with the terms and conditions stipulated in the agreement/contract under which the program(s) have been supplied. */ /** Class that defines events to be generated/consumed by * Service Manager components. */ package com.telefonica.claudia.slm.eventsBus.events; import java.io.Serializable; public class Event implements Serializable { private static final long serialVersionUID = 1L; /** There are seven different types of events: * SERVICE_SLA_VIOLATION_EVENT - Generated by the SLA Protection Rule * Engine. * INFRASTRUCTURE_SLA_VIOLATION_EVENT - Generated by the Policy Engine * in the VEEM. * VEE_HW_MEASUREMENT - Gererated by hypervisors at the VEEs. * AGENT_MEASUREMENT - Generated by agents running inside the Service * Software running in the VEEs. * PROBE_MEASUREMENT - Generated by Probes. * SM_CONTROL_EVENT - Generated by SM components to let the Lifecycle controller know about changes in their statuses */ public static enum EventType { SERVICE_SLA_VIOLATION_EVENT, INFRASTRUCTURE_SLA_VIOLATION_EVENT, VEE_HW_MEASUREMENT, AGENT_MEASUREMENT, PROBE_MEASUREMENT, SM_CONTROL_EVENT, SMI_CHANNEL_EVENT, ADMINISTRATIVE_EVENT, FSM_BUS_EVENT}; /** * In the JMS system, there is a topic (bus channel) per each event type. * This method returns the topic name corresponding to each event type. * * @param Type of event to return its corresponding topic name. * @return The topic (channel) name. */ public static String busTopicForEventType(EventType eventType){ switch(eventType) { case SERVICE_SLA_VIOLATION_EVENT: return EventType.SERVICE_SLA_VIOLATION_EVENT.toString(); case INFRASTRUCTURE_SLA_VIOLATION_EVENT: return EventType.INFRASTRUCTURE_SLA_VIOLATION_EVENT.toString(); case VEE_HW_MEASUREMENT: return EventType.VEE_HW_MEASUREMENT.toString(); case AGENT_MEASUREMENT: return EventType.AGENT_MEASUREMENT.toString(); case PROBE_MEASUREMENT: return EventType.PROBE_MEASUREMENT.toString(); case SM_CONTROL_EVENT: return EventType.SM_CONTROL_EVENT.toString(); case SMI_CHANNEL_EVENT: return EventType.SMI_CHANNEL_EVENT.toString(); case FSM_BUS_EVENT: return EventType.FSM_BUS_EVENT.toString(); default: throw new Error("Unkonwn event type???"); } } /** * In the case of the SMI Channel, the events are not distributed over a Topic, but * over a Queue. This way, there are two identifieres needed: the one for the request queue * and the one for the reply queue. This method returns the appropiate name for the chosen queue */ public static String busQueueForEventType(EventType eventType, boolean reply) { switch(eventType) { case SMI_CHANNEL_EVENT: case ADMINISTRATIVE_EVENT: if (reply) return eventType.toString() + "_REPLY"; else return eventType.toString() + "_REQUEST"; default: throw new Error("Unkonwn event type???"); } } /** Time associated to the event. For a VEEHw, Agent or Probe monitoring event, * it is the time the data was generated, for a SLA violation, is the time the * violation happened. */ private long t_0 = 0; /** Delta 0. Used for aggregated data, it is the length of the time interval of * the aggregation. */ private long delta_t = 0; /** Event type */ private EventType type = null; /** * Constructor of events. No event with empty field is allowed. * @param t_0 Time the event creator started running. * @param delta_t Elapsed time since t_0 until the event creation. * event FQN. * @param type Event type. */ protected Event(long t_0, long delta_t, EventType type){ this.t_0 = t_0; this.delta_t = delta_t; this.type = type; } public long getInitialTime() { return t_0; } public long getDeltaT() { return delta_t; } public EventType getEventType(){ return type; } @Override public String toString(){ return "t_0:" + t_0 + " t:" + delta_t + " type:" + type; } }