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

com.gemstone.gemfire.internal.cache.InternalDataView Maven / Gradle / Ivy

The newest version!
/*
 * 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.
 */
/**
 * File comment
 */
package com.gemstone.gemfire.internal.cache;

import java.util.Collection;
import java.util.Iterator;
import java.util.Set;

import com.gemstone.gemfire.cache.EntryNotFoundException;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.UnsupportedOperationInTransactionException;
import com.gemstone.gemfire.internal.cache.execute.InternalRegionFunctionContext;
import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID;
import com.gemstone.gemfire.internal.cache.tier.sockets.VersionedObjectList;
import com.gemstone.gemfire.internal.offheap.annotations.Retained;

/**
 * @author Swapnil Bawaskar
 * @author Greg Passmore
 * @since 6.0tx
 */
public interface InternalDataView {

  /**
   * @param key
   * @param callbackArg
   * @param localRegion
   * @param updateStats
   * @param disableCopyOnRead 
   * @param preferCD 
   * @param lockState
   * @param clientEvent TODO
   * @param returnTombstones TODO
   * @return the object associated with the key
   */
  Object getDeserializedValue(Object key, Object callbackArg,
      LocalRegion localRegion, boolean updateStats, boolean disableCopyOnRead,
      boolean preferCD, TXStateInterface lockState,
      EntryEventImpl clientEvent, boolean returnTombstones, boolean allowReadFromHDFS);

  /**
   * Get the value locally in this case for given key (and possibly bucketId) as
   * it is in the region i.e. without any deserialization/copy etc.
   * @param allowReadFromHDFS if true reads from HDFS
   */
  @Retained
  Object getLocally(Object key, Object callbackArg, int bucketId,
      LocalRegion localRegion, boolean doNotLockEntry, boolean localExecution,
      TXStateInterface lockState, EntryEventImpl clientEvent,
      boolean returnTombstones, boolean allowReadFromHDFS) throws DataLocationException;

  /**
   * @param event
   * @param cacheWrite
   * @param expectedOldValue TODO
   * @throws EntryNotFoundException if the entry is not found in the view
   */
  void destroyExistingEntry(EntryEventImpl event, boolean cacheWrite,
      Object expectedOldValue) throws EntryNotFoundException;

  /**
   * Invalidate the entry
   * @see Region#invalidate(Object)
   * @param event
   * @param invokeCallbacks
   * @param forceNewEntry
   */
  void invalidateExistingEntry(EntryEventImpl event, boolean invokeCallbacks,
      boolean forceNewEntry);

  /**
   * get the entry count
   * @param localRegion
   * @return the entry count
   */
  int entryCount(LocalRegion localRegion);

  /**
   * @param key
   * @param callbackArg
   * @param localRegion
   * @return the value for key in the VM
   */
  Object getValueInVM(Object key, Object callbackArg, LocalRegion localRegion);

  /**
   * @param key
   * @param callbackArg
   * @param localRegion
   * @return true if key exists, false otherwise
   */
  boolean containsKey(Object key, Object callbackArg, LocalRegion localRegion);

  /**
   * Check whether the region contains the given key. Like
   * {@link #containsKey(Object, Object, LocalRegion)} but for the case of
   * transactional views also takes a read lock on the entry while checking for
   * it (and will release the lock immediately or hold till end of transaction
   * depending on isolation level).
   * 
   * @param key
   * @param callbackArg
   * @param localRegion
   * @return true if key exists, false otherwise
   */
  boolean containsKeyWithReadLock(Object key, Object callbackArg,
      LocalRegion localRegion);

  /**
   * @param key
   * @param localRegion
   * @return true if value for key exists, false otherwise
   * @return TODO
   */
  boolean containsValueForKey(Object key, Object callbackArg,
      LocalRegion localRegion);

  /**
   * @param key
   * @param callbackArg
   * @param localRegion
   * @param allowTombstones
   * @return the entry for given key
   */
  Region.Entry getEntry(Object key, Object callbackArg,
      LocalRegion localRegion, boolean allowTombstones);

  /**
   * get entry for the key. Called only on farside.
   * 
   * @param keyInfo
   * @param localRegion
   * @param allowTombstones
   * @return the entry on the remote data store
   */
  EntrySnapshot getEntryOnRemote(KeyInfo keyInfo, LocalRegion localRegion,
      boolean allowTombstones) throws DataLocationException;

  /**
   * Put or create an entry in the data view.
   * @param event specifies the new or updated value  
   * @param ifNew
   * @param ifOld
   * @param expectedOldValue
   * @param requireOldValue
   * @param cacheWrite
   * @param overwriteDestroyed 
   * @param lastModified
   * @return true if operation updated existing data, otherwise false
   */
  boolean putEntry(EntryEventImpl event, boolean ifNew, boolean ifOld,
      Object expectedOldValue, boolean requireOldValue, boolean cacheWrite,
      long lastModified, boolean overwriteDestroyed);

  /**
   * Put or create an entry in the data view. Called only on the farside.
   * @param event specifies the new or updated value  
   * @param ifNew
   * @param ifOld
   * @param expectedOldValue
   * @param requireOldValue
   * @param overwriteDestroyed 
   * @param cacheWrite
   * @param lastModified
   * @return true if operation updated existing data, otherwise false
   */
  boolean putEntryOnRemote(EntryEventImpl event, boolean ifNew, boolean ifOld,
      Object expectedOldValue, boolean requireOldValue, boolean cacheWrite,
      long lastModified, boolean overwriteDestroyed)
      throws DataLocationException;

  /**
   * Destroy an entry in the data view. Called only on the farside.
   * @param event
   * @param cacheWrite TODO
   * @param expectedOldValue
   * @throws DataLocationException TODO
   */
  void destroyOnRemote(EntryEventImpl event, boolean cacheWrite,
      Object expectedOldValue) throws DataLocationException;

  /**
   * Invalidate an entry in the data view. Called only on farside.
   * @param event
   * @param invokeCallbacks
   * @param forceNewEntry
   * @throws DataLocationException
   */
  void invalidateOnRemote(EntryEventImpl event, boolean invokeCallbacks,
      boolean forceNewEntry) throws DataLocationException;

  /**
   * @return true if statistics should be updated later in a batch (such as a tx
   *         commit)
   */
  boolean isDeferredStats();

  /**
   * @param key
   * @param r
   * @param isCreate
   * @param generateCallbacks
   * @param value
   * @param disableCopyOnRead if true then copy on read is disabled for this call
   * @param preferCD true if the preferred result form is CachedDeserializable
   * @param requestingClient the client making the request, or null if from a server
   * @param clientEvent the client's event, if any
   * @param returnTombstones TODO
   * @return the Object associated with the key
   */
  Object findObject(KeyInfo key, LocalRegion r, boolean isCreate,
      boolean generateCallbacks, Object value, boolean disableCopyOnRead,
      boolean preferCD, ClientProxyMembershipID requestingClient,
      EntryEventImpl clientEvent, boolean returnTombstones, boolean allowReadFromHDFS);

  /**
   * 
   * @param key
   * @param currRgn
   * @param allowTombstones
   * @return an Entry for the key
   */
  Region.Entry getEntryForIterator(KeyInfo key, LocalRegion currRgn,
      boolean allowTombstones);

  /**
   * 
   * @param key
   * @param currRgn
   * @param updateStats
   * @param clientEvent
   * @param allowTombstones
   * @return the value for the key
   */
  Object getValueForIterator(KeyInfo key, LocalRegion currRgn,
      boolean updateStats, boolean preferCD, EntryEventImpl clientEvent,
      boolean allowTombstones);

  /**
   * 
   * @param keyInfo
   * @param currRgn
   * @param allowTombstones
   * @return the key for the provided key
   */
  Object getKeyForIterator(KeyInfo keyInfo, LocalRegion currRgn,
      boolean allowTombstones);

  /**
   * Used by {@link TXStateInterface} implementations to return back even locked
   * entries whose value may be deleted.
   * 
   * @param key
   * @param currRgn
   * @return the key for the provided key
   */
  Object getKeyForIterator(Object key, LocalRegion currRgn);

  /**
   * @param currRgn
   */
  Collection getAdditionalKeysForIterator(LocalRegion currRgn);

  /**
   * 
   * @param currRegion
   * @return collection of keys in the region
   */
  Iterator getRegionKeysForIteration(LocalRegion currRegion,
      boolean includeValues);

  /**
   * Get the iterator of local entries for the given function context. The entry
   * may be either a RegionEntry or TXEntryState depending on whether it is
   * present in region or only in TX view respectively.
   * 
   * @param context
   *          function context, if any, to use for filtering of data
   * @param primaryOnly
   *          if true and function context is null or has no filter then only
   *          consider the local primary bucket entries
   * @param forUpdate
   *          if true then indicates that the the entry must be locked for write
   *          when in a transactional context
   * @param includeValues
   *          if true then iterator needs the values else only keys (e.g. to
   *          avoid disk reads)
   * @param currRegion
   *          the region being read
   */
  Iterator getLocalEntriesIterator(InternalRegionFunctionContext context,
      boolean primaryOnly, boolean forUpdate, boolean includeValues,
      LocalRegion currRegion);

  /**
   * This method is similar to the above one but this has been added for gemfirexd
   * single hop implementation as there we would have the bucketSet and we don't want
   * to make a context object  unnecessarily.
   * 
   * @param bucketSet 
   *          set of buckets for which we want the iterator
   * @param primaryOnly
   *          if true and function context is null or has no filter then only
   *          consider the local primary bucket entries
   * @param forUpdate
   *          if true then indicates that the the entry must be locked for write
   *          when in a transactional context
   * @param includeValues
   *          if true then iterator needs the values else only keys (e.g. to
   *          avoid disk reads)
   * @param currRegion
   *          the region being read
   */
  public Iterator getLocalEntriesIterator(Set bucketSet,
      boolean primaryOnly, boolean forUpdate, boolean includeValues,
      LocalRegion currRegion);

  /**
   * 
   * @param localRegion
   * @param key
   * @param doNotLockEntry
   * @param requestingClient the client that made the request, or null if not from a client
   * @param clientEvent the client event, if any
   * @param returnTombstones TODO
   * @return the serialized value from the cache
   */
  Object getSerializedValue(LocalRegion localRegion, KeyInfo key,
      boolean doNotLockEntry, ClientProxyMembershipID requestingClient,
      EntryEventImpl clientEvent, boolean returnTombstones, boolean allowReadFromHDFS)
      throws DataLocationException;

  void checkSupportsRegionDestroy()
      throws UnsupportedOperationInTransactionException;

  void checkSupportsRegionInvalidate()
      throws UnsupportedOperationInTransactionException;

  /**
   * @param localRegion
   * @param bucketId
   * @param allowTombstones whether to include destroyed entries in the result
   * @return Set of keys in the given bucket
   */
  Set getBucketKeys(LocalRegion localRegion, int bucketId,
      boolean allowTombstones);

  void postPutAll(DistributedPutAllOperation putallOp,
      VersionedObjectList successfulPuts, LocalRegion region);

  Region.Entry accessEntry(Object key, Object callbackArg,
      LocalRegion localRegion);

  void updateEntryVersion(EntryEventImpl event) throws EntryNotFoundException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy