All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.client.rest.RestCacheClient Maven / Gradle / Ivy

There is a newer version: 14.0.33.Final
Show newest version
package org.infinispan.client.rest;

import java.util.Map;
import java.util.concurrent.CompletionStage;

import org.infinispan.commons.api.CacheContainerAdmin;
import org.infinispan.commons.dataconversion.MediaType;
import org.infinispan.configuration.cache.XSiteStateTransferMode;

/**
 * @author Tristan Tarrant <[email protected]>
 * @since 10.0
 **/
public interface RestCacheClient {

   /**
    * Returns the name of the cache
    */
   String name();

   /**
    * Retrieve all keys
    *
    * @return Response with inputStream to get all the keys
    */
   CompletionStage keys();

   /**
    * Retrieve keys limited by count
    *
    * @param limit The maximum number of keys to retrieve
    * @return Response with InputStream to get the keys
    */
   CompletionStage keys(int limit);

   /**
    * Retrieves entries without metadata
    *
    * @return Response with InputStream to get the entries
    */
   default CompletionStage entries() {
      return entries(false);
   }

   /**
    * Retrieves entries without metadata
    *
    * @param contentNegotiation if true, the server will convert keys and values to a readable format and return headers with the negotiated media type.
    * @return Response with InputStream to get the entries
    */
   CompletionStage entries(boolean contentNegotiation);

   /**
    * Retrieves entries limited by count
    *
    * @param limit: The maximum number of entries to retrieve, or -1 to retrieve all
    */
   CompletionStage entries(int limit);

   /**
    * Retrieves entries with limit and metadata
    *
    * @param limit:    The maximum number of entries to retrieve, or -1 to retrieve all
    * @param metadata: if true, includes the metadata for each entry
    */
   CompletionStage entries(int limit, boolean metadata);

   /**
    * Retrieves all keys from the cache with a specific MediaType or list of MediaTypes.
    */
   CompletionStage keys(String mediaType);

   /**
    * Retrieves the cache configuration
    */
   default CompletionStage configuration() {
      return configuration(null);
   }

   /**
    * Retrieves the cache configuration with a specific MediaType or list of MediaTypes.
    */
   CompletionStage configuration(String mediaType);

   /**
    * Clears a cache
    */
   CompletionStage clear();

   /**
    * Obtains the total number of elements in the cache
    */
   CompletionStage size();

   /**
    * POSTs a key/value to the cache as text/plain
    *
    * @param key
    * @param value
    * @return
    */
   CompletionStage post(String key, String value);

   /**
    * POSTs a key/value to the cache as text/plain with the specified expiration
    *
    * @param key
    * @param value
    * @param ttl
    * @param maxIdle
    * @return
    */
   CompletionStage post(String key, String value, long ttl, long maxIdle);

   /**
    * POSTs a key/value to the cache with the specified encoding
    *
    * @param key
    * @param value
    * @return
    */
   CompletionStage post(String key, RestEntity value);

   /**
    * POSTs a key/value to the cache with the specified encoding and expiration
    *
    * @param key
    * @param value
    * @param ttl
    * @param maxIdle
    * @return
    */
   CompletionStage post(String key, RestEntity value, long ttl, long maxIdle);

   /**
    * PUTs a key/value to the cache as text/plain
    *
    * @param key
    * @param value
    * @return
    */
   CompletionStage put(String key, String value);

   /**
    * PUT a key/value to the cache with custom media types for keys and values
    */
   CompletionStage put(String key, String keyContentType, RestEntity value);

   /**
    * Same as {@link #put(String, String, RestEntity)} but allowing custom headers.
    */
   CompletionStage put(String key, String keyContentType, RestEntity value, Map headers);

   /**
    * PUT an entry with metadata.
    *
    * @param key The key
    * @param keyContentType The {@link MediaType} of the key
    * @param value a {@link RestEntity} containing the value and its MediaType
    * @param ttl The time to live value
    * @param maxIdle The max idle value
    * @return
    */
   CompletionStage put(String key, String keyContentType, RestEntity value, long ttl, long maxIdle);

   /**
    * PUTs a key/value to the cache as text/plain with the specified expiration
    *
    * @param key
    * @param value
    * @param ttl
    * @param maxIdle
    * @return
    */
   CompletionStage put(String key, String value, long ttl, long maxIdle);

   /**
    * PUTs a key/value to the cache with the specified encoding
    *
    * @param key
    * @param value
    * @return
    */
   CompletionStage put(String key, RestEntity value);

   /**
    * Same as {@link #put(String, RestEntity)} also allowing one or more {@link org.infinispan.context.Flag} to be passed.
    */
   CompletionStage put(String key, RestEntity value, String... flags);

   /**
    * PUTs a key/value to the cache with the specified encoding and expiration
    *
    * @param key
    * @param value
    * @param ttl
    * @param maxIdle
    * @return
    */
   CompletionStage put(String key, RestEntity value, long ttl, long maxIdle);

   /**
    * GETs a key from the cache
    *
    * @param key
    * @return
    */
   CompletionStage get(String key);

   /**
    * Same as {@link #get(String)} but allowing custom headers.
    */
   CompletionStage get(String key, Map headers);

   /**
    * GETs a key from the cache with a specific MediaType or list of MediaTypes.
    */
   CompletionStage get(String key, String mediaType);

   /**
    * Same as {@link #get(String, String)} but with an option to return extended headers.
    */
   CompletionStage get(String key, String mediaType, boolean extended);


   /**
    * Similar to {@link #get(String)} but only retrieves headers
    *
    * @param key
    * @return
    */
   CompletionStage head(String key);

   /**
    * Similar to {@link #head(String)} but allowing custom headers
    */
   CompletionStage head(String key, Map headers);

   /**
    * DELETEs an entry from the cache
    *
    * @param key
    * @return
    */
   CompletionStage remove(String key);

   /**
    * Same as {@link #remove(String)} but allowing custom headers
    */
   CompletionStage remove(String test, Map headers);

   /**
    * Creates the cache using the supplied template name
    *
    * @param template the name of a template
    * @param flags    any flags to apply to the create operation, e.g. {@link org.infinispan.commons.api.CacheContainerAdmin.AdminFlag#VOLATILE}
    * @return
    */
   CompletionStage createWithTemplate(String template, CacheContainerAdmin.AdminFlag... flags);

   /**
    * Obtains statistics for the cache
    *
    * @return
    */
   CompletionStage stats();

   /**
    * Obtain metrics about the distribution of data of the cache.
    *
    * @return
    */
   CompletionStage distribution();

   /**
    * Creates the cache using the supplied configuration
    *
    * @param configuration the configuration, in XML, JSON or YAML format
    * @param flags         any flags to apply to the create operation, e.g. {@link org.infinispan.commons.api.CacheContainerAdmin.AdminFlag#VOLATILE}
    * @return
    */
   CompletionStage createWithConfiguration(RestEntity configuration, CacheContainerAdmin.AdminFlag... flags);

   /**
    * Updates the cache configuration
    *
    * @param configuration the configuration, in XML, JSON or YAML format
    * @param flags         any flags to apply to the update operation, e.g. {@link org.infinispan.commons.api.CacheContainerAdmin.AdminFlag#VOLATILE}
    * @return
    */
   CompletionStage updateWithConfiguration(RestEntity configuration, CacheContainerAdmin.AdminFlag... flags);

   /**
    * Removes the cache
    *
    * @return
    */
   CompletionStage delete();

   /**
    * Executes an Ickle-query
    *
    * @param query the ickle query
    */
   default CompletionStage query(String query) {
      return query(query, false);
   }

   /**
    * Executes an Ickle-query
    *
    * @param query the ickle query
    * @param local if true, query is restricted to the data present in the node that process the request.
    */
   CompletionStage query(String query, boolean local);

   /**
    * Executes an Ickle-query
    *
    * @param query      the ickle query
    * @param maxResults the maximum number of results to return
    * @param offset     the offset within the result from which to return results
    */
   CompletionStage query(String query, int maxResults, int offset);

   /**
    * Executes an Ickle-query
    *
    * @param query            the ickle query
    * @param maxResults       the maximum number of results to return
    * @param offset           the offset within the result from which to return results
    * @param hitCountAccuracy the limit to the hit count accuracy to return sooner
    */
   CompletionStage query(String query, int maxResults, int offset, int hitCountAccuracy);

   /**
    * @return the status of all backup sites
    */
   CompletionStage xsiteBackups();

   /**
    * @return the status of a single backup site
    */
   CompletionStage backupStatus(String site);

   /**
    * Take a backup site offline
    */
   CompletionStage takeSiteOffline(String site);

   /**
    * Bring back a backup site online
    */
   CompletionStage bringSiteOnline(String site);

   /**
    * Starts the state push to a backup site
    */
   CompletionStage pushSiteState(String site);

   /**
    * Cancels the state push
    */
   CompletionStage cancelPushState(String site);

   /**
    * Cancel the receiving state on a backup site
    */
   CompletionStage cancelReceiveState(String site);

   /**
    * Obtain the status of a state push to a backup site
    */
   CompletionStage pushStateStatus();

   /**
    * Get the configuration used to automatically take a backup site offline
    */
   CompletionStage getXSiteTakeOfflineConfig(String site);

   /**
    * Updates the configuration used to automatically take a backup site offline
    */
   CompletionStage updateXSiteTakeOfflineConfig(String site, int afterFailures, long minTimeToWait);

   /**
    * Clear the status of a state push in a site
    */
   CompletionStage clearPushStateStatus();

   /**
    * Returns the cross-site replication state transfer mode.
    *
    * @see XSiteStateTransferMode
    */
   CompletionStage xSiteStateTransferMode(String site);

   /**
    * Sets the cross-site replication state transfer mode.
    *
    * @see XSiteStateTransferMode
    */
   CompletionStage xSiteStateTransferMode(String site, XSiteStateTransferMode mode);

   /**
    * Check if the cache exists
    */
   CompletionStage exists();

   /**
    * Execute a Rolling Upgrade processing
    */
   CompletionStage synchronizeData(Integer readBatch, Integer threads);

   /**
    * Execute a Rolling Upgrade processing using defaults.
    */
   CompletionStage synchronizeData();

   /**
    * Disconnects the target cluster from the source cluster after a Rolling Upgrade
    */
   CompletionStage disconnectSource();

   /**
    * Connects the target cluster to a source cluster before a Rolling Upgrade
    *
    * @param remoteStoreJsonConfig The remote-store config as JSON
    */
   CompletionStage connectSource(RestEntity remoteStoreJsonConfig);

   /**
    * Checks if the cache is connected through a remote store to perform rolling upgrades
    */
   CompletionStage sourceConnected();

   /**
    * Return the remote store configuration in case the case has been connected to another cluster using
    * {@link #connectSource(RestEntity)}
    */
   CompletionStage sourceConnection();

   /**
    * Rebuild the search indexes of the cache based on its data.
    */
   CompletionStage reindex();

   /**
    * Same as {@link #reindex()} but only considers data from the local cluster member.
    */
   CompletionStage reindexLocal();

   /**
    * Deletes all the indexes from the cache.
    */
   CompletionStage clearIndex();

   /**
    * Update index schema for the current cache.
    */
   CompletionStage updateIndexSchema();

   /**
    * Obtain statistics about queries.
    *
    * @deprecated Use {@link #searchStats()} instead.
    */
   @Deprecated(forRemoval = true)
   CompletionStage queryStats();

   /**
    * Obtain statistics about the indexes.
    *
    * @deprecated Use {@link #searchStats()} instead.
    */
   @Deprecated(forRemoval = true)
   CompletionStage indexStats();

   /**
    * Clear runtime query statistics.
    *
    * @deprecated Use {@link #searchStats()} and {@link #clearSearchStats()}.
    */
   @Deprecated(forRemoval = true)
   CompletionStage clearQueryStats();


   /**
    * Obtains details about the cache
    */
   CompletionStage details();

   /**
    * Obtains the index metamodel for the current cache.
    * The query has to be indexed.
    *
    * @return the stage of the response containing the metamodel of the index
    */
   CompletionStage indexMetamodel();

   /**
    * Obtain query and indexing statistics for the cache.
    */
   CompletionStage searchStats();

   /**
    * Clear search stats.
    */
   CompletionStage clearSearchStats();

   /**
    * Enables automatic rebalancing for the cache.
    */
   CompletionStage enableRebalancing();

   /**
    * Disables automatic rebalancing for the cache.
    */
   CompletionStage disableRebalancing();

   /**
    * Updates a configuration attribute.
    */
   CompletionStage updateConfigurationAttribute(String attribute, String value);

   /**
    * Retrieves all available configuration attributes for this cache
    */
   CompletionStage configurationAttributes();

   /**
    * Retrieves all available configuration attributes for this cache optionally including values and types
    */
   CompletionStage configurationAttributes(boolean full);

   /**
    * Retrieves the Cache's Availability status.
    */
   CompletionStage getAvailability();

   /**
    * Sets the Cache's Avaialability
    */
   CompletionStage setAvailability(String availability);

   /**
    * Force the current cache topology as the stable if not running.
    */
   CompletionStage markTopologyStable(boolean force);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy