vjagadish1989 commented on a change in pull request #593: URL: https://github.com/apache/samza/pull/593#discussion_r208819207
########## File path: samza-core/src/main/java/org/apache/samza/table/remote/TableAsyncHelper.java ########## @@ -0,0 +1,176 @@ +/* + * 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.table.remote; + +import java.util.Collection; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.function.BiFunction; +import java.util.function.Function; + +import org.apache.samza.metrics.Timer; +import org.apache.samza.storage.kv.Entry; + +import com.google.common.annotations.VisibleForTesting; + + +/** + * Helper class to handle async table IO requests with rate limiting on behalf of the remote tables. + * + * It provides a set of non-blocking execute() methods to ease the implementation of the different + * CRUD operations in table. These async requests are dispatched by a single-threaded executor Review comment: - It incurs a non-trivial overhead to completely understand this "helper" abstraction since., it involves multiple Function pointers, Futures, Generics and threads. - It's only used in one place currently and IMO, we should have a higher bar to include new abstractions to the Samza codebase. - The table is simply passing some of its state to the "helper" and handling errors from the execute methods on the helper. This blurs the roles between these 2 classes - You can always create utility methods if you prefer on the Table class / static methods under ThrottlerUtils ---------------------------------------------------------------- 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: [email protected]
