You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/05/17 07:55:38 UTC

[GitHub] [flink] echauchot commented on a diff in pull request #19680: [FLINK-27457] Implement flush() logic in Cassandra output formats

echauchot commented on code in PR #19680:
URL: https://github.com/apache/flink/pull/19680#discussion_r874488570


##########
flink-connectors/flink-connector-cassandra/src/main/java/org/apache/flink/connectors/cassandra/utils/SinkUtils.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.flink.connectors.cassandra.utils;
+
+import java.io.Serializable;
+import java.time.Duration;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/** Utility class for sinks. */
+public class SinkUtils implements Serializable {
+
+    /**
+     * Acquire permits on the given semaphore within a given allowed timeout and deal with errors.
+     *
+     * @param permits the mumber of permits to acquire.
+     * @param maxConcurrentRequests the maximum number of permits the semaphore was initialized
+     *     with.
+     * @param maxConcurrentRequestsTimeout the timeout to acquire the permits.
+     * @param semaphore the semaphore to acquire permits to.
+     * @throws InterruptedException if the current thread was interrupted.
+     * @throws TimeoutException if the waiting time elapsed before all permits were acquired.
+     */
+    public static void tryAcquire(

Review Comment:
   I just reused what already existed in `CassandraSinkBase` which signature is: `private void tryAcquire(int permits) throws InterruptedException, TimeoutException`



-- 
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: issues-unsubscribe@flink.apache.org

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