Sanil15 commented on a change in pull request #1219: SAMZA-2373: [SEP-22] 
Container Placement Service (core functionality) for container move and restart
URL: https://github.com/apache/samza/pull/1219#discussion_r366489208
 
 

 ##########
 File path: 
samza-api/src/main/java/org/apache/samza/container/placements/ContainerPlacementMessage.java
 ##########
 @@ -0,0 +1,147 @@
+/*
+ * 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.samza.container.placements;
+
+import com.google.common.base.Preconditions;
+import java.time.Duration;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+
+
+/**
+ * Encapsulates the request or response payload information between the 
ContainerPlacementHandler service and external
+ * controllers issuing placement actions
+ */
+public abstract class ContainerPlacementMessage {
+
+  public enum StatusCode {
+    /**
+     * Indicates that the container placement action is created
+     */
+    CREATED,
+
+    /**
+     * Indicates that the container placement action was rejected because 
request was deemed invalid
+     */
+    BAD_REQUEST,
+
+    /**
+     * Indicates that the container placement action is accepted and waiting 
to be processed
+     */
+    ACCEPTED,
+
+    /**
+     * Indicates that the container placement action is in progress
+     */
+    IN_PROGRESS,
+
+    /**
+     * Indicates that the container placement action is in progress
+     */
+    SUCCEEDED,
+
+    /**
+     * Indicates that the container placement action is in failed
+     */
+    FAILED;
+  }
+
+  /**
+   * UUID attached to a message which helps in identifying duplicate request 
messages written to metastore and not
+   * retake actions even if metastore is eventually consistent
+   */
+  protected final UUID uuid;
+  /**
+   * Unique identifier for a deployment so messages can be invalidated across 
a job restarts
+   * for ex yarn bases cluster manager should set this to app attempt id
+   */
+  protected final String applicationId;
+  // Logical container Id 0, 1, 2
+  protected final String processorId;
+  // Destination host where container is desired to be moved
+  protected final String destinationHost;
+  // Optional request expiry which acts as a timeout for any resource request 
to cluster manager
+  protected final Optional<Duration> requestExpiryTimeout;
+  // Status of the current request
+  protected final StatusCode statusCode;
+
+  protected ContainerPlacementMessage(UUID uuid, String applicationId, String 
processorId, String destinationHost,
+      Duration requestExpiryTimeout, StatusCode statusCode) {
+    Preconditions.checkNotNull(uuid, "uuid cannot be null");
+    Preconditions.checkNotNull(applicationId, "applicationId cannot be null");
+    Preconditions.checkNotNull(processorId, "processorId cannot be null");
+    Preconditions.checkNotNull(destinationHost, "destinationHost cannot be 
null");
+    Preconditions.checkNotNull(statusCode, "statusCode cannot be null");
+    this.uuid = uuid;
 
 Review comment:
   Sure but for consistency with other code I prefer to use Preconditions, 
https://stackoverflow.com/questions/34646554/java-util-objects-requirenonnull-vs-preconditions-checknotnull

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to