Java Code Examples for org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError#setEntityId()

The following examples show how to use org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError#setEntityId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestTimelineRecords.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimelinePutErrors() throws Exception {
  TimelinePutResponse TimelinePutErrors = new TimelinePutResponse();
  TimelinePutError error1 = new TimelinePutError();
  error1.setEntityId("entity id 1");
  error1.setEntityId("entity type 1");
  error1.setErrorCode(TimelinePutError.NO_START_TIME);
  TimelinePutErrors.addError(error1);
  List<TimelinePutError> response = new ArrayList<TimelinePutError>();
  response.add(error1);
  TimelinePutError error2 = new TimelinePutError();
  error2.setEntityId("entity id 2");
  error2.setEntityId("entity type 2");
  error2.setErrorCode(TimelinePutError.IO_EXCEPTION);
  response.add(error2);
  TimelinePutErrors.addErrors(response);
  LOG.info("Errors in JSON:");
  LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(TimelinePutErrors, true));

  Assert.assertEquals(3, TimelinePutErrors.getErrors().size());
  TimelinePutError e = TimelinePutErrors.getErrors().get(0);
  Assert.assertEquals(error1.getEntityId(), e.getEntityId());
  Assert.assertEquals(error1.getEntityType(), e.getEntityType());
  Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
  e = TimelinePutErrors.getErrors().get(1);
  Assert.assertEquals(error1.getEntityId(), e.getEntityId());
  Assert.assertEquals(error1.getEntityType(), e.getEntityType());
  Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
  e = TimelinePutErrors.getErrors().get(2);
  Assert.assertEquals(error2.getEntityId(), e.getEntityId());
  Assert.assertEquals(error2.getEntityType(), e.getEntityType());
  Assert.assertEquals(error2.getErrorCode(), e.getErrorCode());
}
 
Example 2
Source File: LeveldbTimelineStore.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Handle error and set it in response.
 */
private static void handleError(TimelineEntity entity, TimelinePutResponse response, final int errorCode) {
  TimelinePutError error = new TimelinePutError();
  error.setEntityId(entity.getEntityId());
  error.setEntityType(entity.getEntityType());
  error.setErrorCode(errorCode);
  response.addError(error);
}
 
Example 3
Source File: TestTimelineRecords.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimelinePutErrors() throws Exception {
  TimelinePutResponse TimelinePutErrors = new TimelinePutResponse();
  TimelinePutError error1 = new TimelinePutError();
  error1.setEntityId("entity id 1");
  error1.setEntityId("entity type 1");
  error1.setErrorCode(TimelinePutError.NO_START_TIME);
  TimelinePutErrors.addError(error1);
  List<TimelinePutError> response = new ArrayList<TimelinePutError>();
  response.add(error1);
  TimelinePutError error2 = new TimelinePutError();
  error2.setEntityId("entity id 2");
  error2.setEntityId("entity type 2");
  error2.setErrorCode(TimelinePutError.IO_EXCEPTION);
  response.add(error2);
  TimelinePutErrors.addErrors(response);
  LOG.info("Errors in JSON:");
  LOG.info(TimelineUtils.dumpTimelineRecordtoJSON(TimelinePutErrors, true));

  Assert.assertEquals(3, TimelinePutErrors.getErrors().size());
  TimelinePutError e = TimelinePutErrors.getErrors().get(0);
  Assert.assertEquals(error1.getEntityId(), e.getEntityId());
  Assert.assertEquals(error1.getEntityType(), e.getEntityType());
  Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
  e = TimelinePutErrors.getErrors().get(1);
  Assert.assertEquals(error1.getEntityId(), e.getEntityId());
  Assert.assertEquals(error1.getEntityType(), e.getEntityType());
  Assert.assertEquals(error1.getErrorCode(), e.getErrorCode());
  e = TimelinePutErrors.getErrors().get(2);
  Assert.assertEquals(error2.getEntityId(), e.getEntityId());
  Assert.assertEquals(error2.getEntityType(), e.getEntityType());
  Assert.assertEquals(error2.getErrorCode(), e.getErrorCode());
}
 
Example 4
Source File: LeveldbTimelineStore.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Handle error and set it in response.
 */
private static void handleError(TimelineEntity entity, TimelinePutResponse response, final int errorCode) {
  TimelinePutError error = new TimelinePutError();
  error.setEntityId(entity.getEntityId());
  error.setEntityType(entity.getEntityType());
  error.setErrorCode(errorCode);
  response.addError(error);
}