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

com.gemstone.gemfire.cache.LoaderHelper Maven / Gradle / Ivy

/*
 * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
 *
 * Licensed 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. See accompanying
 * LICENSE file.
 */

package com.gemstone.gemfire.cache;

/** Provides a set of APIs to help the
 * implementation of the CacheLoader load method. An instance of LoaderHelper
 * is only valid within the {@link CacheLoader#load(LoaderHelper) load}
 * method.
 *
 * @author Dave Monnie
 *
 * @see CacheLoader#load(LoaderHelper) load
 * @since 2.0
 */
public interface LoaderHelper
{
  /** Searches other caches for the value to be loaded. If the cache
   * is part of a distributed caching system, netSearch
   * will try to locate the requested value in any other cache within
   * the system.  If the search is successful, a reference to a local
   * copy of the value is returned. If there is no value for this
   * entry present in the system, and doNetLoad is true, GemFire looks
   * for and invokes CacheLoaders in other nodes in the
   * system.  The net load will invoke one loader at a time until a
   * loader either returns a non-null value or throws an exception.
   * If the object is not found, null is returned.
   *
   * @param doNetLoad 
   *        if true, and there is no valid value found for this entry
   *        in the system, then look for and invoke loaders on other
   *        nodes
   *
   * @return the requested value or null if not found
   *
   * @throws TimeoutException if the netSearch times out before
   *         getting a response from another cache
   * @throws CacheLoaderException
   *         If netSearch is attempted on a {@linkplain
   *         com.gemstone.gemfire.cache.Scope#LOCAL local} region. 
   */
  public V netSearch(boolean doNetLoad)
    throws CacheLoaderException, TimeoutException;

  /**
   * Returns the key for the value being loaded.
   *
   * @return the name Object for the object being loaded
   * @see CacheLoader#load(LoaderHelper) load
   */
  public K getKey();

  /**
   * Returns the region to which the entry belongs.
   *
   * @return the name of the region for the object being loaded
   * @see CacheLoader#load(LoaderHelper) load
   */
  public Region getRegion();

  /** Return the argument object for the load method that was passed in from
   * application code. This object is passed in as aLoaderArgument in
   * {@link Region#get(Object, Object) get}.
   * @return the argument or null if one was not supplied
   */
  public Object getArgument();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy