|
@@ -15,7 +15,7 @@
|
|
|
* See the License for the specific language governing permissions and
|
|
|
* limitations under the License.
|
|
|
*/
|
|
|
-package org.apache.hadoop.yarn.server.applicationhistoryservice.apptimeline;
|
|
|
+package org.apache.hadoop.yarn.server.applicationhistoryservice.timeline;
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertNull;
|
|
@@ -35,15 +35,17 @@ import java.util.Set;
|
|
|
import java.util.SortedSet;
|
|
|
import java.util.TreeSet;
|
|
|
|
|
|
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEntities;
|
|
|
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEntity;
|
|
|
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEvent;
|
|
|
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSEvents.ATSEventsOfOneEntity;
|
|
|
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSPutErrors;
|
|
|
-import org.apache.hadoop.yarn.api.records.apptimeline.ATSPutErrors.ATSPutError;
|
|
|
-import org.apache.hadoop.yarn.server.applicationhistoryservice.apptimeline.ApplicationTimelineReader.Field;
|
|
|
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
|
|
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
|
|
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEvent;
|
|
|
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
|
|
|
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents.EventsOfOneEntity;
|
|
|
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError;
|
|
|
+import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.TimelineStore;
|
|
|
+import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.NameValuePair;
|
|
|
+import org.apache.hadoop.yarn.server.applicationhistoryservice.timeline.TimelineReader.Field;
|
|
|
|
|
|
-public class ApplicationTimelineStoreTestUtils {
|
|
|
+public class TimelineStoreTestUtils {
|
|
|
|
|
|
protected static final Map<String, Object> EMPTY_MAP =
|
|
|
Collections.emptyMap();
|
|
@@ -52,11 +54,11 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
protected static final Map<String, Set<String>> EMPTY_REL_ENTITIES =
|
|
|
Collections.emptyMap();
|
|
|
|
|
|
- protected ApplicationTimelineStore store;
|
|
|
- protected String entity1;
|
|
|
+ protected TimelineStore store;
|
|
|
+ protected String entityId1;
|
|
|
protected String entityType1;
|
|
|
- protected String entity1b;
|
|
|
- protected String entity2;
|
|
|
+ protected String entityId1b;
|
|
|
+ protected String entityId2;
|
|
|
protected String entityType2;
|
|
|
protected Map<String, Set<Object>> primaryFilters;
|
|
|
protected Map<String, Object> secondaryFilters;
|
|
@@ -66,19 +68,19 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
protected NameValuePair userFilter;
|
|
|
protected Collection<NameValuePair> goodTestingFilters;
|
|
|
protected Collection<NameValuePair> badTestingFilters;
|
|
|
- protected ATSEvent ev1;
|
|
|
- protected ATSEvent ev2;
|
|
|
- protected ATSEvent ev3;
|
|
|
- protected ATSEvent ev4;
|
|
|
+ protected TimelineEvent ev1;
|
|
|
+ protected TimelineEvent ev2;
|
|
|
+ protected TimelineEvent ev3;
|
|
|
+ protected TimelineEvent ev4;
|
|
|
protected Map<String, Object> eventInfo;
|
|
|
- protected List<ATSEvent> events1;
|
|
|
- protected List<ATSEvent> events2;
|
|
|
+ protected List<TimelineEvent> events1;
|
|
|
+ protected List<TimelineEvent> events2;
|
|
|
|
|
|
/**
|
|
|
* Load test data into the given store
|
|
|
*/
|
|
|
protected void loadTestData() throws IOException {
|
|
|
- ATSEntities atsEntities = new ATSEntities();
|
|
|
+ TimelineEntities entities = new TimelineEntities();
|
|
|
Map<String, Set<Object>> primaryFilters =
|
|
|
new HashMap<String, Set<Object>>();
|
|
|
Set<Object> l1 = new HashSet<Object>();
|
|
@@ -94,62 +96,62 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
otherInfo1.put("info1", "val1");
|
|
|
otherInfo1.putAll(secondaryFilters);
|
|
|
|
|
|
- String entity1 = "id_1";
|
|
|
+ String entityId1 = "id_1";
|
|
|
String entityType1 = "type_1";
|
|
|
- String entity1b = "id_2";
|
|
|
- String entity2 = "id_2";
|
|
|
+ String entityId1b = "id_2";
|
|
|
+ String entityId2 = "id_2";
|
|
|
String entityType2 = "type_2";
|
|
|
|
|
|
Map<String, Set<String>> relatedEntities =
|
|
|
new HashMap<String, Set<String>>();
|
|
|
- relatedEntities.put(entityType2, Collections.singleton(entity2));
|
|
|
+ relatedEntities.put(entityType2, Collections.singleton(entityId2));
|
|
|
|
|
|
- ATSEvent ev3 = createEvent(789l, "launch_event", null);
|
|
|
- ATSEvent ev4 = createEvent(-123l, "init_event", null);
|
|
|
- List<ATSEvent> events = new ArrayList<ATSEvent>();
|
|
|
+ TimelineEvent ev3 = createEvent(789l, "launch_event", null);
|
|
|
+ TimelineEvent ev4 = createEvent(-123l, "init_event", null);
|
|
|
+ List<TimelineEvent> events = new ArrayList<TimelineEvent>();
|
|
|
events.add(ev3);
|
|
|
events.add(ev4);
|
|
|
- atsEntities.setEntities(Collections.singletonList(createEntity(entity2,
|
|
|
+ entities.setEntities(Collections.singletonList(createEntity(entityId2,
|
|
|
entityType2, null, events, null, null, null)));
|
|
|
- ATSPutErrors response = store.put(atsEntities);
|
|
|
+ TimelinePutResponse response = store.put(entities);
|
|
|
assertEquals(0, response.getErrors().size());
|
|
|
|
|
|
- ATSEvent ev1 = createEvent(123l, "start_event", null);
|
|
|
- atsEntities.setEntities(Collections.singletonList(createEntity(entity1,
|
|
|
+ TimelineEvent ev1 = createEvent(123l, "start_event", null);
|
|
|
+ entities.setEntities(Collections.singletonList(createEntity(entityId1,
|
|
|
entityType1, 123l, Collections.singletonList(ev1),
|
|
|
relatedEntities, primaryFilters, otherInfo1)));
|
|
|
- response = store.put(atsEntities);
|
|
|
+ response = store.put(entities);
|
|
|
assertEquals(0, response.getErrors().size());
|
|
|
- atsEntities.setEntities(Collections.singletonList(createEntity(entity1b,
|
|
|
+ entities.setEntities(Collections.singletonList(createEntity(entityId1b,
|
|
|
entityType1, null, Collections.singletonList(ev1), relatedEntities,
|
|
|
primaryFilters, otherInfo1)));
|
|
|
- response = store.put(atsEntities);
|
|
|
+ response = store.put(entities);
|
|
|
assertEquals(0, response.getErrors().size());
|
|
|
|
|
|
Map<String, Object> eventInfo = new HashMap<String, Object>();
|
|
|
eventInfo.put("event info 1", "val1");
|
|
|
- ATSEvent ev2 = createEvent(456l, "end_event", eventInfo);
|
|
|
+ TimelineEvent ev2 = createEvent(456l, "end_event", eventInfo);
|
|
|
Map<String, Object> otherInfo2 = new HashMap<String, Object>();
|
|
|
otherInfo2.put("info2", "val2");
|
|
|
- atsEntities.setEntities(Collections.singletonList(createEntity(entity1,
|
|
|
+ entities.setEntities(Collections.singletonList(createEntity(entityId1,
|
|
|
entityType1, null, Collections.singletonList(ev2), null,
|
|
|
primaryFilters, otherInfo2)));
|
|
|
- response = store.put(atsEntities);
|
|
|
+ response = store.put(entities);
|
|
|
assertEquals(0, response.getErrors().size());
|
|
|
- atsEntities.setEntities(Collections.singletonList(createEntity(entity1b,
|
|
|
+ entities.setEntities(Collections.singletonList(createEntity(entityId1b,
|
|
|
entityType1, 789l, Collections.singletonList(ev2), null,
|
|
|
primaryFilters, otherInfo2)));
|
|
|
- response = store.put(atsEntities);
|
|
|
+ response = store.put(entities);
|
|
|
assertEquals(0, response.getErrors().size());
|
|
|
|
|
|
- atsEntities.setEntities(Collections.singletonList(createEntity(
|
|
|
+ entities.setEntities(Collections.singletonList(createEntity(
|
|
|
"badentityid", "badentity", null, null, null, null, otherInfo1)));
|
|
|
- response = store.put(atsEntities);
|
|
|
+ response = store.put(entities);
|
|
|
assertEquals(1, response.getErrors().size());
|
|
|
- ATSPutError error = response.getErrors().get(0);
|
|
|
+ TimelinePutError error = response.getErrors().get(0);
|
|
|
assertEquals("badentityid", error.getEntityId());
|
|
|
assertEquals("badentity", error.getEntityType());
|
|
|
- assertEquals(ATSPutError.NO_START_TIME, error.getErrorCode());
|
|
|
+ assertEquals(TimelinePutError.NO_START_TIME, error.getErrorCode());
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -187,10 +189,10 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
otherInfo.put("info2", "val2");
|
|
|
otherInfo.putAll(secondaryFilters);
|
|
|
|
|
|
- entity1 = "id_1";
|
|
|
+ entityId1 = "id_1";
|
|
|
entityType1 = "type_1";
|
|
|
- entity1b = "id_2";
|
|
|
- entity2 = "id_2";
|
|
|
+ entityId1b = "id_2";
|
|
|
+ entityId2 = "id_2";
|
|
|
entityType2 = "type_2";
|
|
|
|
|
|
ev1 = createEvent(123l, "start_event", null);
|
|
@@ -198,20 +200,20 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
eventInfo = new HashMap<String, Object>();
|
|
|
eventInfo.put("event info 1", "val1");
|
|
|
ev2 = createEvent(456l, "end_event", eventInfo);
|
|
|
- events1 = new ArrayList<ATSEvent>();
|
|
|
+ events1 = new ArrayList<TimelineEvent>();
|
|
|
events1.add(ev2);
|
|
|
events1.add(ev1);
|
|
|
|
|
|
relEntityMap =
|
|
|
new HashMap<String, Set<String>>();
|
|
|
Set<String> ids = new HashSet<String>();
|
|
|
- ids.add(entity1);
|
|
|
- ids.add(entity1b);
|
|
|
+ ids.add(entityId1);
|
|
|
+ ids.add(entityId1b);
|
|
|
relEntityMap.put(entityType1, ids);
|
|
|
|
|
|
ev3 = createEvent(789l, "launch_event", null);
|
|
|
ev4 = createEvent(-123l, "init_event", null);
|
|
|
- events2 = new ArrayList<ATSEvent>();
|
|
|
+ events2 = new ArrayList<TimelineEvent>();
|
|
|
events2.add(ev3);
|
|
|
events2.add(ev4);
|
|
|
}
|
|
@@ -221,39 +223,39 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
verifyEntityInfo(null, null, null, null, null, null,
|
|
|
store.getEntity("id_1", "type_2", EnumSet.allOf(Field.class)));
|
|
|
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
- primaryFilters, otherInfo, store.getEntity(entity1, entityType1,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ primaryFilters, otherInfo, store.getEntity(entityId1, entityType1,
|
|
|
EnumSet.allOf(Field.class)));
|
|
|
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
- primaryFilters, otherInfo, store.getEntity(entity1b, entityType1,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ primaryFilters, otherInfo, store.getEntity(entityId1b, entityType1,
|
|
|
EnumSet.allOf(Field.class)));
|
|
|
|
|
|
- verifyEntityInfo(entity2, entityType2, events2, relEntityMap,
|
|
|
- EMPTY_PRIMARY_FILTERS, EMPTY_MAP, store.getEntity(entity2, entityType2,
|
|
|
+ verifyEntityInfo(entityId2, entityType2, events2, relEntityMap,
|
|
|
+ EMPTY_PRIMARY_FILTERS, EMPTY_MAP, store.getEntity(entityId2, entityType2,
|
|
|
EnumSet.allOf(Field.class)));
|
|
|
|
|
|
// test getting single fields
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, null, null, null,
|
|
|
- store.getEntity(entity1, entityType1, EnumSet.of(Field.EVENTS)));
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, null, null, null,
|
|
|
+ store.getEntity(entityId1, entityType1, EnumSet.of(Field.EVENTS)));
|
|
|
|
|
|
- verifyEntityInfo(entity1, entityType1, Collections.singletonList(ev2),
|
|
|
- null, null, null, store.getEntity(entity1, entityType1,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, Collections.singletonList(ev2),
|
|
|
+ null, null, null, store.getEntity(entityId1, entityType1,
|
|
|
EnumSet.of(Field.LAST_EVENT_ONLY)));
|
|
|
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
- primaryFilters, otherInfo, store.getEntity(entity1b, entityType1,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ primaryFilters, otherInfo, store.getEntity(entityId1b, entityType1,
|
|
|
null));
|
|
|
|
|
|
- verifyEntityInfo(entity1, entityType1, null, null, primaryFilters, null,
|
|
|
- store.getEntity(entity1, entityType1,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, null, null, primaryFilters, null,
|
|
|
+ store.getEntity(entityId1, entityType1,
|
|
|
EnumSet.of(Field.PRIMARY_FILTERS)));
|
|
|
|
|
|
- verifyEntityInfo(entity1, entityType1, null, null, null, otherInfo,
|
|
|
- store.getEntity(entity1, entityType1, EnumSet.of(Field.OTHER_INFO)));
|
|
|
+ verifyEntityInfo(entityId1, entityType1, null, null, null, otherInfo,
|
|
|
+ store.getEntity(entityId1, entityType1, EnumSet.of(Field.OTHER_INFO)));
|
|
|
|
|
|
- verifyEntityInfo(entity2, entityType2, null, relEntityMap, null, null,
|
|
|
- store.getEntity(entity2, entityType2,
|
|
|
+ verifyEntityInfo(entityId2, entityType2, null, relEntityMap, null, null,
|
|
|
+ store.getEntity(entityId2, entityType2,
|
|
|
EnumSet.of(Field.RELATED_ENTITIES)));
|
|
|
}
|
|
|
|
|
@@ -272,31 +274,31 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
store.getEntities("type_3", null, null, null, userFilter,
|
|
|
null, null).getEntities().size());
|
|
|
|
|
|
- List<ATSEntity> entities =
|
|
|
+ List<TimelineEntity> entities =
|
|
|
store.getEntities("type_1", null, null, null, null, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
|
|
|
entities = store.getEntities("type_2", null, null, null, null, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(1, entities.size());
|
|
|
- verifyEntityInfo(entity2, entityType2, events2, relEntityMap,
|
|
|
+ verifyEntityInfo(entityId2, entityType2, events2, relEntityMap,
|
|
|
EMPTY_PRIMARY_FILTERS, EMPTY_MAP, entities.get(0));
|
|
|
|
|
|
entities = store.getEntities("type_1", 1l, null, null, null, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(1, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
|
|
|
entities = store.getEntities("type_1", 1l, 0l, null, null, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(1, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
|
|
|
entities = store.getEntities("type_1", null, 234l, null, null, null,
|
|
@@ -314,17 +316,17 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
entities = store.getEntities("type_1", null, null, 345l, null, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
|
|
|
entities = store.getEntities("type_1", null, null, 123l, null, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
}
|
|
|
|
|
@@ -343,12 +345,12 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
new NameValuePair("none", "none"), null,
|
|
|
EnumSet.allOf(Field.class)).getEntities().size());
|
|
|
|
|
|
- List<ATSEntity> entities = store.getEntities("type_1", null, null, null,
|
|
|
+ List<TimelineEntity> entities = store.getEntities("type_1", null, null, null,
|
|
|
userFilter, null, EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
|
|
|
entities = store.getEntities("type_2", null, null, null, userFilter, null,
|
|
@@ -358,13 +360,13 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
entities = store.getEntities("type_1", 1l, null, null, userFilter, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(1, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
|
|
|
entities = store.getEntities("type_1", 1l, 0l, null, userFilter, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(1, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
|
|
|
entities = store.getEntities("type_1", null, 234l, null, userFilter, null,
|
|
@@ -378,28 +380,28 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
entities = store.getEntities("type_1", null, null, 345l, userFilter, null,
|
|
|
EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
}
|
|
|
|
|
|
public void testGetEntitiesWithSecondaryFilters() throws IOException {
|
|
|
// test using secondary filter
|
|
|
- List<ATSEntity> entities = store.getEntities("type_1", null, null, null,
|
|
|
+ List<TimelineEntity> entities = store.getEntities("type_1", null, null, null,
|
|
|
null, goodTestingFilters, EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
|
|
|
entities = store.getEntities("type_1", null, null, null, userFilter,
|
|
|
goodTestingFilters, EnumSet.allOf(Field.class)).getEntities();
|
|
|
assertEquals(2, entities.size());
|
|
|
- verifyEntityInfo(entity1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(0));
|
|
|
- verifyEntityInfo(entity1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
+ verifyEntityInfo(entityId1b, entityType1, events1, EMPTY_REL_ENTITIES,
|
|
|
primaryFilters, otherInfo, entities.get(1));
|
|
|
|
|
|
entities = store.getEntities("type_1", null, null, null, null,
|
|
@@ -414,75 +416,75 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
public void testGetEvents() throws IOException {
|
|
|
// test getting entity timelines
|
|
|
SortedSet<String> sortedSet = new TreeSet<String>();
|
|
|
- sortedSet.add(entity1);
|
|
|
- List<ATSEventsOfOneEntity> timelines =
|
|
|
+ sortedSet.add(entityId1);
|
|
|
+ List<EventsOfOneEntity> timelines =
|
|
|
store.getEntityTimelines(entityType1, sortedSet, null, null,
|
|
|
null, null).getAllEvents();
|
|
|
assertEquals(1, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev2, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev2, ev1);
|
|
|
|
|
|
- sortedSet.add(entity1b);
|
|
|
+ sortedSet.add(entityId1b);
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, null,
|
|
|
null, null, null).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev2, ev1);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev2, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev2, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev2, ev1);
|
|
|
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, 1l,
|
|
|
null, null, null).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev2);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev2);
|
|
|
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, null,
|
|
|
345l, null, null).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev2);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev2);
|
|
|
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, null,
|
|
|
123l, null, null).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev2);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev2);
|
|
|
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, null,
|
|
|
null, 345l, null).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev1);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev1);
|
|
|
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, null,
|
|
|
null, 123l, null).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev1);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev1);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev1);
|
|
|
|
|
|
timelines = store.getEntityTimelines(entityType1, sortedSet, null,
|
|
|
null, null, Collections.singleton("end_event")).getAllEvents();
|
|
|
assertEquals(2, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity1, entityType1, ev2);
|
|
|
- verifyEntityTimeline(timelines.get(1), entity1b, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId1, entityType1, ev2);
|
|
|
+ verifyEntityTimeline(timelines.get(1), entityId1b, entityType1, ev2);
|
|
|
|
|
|
- sortedSet.add(entity2);
|
|
|
+ sortedSet.add(entityId2);
|
|
|
timelines = store.getEntityTimelines(entityType2, sortedSet, null,
|
|
|
null, null, null).getAllEvents();
|
|
|
assertEquals(1, timelines.size());
|
|
|
- verifyEntityTimeline(timelines.get(0), entity2, entityType2, ev3, ev4);
|
|
|
+ verifyEntityTimeline(timelines.get(0), entityId2, entityType2, ev3, ev4);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Verify a single entity
|
|
|
*/
|
|
|
- protected static void verifyEntityInfo(String entity, String entityType,
|
|
|
- List<ATSEvent> events, Map<String, Set<String>> relatedEntities,
|
|
|
+ protected static void verifyEntityInfo(String entityId, String entityType,
|
|
|
+ List<TimelineEvent> events, Map<String, Set<String>> relatedEntities,
|
|
|
Map<String, Set<Object>> primaryFilters, Map<String, Object> otherInfo,
|
|
|
- ATSEntity retrievedEntityInfo) {
|
|
|
- if (entity == null) {
|
|
|
+ TimelineEntity retrievedEntityInfo) {
|
|
|
+ if (entityId == null) {
|
|
|
assertNull(retrievedEntityInfo);
|
|
|
return;
|
|
|
}
|
|
|
- assertEquals(entity, retrievedEntityInfo.getEntityId());
|
|
|
+ assertEquals(entityId, retrievedEntityInfo.getEntityId());
|
|
|
assertEquals(entityType, retrievedEntityInfo.getEntityType());
|
|
|
if (events == null) {
|
|
|
assertNull(retrievedEntityInfo.getEvents());
|
|
@@ -511,9 +513,9 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
* Verify timeline events
|
|
|
*/
|
|
|
private static void verifyEntityTimeline(
|
|
|
- ATSEventsOfOneEntity retrievedEvents, String entity, String entityType,
|
|
|
- ATSEvent... actualEvents) {
|
|
|
- assertEquals(entity, retrievedEvents.getEntityId());
|
|
|
+ EventsOfOneEntity retrievedEvents, String entityId, String entityType,
|
|
|
+ TimelineEvent... actualEvents) {
|
|
|
+ assertEquals(entityId, retrievedEvents.getEntityId());
|
|
|
assertEquals(entityType, retrievedEvents.getEntityType());
|
|
|
assertEquals(actualEvents.length, retrievedEvents.getEvents().size());
|
|
|
for (int i = 0; i < actualEvents.length; i++) {
|
|
@@ -524,36 +526,36 @@ public class ApplicationTimelineStoreTestUtils {
|
|
|
/**
|
|
|
* Create a test entity
|
|
|
*/
|
|
|
- protected static ATSEntity createEntity(String entity, String entityType,
|
|
|
- Long startTime, List<ATSEvent> events,
|
|
|
+ protected static TimelineEntity createEntity(String entityId, String entityType,
|
|
|
+ Long startTime, List<TimelineEvent> events,
|
|
|
Map<String, Set<String>> relatedEntities,
|
|
|
Map<String, Set<Object>> primaryFilters,
|
|
|
Map<String, Object> otherInfo) {
|
|
|
- ATSEntity atsEntity = new ATSEntity();
|
|
|
- atsEntity.setEntityId(entity);
|
|
|
- atsEntity.setEntityType(entityType);
|
|
|
- atsEntity.setStartTime(startTime);
|
|
|
- atsEntity.setEvents(events);
|
|
|
+ TimelineEntity entity = new TimelineEntity();
|
|
|
+ entity.setEntityId(entityId);
|
|
|
+ entity.setEntityType(entityType);
|
|
|
+ entity.setStartTime(startTime);
|
|
|
+ entity.setEvents(events);
|
|
|
if (relatedEntities != null) {
|
|
|
for (Entry<String, Set<String>> e : relatedEntities.entrySet()) {
|
|
|
for (String v : e.getValue()) {
|
|
|
- atsEntity.addRelatedEntity(e.getKey(), v);
|
|
|
+ entity.addRelatedEntity(e.getKey(), v);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- atsEntity.setRelatedEntities(null);
|
|
|
+ entity.setRelatedEntities(null);
|
|
|
}
|
|
|
- atsEntity.setPrimaryFilters(primaryFilters);
|
|
|
- atsEntity.setOtherInfo(otherInfo);
|
|
|
- return atsEntity;
|
|
|
+ entity.setPrimaryFilters(primaryFilters);
|
|
|
+ entity.setOtherInfo(otherInfo);
|
|
|
+ return entity;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Create a test event
|
|
|
*/
|
|
|
- private static ATSEvent createEvent(long timestamp, String type, Map<String,
|
|
|
+ private static TimelineEvent createEvent(long timestamp, String type, Map<String,
|
|
|
Object> info) {
|
|
|
- ATSEvent event = new ATSEvent();
|
|
|
+ TimelineEvent event = new TimelineEvent();
|
|
|
event.setTimestamp(timestamp);
|
|
|
event.setEventType(type);
|
|
|
event.setEventInfo(info);
|