Bläddra i källkod

YARN-4823. Refactor the nested reservation id field in listReservation to simple string field. (subru via asuresh)

(cherry picked from commit 00bebb7e58ba6899904e1619d151aa1b2f5b6acd)
Arun Suresh 9 år sedan
förälder
incheckning
f6fde85c5c

+ 0 - 64
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ReservationIdInfo.java

@@ -1,64 +0,0 @@
-/**
- * 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.resourcemanager.webapp.dao;
-
-import org.apache.hadoop.yarn.api.records.ReservationId;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- * Simple class that represent a reservation ID.
- */
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.FIELD)
-public class ReservationIdInfo {
-  @XmlElement(name = "cluster-timestamp")
-  private long clusterTimestamp;
-
-  @XmlElement(name = "reservation-id")
-  private long reservationId;
-
-  public ReservationIdInfo() {
-    this.clusterTimestamp = 0;
-    this.reservationId = 0;
-  }
-
-  public ReservationIdInfo(ReservationId reservationId) {
-    this.clusterTimestamp = reservationId.getClusterTimestamp();
-    this.reservationId = reservationId.getId();
-  }
-
-  public long getClusterTimestamp() {
-    return this.clusterTimestamp;
-  }
-
-  public void setClusterTimestamp(long newClusterTimestamp) {
-    this.clusterTimestamp = newClusterTimestamp;
-  }
-
-  public long getReservationId() {
-    return this.reservationId;
-  }
-
-  public void setReservationId(long newReservationId) {
-    this.reservationId = newReservationId;
-  }
-}

+ 3 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ReservationInfo.java

@@ -44,7 +44,7 @@ public class ReservationInfo {
   private List<ResourceAllocationInfo> resourceAllocations = new ArrayList<>();
 
   @XmlElement(name = "reservation-id")
-  private ReservationIdInfo reservationId;
+  private String reservationId;
 
   @XmlElement(name = "reservation-definition")
   private ReservationDefinitionInfo reservationDefinition;
@@ -55,7 +55,6 @@ public class ReservationInfo {
     user = "";
 
     reservationDefinition = new ReservationDefinitionInfo();
-    reservationId = new ReservationIdInfo();
   }
 
   public ReservationInfo(ReservationAllocationState allocation, boolean
@@ -74,7 +73,7 @@ public class ReservationInfo {
       }
     }
 
-    reservationId = new ReservationIdInfo(allocation.getReservationId());
+    reservationId = allocation.getReservationId().toString();
     reservationDefinition = new ReservationDefinitionInfo(
             allocation.getReservationDefinition());
   }
@@ -95,7 +94,7 @@ public class ReservationInfo {
     return resourceAllocations;
   }
 
-  public ReservationIdInfo getReservationId() {
+  public String getReservationId() {
     return reservationId;
   }
 

+ 6 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesReservation.java

@@ -821,9 +821,8 @@ public class TestRMWebServicesReservation extends JerseyTestBase {
 
     testRDLHelper(reservations);
 
-    long reservationId = reservations.getJSONObject("reservation-id")
-            .getLong("reservation-id");
-    assertEquals(id1.getId(), reservationId);
+    String reservationId = reservations.getString("reservation-id");
+    assertEquals(id1.toString(), reservationId);
 
     rm.stop();
   }
@@ -879,9 +878,8 @@ public class TestRMWebServicesReservation extends JerseyTestBase {
 
     testRDLHelper(reservations);
 
-    long reservationId = reservations.getJSONObject("reservation-id")
-            .getLong("reservation-id");
-    assertEquals(id1.getId(), reservationId);
+    String reservationId = reservations.getString("reservation-id");
+    assertEquals(id1.toString(), reservationId);
 
     assertTrue(reservations.has("resource-allocations"));
 
@@ -916,9 +914,8 @@ public class TestRMWebServicesReservation extends JerseyTestBase {
 
     testRDLHelper(reservations);
 
-    long reservationId = reservations.getJSONObject("reservation-id")
-            .getLong("reservation-id");
-    assertEquals(id1.getId(), reservationId);
+    String reservationId = reservations.getString("reservation-id");
+    assertEquals(id1.toString(), reservationId);
 
     assertTrue(!reservations.has("resource-allocations"));