Sanil15 commented on a change in pull request #1227: SAMZA-2404: [SEP-22] 
Container Placement Handler for dispatching container placement messages 
between metastore and JobCoordinator
URL: https://github.com/apache/samza/pull/1227#discussion_r351540949
 
 

 ##########
 File path: 
samza-core/src/main/java/org/apache/samza/clustermanager/container/placement/ContainerPlacementHandler.java
 ##########
 @@ -0,0 +1,287 @@
+/*
+ * 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.clustermanager.container.placement;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.samza.SamzaException;
+import org.apache.samza.clustermanager.ContainerProcessManager;
+import org.apache.samza.container.placement.ContainerPlacementMessage;
+import org.apache.samza.container.placement.ContainerPlacementRequestMessage;
+import org.apache.samza.container.placement.ContainerPlacementResponseMessage;
+import 
org.apache.samza.coordinator.metadatastore.NamespaceAwareCoordinatorStreamStore;
+import org.apache.samza.metadatastore.MetadataStore;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Stateless handler that dispatches {@link ContainerPlacementRequestMessage} 
read from {@link MetadataStore} to Job Coordinator
+ * and writes responses {@link 
org.apache.samza.container.placement.ContainerPlacementResponseMessage} from 
Job Coordinator
+ * to Metastore.
+ *
+ * {@link ContainerPlacementRequestMessage} are written under namespace {@code 
REQUEST_STORE_NAMESPACE}
+ * {@link ContainerPlacementResponseMessage} are written under namespace 
{@code RESPONSE_STORE_NAMESPACE}
+ */
+public class ContainerPlacementHandler implements Runnable {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(ContainerPlacementHandler.class);
+
+  private static final Integer VERSION = 1;
+  public static final String REQUEST_STORE_NAMESPACE = 
"samza-request-place-container-v" + VERSION;
 
 Review comment:
   Note to reviewers: Two namespace-aware stores are maintained one for 
requests & other for responses in the same metastore so at a time a job having 
n containers will have at the max: n X 2 extra messages in the metastore which 
will be GC'd on restart 

----------------------------------------------------------------
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