001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.yarn.api.records.timeline; 020 021import java.util.ArrayList; 022import java.util.List; 023 024import javax.xml.bind.annotation.XmlAccessType; 025import javax.xml.bind.annotation.XmlAccessorType; 026import javax.xml.bind.annotation.XmlElement; 027import javax.xml.bind.annotation.XmlRootElement; 028 029import org.apache.hadoop.classification.InterfaceAudience.Public; 030import org.apache.hadoop.classification.InterfaceStability.Unstable; 031 032/** 033 * The class that hosts a list of events, which are categorized according to 034 * their related entities. 035 */ 036@XmlRootElement(name = "events") 037@XmlAccessorType(XmlAccessType.NONE) 038@Public 039@Unstable 040public class TimelineEvents { 041 042 private List<EventsOfOneEntity> allEvents = 043 new ArrayList<EventsOfOneEntity>(); 044 045 public TimelineEvents() { 046 047 } 048 049 /** 050 * Get a list of {@link EventsOfOneEntity} instances 051 * 052 * @return a list of {@link EventsOfOneEntity} instances 053 */ 054 @XmlElement(name = "events") 055 public List<EventsOfOneEntity> getAllEvents() { 056 return allEvents; 057 } 058 059 /** 060 * Add a single {@link EventsOfOneEntity} instance into the existing list 061 * 062 * @param eventsOfOneEntity 063 * a single {@link EventsOfOneEntity} instance 064 */ 065 public void addEvent(EventsOfOneEntity eventsOfOneEntity) { 066 allEvents.add(eventsOfOneEntity); 067 } 068 069 /** 070 * Add a list of {@link EventsOfOneEntity} instances into the existing list 071 * 072 * @param allEvents 073 * a list of {@link EventsOfOneEntity} instances 074 */ 075 public void addEvents(List<EventsOfOneEntity> allEvents) { 076 this.allEvents.addAll(allEvents); 077 } 078 079 /** 080 * Set the list to the given list of {@link EventsOfOneEntity} instances 081 * 082 * @param allEvents 083 * a list of {@link EventsOfOneEntity} instances 084 */ 085 public void setEvents(List<EventsOfOneEntity> allEvents) { 086 this.allEvents.clear(); 087 this.allEvents.addAll(allEvents); 088 } 089 090 /** 091 * The class that hosts a list of events that are only related to one entity. 092 */ 093 @XmlRootElement(name = "events") 094 @XmlAccessorType(XmlAccessType.NONE) 095 @Public 096 @Unstable 097 public static class EventsOfOneEntity { 098 099 private String entityId; 100 private String entityType; 101 private List<TimelineEvent> events = new ArrayList<TimelineEvent>(); 102 103 public EventsOfOneEntity() { 104 105 } 106 107 /** 108 * Get the entity Id 109 * 110 * @return the entity Id 111 */ 112 @XmlElement(name = "entity") 113 public String getEntityId() { 114 return entityId; 115 } 116 117 /** 118 * Set the entity Id 119 * 120 * @param entityId 121 * the entity Id 122 */ 123 public void setEntityId(String entityId) { 124 this.entityId = entityId; 125 } 126 127 /** 128 * Get the entity type 129 * 130 * @return the entity type 131 */ 132 @XmlElement(name = "entitytype") 133 public String getEntityType() { 134 return entityType; 135 } 136 137 /** 138 * Set the entity type 139 * 140 * @param entityType 141 * the entity type 142 */ 143 public void setEntityType(String entityType) { 144 this.entityType = entityType; 145 } 146 147 /** 148 * Get a list of events 149 * 150 * @return a list of events 151 */ 152 @XmlElement(name = "events") 153 public List<TimelineEvent> getEvents() { 154 return events; 155 } 156 157 /** 158 * Add a single event to the existing event list 159 * 160 * @param event 161 * a single event 162 */ 163 public void addEvent(TimelineEvent event) { 164 events.add(event); 165 } 166 167 /** 168 * Add a list of event to the existing event list 169 * 170 * @param events 171 * a list of events 172 */ 173 public void addEvents(List<TimelineEvent> events) { 174 this.events.addAll(events); 175 } 176 177 /** 178 * Set the event list to the given list of events 179 * 180 * @param events 181 * a list of events 182 */ 183 public void setEvents(List<TimelineEvent> events) { 184 this.events = events; 185 } 186 187 } 188 189}