66 * to you under the Apache License, Version 2.0 (the
77 * "License"); you may not use this file except in compliance
88 * with the License. You may obtain a copy of the License at
9- *
10- * http://www.apache.org/licenses/LICENSE-2.0
11- *
9+ * <p>
10+ * http://www.apache.org/licenses/LICENSE-2.0
11+ * <p>
1212 * Unless required by applicable law or agreed to in writing, software
1313 * distributed under the License is distributed on an "AS IS" BASIS,
1414 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8787import org .apache .hadoop .yarn .webapp .dao .SchedConfUpdateInfo ;
8888
8989/**
90- * Configuration holder for class serialization setup used by the ResourceManager web services layer.
90+ * Configuration holder for class serialization setup
91+ * used by the ResourceManager web services layer.
9192 *
9293 * <p>This class manages two categories of data transfer objects (DTOs):</p>
9394 * <ul>
94- * <li><b>Wrapped classes</b> – classes whose JSON representation includes a root wrapper element.</li>
95- * <li><b>Unwrapped classes</b> – classes whose JSON representation omits a root wrapper element.</li>
95+ * <li><b>Wrapped classes</b>
96+ * – classes whose JSON representation includes a root wrapper element.</li>
97+ * <li><b>Unwrapped classes</b>
98+ * – classes whose JSON representation omits a root wrapper element.</li>
9699 * </ul>
97100 *
98101 * <p>The configuration is initialized with a default list of constant classes and may optionally
139142public class ClassSerialisationConfig {
140143 private static final Logger LOG = LoggerFactory .getLogger (ClassSerialisationConfig .class );
141144
142- private static final Set <Class <?>> CONST_WRAPPED_CLASSES = Sets .newHashSet (
143- ActivitiesInfo .class ,
144- AppActivitiesInfo .class ,
145- AppAttemptInfo .class ,
146- AppAttemptsInfo .class ,
147- AppInfo .class ,
148- ApplicationStatisticsInfo .class ,
149- AppsInfo .class ,
150- AppTimeoutInfo .class ,
151- AppTimeoutsInfo .class ,
152- BulkActivitiesInfo .class ,
153- CapacitySchedulerHealthInfo .class ,
154- CapacitySchedulerInfo .class ,
155- CapacitySchedulerQueueInfo .class ,
156- CapacitySchedulerQueueInfoList .class ,
157- ClusterInfo .class ,
158- ClusterMetricsInfo .class ,
159- ConfigVersionInfo .class ,
160- FairSchedulerQueueInfoList .class ,
161- FifoSchedulerInfo .class ,
162- NewReservation .class ,
163- NodeInfo .class ,
164- NodesInfo .class ,
165- QueueAclInfo .class ,
166- QueueAclsInfo .class ,
167- RemoteExceptionData .class ,
168- ReservationDeleteRequestInfo .class ,
169- ReservationDeleteResponseInfo .class ,
170- ReservationSubmissionRequestInfo .class ,
171- ReservationUpdateRequestInfo .class ,
172- ReservationUpdateResponseInfo .class ,
173- ResourceInfo .class ,
174- ResourceInformationsInfo .class ,
175- SchedulerInfo .class ,
176- SchedulerOverviewInfo .class ,
177- SchedulerTypeInfo .class ,
178- StatisticsItemInfo .class ,
179- UserInfo .class ,
180- UserMetricsInfo .class ,
181- UsersInfo .class
182- );
183-
184- private static final Set <Class <?>> CONST_UNWRAPPED_CLASSES = Sets .newHashSet (
185- ApplicationSubmissionContextInfo .class ,
186- AppPriority .class ,
187- AppQueue .class ,
188- AppState .class ,
189- ClusterUserInfo .class ,
190- ConfInfo .class ,
191- ContainerLaunchContextInfo .class ,
192- DelegationToken .class ,
193- LabelsToNodesInfo .class ,
194- LocalResourceInfo .class ,
195- NewApplication .class ,
196- NodeLabelsInfo .class ,
197- NodeToLabelsEntryList .class ,
198- NodeToLabelsInfo .class ,
199- ReservationListInfo .class ,
200- ResourceOptionInfo .class ,
201- SchedConfUpdateInfo .class
202- );
145+ private static final Set <Class <?>> CONST_WRAPPED_CLASSES =
146+ Sets .newHashSet (ActivitiesInfo .class , AppActivitiesInfo .class , AppAttemptInfo .class ,
147+ AppAttemptsInfo .class , AppInfo .class , ApplicationStatisticsInfo .class , AppsInfo .class ,
148+ AppTimeoutInfo .class , AppTimeoutsInfo .class , BulkActivitiesInfo .class ,
149+ CapacitySchedulerHealthInfo .class , CapacitySchedulerInfo .class ,
150+ CapacitySchedulerQueueInfo .class , CapacitySchedulerQueueInfoList .class , ClusterInfo .class ,
151+ ClusterMetricsInfo .class , ConfigVersionInfo .class , FairSchedulerQueueInfoList .class ,
152+ FifoSchedulerInfo .class , NewReservation .class , NodeInfo .class , NodesInfo .class ,
153+ QueueAclInfo .class , QueueAclsInfo .class , RemoteExceptionData .class ,
154+ ReservationDeleteRequestInfo .class , ReservationDeleteResponseInfo .class ,
155+ ReservationSubmissionRequestInfo .class , ReservationUpdateRequestInfo .class ,
156+ ReservationUpdateResponseInfo .class , ResourceInfo .class , ResourceInformationsInfo .class ,
157+ SchedulerInfo .class , SchedulerOverviewInfo .class , SchedulerTypeInfo .class ,
158+ StatisticsItemInfo .class , UserInfo .class , UserMetricsInfo .class , UsersInfo .class );
159+
160+ private static final Set <Class <?>> CONST_UNWRAPPED_CLASSES =
161+ Sets .newHashSet (ApplicationSubmissionContextInfo .class , AppPriority .class , AppQueue .class ,
162+ AppState .class , ClusterUserInfo .class , ConfInfo .class , ContainerLaunchContextInfo .class ,
163+ DelegationToken .class , LabelsToNodesInfo .class , LocalResourceInfo .class ,
164+ NewApplication .class , NodeLabelsInfo .class , NodeToLabelsEntryList .class ,
165+ NodeToLabelsInfo .class , ReservationListInfo .class , ResourceOptionInfo .class ,
166+ SchedConfUpdateInfo .class );
203167
204168 private final Set <Class <?>> wrappedClasses ;
205169 private final Set <Class <?>> unWrappedClasses ;
206170
171+ /**
172+ * Default constructor
173+ */
207174 public ClassSerialisationConfig () {
208175 this (new Configuration ());
209176 }
210177
178+ /**
179+ * Constructs a new {@code ClassSerialisationConfig} instance and initializes
180+ * the sets of wrapped and unwrapped classes used for JSON serialization.
181+ *
182+ * @param conf the Hadoop {@link Configuration} instance (typically injected via
183+ * dependency injection) used to load optional custom class definitions
184+ */
211185 @ Inject
212186 public ClassSerialisationConfig (@ javax .inject .Named ("conf" ) Configuration conf ) {
213187 wrappedClasses = new HashSet <>(CONST_WRAPPED_CLASSES );
214188 try {
215- wrappedClasses .addAll (Arrays .asList (conf .getClasses (YarnConfiguration .YARN_HTTP_WEBAPP_CUSTOM_DAO_CLASSES )));
189+ wrappedClasses .addAll (
190+ Arrays .asList (conf .getClasses (YarnConfiguration .YARN_HTTP_WEBAPP_CUSTOM_DAO_CLASSES )));
216191 } catch (RuntimeException e ) {
217192 LOG .warn ("Failed to load YARN_HTTP_WEBAPP_CUSTOM_DAO_CLASSES" , e );
218193 }
219194
220195 unWrappedClasses = new HashSet <>(CONST_UNWRAPPED_CLASSES );
221196 try {
222- wrappedClasses .addAll (Arrays .asList (conf .getClasses (YarnConfiguration .YARN_HTTP_WEBAPP_CUSTOM_UNWRAPPED_DAO_CLASSES )));
197+ wrappedClasses .addAll (Arrays .asList (
198+ conf .getClasses (YarnConfiguration .YARN_HTTP_WEBAPP_CUSTOM_UNWRAPPED_DAO_CLASSES )));
223199 } catch (RuntimeException e ) {
224200 LOG .warn ("Failed to load YARN_HTTP_WEBAPP_CUSTOM_DAO_CLASSES" , e );
225201 }
@@ -229,19 +205,34 @@ public ClassSerialisationConfig(@javax.inject.Named("conf") Configuration conf)
229205
230206 Set <Class <?>> duplicates = new HashSet <>(wrappedClasses );
231207 duplicates .retainAll (unWrappedClasses );
232-
233208 if (!duplicates .isEmpty ()) {
234209 throw new Error (String .format ("Duplicate classes found: %s" , duplicates ));
235210 }
236211 }
237212
213+ /**
214+ * Returns the set of classes whose JSON representation should include a root element.
215+ * <p>
216+ * These classes are used by MOXy JSON providers to determine which data transfer
217+ * objects (DTOs) should be wrapped with a root element when serialized.
218+ * </p>
219+ *
220+ * @return an unmodifiable {@link Set} of wrapped classes
221+ */
238222 public Set <Class <?>> getWrappedClasses () {
239223 return wrappedClasses ;
240224 }
241225
226+ /**
227+ * Returns the set of classes whose JSON representation should omit the root element.
228+ * <p>
229+ * These classes are used by MOXy JSON providers to determine which data transfer
230+ * objects (DTOs) should be serialized without a root element in the JSON output.
231+ * </p>
232+ *
233+ * @return an unmodifiable {@link Set} of unwrapped classes
234+ */
242235 public Set <Class <?>> getUnWrappedClasses () {
243236 return unWrappedClasses ;
244237 }
245-
246-
247238}
0 commit comments