YARN-2118. Fixed the type mismatch in Map#containsKey check of TimelineWebServices#injectOwnerInfo. Contributed by Ted Yu.

svn merge --ignore-ancestry -c 1600967 ../../trunk/


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1600969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhijie Shen 2014-06-06 17:49:48 +00:00
parent 10bfa1ef2b
commit 32a71b6f34
3 changed files with 34 additions and 1 deletions

View File

@ -180,6 +180,9 @@ Release 2.5.0 - UNRELEASED
YARN-2119. DEFAULT_PROXY_ADDRESS should use DEFAULT_PROXY_PORT. YARN-2119. DEFAULT_PROXY_ADDRESS should use DEFAULT_PROXY_PORT.
(Anubhav Dhoot via kasha) (Anubhav Dhoot via kasha)
YARN-2118. Fixed the type mismatch in Map#containsKey check of
TimelineWebServices#injectOwnerInfo. (Ted Yu via zjshen)
Release 2.4.1 - UNRELEASED Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -519,7 +519,7 @@ public class TimelineWebServices {
String owner) throws YarnException { String owner) throws YarnException {
if (timelineEntity.getPrimaryFilters() != null && if (timelineEntity.getPrimaryFilters() != null &&
timelineEntity.getPrimaryFilters().containsKey( timelineEntity.getPrimaryFilters().containsKey(
TimelineStore.SystemFilter.ENTITY_OWNER)) { TimelineStore.SystemFilter.ENTITY_OWNER.toString())) {
throw new YarnException( throw new YarnException(
"User should not use the timeline system filter key: " "User should not use the timeline system filter key: "
+ TimelineStore.SystemFilter.ENTITY_OWNER); + TimelineStore.SystemFilter.ENTITY_OWNER);

View File

@ -21,6 +21,11 @@ package org.apache.hadoop.yarn.server.timeline.webapp;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.servlet.Filter; import javax.servlet.Filter;
@ -39,7 +44,9 @@ 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.TimelineEvent;
import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents; import org.apache.hadoop.yarn.api.records.timeline.TimelineEvents;
import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse; import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse.TimelinePutError;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.security.AdminACLsManager; import org.apache.hadoop.yarn.security.AdminACLsManager;
import org.apache.hadoop.yarn.server.timeline.TestMemoryTimelineStore; import org.apache.hadoop.yarn.server.timeline.TestMemoryTimelineStore;
import org.apache.hadoop.yarn.server.timeline.TimelineStore; import org.apache.hadoop.yarn.server.timeline.TimelineStore;
@ -362,6 +369,29 @@ public class TestTimelineWebServices extends JerseyTest {
Assert.assertEquals(0, event2.getEventInfo().size()); Assert.assertEquals(0, event2.getEventInfo().size());
} }
@Test
public void testPostEntitiesWithPrimaryFilter() throws Exception {
TimelineEntities entities = new TimelineEntities();
TimelineEntity entity = new TimelineEntity();
Map<String, Set<Object>> filters = new HashMap<String, Set<Object>>();
filters.put(TimelineStore.SystemFilter.ENTITY_OWNER.toString(), new HashSet<Object>());
entity.setPrimaryFilters(filters);
entity.setEntityId("test id 6");
entity.setEntityType("test type 6");
entity.setStartTime(System.currentTimeMillis());
entities.addEntity(entity);
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("timeline")
.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_JSON)
.post(ClientResponse.class, entities);
TimelinePutResponse putResposne = response.getEntity(TimelinePutResponse.class);
Assert.assertEquals(1, putResposne.getErrors().size());
List<TimelinePutError> errors = putResposne.getErrors();
Assert.assertEquals(TimelinePutResponse.TimelinePutError.SYSTEM_FILTER_CONFLICT,
errors.get(0).getErrorCode());
}
@Test @Test
public void testPostEntities() throws Exception { public void testPostEntities() throws Exception {
TimelineEntities entities = new TimelineEntities(); TimelineEntities entities = new TimelineEntities();