Versions Compared

Key

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

...

Code Block
languagejava
titleStoreQueryParams.java
collapsetrue

package org.apache.kafka.streams;


/**
 * Represents all the query options that a user can provide to state what kind of stores it is expecting. The options would be whether a user would want to enable/disable stale stores* or whether it knows the list of partitions that it specifically wants to fetch. If this information is not provided the default behavior is to fetch the stores for all the partitions available on that instance* for that particular store name.
 * It contains a partition, which for a point queries can be populated from the  KeyQueryMetadata.
 */
public class StoreQueryParams<T> {

    private Integer partition;
    private boolean includeStaleStores;
    private final String storeName;
    private final QueryableStoreType<T> queryableStoreType;

    private StoreQueryParams(final String storeName, final QueryableStoreType<T>  queryableStoreType) {
        this.storeName = storeName;
        this.queryableStoreType = queryableStoreType;
    }

    public static <T> StoreQueryParams<T> fromNameAndType(final String storeName, final QueryableStoreType<T>  queryableStoreType) {
        return new <T> StoreQueryParams<T>(storeName, queryableStoreType);
    }

    /**
     * Get the partition{@link toStoreQueryParams} be used to fetch list of Queryable store from QueryableStoreProviderwith stale(standby, restoring) stores added via fetching the stores.
     *
 If the function returns null,* it@param wouldpartition mean that noThe specific integer partition hasto beenbe requestedfetched so allfrom the localstores partitions
list by using   * for the store will be returned{@link StoreQueryParams}.
     *
     * @return IntegerString partitionstoreName
     */
    public StoreQueryParams<T> withPartition(final Integer getPartition(partition) {
        this.partition = partition;
        return partitionthis;
    }

    /**
     * Get the flag includeStaleStores. If true, include standbys and recovering stores along with running{@link StoreQueryParams} with stale(standby, restoring) stores added via fetching the stores.
     *
     * @return booleanString includeStaleStoresstoreName
     */
    public booleanStoreQueryParams<T> includeStaleStoreswithIncludeStaleStores() {
        this.includeStaleStores = true;
        return includeStaleStoresthis;
    }

    /**
     * Get the partition {@linkto StoreQueryParams}be with stale(standby, restoring) stores added via fetching the storesused to fetch list of Queryable store from QueryableStoreProvider.
     *
 If the function returns *null, @paramit partitionwould mean that Theno specific integerpartition partitionhas tobeen berequested fetchedso fromall the stores list by using {@link StoreQueryParams}local partitions
     * for the store will be returned.
     *
     * @return StringInteger storeNamepartition
     */
    public StoreQueryParams<T> withPartition(final Integer partition() {
        this.partition =return partition;
        return this;
    }

    /**
     * Get the {@link StoreQueryParams} with stale(standby, restoring)flag includeStaleStores. If true, include standbys and recovering stores addedalong viawith fetchingrunning the stores.
     *
     * @return Stringboolean storeNameincludeStaleStores
     */
    public StoreQueryParams<T>boolean withIncludeStaleStoresincludeStaleStores() {
        this.includeStaleStores = true;
        return thisincludeStaleStores;
    }

    /**
     * Get the store name for which key is queried by the user.
     *
     * @return String storeName
     */
    public String storeName() {
        return storeName;
    }

    /**
     * Get the queryable store type for which key is queried by the user.
     *
     * @return QueryableStoreType queryableStoreType
     */
    public QueryableStoreType<T> queryableStoreType() {
        return queryableStoreType;
    }
}

...