You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by rv...@apache.org on 2015/04/28 23:40:25 UTC
[20/51] [partial] incubator-geode git commit: Init
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAccessException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAccessException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAccessException.java
new file mode 100755
index 0000000..759f674
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAccessException.java
@@ -0,0 +1,109 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+import java.io.*;
+import java.util.*;
+import com.gemstone.gemfire.distributed.Role;
+import com.gemstone.gemfire.distributed.internal.membership.InternalRole;
+
+/**
+ * Indicates that an attempt to access the region has failed. Failure is
+ * due to one or more missing {@link MembershipAttributes#getRequiredRoles
+ * required roles}. Region operations may throw this exception when the
+ * {@link MembershipAttributes} have been configured with {@link
+ * LossAction#NO_ACCESS} or {@link LossAction#LIMITED_ACCESS}.
+ *
+ * @author Kirk Lund
+ * @since 5.0
+ */
+public class RegionAccessException extends RegionRoleException {
+private static final long serialVersionUID = 3142958723089038406L;
+
+ /**
+ * Set of missing required roles causing access to the region to fail.
+ * missingRoles is transient to avoid NotSerializableException. See {@link
+ * #writeObject} and {@link #readObject} for custom serialization.
+ */
+ private transient Set missingRoles = Collections.EMPTY_SET;
+
+ /**
+ * Constructs a <code>RegionAccessException</code> with a message.
+ * @param s the String message
+ * @param regionFullPath full path of region for which access was attempted
+ * @param missingRoles the missing required roles that caused this exception
+ */
+ public RegionAccessException(String s, String regionFullPath, Set missingRoles) {
+ super(s, regionFullPath);
+ this.missingRoles = missingRoles;
+ if (this.missingRoles == null) {
+ this.missingRoles = Collections.EMPTY_SET;
+ }
+ }
+
+ /**
+ * Constructs a <code>RegionAccessException</code> with a message and
+ * a cause.
+ * @param s the String message
+ * @param regionFullPath full path of region for which access was attempted
+ * @param missingRoles the missing required roles that caused this exception
+ * @param ex the Throwable cause
+ */
+ public RegionAccessException(String s, String regionFullPath, Set missingRoles, Throwable ex) {
+ super(s, regionFullPath, ex);
+ this.missingRoles = missingRoles;
+ if (this.missingRoles == null) {
+ this.missingRoles = Collections.EMPTY_SET;
+ }
+ }
+
+ /**
+ * Returns the missing required roles that caused this exception.
+ * @return the missing required roles that caused this exception
+ */
+ public Set getMissingRoles() {
+ return this.missingRoles;
+ }
+
+ /**
+ * Override writeObject which is used in serialization. Customize
+ * serialization of this exception to avoid escape of InternalRole
+ * which is not Serializable.
+ */
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+ out.defaultWriteObject();
+ // transform roles to string names which are serializable...
+ Set roleNames = new HashSet(this.missingRoles.size());
+ for (Iterator iter = this.missingRoles.iterator(); iter.hasNext();) {
+ String name = ((Role)iter.next()).getName();
+ roleNames.add(name);
+ }
+ out.writeObject(roleNames);
+ }
+
+ /**
+ * Override readObject which is used in serialization. Customize
+ * serialization of this exception to avoid escape of InternalRole
+ * which is not Serializable.
+ */
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ // transform string names which are serializable back into roles...
+ Set roleNames = (Set)in.readObject();
+ Set roles = new HashSet(roleNames.size());
+ for (Iterator iter = roleNames.iterator(); iter.hasNext();) {
+ String name = (String) iter.next();
+ roles.add(InternalRole.getRole(name));
+ }
+ this.missingRoles = roles;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAttributes.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAttributes.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAttributes.java
new file mode 100644
index 0000000..b97e744
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionAttributes.java
@@ -0,0 +1,450 @@
+/*=========================================================================
+ * Copyright (c) 2010-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * one or more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+import java.io.File;
+import java.util.Set;
+
+import com.gemstone.gemfire.cache.client.Pool;
+import com.gemstone.gemfire.compression.Compressor;
+
+/** Defines attributes for configuring a region.
+ * These are <code>EvictionAttributes</code>,
+ * <code>CacheListener</code>, <code>CacheLoader</code>, <code>CacheWriter</code>,
+ * scope, data policy, and expiration attributes
+ * for the region itself, expiration attributes for the region entries,
+ * and whether statistics are enabled for the region and its entries.
+ *
+ * To create an instance of this interface use {@link AttributesFactory#createRegionAttributes}.
+ *
+ * For compatibility rules and default values, see {@link AttributesFactory}.
+ *
+ * <p>Note that the <code>RegionAttributes</code> are not distributed with the region.
+ *
+ * @author Eric Zoerner
+ *
+ * @see AttributesFactory
+ * @see AttributesMutator
+ * @see Region#getAttributes
+ * @see com.gemstone.gemfire.cache.EvictionAttributes
+ * @since 2.0
+ */
+public interface RegionAttributes<K,V> {
+
+ /** Returns the cache loader associated with this region.
+ * @return the cache loader
+ */
+ public CacheLoader<K,V> getCacheLoader();
+
+ /** Returns the cache writer associated with this region.
+ * @return the cache writer
+ */
+ public CacheWriter<K,V> getCacheWriter();
+
+ /** Returns the class that the keys in this region are constrained to.
+ *
+ * @return the <code>Class</code> the keys must be an
+ * <code>instanceof</code>
+ */
+ public Class<K> getKeyConstraint();
+
+ /** Returns the class that the values in this region are constrained to.
+ *
+ * @return the <code>Class</code> the values must be an
+ * <code>instanceof</code>
+ */
+
+ public Class<V> getValueConstraint();
+
+
+ /** Gets the <code>timeToLive</code> expiration attributes for the region as a whole.
+ * Default is 0 which indicates that no expiration of this type will happen.
+ * @return the timeToLive expiration attributes for this region
+ */
+ public ExpirationAttributes getRegionTimeToLive();
+
+ /** Gets the idleTimeout expiration attributes for the region as a whole.
+ * Default is 0 which indicates that no expiration of this type will happen.
+ * Note that the XML element that corresponds to this method "region-idle-time", does not include "out" in its name.
+ *
+ * @return the IdleTimeout expiration attributes for this region
+ */
+ public ExpirationAttributes getRegionIdleTimeout();
+
+ /** Gets the <code>timeToLive</code> expiration attributes for entries in this region.
+ * Default is 0 which indicates that no expiration of this type is set.
+ * @return the timeToLive expiration attributes for entries in this region
+ */
+ public ExpirationAttributes getEntryTimeToLive();
+
+ /** Gets the <code>idleTimeout</code> expiration attributes for entries in this region.
+ * Default is 0 which indicates that no expiration of this type is set.
+ * Note that the XML element that corresponds to this method "entry-idle-time", does not include "out" in its name.
+ * @return the idleTimeout expiration attributes for entries in this region
+ */
+ public ExpirationAttributes getEntryIdleTimeout();
+
+ /** Gets the <code>entryTimeToLive</code> <code>CustomExpiry</code>, if any
+ * for entries in this region
+ * @return the entryTimeToLive CustomExpiry for entries in this region
+ */
+ public CustomExpiry<K,V> getCustomEntryTimeToLive();
+
+ /** Gets the <code>idleTimeout</code> <code>CustomExpiry</code>, if any
+ * for entries in this region
+ * @return the idleTimeout CustomExpiry for entries in this region
+ */
+ public CustomExpiry<K,V> getCustomEntryIdleTimeout();
+
+ /**
+ * Gets the flag telling a region to ignore JTA transactions.
+ * Default value is set to false.
+ * @since 5.0
+ */
+ public boolean getIgnoreJTA();
+
+ /** Returns the type of mirroring for this region.
+ *
+ * @return the region's <code>MirrorType</code>
+ * @deprecated as of GemFire 5.0, use {@link #getDataPolicy} instead.
+ */
+ @Deprecated
+ public MirrorType getMirrorType();
+
+
+ /** Returns the data policy for this region.
+ * Default value of DataPolicy is set to 'Normal'. Please refer the gemfire documentation for more details on this.
+ *
+ * @return the region's <code>DataPolicy</code>
+ * @since 5.0
+ */
+ public DataPolicy getDataPolicy();
+
+ /** Returns the scope of the region.
+ * Default scope is DISTRIBUTED_NO_ACK. Please refer the gemfire documentation for more details on this.
+ * @return the region's <code>Scope</code>
+ */
+ public Scope getScope();
+
+
+ /**
+ * Attributes that control the size of the <code>Region</code> using an
+ * {@link EvictionAlgorithm} and a {@link EvictionAction}.
+ * @return the region's EvictionAttributes
+ */
+ public EvictionAttributes getEvictionAttributes();
+
+ /** Returns the cache listener for the region.
+ * @throws IllegalStateException if more than one cache listener exists on this attributes
+ * @return the region's <code>CacheListener</code>
+ * @deprecated as of GemFire 5.0, use {@link #getCacheListeners} instead
+ */
+ @Deprecated
+ public CacheListener<K,V> getCacheListener();
+
+ /** Returns an array of all the cache listeners on this attributes.
+ * Modifications to the returned array will not effect the attributes.
+ * @return the region's <code>CacheListener</code>s; an empty array if no listeners
+ * @since 5.0
+ */
+ public CacheListener<K,V>[] getCacheListeners();
+
+ // MAP ATTRIBUTES
+
+
+ /** Returns the initial capacity of the entries map.
+ * Default is 16.
+ * @return the initial capacity of the entries map
+ * @see java.util.HashMap
+ */
+ public int getInitialCapacity();
+
+ /** Returns the load factor of the entries map.
+ * Default is 0.75.
+ * @return the load factor of the entries map
+ * @see java.util.HashMap
+ */
+ public float getLoadFactor();
+
+ /**
+ * Returns true if this member is configured to be lock grantor for the
+ * region. Result will always be false if the scope is not
+ * <code>Scope.GLOBAL</code>.
+ * <p>
+ * This attribute does not indicate whether or not this member is currently
+ * lock grantor. It only indicates that at the time of region creation, this
+ * member should attempt to become lock grantor.
+ * Default value is false.
+ *
+ * @return true if this member is configured to be lock grantor for the region
+ * @see AttributesFactory
+ * @see Region#becomeLockGrantor
+ */
+ public boolean isLockGrantor();
+
+ /**
+ * Returns true if multicast communications are enabled for this region.
+ * Multicast must also be enabled in the DistributedSystem.
+ * Default value is set to false.
+ *
+ * @since 5.0
+ * @return true if this region is configured to allow use of multicast
+ * for distributed messaging
+ * @see AttributesFactory#setMulticastEnabled
+ */
+ public boolean getMulticastEnabled();
+
+ /** Returns the concurrencyLevel of the entries map.
+ * Default is 16.
+ * @return the concurrencyLevel
+ * @see AttributesFactory
+ */
+ public int getConcurrencyLevel();
+
+ /**
+ * Returns whether or not a persistent backup should be made of the
+ * region (as opposed to just writing the overflow data to disk).
+ *
+ * @since 3.2
+ * @deprecated as of GemFire 5.0, use {@link DataPolicy#PERSISTENT_REPLICATE} instead
+ */
+ @Deprecated
+ public boolean getPersistBackup();
+
+ /**
+ * Returns the <code>DiskWriteAttributes</code> that configure how
+ * the region is written to disk.
+ *
+ * @since 3.2
+ * @deprecated as of 6.5 use {@link #getDiskStoreName} instead.
+ */
+ @Deprecated
+ public DiskWriteAttributes getDiskWriteAttributes();
+
+ /**
+ * Returns the directories to which the region's data are written. If
+ * multiple directories are used, GemFire will attempt to distribute the
+ * data evenly amongst them.
+ *
+ * @since 3.2
+ * @deprecated as of 6.5 use {@link DiskStore#getDiskDirs} instead.
+ */
+ @Deprecated
+ public File[] getDiskDirs();
+
+ /**
+ * Returns the value of <code>IndexMaintenanceSynchronous</code> which
+ * specifies whether the region indexes are updated synchronously when a
+ * region is modified or asynchronously in a background thread.
+ * Default value is true.
+ *
+ * @since 4.0
+ */
+ public boolean getIndexMaintenanceSynchronous();
+
+ /**
+ * Returns the <code>PartitionAttributes</code> that configure how
+ * the region is partitioned.
+ *
+ * @since 5.0
+ */
+ public PartitionAttributes getPartitionAttributes();
+
+ /**
+ * Returns the <code>MembershipAttributes</code> that configure required
+ * roles for reliable access to the region.
+ *
+ * @since 5.0
+ */
+ public MembershipAttributes getMembershipAttributes();
+
+ /**
+ * Returns the <code>SubscriptionAttributes</code> that configure
+ * how this region behaves as a subscriber to remote caches.
+ *
+ * @since 5.0
+ */
+ public SubscriptionAttributes getSubscriptionAttributes();
+
+
+ // STATISTICS
+ /** Returns whether the statistics are enabled for this region and its
+ * entries.
+ * Default is false.
+ * @return true if statistics are enabled
+ */
+ public boolean getStatisticsEnabled();
+
+ /**
+ * Returns whether or not acks are sent after an update is processed.
+ * @return True if acks are sent after updates are processed;
+ * false if acks are sent before updates are processed.
+ *
+ * @since 4.1
+ * @deprecated Setting early ack no longer has any effect.
+ */
+ @Deprecated
+ public boolean getEarlyAck();
+
+ /**
+ * Returns whether or not this region is a publisher. Publishers are regions
+ * on which distributed write operations are done.
+ * @return True if a publisher;
+ * false if not (default).
+ *
+ * @since 4.2.3
+ * @deprecated as of 6.5
+ */
+ public boolean getPublisher();
+
+ /**
+ * Returns whether or not conflation is enabled for sending
+ * messages from a cache server to its clients.
+ *
+ * Note: This parameter is only valid for cache server to client
+ * communication. It has no effect in peer to peer communication.
+ *
+ * @deprecated as of GemFire 5.0, use {@link #getEnableSubscriptionConflation} instead
+ #
+ * @return True if conflation is enabled;
+ * false conflation is not enabled (default).
+ *
+ * @since 4.2
+ */
+ @Deprecated
+ public boolean getEnableConflation();
+
+ /**
+ * Returns whether or not conflation is enabled for sending
+ * messages from a cache server to its clients.
+ *
+ * Note: This parameter is only valid for cache server to client
+ * communication. It has no effect in peer to peer communication.
+ *
+ * @return True if conflation is enabled;
+ * false conflation is not enabled (default).
+ *
+ * @since 5.0
+ * @deprecated as of GemFire 5.0, use {@link #getEnableSubscriptionConflation} instead
+ */
+ @Deprecated
+ public boolean getEnableBridgeConflation();
+
+ /**
+ * Returns whether or not conflation is enabled for sending
+ * messages from a cache server to its clients.
+ *
+ * Note: This parameter is only valid for cache server to client
+ * communication. It has no effect in peer to peer communication.
+ *
+ * Default is false.
+ *
+ * @return True if conflation is enabled;
+ * false conflation is not enabled (default).
+ *
+ * @since 5.7
+ */
+ public boolean getEnableSubscriptionConflation();
+ /**
+ * Returns whether or not async conflation is enabled for sending
+ * messages to async peers.
+ *
+ * Default is false.
+ *
+ * @return True if async conflation is enabled;
+ * false async conflation is not enabled (default).
+ *
+ * @since 4.2.3
+ */
+ public boolean getEnableAsyncConflation();
+
+ /**
+ * Returns the sizes of the disk directories in megabytes
+ * @return int[] sizes of the disk directories
+ * @deprecated as of 6.5 use {@link DiskStore#getDiskDirSizes} instead.
+ */
+ public int[] getDiskDirSizes();
+
+
+ /**
+ * Returns the name of the {@link Pool} that this region
+ * will use to communicate with servers, if any.
+ * Returns <code>null</code> if this region communicates with peers.
+ * @return the name of the client-server {@link Pool}
+ * this region will use for server communication; <code>null</code> is returned if
+ * the region communicates with peers.
+ * @since 5.7
+ */
+ public String getPoolName();
+
+ /**
+ * Returns whether or not cloning is enabled on region.
+ * Default is false.
+ *
+ * @return True if cloning is enabled;
+ * false cloning is not enabled (default).
+ *
+ * @since 6.1
+ */
+ public boolean getCloningEnabled();
+
+ /**
+ * Returns the name of the {@link DiskStore} that this region belongs
+ * to, if any.
+ * Returns <code>null</code> if this region belongs to default {@link DiskStore}.
+ * @return the name of the {@link DiskStore} of this region;
+ * <code>null</code> is returned if this region belongs to default
+ * {@link DiskStore}.
+ * @since 6.5
+ */
+ public String getDiskStoreName();
+
+ /**
+ * Returns true if configured synchronous disk writes.
+ * Default is set to true.
+ *
+ * @return Returns true if writes to disk are synchronous and false otherwise
+ * @since 6.5
+ */
+ public boolean isDiskSynchronous();
+
+ /**
+ * Returns a set of gatewaysenderIds
+ */
+ public Set<String> getGatewaySenderIds();
+
+ /**
+ * Returns a set of AsyncEventQueueIds added to the region
+ */
+ public Set<String> getAsyncEventQueueIds();
+
+ /**
+ * Returns true if concurrent update checks are turned on for this region.
+ * <p>
+ * When this is enabled, concurrent updates will be conflated if they are
+ * applied out of order.
+ * <p>
+ * All members must set this attribute the same.
+ *
+ * Default is set to true.
+ *
+ * @since 7.0
+ * @return true if concurrent update checks are turned on
+ */
+ public boolean getConcurrencyChecksEnabled();
+
+ /**
+ * Returns the compressor used by this region's entry values.
+ * @since 8.0
+ * @return null if the region does not have compression enabled.
+ */
+ public Compressor getCompressor();
+}
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDestroyedException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDestroyedException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDestroyedException.java
new file mode 100644
index 0000000..9bdef20
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDestroyedException.java
@@ -0,0 +1,43 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+/**
+ * Indicates that the region has been destroyed. Further operations
+ * on the region object are not allowed.
+ *
+ * @author Eric Zoerner
+ *
+ * @since 2.0
+ */
+public class RegionDestroyedException extends CacheRuntimeException {
+private static final long serialVersionUID = 319804842308010754L;
+ private String regionFullPath;
+
+ /** Constructs a <code>RegionDestroyedException</code> with a message.
+ * @param msg the String message
+ */
+ public RegionDestroyedException(String msg, String regionFullPath) {
+ super(msg);
+ this.regionFullPath = regionFullPath;
+ }
+
+ /** Constructs a <code>RegionDestroyedException</code> with a message and
+ * a cause.
+ * @param s the String message
+ * @param ex the Throwable cause
+ */
+ public RegionDestroyedException(String s, String regionFullPath, Throwable ex) {
+ super(s, ex);
+ this.regionFullPath = regionFullPath;
+ }
+
+ public String getRegionFullPath() {
+ return this.regionFullPath;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDistributionException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDistributionException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDistributionException.java
new file mode 100755
index 0000000..a03f979
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionDistributionException.java
@@ -0,0 +1,114 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+import java.io.*;
+import java.util.*;
+import com.gemstone.gemfire.distributed.Role;
+import com.gemstone.gemfire.distributed.internal.membership.InternalRole;
+
+/**
+ * Indicates that an attempt to send a distributed cache event to one or more
+ * {@link MembershipAttributes#getRequiredRoles required roles} may have
+ * failed. Failure may be caused by departure of one or more required roles
+ * while sending the message to them. If the region scope is {@linkplain
+ * com.gemstone.gemfire.cache.Scope#DISTRIBUTED_NO_ACK DISTRIBUTED_NO_ACK} or
+ * {@linkplain com.gemstone.gemfire.cache.Scope#GLOBAL GLOBAL} then failure
+ * may be caused by one or more required roles not acknowledging receipt of
+ * the message.
+ *
+ * @author Kirk Lund
+ * @since 5.0
+ */
+public class RegionDistributionException extends RegionRoleException {
+private static final long serialVersionUID = -5950359426786805646L;
+
+ /**
+ * Set of missing required roles causing access to the region to fail.
+ * failedRoles is transient to avoid NotSerializableException. See {@link
+ * #writeObject} and {@link #readObject} for custom serialization.
+ */
+ private transient Set failedRoles = Collections.EMPTY_SET;
+
+ /**
+ * Constructs a <code>RegionDistributionException</code> with a message.
+ * @param s the String message
+ * @param regionFullPath full path of region for which access was attempted
+ * @param failedRoles the required roles that caused this exception
+ */
+ public RegionDistributionException(String s, String regionFullPath, Set failedRoles) {
+ super(s, regionFullPath);
+ this.failedRoles = failedRoles;
+ if (this.failedRoles == null) {
+ this.failedRoles = Collections.EMPTY_SET;
+ }
+ }
+
+ /**
+ * Constructs a <code>RegionDistributionException</code> with a message and
+ * a cause.
+ * @param s the String message
+ * @param regionFullPath full path of region for which access was attempted
+ * @param failedRoles the required roles that caused this exception
+ * @param ex the Throwable cause
+ */
+ public RegionDistributionException(String s, String regionFullPath, Set failedRoles, Throwable ex) {
+ super(s, regionFullPath, ex);
+ this.failedRoles = failedRoles;
+ if (this.failedRoles == null) {
+ this.failedRoles = Collections.EMPTY_SET;
+ }
+ }
+
+ /**
+ * Returns the required roles that caused this exception. One or more
+ * roles failed to receive a cache distribution message or acknowledge
+ * receipt of that message.
+ * @return the required roles that caused this exception
+ */
+ public Set getFailedRoles() {
+ return this.failedRoles;
+ }
+
+ /**
+ * Override writeObject which is used in serialization. Customize
+ * serialization of this exception to avoid escape of InternalRole
+ * which is not Serializable.
+ */
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+ out.defaultWriteObject();
+ // transform roles to string names which are serializable...
+ Set roleNames = new HashSet(this.failedRoles.size());
+ for (Iterator iter = this.failedRoles.iterator(); iter.hasNext();) {
+ String name = ((Role)iter.next()).getName();
+ roleNames.add(name);
+ }
+ out.writeObject(roleNames);
+ }
+
+ /**
+ * Override readObject which is used in serialization. Customize
+ * serialization of this exception to avoid escape of InternalRole
+ * which is not Serializable.
+ */
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ // transform string names which are serializable back into roles...
+ Set roleNames = (Set)in.readObject();
+ Set roles = new HashSet(roleNames.size());
+ for (Iterator iter = roleNames.iterator(); iter.hasNext();) {
+ String name = (String) iter.next();
+ roles.add(InternalRole.getRole(name));
+ }
+ this.failedRoles = roles;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionEvent.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionEvent.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionEvent.java
new file mode 100644
index 0000000..eee2c17
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionEvent.java
@@ -0,0 +1,32 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+
+package com.gemstone.gemfire.cache;
+
+/** Contains information about an event affecting a region, including
+ * its identity and the circumstances of the event.
+ * This is passed in to <code>CacheListener</code> and <code>CacheWriter</code>.
+ *
+ * @author Eric Zoerner
+ *
+ *
+ * @see CacheListener
+ * @see CacheWriter
+ * @see EntryEvent
+ * @since 2.0
+ */
+public interface RegionEvent<K,V> extends CacheEvent<K,V> {
+
+ /**
+ * Return true if this region was destroyed but is being reinitialized,
+ * for example if a snapshot was just loaded. Can only return true for
+ * an event related to region destruction.
+ */
+ public boolean isReinitializing();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionExistsException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionExistsException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionExistsException.java
new file mode 100644
index 0000000..e3e89c6
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionExistsException.java
@@ -0,0 +1,56 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+
+package com.gemstone.gemfire.cache;
+
+/**
+ * Indicates that the requested region already exists when a region is
+ * being created.
+ *
+ * @author Eric Zoerner
+ *
+ *
+ * @see Region#createSubregion
+ * @see Cache#createRegion
+ * @since 2.0
+ */
+public class RegionExistsException extends CacheException {
+private static final long serialVersionUID = -5643670216230359426L;
+ private transient Region region;
+
+ /**
+ * Constructs an instance of <code>RegionExistsException</code> with the specified Region.
+ * @param rgn the Region that exists
+ */
+ public RegionExistsException(Region rgn) {
+ super(rgn.getFullPath());
+ this.region = rgn;
+ }
+
+ /**
+ * Constructs an instance of <code>RegionExistsException</code> with the specified detail message
+ * and cause.
+ * @param rgn the Region that exists
+ * @param cause the causal Throwable
+ */
+ public RegionExistsException(Region rgn, Throwable cause) {
+ super(rgn.getFullPath(), cause);
+ this.region = rgn;
+ }
+
+
+ /**
+ * Return the Region that already exists which prevented region creation.
+ * @return the Region that already exists, or null if this exception has
+ * been serialized, in which {@link Throwable#getMessage } will return the
+ * pathFromRoot for the region that exists.
+ */
+ public Region getRegion() {
+ return this.region;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
new file mode 100644
index 0000000..7de43a7
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionFactory.java
@@ -0,0 +1,893 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *=========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+import java.io.File;
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.compression.Compressor;
+import com.gemstone.gemfire.distributed.LeaseExpiredException;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+
+/**
+ * <code>RegionFactory</code> is used to create {@link Region regions}
+ * in a {@link Cache cache}.
+ * Instances of this interface can be created:
+<ul>
+<li>using a {@link RegionShortcut shortcut} by calling {@link Cache#createRegionFactory(RegionShortcut)} which will initialize the factory with the shortcut's region attributes
+<li>using a named region attribute by calling {@link Cache#createRegionFactory(String)} which will initialize the factory the named region attributes
+<li>using a region attribute instance by calling {@link Cache#createRegionFactory(RegionAttributes)} which will initialize the factory with the given region attributes
+<li>by calling {@link Cache#createRegionFactory()} which will initialize the factory with defaults
+</ul>
+Once the factory has been created it can be customized with its setter methods.
+<p>
+The final step is to produce a {@link Region} by calling {@link #create(String)}.
+<p>Example: Create a replicate region with a CacheListener
+<PRE>
+ Cache c = new CacheFactory().create();
+ // Create replicate region.
+ // Add a cache listener before creating region
+ Region r = c.createRegionFactory(REPLICATE)
+ .addCacheListener(myListener)
+ .create("replicate");
+</PRE>
+<p>Example: Create a partition region that has redundancy
+<PRE>
+ Cache c = new CacheFactory().create();
+ // Create replicate region.
+ // Add a cache listener before creating region
+ Region r = c.createRegionFactory(PARTITION_REDUNDANT)
+ .create("partition");
+</PRE>
+ *
+ * @author Mitch Thomas
+ * @since 5.0
+ */
+
+public class RegionFactory<K,V>
+{
+ private final AttributesFactory<K,V> attrsFactory;
+ private final GemFireCacheImpl cache;
+
+ /**
+ * For internal use only.
+ * @since 6.5
+ */
+ protected RegionFactory(GemFireCacheImpl cache) {
+ this.cache = cache;
+ this.attrsFactory = new AttributesFactory<K,V>();
+ }
+
+ /**
+ * For internal use only.
+ * @since 6.5
+ */
+ protected RegionFactory(GemFireCacheImpl cache, RegionShortcut pra) {
+ this.cache = cache;
+ RegionAttributes ra = cache.getRegionAttributes(pra.toString());
+ if (ra == null) {
+ throw new IllegalStateException("The region shortcut " + pra
+ + " has been removed.");
+ }
+ this.attrsFactory = new AttributesFactory<K,V>(ra);
+ }
+
+ /**
+ * For internal use only.
+ * @since 6.5
+ */
+ protected RegionFactory(GemFireCacheImpl cache, RegionAttributes ra) {
+ this.cache = cache;
+ this.attrsFactory = new AttributesFactory<K,V>(ra);
+ }
+
+ /**
+ * For internal use only.
+ * @since 6.5
+ */
+ protected RegionFactory(GemFireCacheImpl cache, String regionAttributesId) {
+ this.cache = cache;
+ RegionAttributes<K,V> ra = getCache().getRegionAttributes(regionAttributesId);
+ if (ra == null) {
+ throw new IllegalStateException(LocalizedStrings.RegionFactory_NO_ATTRIBUTES_ASSOCIATED_WITH_0.toLocalizedString(regionAttributesId));
+ }
+ this.attrsFactory = new AttributesFactory<K,V>(ra);
+ }
+
+ /**
+ * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If
+ * no DistributedSystem exists it creates a DistributedSystem with default
+ * configuration, otherwise it uses the existing DistributedSystem. The
+ * default Region configuration is used.
+ *
+ * @throws CacheException
+ * if unable to connect the DistributedSystem or create a Cache
+ * @deprecated as of 6.5 use {@link Cache#createRegionFactory()} instead.
+ */
+ @Deprecated
+ public RegionFactory() throws CacheWriterException, RegionExistsException,
+ TimeoutException {
+ this((GemFireCacheImpl)new CacheFactory().create());
+ }
+
+ /**
+ * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If
+ * no DistributedSystem exists it creates a DistributedSystem with default
+ * configuration, otherwise it uses the existing DistributedSystem. The Region
+ * configuration is initialized using the provided RegionAttributes.
+ *
+ * @throws CacheException
+ * if unable to connect the DistributedSystem or create a Cache
+ * @deprecated as of 6.5 use {@link Cache#createRegionFactory(RegionAttributes)} instead.
+ */
+ @Deprecated
+ public RegionFactory(RegionAttributes<K,V> regionAttributes)
+ throws CacheWriterException, RegionExistsException, TimeoutException {
+ this((GemFireCacheImpl)new CacheFactory().create(), regionAttributes);
+ }
+
+ /**
+ * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If
+ * no DistributedSystem exists it creates a DistributedSystem with default
+ * configuration, otherwise it uses the existing DistributedSystem. The Region
+ * configuration is initialized using the RegionAttributes identified in the
+ * cache.xml file by the provided identifier.
+ *
+ * @param regionAttributesId
+ * that identifies a set of RegionAttributes in the cache-xml file.
+ * @see Cache#getRegionAttributes
+ * @throws IllegalArgumentException
+ * if there are no attributes associated with the id
+ * @throws CacheException
+ * if unable to connect the DistributedSystem or create a Cache
+ * @deprecated as of 6.5 use {@link Cache#createRegionFactory(String)} instead.
+ */
+ @Deprecated
+ public RegionFactory(String regionAttributesId) throws CacheWriterException,
+ RegionExistsException, TimeoutException {
+ this((GemFireCacheImpl)new CacheFactory().create(), regionAttributesId);
+ }
+
+ /**
+ * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If
+ * a DistributedSystem already exists with the same properties it uses that
+ * DistributedSystem, otherwise a DistributedSystem is created using the
+ * provided properties. The default Region configuration is used.
+ *
+ * @param distributedSystemProperties
+ * an instance of Properties containing
+ * <code>DistributedSystem</code configuration
+ * @throws CacheException if unable to connect the DistributedSystem or create a Cache
+ * @deprecated as of 6.5 use {@link CacheFactory#CacheFactory(Properties)} and {@link Cache#createRegionFactory()} instead.
+ */
+ @Deprecated
+ public RegionFactory(Properties distributedSystemProperties)
+ throws CacheWriterException, RegionExistsException, TimeoutException {
+ this((GemFireCacheImpl)new CacheFactory(distributedSystemProperties).create());
+ }
+
+ /**
+ * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If
+ * a DistributedSystem already exists with the same properties it uses that
+ * DistributedSystem, otherwise a DistributedSystem is created using the
+ * provided properties. The initial Region configuration is set using the
+ * RegionAttributes provided.
+ *
+ * @param distributedSystemProperties
+ * properties used to either find or create a DistributedSystem.
+ * @param regionAttributes
+ * the initial Region configuration for this RegionFactory.
+ * @throws CacheException
+ * if unable to connect the DistributedSystem or create a Cache
+ * @deprecated as of 6.5 use {@link CacheFactory#CacheFactory(Properties)} and {@link Cache#createRegionFactory(RegionAttributes)} instead.
+ */
+ @Deprecated
+ public RegionFactory(Properties distributedSystemProperties,
+ RegionAttributes<K,V> regionAttributes) throws CacheWriterException,
+ RegionExistsException, TimeoutException {
+ this((GemFireCacheImpl)new CacheFactory(distributedSystemProperties).create(), regionAttributes);
+ }
+
+ /**
+ * Constructs a RegionFactory by creating a DistributedSystem and a Cache. If
+ * a DistributedSystem already exists whose properties match those provied, it
+ * uses that DistributedSystem. The Region configuration is initialized using
+ * the RegionAttributes identified in the cache.xml file by the provided
+ * identifier.
+ *
+ * @param distributedSystemProperties
+ * properties used to either find or create a DistributedSystem.
+ * @param regionAttributesId
+ * the identifier for set of RegionAttributes in the cache.xml file
+ * used as the initial Region configuration for this RegionFactory.
+ * @throws IllegalArgumentException
+ * if there are no attributes associated with the id
+ *
+ * @throws CacheException
+ * if unable to connect the DistributedSystem or create a Cache
+ * @deprecated as of 6.5 use {@link CacheFactory#CacheFactory(Properties)} and {@link Cache#createRegionFactory(String)} instead.
+ *
+ */
+ @Deprecated
+ public RegionFactory(Properties distributedSystemProperties,
+ String regionAttributesId) throws CacheWriterException,
+ RegionExistsException, TimeoutException {
+ this((GemFireCacheImpl)new CacheFactory(distributedSystemProperties).create(), regionAttributesId);
+ }
+
+ /**
+ * Returns the cache used by this factory.
+ */
+ private synchronized GemFireCacheImpl getCache() {
+ return this.cache;
+ }
+
+ /**
+ * Sets the cache loader for the next <code>RegionAttributes</code> created.
+ *
+ * @param cacheLoader
+ * the cache loader or null if no loader
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setCacheLoader
+ *
+ */
+ public RegionFactory<K,V> setCacheLoader(CacheLoader<K,V> cacheLoader)
+ {
+ this.attrsFactory.setCacheLoader(cacheLoader);
+ return this;
+ }
+
+ /**
+ * Sets the cache writer for the next <code>RegionAttributes</code> created.
+ *
+ * @param cacheWriter
+ * the cache writer or null if no cache writer
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setCacheWriter
+ */
+ public RegionFactory<K,V> setCacheWriter(CacheWriter<K,V> cacheWriter)
+ {
+ this.attrsFactory.setCacheWriter(cacheWriter);
+ return this;
+ }
+
+ /**
+ * Adds a cache listener to the end of the list of cache listeners on this factory.
+ * @param aListener the cache listener to add
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException if <code>aListener</code> is null
+ * @see AttributesFactory#addCacheListener
+ */
+ public RegionFactory<K,V> addCacheListener(CacheListener<K,V> aListener)
+ {
+ this.attrsFactory.addCacheListener(aListener);
+ return this;
+ }
+
+ /**
+ * Removes all cache listeners and then adds each listener in the specified array.
+ * for the next <code>RegionAttributes</code> created.
+ * @param newListeners a possibly null or empty array of listeners to add to this factory.
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException if the <code>newListeners</code> array has a null element
+ * @see AttributesFactory#initCacheListeners
+ */
+ public RegionFactory<K,V> initCacheListeners(CacheListener<K,V>[] newListeners)
+ {
+ this.attrsFactory.initCacheListeners(newListeners);
+ return this;
+ }
+
+ /**
+ * Sets the eviction attributes that controls growth of the Region to be created.
+ *
+ * @param evictionAttributes for the Region to create
+ * @return a reference to this RegionFactory object
+ */
+ public RegionFactory<K,V> setEvictionAttributes(EvictionAttributes evictionAttributes) {
+ this.attrsFactory.setEvictionAttributes(evictionAttributes);
+ return this;
+ }
+
+ /**
+ * Sets the idleTimeout expiration attributes for region entries for the next
+ * <code>RegionAttributes</code> created.
+ * Note that the XML element that corresponds to this method "entry-idle-time", does not include "out" in its name.
+ *
+ * @param idleTimeout
+ * the idleTimeout ExpirationAttributes for entries in this region
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if idleTimeout is null
+ * @see AttributesFactory#setEntryIdleTimeout
+ */
+ public RegionFactory<K,V> setEntryIdleTimeout(ExpirationAttributes idleTimeout)
+ {
+ this.attrsFactory.setEntryIdleTimeout(idleTimeout);
+ return this;
+ }
+
+ /**
+ * Sets the custom idleTimeout for the next <code>RegionAttributes</code>
+ * created.
+ *
+ * @param custom the custom method
+ * @return the receiver
+ * @see AttributesFactory#setCustomEntryIdleTimeout(CustomExpiry)
+ */
+ public RegionFactory<K,V> setCustomEntryIdleTimeout(CustomExpiry<K,V> custom) {
+ this.attrsFactory.setCustomEntryIdleTimeout(custom);
+ return this;
+ }
+
+ /**
+ * Sets the timeToLive expiration attributes for region entries for the next
+ * <code>RegionAttributes</code> created.
+ *
+ * @param timeToLive
+ * the timeToLive ExpirationAttributes for entries in this region
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if timeToLive is null
+ * @see AttributesFactory#setEntryTimeToLive
+ */
+ public RegionFactory<K,V> setEntryTimeToLive(ExpirationAttributes timeToLive)
+ {
+ this.attrsFactory.setEntryTimeToLive(timeToLive);
+ return this;
+ }
+
+ /**
+ * Sets the custom timeToLive expiration method for the next
+ * <code>RegionAttributes</code> created.
+ * @param custom the custom method
+ * @return the receiver
+ * @see AttributesFactory#setCustomEntryTimeToLive(CustomExpiry)
+ */
+ public RegionFactory<K,V> setCustomEntryTimeToLive(CustomExpiry<K,V> custom) {
+ this.attrsFactory.setCustomEntryTimeToLive(custom);
+ return this;
+ }
+
+ /**
+ * Sets the idleTimeout expiration attributes for the region itself for the
+ * next <code>RegionAttributes</code> created.
+ * Note that the XML element that corresponds to this method "region-idle-time", does not include "out" in its name.
+ *
+ * @param idleTimeout
+ * the ExpirationAttributes for this region idleTimeout
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if idleTimeout is null
+ * @see AttributesFactory#setRegionIdleTimeout
+ */
+ public RegionFactory<K,V> setRegionIdleTimeout(ExpirationAttributes idleTimeout)
+ {
+ this.attrsFactory.setRegionIdleTimeout(idleTimeout);
+ return this;
+ }
+
+ /**
+ * Sets the timeToLive expiration attributes for the region itself for the
+ * next <code>RegionAttributes</code> created.
+ *
+ * @param timeToLive
+ * the ExpirationAttributes for this region timeToLive
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if timeToLive is null
+ * @see AttributesFactory#setRegionTimeToLive
+ */
+ public RegionFactory<K,V> setRegionTimeToLive(ExpirationAttributes timeToLive)
+ {
+ this.attrsFactory.setRegionTimeToLive(timeToLive);
+ return this;
+ }
+
+ /**
+ * Sets the scope for the next <code>RegionAttributes</code> created.
+ *
+ * @param scopeType
+ * the type of Scope to use for the region
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if scopeType is null
+ * @see AttributesFactory#setScope
+ */
+ public RegionFactory<K,V> setScope(Scope scopeType)
+ {
+ this.attrsFactory.setScope(scopeType);
+ return this;
+ }
+
+ /**
+ * Sets the data policy for the next <code>RegionAttributes</code> created.
+ *
+ * @param dataPolicy
+ * The type of mirroring to use for the region
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if dataPolicy is null
+ * @see AttributesFactory#setDataPolicy
+ */
+ public RegionFactory<K,V> setDataPolicy(DataPolicy dataPolicy)
+ {
+ this.attrsFactory.setDataPolicy(dataPolicy);
+ return this;
+ }
+
+ /**
+ * Sets for this region whether or not acks are sent after an update is processed.
+ *
+ * @param earlyAck set to true for the acknowledgement to be sent prior to processing the update
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setEarlyAck(boolean)
+ * @deprecated As of 6.5 this setting no longer has any effect.
+ */
+ @Deprecated
+ public RegionFactory<K,V> setEarlyAck(boolean earlyAck) {
+ this.attrsFactory.setEarlyAck(earlyAck);
+ return this;
+ }
+
+ /**
+ * Sets whether distributed operations on this region should attempt to use multicast.
+ *
+ * @since 5.0
+ * @param value true to enable multicast
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setMulticastEnabled(boolean)
+ */
+ public RegionFactory<K,V> setMulticastEnabled(boolean value) {
+ this.attrsFactory.setMulticastEnabled(value);
+ return this;
+ }
+
+ /**
+ * Sets the pool name attribute.
+ * This causes regions that use these attributes
+ * to be a client region which communicates with the
+ * servers that the connection pool communicates with.
+ * <p>If this attribute is set to <code>null</code> or <code>""</code>
+ * then the connection pool is disabled causing regions that use these attributes
+ * to be communicate with peers instead of servers.
+ * <p>The named connection pool must exist on the cache at the time these
+ * attributes are used to create a region. See {@link PoolManager#createFactory}
+ * for how to create a connection pool.
+ * @param poolName the name of the connection pool to use; if <code>null</code>
+ * or <code>""</code> then the connection pool attribute is disabled for regions
+ * using these attributes.
+ * @return a reference to this RegionFactory object
+ * @throws IllegalStateException if a cache loader or cache writer has already
+ * been set.
+ * @since 5.7
+ */
+ public RegionFactory<K,V> setPoolName(String poolName) {
+ this.attrsFactory.setPoolName(poolName);
+ return this;
+ }
+
+ /**
+ * Sets whether or not this region should be considered a publisher.
+ * @since 5.0
+ * @deprecated as of 6.5
+ */
+ @Deprecated
+ public void setPublisher(boolean v) {
+// this.attrsFactory.setPublisher(v);
+ }
+ /**
+ * Sets whether or not conflation is enabled for sending messages
+ * to async peers.
+ * @param value true to enable async conflation
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setEnableAsyncConflation(boolean)
+ */
+ public RegionFactory<K,V> setEnableAsyncConflation(boolean value) {
+ this.attrsFactory.setEnableAsyncConflation(value);
+ return this;
+ }
+
+ /**
+ * Sets whether or not conflation is enabled for sending messages
+ * from a cache server to its clients.
+ * @param value true to enable subscription conflation
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setEnableSubscriptionConflation(boolean)
+ */
+ public RegionFactory<K,V> setEnableSubscriptionConflation(boolean value) {
+ this.attrsFactory.setEnableSubscriptionConflation(value);
+ return this;
+ }
+
+ /**
+ * Sets the key constraint for the next <code>RegionAttributes</code>
+ * created. Keys in the region will be constrained to this class (or
+ * subclass). Any attempt to store a key of an incompatible type in the region
+ * will cause a <code>ClassCastException</code> to be thrown.
+ *
+ * @param keyConstraint
+ * The Class to constrain the keys to, or null if no constraint
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if <code>keyConstraint</code> is a class denoting a primitive
+ * type
+ * @see AttributesFactory#setKeyConstraint
+ */
+ public RegionFactory<K,V> setKeyConstraint(Class<K> keyConstraint)
+ {
+ this.attrsFactory.setKeyConstraint(keyConstraint);
+ return this;
+ }
+
+ /**
+ * Sets the value constraint for the next <code>RegionAttributes</code>
+ * created. Values in the region will be constrained to this class (or
+ * subclass). Any attempt to store a value of an incompatible type in the
+ * region will cause a <code>ClassCastException</code> to be thrown.
+ *
+ * @param valueConstraint
+ * The Class to constrain the values to, or null if no constraint
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if <code>valueConstraint</code> is a class denoting a primitive
+ * type
+ * @see AttributesFactory#setValueConstraint
+ */
+ public RegionFactory<K,V> setValueConstraint(Class<V> valueConstraint)
+ {
+ this.attrsFactory.setValueConstraint(valueConstraint);
+ return this;
+ }
+
+ /**
+ * Sets the entry initial capacity for the next <code>RegionAttributes</code>
+ * created. This value is used in initializing the map that holds the entries.
+ *
+ * @param initialCapacity
+ * the initial capacity of the entry map
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException if initialCapacity is negative.
+ * @see java.util.HashMap
+ * @see AttributesFactory#setInitialCapacity
+ */
+ public RegionFactory<K,V> setInitialCapacity(int initialCapacity)
+ {
+ this.attrsFactory.setInitialCapacity(initialCapacity);
+ return this;
+ }
+
+ /**
+ * Sets the entry load factor for the next <code>RegionAttributes</code>
+ * created. This value is used in initializing the map that holds the entries.
+ *
+ * @param loadFactor
+ * the load factor of the entry map
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if loadFactor is nonpositive
+ * @see java.util.HashMap
+ * @see AttributesFactory#setLoadFactor
+ */
+ public RegionFactory<K,V> setLoadFactor(float loadFactor)
+ {
+ this.attrsFactory.setLoadFactor(loadFactor);
+ return this;
+ }
+
+ /**
+ * Sets the concurrency level tof the next <code>RegionAttributes</code>
+ * created. This value is used in initializing the map that holds the entries.
+ *
+ * @param concurrencyLevel
+ * the concurrency level of the entry map
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException
+ * if concurrencyLevel is nonpositive
+ * @see AttributesFactory#setConcurrencyLevel
+ */
+ public RegionFactory<K,V> setConcurrencyLevel(int concurrencyLevel)
+ {
+ this.attrsFactory.setConcurrencyLevel(concurrencyLevel);
+ return this;
+ }
+
+ /**
+ * Enables a versioning system that detects concurrent modifications and
+ * ensures that region contents are consistent across the distributed
+ * system. This setting must be the same in each member having the region.
+ *
+ * @since 7.0
+ * @param enabled whether concurrency checks should be enabled for the region
+ * @see AttributesFactory#setConcurrencyChecksEnabled
+ */
+ public RegionFactory<K,V> setConcurrencyChecksEnabled(boolean enabled)
+ {
+ this.attrsFactory.setConcurrencyChecksEnabled(enabled);
+ return this;
+ }
+
+ /**
+ * Returns whether or not disk writes are asynchronous.
+ *
+ * @return a reference to this RegionFactory object
+ * @see Region#writeToDisk
+ * @see AttributesFactory#setDiskWriteAttributes
+ * @deprecated as of 6.5 use {@link #setDiskStoreName} instead
+ *
+ */
+ @Deprecated
+ public RegionFactory<K,V> setDiskWriteAttributes(DiskWriteAttributes attrs)
+ {
+ this.attrsFactory.setDiskWriteAttributes(attrs);
+ return this;
+ }
+
+ /**
+ * Sets the DiskStore name attribute.
+ * This causes the region to belong to the DiskStore.
+ * @param name the name of the diskstore
+ * @return a reference to this RegionFactory object
+ * @since 6.5
+ *
+ * @see AttributesFactory#setDiskStoreName
+ */
+ public RegionFactory<K,V> setDiskStoreName(String name) {
+ this.attrsFactory.setDiskStoreName(name);
+ return this;
+ }
+
+ /**
+ * Sets whether or not the writing to the disk is synchronous.
+ *
+ * @param isSynchronous
+ * boolean if true indicates synchronous writes
+ * @return a reference to this RegionFactory object
+ * @since 6.5
+ */
+ public RegionFactory<K,V> setDiskSynchronous(boolean isSynchronous)
+ {
+ this.attrsFactory.setDiskSynchronous(isSynchronous);
+ return this;
+ }
+
+ /**
+ * Sets the directories to which the region's data are written. If multiple
+ * directories are used, GemFire will attempt to distribute the data evenly
+ * amongst them.
+ *
+ * @return a reference to this RegionFactory object
+ * @throws GemfireIOException if a directory cannot be created
+ *
+ * @see AttributesFactory#setDiskDirs
+ * @deprecated as of 6.5 use {@link DiskStoreFactory#setDiskDirs} instead
+ */
+ @Deprecated
+ public RegionFactory<K,V> setDiskDirs(File[] diskDirs)
+ {
+ this.attrsFactory.setDiskDirs(diskDirs);
+ return this;
+ }
+
+ /**
+ * Sets the directories to which the region's data are written and also set their sizes in megabytes
+ *
+ * @return a reference to this RegionFactory object
+ * @throws IllegalArgumentException if length of the size array
+ * does not match to the length of the dir array
+ * @throws GemfireIOException if a directory cannot be created
+ *
+ * @since 5.1
+ * @see AttributesFactory#setDiskDirsAndSizes
+ * @deprecated as of 6.5 use {@link DiskStoreFactory#setDiskDirsAndSizes} instead
+ */
+ @Deprecated
+ public RegionFactory<K,V> setDiskDirsAndSizes(File[] diskDirs,int[] diskSizes) {
+ this.attrsFactory.setDiskDirsAndSizes(diskDirs, diskSizes);
+ return this;
+ }
+
+ /**
+ * Sets the <code>PartitionAttributes</code> that describe how the region is
+ * partitioned among members of the distributed system.
+ *
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setPartitionAttributes
+ */
+ public RegionFactory<K,V> setPartitionAttributes(PartitionAttributes partition)
+ {
+ this.attrsFactory.setPartitionAttributes(partition);
+ return this;
+ }
+
+ /**
+ * Sets the <code>MembershipAttributes</code> that describe the membership
+ * roles required for reliable access to the region.
+ *
+ * @param ra the MembershipAttributes to use
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setMembershipAttributes
+ */
+ public RegionFactory<K,V> setMembershipAttributes(MembershipAttributes ra) {
+ this.attrsFactory.setMembershipAttributes(ra);
+ return this;
+ }
+
+ /**
+ * Sets how indexes on this region are kept current.
+ *
+ * @param synchronous
+ * whether indexes are maintained in a synchronized fashion
+ * @return a reference to this RegionFactory object
+ */
+ public RegionFactory<K,V> setIndexMaintenanceSynchronous(boolean synchronous)
+ {
+ this.attrsFactory.setIndexMaintenanceSynchronous(synchronous);
+ return this;
+ }
+
+ /**
+ * Sets whether statistics are enabled for this region and its entries.
+ *
+ * @param statisticsEnabled
+ * whether statistics are enabled
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setStatisticsEnabled
+ */
+ public RegionFactory<K,V> setStatisticsEnabled(boolean statisticsEnabled)
+ {
+ this.attrsFactory.setStatisticsEnabled(statisticsEnabled);
+ return this;
+ }
+
+ /**
+ * Sets whether operations on this region should be controlled by
+ * JTA transactions or not
+ * @since 5.0
+ */
+ public RegionFactory<K,V> setIgnoreJTA(boolean flag) {
+ this.attrsFactory.setIgnoreJTA(flag);
+ return this;
+ }
+
+ /**
+ * Sets whether this region should become lock grantor.
+ *
+ * @param isLockGrantor
+ * whether this region should become lock grantor
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setLockGrantor
+ */
+ public RegionFactory<K,V> setLockGrantor(boolean isLockGrantor)
+ {
+ this.attrsFactory.setLockGrantor(isLockGrantor);
+ return this;
+ }
+
+ /**
+ * Sets the kind of interest this region has in events occuring in other caches that define
+ * the region by the same name.
+ * @param sa the attributes decribing the interest
+ * @return a reference to this RegionFactory object
+ * @see AttributesFactory#setSubscriptionAttributes(SubscriptionAttributes)
+ */
+ public RegionFactory<K,V> setSubscriptionAttributes(SubscriptionAttributes sa) {
+ this.attrsFactory.setSubscriptionAttributes(sa);
+ return this;
+ }
+
+ /**
+ * Creates a region with the given name in this factory's {@link Cache}
+ * using the configuration contained in this factory. Validation of the
+ * provided attributes may cause exceptions to be thrown if there are problems
+ * with the configuration data.
+ *
+ * @param name
+ * the name of the region to create
+ *
+ * @return the region object
+ * @throws LeaseExpiredException
+ * if lease expired on distributed lock for Scope.GLOBAL
+ * @throws RegionExistsException
+ * if a region, shared or unshared, is already in this cache
+ * @throws TimeoutException
+ * if timed out getting distributed lock for Scope.GLOBAL
+ * @throws CacheClosedException
+ * if the cache is closed
+ * @throws IllegalStateException
+ * if the supplied RegionAttributes are incompatible with this region
+ * in another cache in the distributed system (see
+ * {@link AttributesFactory} for compatibility rules)
+ */
+ @SuppressWarnings("unchecked")
+ public Region<K,V> create(String name) throws CacheExistsException,
+ RegionExistsException, CacheWriterException, TimeoutException
+ {
+ @SuppressWarnings("deprecation")
+ RegionAttributes<K,V> ra = this.attrsFactory.create();
+ return getCache().createRegion(name, ra);
+ }
+ /**
+ * Creates a sub-region in the {@link Cache} using
+ * the configuration contained in this RegionFactory. Validation of the
+ * provided attributes may cause exceptions to be thrown if there are problems
+ * with the configuration data.
+ *
+ * @param parent
+ * the existing region that will contain the created sub-region
+ * @param name
+ * the name of the region to create
+ *
+ * @return the region object
+ * @throws RegionExistsException
+ * if a region with the given name already exists in this cache
+ * @throws RegionDestroyedException
+ * if the parent region has been closed or destroyed
+ * @throws CacheClosedException
+ * if the cache is closed
+ * @since 7.0
+ */
+ @SuppressWarnings("unchecked")
+ public Region<K,V> createSubregion(Region<?,?> parent, String name) throws RegionExistsException {
+ @SuppressWarnings("deprecation")
+ RegionAttributes<K,V> ra = this.attrsFactory.create();
+ return ((LocalRegion)parent).createSubregion(name, ra);
+ }
+
+ /**
+ * Sets cloning on region
+ * @param cloningEnable
+ * @return a reference to this RegionFactory object
+ * @since 6.1
+ * @see AttributesFactory#setCloningEnabled
+ */
+ public RegionFactory<K,V> setCloningEnabled(boolean cloningEnable) {
+ this.attrsFactory.setCloningEnabled(cloningEnable);
+ return this;
+ }
+
+ /**
+ * Adds a gatewaySenderId to the RegionAttributes
+ * @param gatewaySenderId
+ * @return a reference to this RegionFactory object
+ * @since 7.0
+ * @see AttributesFactory#addGatewaySenderId(String)
+ */
+ public RegionFactory<K,V> addGatewaySenderId(String gatewaySenderId)
+ {
+ this.attrsFactory.addGatewaySenderId(gatewaySenderId);
+ return this;
+ }
+
+ /**
+ * Adds a asyncEventQueueId to the RegionAttributes
+ *
+ * @param asyncEventQueueId id of AsyncEventQueue
+ * @return a reference to this RegionFactory instance
+ * @since 7.0
+ */
+ public RegionFactory<K,V> addAsyncEventQueueId(String asyncEventQueueId) {
+ this.attrsFactory.addAsyncEventQueueId(asyncEventQueueId);
+ return this;
+ }
+
+ /**
+ * Set the compressor to be used by this region for compressing
+ * region entry values.
+ * @param compressor a compressor
+ * @return a reference to this RegionFactory instance
+ * @since 8.0
+ */
+ public RegionFactory<K,V> setCompressor(Compressor compressor) {
+ this.attrsFactory.setCompressor(compressor);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionMembershipListener.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionMembershipListener.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionMembershipListener.java
new file mode 100644
index 0000000..584e4f5
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionMembershipListener.java
@@ -0,0 +1,74 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+import com.gemstone.gemfire.distributed.DistributedMember;
+
+/**
+ * A listener that can be implemented to handle region membership events.
+ *
+ * <p>
+ * Instead of implementing this interface it is recommended that you extend
+ * the {@link com.gemstone.gemfire.cache.util.RegionMembershipListenerAdapter} class.
+ *
+ * @author Darrel Schneider
+ *
+ *
+ * @see AttributesFactory#addCacheListener
+ * @see AttributesFactory#initCacheListeners
+ * @see RegionAttributes#getCacheListeners
+ * @see AttributesMutator#addCacheListener
+ * @see AttributesMutator#removeCacheListener
+ * @see AttributesMutator#initCacheListeners
+ * @since 5.0
+ */
+public interface RegionMembershipListener<K,V> extends CacheListener<K,V> {
+ /**
+ * Invoked when the listener is first initialized and is
+ * given the set of members that have the region created at that time.
+ * The listener is initialized when:
+ * <ul>
+ * <li> the region is created with an already added listener
+ * <li> a listener is added using the {@link AttributesMutator}.
+ * </ul>
+ * @param region the {@link Region} the listener is registered on
+ * @param initialMembers an array of the other members that have this region
+ * at the time this listener is added.
+ */
+ public void initialMembers(Region<K,V> region, DistributedMember[] initialMembers);
+ /**
+ * Invoked when another member has created the distributed region this
+ * listener is on.
+ * @param event the event from the member whose region was created.
+ */
+ public void afterRemoteRegionCreate(RegionEvent<K,V> event);
+
+ /**
+ * Invoked when another member's distributed region is no longer
+ * available to this cache due to normal operations.
+ * This can be triggered by one of the following methods:
+ * <ul>
+ * <li>{@link Region#localDestroyRegion()}
+ * <li>{@link Region#close}
+ * <li>{@link Cache#close()}
+ * </ul>
+ * This differs from afterRemoteRegionCrash notification in that the
+ * departed member performed an action either to remove its region or to close
+ * its region or cache.
+ * @param event the event from the member whose region is no longer available.
+ */
+ public void afterRemoteRegionDeparture(RegionEvent<K,V> event);
+ /**
+ * Invoked when another member's distributed region is no longer
+ * available to this cache because the member has crashed or is no
+ * longer reachable on the network.<p>
+
+ * @param event the event from the member whose region is no longer available.
+ */
+ public void afterRemoteRegionCrash(RegionEvent<K,V> event);
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionReinitializedException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionReinitializedException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionReinitializedException.java
new file mode 100644
index 0000000..61b9e6e
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionReinitializedException.java
@@ -0,0 +1,39 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+/**
+ * Indicates that the region has been reinitialized. Further operations
+ * on the region object are not allowed using this region reference.
+ * A new reference must be acquired from the Cache the region's parent
+ * region.
+ *
+ * @author Eric Zoerner
+ *
+ * @since 4.0
+ */
+public class RegionReinitializedException extends RegionDestroyedException {
+private static final long serialVersionUID = 8532904304288670752L;
+// private String regionFullPath;
+
+ /** Constructs a <code>RegionReinitializedException</code> with a message.
+ * @param msg the String message
+ */
+ public RegionReinitializedException(String msg, String regionFullPath) {
+ super(msg, regionFullPath);
+ }
+
+ /** Constructs a <code>RegionDestroyedException</code> with a message and
+ * a cause.
+ * @param s the String message
+ * @param ex the Throwable cause
+ */
+ public RegionReinitializedException(String s, String regionFullPath, Throwable ex) {
+ super(s, regionFullPath, ex);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleException.java
new file mode 100755
index 0000000..49a854e
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleException.java
@@ -0,0 +1,54 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+/**
+ * Indicates that a {@link Region} reliability failure has occurred.
+ * Reliability for a <code>Region</code> is defined by its
+ * {@link MembershipAttributes}.
+ *
+ * @author Kirk Lund
+ * @since 5.0
+ */
+public abstract class RegionRoleException extends RoleException {
+
+ /** The full path of the region affected by the reliability failure */
+ private String regionFullPath;
+
+ /**
+ * Constructs a <code>RegionRoleException</code> with a message.
+ * @param s the String message
+ * @param regionFullPath full path of region for which access was attempted
+ */
+ public RegionRoleException(String s, String regionFullPath) {
+ super(s);
+ this.regionFullPath = regionFullPath;
+ }
+
+ /**
+ * Constructs a <code>RegionRoleException</code> with a message and
+ * a cause.
+ * @param s the String message
+ * @param regionFullPath full path of region for which access was attempted
+ * @param ex the Throwable cause
+ */
+ public RegionRoleException(String s, String regionFullPath, Throwable ex) {
+ super(s, ex);
+ this.regionFullPath = regionFullPath;
+ }
+
+ /**
+ * Returns the full path of the region for which access was attempted.
+ * @return the full path of the region for which access was attempted
+ */
+ public String getRegionFullPath() {
+ return this.regionFullPath;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleListener.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleListener.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleListener.java
new file mode 100755
index 0000000..01a0663
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionRoleListener.java
@@ -0,0 +1,45 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+package com.gemstone.gemfire.cache;
+
+/**
+ * A listener that can be implemented to handle region reliability membership
+ * events. These are membership events that are specific to loss or gain of
+ * required roles as defined by the region's {@link MembershipAttributes}.
+ * <p>
+ * Instead of implementing this interface it is recommended that you extend
+ * the {@link com.gemstone.gemfire.cache.util.RegionRoleListenerAdapter}
+ * class.
+ *
+ * @author Kirk Lund
+ *
+ * @see AttributesFactory#setCacheListener
+ * @see RegionAttributes#getCacheListener
+ * @see AttributesMutator#setCacheListener
+ * @since 5.0
+ */
+public interface RegionRoleListener<K,V> extends CacheListener<K,V> {
+
+ /**
+ * Invoked when a required role has returned to the distributed system
+ * after being absent.
+ *
+ * @param event describes the member that fills the required role.
+ */
+ public void afterRoleGain(RoleEvent<K,V> event);
+
+ /**
+ * Invoked when a required role is no longer available in the distributed
+ * system.
+ *
+ * @param event describes the member that last filled the required role.
+ */
+ public void afterRoleLoss(RoleEvent<K,V> event);
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
new file mode 100644
index 0000000..9ea65c0
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/RegionService.java
@@ -0,0 +1,133 @@
+/*=========================================================================
+ * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved.
+ * This product is protected by U.S. and international copyright
+ * and intellectual property laws. Pivotal products are covered by
+ * more patents listed at http://www.pivotal.io/patents.
+ *========================================================================
+ */
+
+package com.gemstone.gemfire.cache;
+
+import java.util.Properties;
+import java.util.Set;
+
+import com.gemstone.gemfire.CancelCriterion;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.pdx.PdxInstance;
+import com.gemstone.gemfire.pdx.PdxInstanceFactory;
+
+/**
+ * A RegionService provides access to existing {@link Region regions} that exist
+ * in a {@link GemFireCache GemFire cache}.
+ * Regions can be obtained using {@link #getRegion}
+ * and queried using {@link #getQueryService}.
+ * The service should be {@link #close closed} to free up resources
+ * once it is no longer needed.
+ * Once it {@link #isClosed is closed} any attempt to use it or any {@link Region regions}
+ * obtained from it will cause a {@link CacheClosedException} to be thrown.
+ * <p>
+ * Instances of the interface are created using one of the following methods:
+ * <ul>
+ * <li> {@link CacheFactory#create()} creates a server instance of {@link Cache}.
+ * <li> {@link ClientCacheFactory#create()} creates a client instance of {@link ClientCache}.
+ * <li> {@link ClientCache#createAuthenticatedView(Properties)} creates a client multiuser authenticated cache view.
+ * </ul>
+ * <p>
+ *
+ * @since 6.5
+ * @author darrel
+ */
+public interface RegionService {
+ /**
+ * the cancellation criterion for this service
+ * @return the service's cancellation object
+ */
+ public CancelCriterion getCancelCriterion();
+ /**
+ * Return the existing region (or subregion) with the specified
+ * path.
+ * Whether or not the path starts with a forward slash it is interpreted as a
+ * full path starting at a root.
+ *
+ * @param path the path to the region
+ * @return the Region or null if not found
+ * @throws IllegalArgumentException if path is null, the empty string, or "/"
+ */
+ public <K,V> Region<K,V> getRegion(String path);
+
+ /**
+ * Returns unmodifiable set of the root regions that are in the region service.
+ * This set is a snapshot; it is not backed by the region service.
+ *
+ * @return a Set of regions
+ */
+ public Set<Region<?,?>> rootRegions();
+
+ // We did not have time to add this feature to 6.6.2
+// /**
+// * Returns a factory that can create a {@link PdxInstance}.
+// * If you want to be able to deserialize the PdxInstance then name
+// * must be a correct class name and expectDomainClass should be set to true.
+// * If you want to just create an object that will always be a PdxInstance set expectDomainClass to false.
+// * @param name the name of the pdx type that
+// * the PdxInstance will represent. If expectDomainClass is true then
+// * this must be the full class and package name of the domain class.
+// * Otherwise it just needs to be a unique string that identifies this instances type.
+// * @param expectDomainClass if true then during deserialization a domain class will
+// * be expected. If false then this type will always deserialize to a PdxInstance
+// * even if read-serialized is false and {@link PdxInstance#getObject()} will return
+// * the PdxInstance.
+// * @return the factory
+// */
+// public PdxInstanceFactory createPdxInstanceFactory(String name, boolean expectDomainClass);
+
+ /**
+ * Returns a factory that can create a {@link PdxInstance}.
+ * @param className the fully qualified class name that the PdxInstance will become
+ * when it is fully deserialized.
+ * @return the factory
+ * @since 6.6.2
+ */
+ public PdxInstanceFactory createPdxInstanceFactory(String className);
+ /**
+ * Creates and returns a PdxInstance that represents an enum value.
+ * @param className the name of the enum class
+ * @param enumName the name of the enum constant
+ * @param enumOrdinal the ordinal value of the enum constant
+ * @return a PdxInstance that represents the enum value
+ * @throws IllegalArgumentException if className or enumName are <code>null</code>.
+ * @since 6.6.2
+ */
+ public PdxInstance createPdxEnum(String className, String enumName, int enumOrdinal);
+
+ /**
+ * Return the QueryService for this region service.
+ * For a region service in a client the returned QueryService will
+ * execute queries on the server.
+ * For a region service not in a client the returned QueryService will
+ * execute queries on the local and peer regions.
+ */
+ public QueryService getQueryService();
+ /**
+ * Terminates this region service and releases all its resources.
+ * Calls {@link Region#close} on each region in the service.
+ * After this service is closed, any further
+ * method calls on this service or any region object
+ * obtained from the service will throw
+ * {@link CacheClosedException}, unless otherwise noted.
+ * @throws CacheClosedException if the service is already closed.
+ */
+ public void close();
+ /**
+ * Indicates if this region service has been closed.
+ * After a new service is created, this method returns false;
+ * After close is called on this service, this method
+ * returns true. This method does not throw <code>CacheClosedException</code>
+ * if the service is closed.
+ *
+ * @return true, if this service has just been created or has started to close; false, otherwise
+ */
+ public boolean isClosed();
+}
\ No newline at end of file