You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by GitBox <gi...@apache.org> on 2022/05/18 20:34:59 UTC

[GitHub] [samza] ajothomas commented on a diff in pull request #1605: SAMZA-2742: [Pipeline Drain] [WIP] Add Drain components and integrate them with SamzaContainer and JC

ajothomas commented on code in PR #1605:
URL: https://github.com/apache/samza/pull/1605#discussion_r876347348


##########
samza-core/src/main/java/org/apache/samza/drain/DrainMonitor.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.drain;
+
+/**
+ * DrainMonitor implementations are intended to monitor the MetadataStore for {@link DrainNotification} and invokes
+ * the {@link Callback}.
+ * */
+public interface DrainMonitor {
+  /**
+   * Starts the DrainMonitor.
+   * */
+  void start();
+
+  /**
+   * Stops the DrainMonitor.
+   * */
+  void stop();
+
+  /**
+   * Register a callback to be executed when DrainNotification is encountered.
+   *
+   * @param callback the callback to register.
+   * @return Returns {@code true} if registration was successful and {@code false} if not.
+   * Registration can fail it the DrainMonitor is stopped or a callback is already registered.
+   * */
+  boolean registerCallback(Callback callback);

Review Comment:
   DrainMonitor is the component which checks for DrainNotification in the metadata-store. It's implementations are SinglePollDrainMonitor and PollingDrainMonitor. The former checks for drain exactly once, typically used on container startup. The latter will poll the metadata-store periodically for drain. SamzaContainer/JC will register the callback which is an action that should be invoked by the DrainMonitor whenever it encounters Drain.



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

To unsubscribe, e-mail: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org