Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleRescanRuntimeProvider
/**
 * Runtime provider for fully loading and periodically reloading all entries of the lookup table and
 * storing the table locally for lookup.
 *
 * <p>Implementations should provide a {@link ScanTableSource.ScanRuntimeProvider} in order to reuse
 * the ability of scanning for loading all entries from the lookup table.
 */
@PublicEvolving
public interface FullCachingLookupProvider extends LookupTableSource.LookupRuntimeProvider {    
  
	/**
     * Creates {@link FullCachingLookupProvider} with provided scan runtime provider and reload
     * time.
     */
    static FullCachingLookupProvider of(
            ScanTableSource.ScanRuntimeProvider scanRuntimeProvider, ReloadTime reloadTime) {
        return new FullCachingLookupProvider() {
            @Override
            public ScanTableSource.ScanRuntimeProvider getScanRuntimeProvider() {
                return scanRuntimeProvider;
            }

            @Override
            public ReloadTime getReloadTime() {
                return reloadTime;
            }
        };
    }      


	/**
     * Gets the {@link org.apache.flink.table.connector.source.ScanTableSource.ScanRuntimeProvider}
     * for executing the periodically reload.
     */
    ScanTableSource.ScanRuntimeProvider getScanRuntimeProvider();  
	/** Gets the time when to reload cache. See {@link ReloadTime}. */
    ReloadTime getReloadTime();

    /** Defines at what time the cache should be reloaded. */
    interface ReloadTime extends Serializable {
        /** Gets the interval between two reload operations. */
        Duration getReloadInterval();

        /** Gets the start time of the reload operation in UTC. */
        LocalTime getReloadStartTime();

        /** Creates reload time with periodic intervals. */
        static ReloadTime withInterval(Duration reloadInterval) {
            return new ReloadTime() {
                @Override
                public Duration getReloadInterval() {
                    return reloadInterval;
                }

                @Override
                public LocalTime getReloadStartTime() {
                    return LocalTime.now(ZoneOffset.UTC);
                }
            };
        }

        /**
         * Creates reload time with periodic intervals after initial delay up to {@code
         * reloadStartTime}.
         */
        static ReloadTime withIntervalAfterDelay(
                Duration reloadInterval, LocalTime reloadStartTime) {
            return new ReloadTime() {
                @Override
                public Duration getReloadInterval() {
                    return reloadInterval;
                }

                @Override
                public LocalTime getReloadStartTime() {
                    return reloadStartTime;
                }
            };
        }

        /** Creates reload time daily at specified {@code reloadStartTime}. */
        static ReloadTime dailyAtSpecifiedTime(LocalTime reloadStartTime) {
            return new ReloadTime() {
                @Override
                public Duration getReloadInterval() {
                    return Duration.ofDays(1);
                }

                @Override
                public LocalTime getReloadStartTime() {
                    return reloadStartTime;
                }
            };
        }
    }
 }

...