mynameborat commented on a change in pull request #938: SAMZA-1531: Support 
run.id in standalone for batch processing.
URL: https://github.com/apache/samza/pull/938#discussion_r262817813
 
 

 ##########
 File path: 
samza-core/src/main/java/org/apache/samza/coordinator/DistributedReadWriteLock.java
 ##########
 @@ -0,0 +1,70 @@
+/*
+ * 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.coordinator;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+
+/**
+ * Lock to acquire read access or write access
+ * At any point in time, only one processor can hold the lock
+ * The processor that has acquired the lock, holds it until it does `unlock` 
explicitly
+ * The first processor to acquire the lock should be given a WRITE access
+ * All other subsequent requests should acquire only READ access
+ */
+public interface DistributedReadWriteLock {
+
+  /**
+   * Try to acquire lock: returns the type of access lock was acquired for
+   * @param timeout Duration of lock acquiring timeout.
+   * @param unit Time Unit of the timeout defined above.
+   * @return AccessType.READ if lock is acquired for read, AcessType.WRITE if 
acquired for write and AccessType.NONE if not acquired
+   * @throws TimeoutException if could not acquire the lock.
+   */
+  AccessType lock(long timeout, TimeUnit unit) throws TimeoutException;
+
+  /**
+   * Release the lock
+   */
+  void unlock();
+
+  /**
+   * Clean state of the lock
+   */
+  void cleanState();
 
 Review comment:
   Can you elaborate on what the state and what the expectations from framework?
   Another useful thing to document would be about the lifecycle of the lock 
and where `cleanState` falls in it.

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