Github user d2r commented on a diff in the pull request:
https://github.com/apache/storm/pull/921#discussion_r47962909
--- Diff:
storm-core/src/jvm/backtype/storm/scheduler/resource/SchedulingResult.java ---
@@ -0,0 +1,116 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 backtype.storm.scheduler.resource;
+
+import backtype.storm.scheduler.ExecutorDetails;
+import backtype.storm.scheduler.WorkerSlot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * This class serves as a mechanism to return results and messages from a
scheduling strategy to the Resource Aware Scheduler
+ */
+public class SchedulingResult {
+
+ //contains the result for the attempted scheduling
+ private Map<WorkerSlot, Collection<ExecutorDetails>>
schedulingResultMap = null;
+
+ //status of scheduling the topology e.g. success or fail?
+ private SchedulingStatus status = null;
+
+ //arbitrary message to be returned when scheduling is done
+ private String message = null;
+
+ //error message returned is something went wrong
+ private String errorMessage = null;
+
+ private static final Logger LOG =
LoggerFactory.getLogger(SchedulingResult.class);
+
+ private SchedulingResult(SchedulingStatus status, Map<WorkerSlot,
Collection<ExecutorDetails>> schedulingResultMap, String message, String
errorMessage) {
+ this.status = status;
+ this.schedulingResultMap = schedulingResultMap;
+ this.message = message;
+ this.errorMessage = errorMessage;
+ }
+
+ public static SchedulingResult failure(SchedulingStatus status, String
errorMessage) {
+ return new SchedulingResult(status, null, null, errorMessage);
+ }
+
+ public static SchedulingResult success(Map<WorkerSlot,
Collection<ExecutorDetails>> schedulingResultMap) {
+ return SchedulingResult.successWithMsg(schedulingResultMap, null);
+ }
+
+ public static SchedulingResult successWithMsg(Map<WorkerSlot,
Collection<ExecutorDetails>> schedulingResultMap, String message) {
+ if (schedulingResultMap == null) {
+ throw new IllegalStateException("Cannot declare scheduling
success without providing a non null scheduling map!");
+ }
+ return new SchedulingResult(SchedulingStatus.SUCCESS,
schedulingResultMap, message, null);
+ }
+
+ public SchedulingStatus getStatus() {
+ return this.status;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public String getErrorMessage() {
+ return this.errorMessage;
+ }
+
+ public Map<WorkerSlot, Collection<ExecutorDetails>>
getSchedulingResultMap() {
+ return schedulingResultMap;
--- End diff --
`return this.schedulingResultMap` just for consistency
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---