[
https://issues.apache.org/jira/browse/YARN-11877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18062729#comment-18062729
]
ASF GitHub Bot commented on YARN-11877:
---------------------------------------
abstractdog commented on code in PR #8018:
URL: https://github.com/apache/hadoop/pull/8018#discussion_r2884125863
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestTimelineServerRequests.java:
##########
@@ -0,0 +1,157 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.applicationhistoryservice;
+
+import java.io.IOException;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
+import org.apache.hadoop.yarn.api.records.timeline.TimelinePutResponse;
+import org.apache.hadoop.yarn.api.records.timeline.reader.TimelineEntityReader;
+import org.apache.hadoop.yarn.client.api.TimelineClient;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.exceptions.YarnException;
+import org.apache.hadoop.yarn.server.timeline.MemoryTimelineStore;
+import org.apache.hadoop.yarn.server.timeline.TimelineStore;
+
+import static
org.apache.hadoop.yarn.conf.YarnConfiguration.TIMELINE_HTTP_AUTH_PREFIX;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class TestTimelineServerRequests {
+ private static final Logger LOG =
+ LoggerFactory.getLogger(TestTimelineServerRequests.class);
+
+ private static final String HOST = "localhost";
+ private static final String TIMELINE_SERVICE_WEBAPP_ADDRESS = HOST + ":0";
+ private static final String ENTITY_TYPE = "TEST_ENTITY_TYPE";
+ private static final String ENTITY_ID = "test_entity_1";
+ private static ApplicationHistoryServer testTimelineServer;
+ private static Configuration conf;
+
+ @BeforeAll
+ public static void setup() {
+ try {
+ testTimelineServer = new ApplicationHistoryServer();
+ conf = new Configuration(false);
+ conf.setStrings(TIMELINE_HTTP_AUTH_PREFIX + "type", "simple");
+
+ conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
+ conf.setClass(YarnConfiguration.TIMELINE_SERVICE_STORE,
+ MemoryTimelineStore.class, TimelineStore.class);
+ conf.set(YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
+ TIMELINE_SERVICE_WEBAPP_ADDRESS);
+ conf.setInt(YarnConfiguration.TIMELINE_SERVICE_CLIENT_MAX_RETRIES, 1);
+
+ testTimelineServer.init(conf);
+ testTimelineServer.start();
+ } catch (Exception e) {
+ LOG.error("Failed to setup TimelineServer", e);
+ fail("Couldn't setup TimelineServer");
+ }
+ }
+
+ @AfterAll
+ public static void tearDown() throws Exception {
+ if (testTimelineServer != null) {
+ testTimelineServer.stop();
+ }
+ }
+
+ @Test
+ void testPutAndGetTimelineEntity() throws Exception {
+ putEntity();
+ getEntity();
+ }
+
+ private void putEntity() throws IOException, YarnException {
+ TimelineClient client = createTimelineClient();
+ try {
+ TimelineEntity entityToStore = new TimelineEntity();
+ entityToStore.setEntityType(ENTITY_TYPE);
+ entityToStore.setEntityId(ENTITY_ID);
+ entityToStore.setStartTime(System.currentTimeMillis());
+ TimelinePutResponse putResponse = client.putEntities(entityToStore);
+ if (!putResponse.getErrors().isEmpty()) {
+ LOG.error("putResponse errors: {}", putResponse.getErrors());
+ }
+ assertTrue(putResponse.getErrors().isEmpty(),
+ "There were some errors in the putResponse");
+ TimelineEntity entityToRead =
+ testTimelineServer.getTimelineStore().getEntity(ENTITY_ID,
ENTITY_TYPE,
+ null);
+ assertNotNull(entityToRead, "Timeline entity should not be null");
+ } finally {
+ client.stop();
+ }
+ }
+
+ private TimelineClient createTimelineClient() {
+ TimelineClient client = TimelineClient.createTimelineClient();
+ client.init(conf);
+ client.start();
+ return client;
+ }
+
+ private void getEntity() {
+ String appUrl = "http://" + HOST + ":" + testTimelineServer.getPort()
+ + "/ws/v1/timeline/" + ENTITY_TYPE + "/" + ENTITY_ID
+ + "?user.name=foo";
Review Comment:
I think this would look better with a String.format
> Resolve JAXB IllegalAnnotation issue in TimelineEntity with Jersey 2.x
> ----------------------------------------------------------------------
>
> Key: YARN-11877
> URL: https://issues.apache.org/jira/browse/YARN-11877
> Project: Hadoop YARN
> Issue Type: Improvement
> Components: timelineservice
> Affects Versions: 3.5.0
> Reporter: Shilun Fan
> Assignee: Shilun Fan
> Priority: Major
> Labels: pull-request-available
>
> After upgrading to {*}Jersey 2.46{*}, retrieving *Timeline entities* via the
> {{/ws/v1/timeline/}} endpoint triggers the following exception:
> {code:java}
> java.lang.RuntimeException: TimelineEntity and TimelineEntities has
> IllegalAnnotation{code}
> The root cause is a JAXB binding compatibility issue related to interface
> types defined in TimelineEntity, which leads to illegal annotation errors
> during serialization or deserialization.
> For more background information, please refer to the mailing list discussion:
> https://lists.apache.org/thread/y70j1wqj00rhon4hxjkws6k55514sbfo
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]