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/07/29 13:16:44 UTC

[GitHub] [flink] SmirAlex commented on a diff in pull request #20382: [FLINK-28419][table] Add runtime provider interface for full caching lookup + implement Periodic and Timed cache reload triggers

SmirAlex commented on code in PR #20382:
URL: https://github.com/apache/flink/pull/20382#discussion_r933252511


##########
flink-table/flink-table-common/src/test/java/org/apache/flink/table/connector/source/lookup/cache/trigger/PeriodicCacheReloadTriggerTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.table.connector.source.lookup.cache.trigger;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.testutils.ScheduledTask;
+import org.apache.flink.table.connector.source.lookup.cache.trigger.PeriodicCacheReloadTrigger.ScheduleMode;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+import org.mockito.Mockito;
+
+import java.time.Duration;
+import java.util.Collection;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.flink.table.connector.source.lookup.LookupOptions.CACHE_TYPE;
+import static org.apache.flink.table.connector.source.lookup.LookupOptions.FULL_CACHE_RELOAD_STRATEGY;
+import static org.apache.flink.table.connector.source.lookup.LookupOptions.LookupCacheType.FULL;
+import static org.apache.flink.table.connector.source.lookup.LookupOptions.LookupCacheType.PARTIAL;
+import static org.apache.flink.table.connector.source.lookup.LookupOptions.ReloadStrategy.PERIODIC;
+import static org.apache.flink.table.connector.source.lookup.LookupOptions.ReloadStrategy.TIMED;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Unit test for {@link PeriodicCacheReloadTrigger}. */
+class PeriodicCacheReloadTriggerTest {
+
+    private final ScheduleStrategyExecutorService scheduledExecutor =
+            new ScheduleStrategyExecutorService();
+
+    private final Runnable reloadTask = Mockito.mock(Runnable.class);

Review Comment:
   Yea, I just thought this little one would be ok, because basically we don't need any implementation of this Runnable, except counting calls of one method. Anyway I fixed that, no problem.



##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/source/lookup/cache/trigger/CacheReloadTrigger.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.table.connector.source.lookup.cache.trigger;
+
+import org.apache.flink.annotation.PublicEvolving;
+
+import java.io.Serializable;
+import java.util.concurrent.CompletableFuture;
+
+/** Customized trigger for reloading lookup table entries. */
+@PublicEvolving
+public interface CacheReloadTrigger extends AutoCloseable, Serializable {
+
+    /** Open the trigger. */
+    void open(Context context) throws Exception;
+
+    /**
+     * Context of {@link CacheReloadTrigger} for getting information about times and triggering
+     * reload.
+     */
+    interface Context {

Review Comment:
   Fixed



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