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:27 UTC
[22/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/MembershipAttributes.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MembershipAttributes.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MembershipAttributes.java
new file mode 100755
index 0000000..aa1e98d
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MembershipAttributes.java
@@ -0,0 +1,260 @@
+/*=========================================================================
+ * 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.DataSerializable;
+import com.gemstone.gemfire.DataSerializer;
+import com.gemstone.gemfire.distributed.internal.membership.InternalRole;
+import com.gemstone.gemfire.distributed.Role;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Configuration attributes for defining reliability requirements and behavior
+ * for a <code>Region</code>.
+ *
+ * <p><code>MembershipAttributes</code> provides options for configuring a
+ * <code>Region</code> to require one or more membership roles to be present
+ * in the system for reliable access to the <code>Region</code>. Each
+ * {@link Role} is a user defined string name, such as Producer or Backup or
+ * FooProducer.</p>
+ *
+ * <p>The {@link LossAction} defines the behavior when one or
+ * more required roles are missing.</p>
+ *
+ * <p>The {@link ResumptionAction} specifies the action to be taken when
+ * reliability resumes.</p>
+ *
+ * <p><code>MembershipAttributes</code> have no effect unless one or more
+ * required roles are specified. These attributes are immutable after the
+ * <code>Region</code> has been created.</p>
+ *
+ * @author Kirk Lund
+ * @since 5.0
+ */
+public class MembershipAttributes implements DataSerializable, Externalizable {
+
+ /**
+ * Array of required role names by this process for reliable access to the
+ * region
+ */
+ private /*final*/ Set<Role> requiredRoles;
+
+ /**
+ * The configuration defining how this process behaves when there are
+ * missing required roles
+ */
+ private /*final*/ LossAction lossAction;
+
+ /**
+ * The action to take when missing required roles return to the system
+ */
+ private /*final*/ ResumptionAction resumptionAction;
+
+ /**
+ * Creates a new <code>MembershipAttributes</code> with the default
+ * configuration of no required roles.
+ */
+ public MembershipAttributes() {
+ this.requiredRoles = Collections.emptySet();
+ this.lossAction = LossAction.FULL_ACCESS;
+ this.resumptionAction = ResumptionAction.NONE;
+ }
+
+ /**
+ * Creates a new <code>MembershipAttributes</code> with the specified
+ * required role names. Reliability policy will default to {@linkplain
+ * LossAction#NO_ACCESS NO_ACCESS}, and resumption action will
+ * default to {@linkplain ResumptionAction#REINITIALIZE REINITIALIZE}.
+ *
+ * @param requiredRoles
+ * array of role names required by this process for reliable access to
+ * the region
+ * @throws IllegalArgumentException
+ * if no requiredRoles are specified
+ */
+ public MembershipAttributes(String[] requiredRoles){
+ this(requiredRoles, LossAction.NO_ACCESS, ResumptionAction.REINITIALIZE);
+ }
+
+ /**
+ * Creates a new <code>MembershipAttributes</code> with the specified
+ * required role names, reliability policy, and resumption action.
+ *
+ * @param requiredRoles
+ * array of role names required by this process for reliable access to
+ * the region
+ * @param lossAction
+ * the configuration defining how this process behaves when there are
+ * missing required roles
+ * @param resumptionAction
+ * the action to take when missing required roles return to the system
+ * @throws IllegalArgumentException
+ * if the resumptionAction is incompatible with the lossAction
+ * or if no requiredRoles are specified
+ */
+ public MembershipAttributes(String[] requiredRoles,
+ LossAction lossAction,
+ ResumptionAction resumptionAction) {
+ this.requiredRoles = toRoleSet(requiredRoles);
+ if (this.requiredRoles.isEmpty()) {
+ throw new IllegalArgumentException(LocalizedStrings.MembershipAttributes_ONE_OR_MORE_REQUIRED_ROLES_MUST_BE_SPECIFIED.toLocalizedString());
+ }
+ this.lossAction = lossAction;
+ this.resumptionAction = resumptionAction;
+ }
+
+ /**
+ * Returns the set of {@linkplain com.gemstone.gemfire.distributed.Role
+ * Role}s that are required for the reliability of this region.
+ */
+ public Set<Role> getRequiredRoles() {
+ return Collections.unmodifiableSet(this.requiredRoles);
+ }
+
+ /**
+ * Returns true if there are one or more required roles specified.
+ */
+ public boolean hasRequiredRoles() {
+ return !this.requiredRoles.isEmpty();
+ }
+
+ /**
+ * Returns the reliability policy that describes behavior if any required
+ * roles are missing.
+ */
+ public LossAction getLossAction() {
+ return this.lossAction;
+ }
+
+ /**
+ * Returns the resumption action that describes behavior when
+ */
+ public ResumptionAction getResumptionAction() {
+ return this.resumptionAction;
+ }
+
+ private final Set<Role> toRoleSet(String[] roleNames) {
+ if (roleNames == null || roleNames.length == 0) {
+ return Collections.emptySet();
+ }
+ Set<Role> roleSet = new HashSet<Role>();
+ for (int i = 0; i < roleNames.length; i++) {
+ roleSet.add(InternalRole.getRole(roleNames[i]));
+ }
+ return roleSet;
+ }
+
+ /**
+ * Indicates whether some other object is "equal to" this one.
+ *
+ * @param other the reference object with which to compare.
+ * @return true if this object is the same as the obj argument;
+ * false otherwise.
+ */
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) return true;
+ if (other == null) return false;
+ if (!(other instanceof MembershipAttributes)) return false;
+ final MembershipAttributes that = (MembershipAttributes) other;
+
+ if (this.requiredRoles != that.requiredRoles &&
+ !(this.requiredRoles != null &&
+ this.requiredRoles.equals(that.requiredRoles))) return false;
+ if (this.lossAction != that.lossAction &&
+ !(this.lossAction != null &&
+ this.lossAction.equals(that.lossAction))) return false;
+ if (this.resumptionAction != that.resumptionAction &&
+ !(this.resumptionAction != null &&
+ this.resumptionAction.equals(that.resumptionAction))) return false;
+
+ return true;
+ }
+
+ /**
+ * Returns a hash code for the object. This method is supported for the
+ * benefit of hashtables such as those provided by java.util.Hashtable.
+ *
+ * @return the integer 0 if description is null; otherwise a unique integer.
+ */
+ @Override
+ public int hashCode() {
+ int result = 17;
+ final int mult = 37;
+
+ result = mult * result +
+ (this.requiredRoles == null ? 0 : this.requiredRoles.hashCode());
+ result = mult * result +
+ (this.lossAction == null ? 0 : this.lossAction.hashCode());
+ result = mult * result +
+ (this.resumptionAction == null ? 0 : this.resumptionAction.hashCode());
+
+ return result;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return a string representation of the object
+ */
+ @Override
+ public String toString() {
+ if (!hasRequiredRoles()) {
+ return "RequiredRoles(none)";
+ }
+ else {
+ final StringBuffer sb = new StringBuffer();
+ sb.append("RequiredRoles(");
+ boolean comma = false;
+ for (Iterator<Role> iter = this.requiredRoles.iterator(); iter.hasNext();) {
+ if (comma) sb.append(",");
+ Role role = iter.next();
+ sb.append(role.getName());
+ comma = true;
+ }
+ sb.append("); Policy:");
+ sb.append(this.lossAction.toString());
+ sb.append("; Action:");
+ sb.append(this.resumptionAction.toString());
+ return sb.toString();
+ }
+ }
+
+ public void toData(DataOutput out) throws IOException {
+ String[] names = new String[this.requiredRoles.size()];
+ Iterator<Role> iter = this.requiredRoles.iterator();
+ for (int i = 0; i < names.length; i++) {
+ names[i] = iter.next().getName();
+ }
+ DataSerializer.writeStringArray(names, out);
+ out.writeByte(this.lossAction.ordinal);
+ out.writeByte(this.resumptionAction.ordinal);
+ }
+
+ public void fromData(DataInput in)
+ throws IOException, ClassNotFoundException {
+ this.requiredRoles = toRoleSet(DataSerializer.readStringArray(in));
+ this.lossAction = LossAction.fromOrdinal(in.readByte());
+ this.resumptionAction = ResumptionAction.fromOrdinal(in.readByte());
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ // added to fix bug 36619
+ toData(out);
+ }
+
+ public void readExternal(ObjectInput in)
+ throws IOException, ClassNotFoundException {
+ // added to fix bug 36619
+ fromData(in);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MirrorType.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MirrorType.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MirrorType.java
new file mode 100644
index 0000000..9e2e060
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/MirrorType.java
@@ -0,0 +1,127 @@
+/*=========================================================================
+ * 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.*;
+
+/**
+ * Enumerated type for region mirroring.
+ *
+ * @author Eric Zoerner
+ *
+ *
+ * @see AttributesFactory#setMirrorType
+ * @see RegionAttributes#getMirrorType
+ *
+ * @deprecated as of GemFire 5.0, use {@link DataPolicy} instead.
+ *
+ * @since 3.0
+ */
+@Deprecated
+public class MirrorType implements java.io.Serializable {
+ private static final long serialVersionUID = -6632651349646672540L;
+
+ /** New entries created in other caches for this region are
+ * not automatically propagated to this region in this cache.
+ * @deprecated as of GemFire 5.0, use {@link DataPolicy#NORMAL} instead.
+ */
+ @Deprecated
+ public static final MirrorType NONE = new MirrorType("NONE", DataPolicy.NORMAL);
+
+ /**
+ * New entries created in other caches for this region are
+ * propagated to this region in this cache, but the value is not
+ * necessarily copied to this cache with the key.
+ * @deprecated as of GemFire 5.0, use {@link DataPolicy#REPLICATE} instead.
+ */
+ @Deprecated
+ public static final MirrorType KEYS = new MirrorType("KEYS", DataPolicy.REPLICATE);
+
+ /**
+ * New entries created in other caches for this region
+ * are propagated to this region in this cache and the value
+ * is also copied to this cache.
+ * @deprecated as of GemFire 5.0, use {@link DataPolicy#REPLICATE} instead.
+ */
+ @Deprecated
+ public static final MirrorType KEYS_VALUES = new MirrorType("KEYS_VALUES", DataPolicy.REPLICATE);
+
+
+ /** The name of this mirror type. */
+ private final transient String name;
+
+ /**
+ * The data policy that corresponds to this mirror type.
+ */
+ private final transient DataPolicy dataPolicy;
+
+ // The 4 declarations below are necessary for serialization
+ /** int used as ordinal to represent this Scope */
+ public final int ordinal = nextOrdinal++;
+
+ private static int nextOrdinal = 0;
+
+ private static final MirrorType[] VALUES =
+ { NONE, KEYS, KEYS_VALUES };
+
+ private Object readResolve() throws ObjectStreamException {
+ return VALUES[ordinal]; // Canonicalize
+ }
+
+
+ /** Creates a new instance of MirrorType. */
+ private MirrorType(String name, DataPolicy dataPolicy) {
+ this.name = name;
+ this.dataPolicy = dataPolicy;
+ }
+
+ /** Return the MirrorType represented by specified ordinal */
+ public static MirrorType fromOrdinal(int ordinal) {
+ return VALUES[ordinal];
+ }
+
+
+ /**
+ * Returns the {@link DataPolicy} that corresponds to this mirror type.
+ * @since 5.0
+ */
+ public DataPolicy getDataPolicy() {
+ return this.dataPolicy;
+ }
+
+ /** Return whether this is <code>KEYS</code>. */
+ public boolean isKeys() {
+ return this == KEYS;
+ }
+
+ /** Return whether this is <code>KEYS_VALUES</code>. */
+ public boolean isKeysValues() {
+ return this == KEYS_VALUES;
+ }
+
+ /** Return whether this is <code>NONE</code>. */
+ public boolean isNone() {
+ return this == NONE;
+ }
+
+ /** Return whether this indicates a mirrored type.
+ * @return true if <code>KEYS</code> or <code>KEYS_VALUES</code>
+ */
+ public boolean isMirrored() {
+ return this != NONE;
+ }
+
+ /** Returns a string representation for this mirror type.
+ * @return the name of this mirror type
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoQueueServersAvailableException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoQueueServersAvailableException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoQueueServersAvailableException.java
new file mode 100644
index 0000000..4eee7b4
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoQueueServersAvailableException.java
@@ -0,0 +1,55 @@
+/*=========================================================================
+ * 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.cache.client.ServerConnectivityException;
+
+/**
+ * Indicates that this client cannot contact any queue servers and
+ * therefore cannot perform operations that require a queue, such as
+ * registering interest.
+ * @author dsmith
+ * @since 5.7
+ */
+public class NoQueueServersAvailableException extends ServerConnectivityException {
+
+ private static final long serialVersionUID = 8484086019155762365L;
+
+ /**
+ * Create a new instance of NoPrimaryAvailableException without a detail message or cause.
+ */
+ public NoQueueServersAvailableException() {
+ }
+
+ /**
+ *
+ * Create a new instance of NoPrimaryAvailableException with a detail message
+ * @param message the detail message
+ */
+ public NoQueueServersAvailableException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create a new instance of NoPrimaryAvailableException with a detail message and cause
+ * @param message the detail message
+ * @param cause the cause
+ */
+ public NoQueueServersAvailableException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create a new instance of NoPrimaryAvailableException with a cause
+ * @param cause the cause
+ */
+ public NoQueueServersAvailableException(Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoSubscriptionServersAvailableException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoSubscriptionServersAvailableException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoSubscriptionServersAvailableException.java
new file mode 100644
index 0000000..3e19a5e
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/NoSubscriptionServersAvailableException.java
@@ -0,0 +1,55 @@
+/*=========================================================================
+ * 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.cache.client.ServerConnectivityException;
+
+/**
+ * Indicates that this client cannot contact any servers and
+ * therefore cannot perform operations that require subscriptions, such as
+ * registering interest.
+ * @author dsmith
+ * @since 5.7
+ */
+public class NoSubscriptionServersAvailableException extends ServerConnectivityException {
+
+ private static final long serialVersionUID = 8484086019155762365L;
+
+ /**
+ * Create a new instance of NoSubscriptionServersAvailableException without a detail message or cause.
+ */
+ public NoSubscriptionServersAvailableException() {
+ }
+
+ /**
+ *
+ * Create a new instance of NoSubscriptionServersAvailableException with a detail message
+ * @param message the detail message
+ */
+ public NoSubscriptionServersAvailableException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create a new instance of NoSubscriptionServersAvailableException with a detail message and cause
+ * @param message the detail message
+ * @param cause the cause
+ */
+ public NoSubscriptionServersAvailableException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create a new instance of NoSubscriptionServersAvailableException with a cause
+ * @param cause the cause
+ */
+ public NoSubscriptionServersAvailableException(Throwable cause) {
+ super(cause);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/Operation.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/Operation.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/Operation.java
new file mode 100644
index 0000000..c2571fe
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/Operation.java
@@ -0,0 +1,987 @@
+/*=========================================================================
+ * 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 com.gemstone.gemfire.internal.cache.OpType;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+
+/**
+ * Enumerated type for an event operation.
+ * This class describes the operation that generated the event.
+ *
+ * @author Darrel Schneider
+ *
+ *
+ * @see CacheEvent#getOperation
+ *
+ * @since 5.0
+ */
+public final class Operation implements java.io.Serializable {
+ private static final long serialVersionUID = -7521751729852504238L;
+
+ private static byte nextOrdinal = 0;
+ private static final Operation[] VALUES = new Operation[55];
+
+ private static final byte OP_TYPE_CREATE = OpType.CREATE;
+ private static final byte OP_TYPE_UPDATE = OpType.UPDATE;
+ private static final byte OP_TYPE_GET = OpType.GET;
+ private static final byte OP_TYPE_INVALIDATE = OpType.INVALIDATE;
+ private static final byte OP_TYPE_GET_ENTRY = OpType.GET_ENTRY;
+ private static final byte OP_TYPE_CONTAINS_KEY = OpType.CONTAINS_KEY;
+ private static final byte OP_TYPE_CONTAINS_VALUE = OpType.CONTAINS_VALUE;
+ private static final byte OP_TYPE_DESTROY = OpType.DESTROY;
+ private static final byte OP_TYPE_CONTAINS_VALUE_FOR_KEY = OpType.CONTAINS_VALUE_FOR_KEY;
+ private static final byte OP_TYPE_FUNCTION_EXECUTION = OpType.FUNCTION_EXECUTION;
+ private static final byte OP_TYPE_CLEAR = OpType.CLEAR;
+ private static final byte OP_TYPE_MARKER = OpType.MARKER;
+ private static final byte OP_TYPE_UPDATE_VERSION = OpType.UPDATE_ENTRY_VERSION;
+
+ private static final int OP_DETAILS_NONE = 0;
+ private static final int OP_DETAILS_SEARCH = 1;
+ private static final int OP_DETAILS_LOCAL_LOAD = 2;
+ private static final int OP_DETAILS_NET_LOAD = 4;
+ private static final int OP_DETAILS_EXPIRE = 8;
+ private static final int OP_DETAILS_EVICT = 16;
+ private static final int OP_DETAILS_PUTALL = 32;
+ private static final int OP_DETAILS_GUARANTEES_OLD_VALUE = 64;
+ private static final int OP_DETAILS_REMOVEALL = 128;
+
+ /**
+ * TAKE NOTE!!!
+ * The order if the following static constructors calls must be maintained for backwards compatibility.
+ * Any new operations need to be added to the end.
+ */
+
+ /**
+ * A marker operation.
+ */
+ public static final Operation MARKER
+ = new Operation("MARKER",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_MARKER,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry creation.
+ * @see Region#create(Object, Object)
+ */
+ public static final Operation CREATE
+ = new Operation("CREATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry creation caused by a putAll invocation
+ * @see Region#putAll
+ */
+ public static final Operation PUTALL_CREATE
+ = new Operation("PUTALL_CREATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_PUTALL
+ );
+
+ /**
+ * A 'value for key' operation.
+ * @see Region#get(Object)
+ */
+ public static final Operation GET
+ = new Operation("GET",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_GET,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A 'entry for key' operation.
+ * @see Region#getEntry(Object)
+ */
+ public static final Operation GET_ENTRY
+ = new Operation("GET_ENTRY",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_GET_ENTRY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A 'check for existence of key' operation.
+ * @see Region#containsKey(Object)
+ */
+ public static final Operation CONTAINS_KEY
+ = new Operation("CONTAINS_KEY",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CONTAINS_KEY,
+ OP_DETAILS_NONE
+ );
+ /**
+ * A 'check for existence of value' operation.
+ * @see Region#containsValueForKey(Object)
+ */
+ public static final Operation CONTAINS_VALUE
+ = new Operation("CONTAINS_VALUE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CONTAINS_VALUE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A 'check for existence of value for given key' operation.
+ * @see Region#containsValueForKey(Object)
+ */
+ public static final Operation CONTAINS_VALUE_FOR_KEY
+ = new Operation("CONTAINS_VALUE_FOR_KEY",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CONTAINS_VALUE_FOR_KEY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A 'function execution' operation.
+ * @see FunctionService
+ */
+ public static final Operation FUNCTION_EXECUTION
+ = new Operation("FUNCTION_EXECUTION",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_FUNCTION_EXECUTION,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry creation caused by a netsearch
+ * @see Region#get(Object)
+ */
+ public static final Operation SEARCH_CREATE
+ = new Operation("SEARCH_CREATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_SEARCH
+ );
+
+ /**
+ * An entry creation caused by a local loader
+ * @see Region#get(Object)
+ * @see CacheLoader
+ */
+ public static final Operation LOCAL_LOAD_CREATE
+ = new Operation("LOCAL_LOAD_CREATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_LOCAL_LOAD
+ );
+ /**
+ * An entry creation caused by a net loader
+ * @see Region#get(Object)
+ * @see CacheLoader
+ */
+ public static final Operation NET_LOAD_CREATE
+ = new Operation("NET_LOAD_CREATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_NET_LOAD
+ );
+
+ /**
+ * An entry update.
+ * @see Region#put(Object, Object)
+ */
+ public static final Operation UPDATE
+ = new Operation("UPDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_UPDATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry update caused by a putAll invocation.
+ * @see Region#putAll
+ */
+ public static final Operation PUTALL_UPDATE
+ = new Operation("PUTALL_UPDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_UPDATE,
+ OP_DETAILS_PUTALL
+ );
+
+ /**
+ * An entry update caused by a net search.
+ * @see Region#get(Object)
+ */
+ public static final Operation SEARCH_UPDATE
+ = new Operation("SEARCH_UPDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_UPDATE,
+ OP_DETAILS_SEARCH
+ );
+
+ /**
+ * An entry update caused by a local load.
+ * @see Region#get(Object)
+ * @see CacheLoader
+ */
+ public static final Operation LOCAL_LOAD_UPDATE
+ = new Operation("LOCAL_LOAD_UPDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_UPDATE,
+ OP_DETAILS_LOCAL_LOAD
+ );
+
+ /**
+ * An entry update caused by a net load.
+ * @see Region#get(Object)
+ * @see CacheLoader
+ */
+ public static final Operation NET_LOAD_UPDATE
+ = new Operation("NET_LOAD_UPDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_UPDATE,
+ OP_DETAILS_NET_LOAD
+ );
+
+ /**
+ * An entry distributed invalidate.
+ * @see Region#invalidate(Object)
+ */
+ public static final Operation INVALIDATE
+ = new Operation("INVALIDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry local invalidate.
+ * @see Region#localInvalidate(Object)
+ */
+ public static final Operation LOCAL_INVALIDATE
+ = new Operation("LOCAL_INVALIDATE",
+ true, // isLocal
+ false, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry distributed destroy.
+ * @see Region#destroy(Object)
+ */
+ public static final Operation DESTROY
+ = new Operation("DESTROY",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+ /**
+ * An entry local destroy.
+ * @see Region#localDestroy(Object)
+ */
+ public static final Operation LOCAL_DESTROY
+ = new Operation("LOCAL_DESTROY",
+ true, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry local destroy caused by an eviction.
+ * @see Region#localDestroy(Object)
+ */
+ public static final Operation EVICT_DESTROY
+ = new Operation("EVICT_DESTROY",
+ true, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_EVICT
+ );
+
+ /**
+ * A region load snapshot.
+ * @see Region#loadSnapshot
+ */
+ public static final Operation REGION_LOAD_SNAPSHOT
+ = new Operation("REGION_LOAD_SNAPSHOT",
+ false, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region local destroy.
+ * @see Region#localDestroyRegion()
+ */
+ public static final Operation REGION_LOCAL_DESTROY
+ = new Operation("REGION_LOCAL_DESTROY",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region create.
+ * @see Region#createSubregion
+ * @see Cache#createRegion
+ */
+ public static final Operation REGION_CREATE
+ = new Operation("REGION_CREATE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region close
+ * @see Region#close
+ */
+ public static final Operation REGION_CLOSE
+ = new Operation("REGION_CLOSE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY, // @todo darrel: should close be a destroy?
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region distributed destroy.
+ * @see Region#destroyRegion()
+ */
+ public static final Operation REGION_DESTROY
+ = new Operation("REGION_DESTROY",
+ false, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An entry distributed destroy triggered by expiration
+ * @see RegionAttributes#getEntryTimeToLive
+ * @see RegionAttributes#getEntryIdleTimeout
+ * @see ExpirationAction#DESTROY
+ */
+ public static final Operation EXPIRE_DESTROY
+ = new Operation("EXPIRE_DESTROY",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_EXPIRE
+ );
+ /**
+ * An entry local destroy triggered by expiration
+ * @see RegionAttributes#getEntryTimeToLive
+ * @see RegionAttributes#getEntryIdleTimeout
+ * @see ExpirationAction#LOCAL_DESTROY
+ */
+ public static final Operation EXPIRE_LOCAL_DESTROY
+ = new Operation("EXPIRE_LOCAL_DESTROY",
+ true, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_EXPIRE
+ );
+ /**
+ * An entry distributed invalidate triggered by expiration
+ * @see RegionAttributes#getEntryTimeToLive
+ * @see RegionAttributes#getEntryIdleTimeout
+ * @see ExpirationAction#INVALIDATE
+ */
+ public static final Operation EXPIRE_INVALIDATE
+ = new Operation("EXPIRE_INVALIDATE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_EXPIRE
+ );
+
+ /**
+ * An entry local invalidate triggered by expiration
+ * @see RegionAttributes#getEntryTimeToLive
+ * @see RegionAttributes#getEntryIdleTimeout
+ * @see ExpirationAction#LOCAL_INVALIDATE
+ */
+ public static final Operation EXPIRE_LOCAL_INVALIDATE
+ = new Operation("EXPIRE_LOCAL_INVALIDATE",
+ true, // isLocal
+ false, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_EXPIRE
+ );
+
+ /**
+ * A region distributed destroy triggered by expiration
+ * @see RegionAttributes#getRegionTimeToLive
+ * @see RegionAttributes#getRegionIdleTimeout
+ * @see ExpirationAction#DESTROY
+ */
+ public static final Operation REGION_EXPIRE_DESTROY
+ = new Operation("REGION_EXPIRE_DESTROY",
+ false, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_EXPIRE
+ );
+ /**
+ * A region local destroy triggered by expiration
+ * @see RegionAttributes#getRegionTimeToLive
+ * @see RegionAttributes#getRegionIdleTimeout
+ * @see ExpirationAction#LOCAL_DESTROY
+ */
+ public static final Operation REGION_EXPIRE_LOCAL_DESTROY
+ = new Operation("REGION_EXPIRE_LOCAL_DESTROY",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_EXPIRE
+ );
+ /**
+ * A region distributed invalidate triggered by expiration
+ * @see RegionAttributes#getRegionTimeToLive
+ * @see RegionAttributes#getRegionIdleTimeout
+ * @see ExpirationAction#INVALIDATE
+ */
+ public static final Operation REGION_EXPIRE_INVALIDATE
+ = new Operation("REGION_EXPIRE_INVALIDATE",
+ false, // isLocal
+ true, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_EXPIRE
+ );
+ /**
+ * A region local invalidate triggered by expiration
+ * @see RegionAttributes#getRegionTimeToLive
+ * @see RegionAttributes#getRegionIdleTimeout
+ * @see ExpirationAction#LOCAL_INVALIDATE
+ */
+ public static final Operation REGION_EXPIRE_LOCAL_INVALIDATE
+ = new Operation("REGION_EXPIRE_LOCAL_INVALIDATE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_EXPIRE
+ );
+ /**
+ * A region local invalidate.
+ * @see Region#localInvalidateRegion()
+ */
+ public static final Operation REGION_LOCAL_INVALIDATE
+ = new Operation("REGION_LOCAL_INVALIDATE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region distributed invalidate.
+ * @see Region#invalidateRegion()
+ */
+ public static final Operation REGION_INVALIDATE
+ = new Operation("REGION_INVALIDATE",
+ false, // isLocal
+ true, // isRegion
+ OP_TYPE_INVALIDATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region clear.
+ * @see Region#clear
+ */
+ public static final Operation REGION_CLEAR
+ = new Operation("REGION_CLEAR",
+ false, // isLocal
+ true, // isRegion
+ OP_TYPE_CLEAR,
+ OP_DETAILS_NONE
+ );
+ /**
+ * A region local clear.
+ * @see Region#localClear
+ */
+ public static final Operation REGION_LOCAL_CLEAR
+ = new Operation("REGION_LOCAL_CLEAR",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_CLEAR,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A cache create. Note that this is marked as a region operation.
+ * @see CacheFactory#create
+ */
+ public static final Operation CACHE_CREATE
+ = new Operation("CACHE_CREATE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A cache close. Note that this is marked as a region operation.
+ * @see Cache#close()
+ */
+ public static final Operation CACHE_CLOSE
+ = new Operation("CACHE_CLOSE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY, // @todo darrel: should close be a destroy?
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A cache close due to being forced out of the distributed system
+ * by other members. This typically happens
+ * when a member becomes unresponsive and does not respond to heartbeat requests
+ * within the <a href="../distributed/DistributedSystem.html#member-timeout">"member-timeout"</a>
+ * period.<br>
+ * Note that this is marked as a region operation.
+ */
+ public static final Operation FORCED_DISCONNECT
+ = new Operation("FORCED_DISCONNECT",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A region destroy triggered by {@link ResumptionAction#REINITIALIZE}.
+ * @see ResumptionAction#REINITIALIZE
+ */
+ public static final Operation REGION_REINITIALIZE
+ = new Operation("REGION_REINITIALIZE",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * A cache close triggered by {@link LossAction#RECONNECT}.
+ * @see LossAction#RECONNECT
+ */
+ public static final Operation CACHE_RECONNECT
+ = new Operation("CACHE_RECONNECT",
+ true, // isLocal
+ true, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An atomic entry creation operation
+ * @see java.util.concurrent.ConcurrentMap#putIfAbsent(Object, Object)
+ * @since 6.5
+ */
+ public static final Operation PUT_IF_ABSENT
+ = new Operation("PUT_IF_ABSENT",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_CREATE,
+ OP_DETAILS_GUARANTEES_OLD_VALUE
+ );
+
+ /**
+ * An atomic update operation
+ * @see java.util.concurrent.ConcurrentMap#replace(Object, Object, Object)
+ * @since 6.5
+ */
+ public static final Operation REPLACE
+ = new Operation("REPLACE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_UPDATE,
+ OP_DETAILS_GUARANTEES_OLD_VALUE);
+
+ /**
+ * An atomic destroy destroy operation
+ * @see java.util.concurrent.ConcurrentMap#remove(Object, Object)
+ * @since 6.5
+ */
+ public static final Operation REMOVE
+ = new Operation("REMOVE",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_NONE
+ );
+
+ /**
+ * An internal operation used to update the version stamp of an entry.
+ */
+ public static final Operation UPDATE_VERSION_STAMP
+ = new Operation("UPDATE_VERSION",
+ false, //isLocal
+ false, //isRegion
+ OP_TYPE_UPDATE_VERSION, //opType
+ OP_DETAILS_NONE //opDetails
+ );
+
+ /**
+ * An entry distributed destroy caused by a removeAll.
+ * @see Region#removeAll(java.util.Collection)
+ * @since 8.1
+ */
+ public static final Operation REMOVEALL_DESTROY
+ = new Operation("REMOVEALL_DESTROY",
+ false, // isLocal
+ false, // isRegion
+ OP_TYPE_DESTROY,
+ OP_DETAILS_REMOVEALL
+ );
+
+ /** The name of this mirror type. */
+ private final transient String name;
+
+ /** byte used as ordinal to represent this Operation */
+ public final byte ordinal;
+
+ /** True if a local op; false if distributed op. */
+ private final transient boolean isLocal;
+
+ /** True if a region operation; false if entry op. */
+ private final transient boolean isRegion;
+
+ /** One of the following:
+ * OP_TYPE_CREATE,
+ * OP_TYPE_UPDATE,
+ * OP_TYPE_INVALIDATE,
+ * OP_TYPE_DESTROY,
+ * OP_TYPE_CLEAR
+ */
+ private final transient byte opType;
+
+ /** One of the following:
+ * OP_DETAILS_NONE,
+ * OP_DETAILS_SEARCH,
+ * OP_DETAILS_LOCAL_LOAD,
+ * OP_DETAILS_NET_LOAD,
+ * OP_DETAILS_EXPIRE,
+ * OP_DETAILS_EVICT
+ * OP_DETAILS_PUTALL
+ * OP_DETAILS_GUARANTEES_OLD_VALUE
+ * OP_DETAILS_REMOVEALL
+ */
+ private final transient int opDetails;
+
+
+ private Object readResolve() throws ObjectStreamException {
+ return VALUES[ordinal]; // Canonicalize
+ }
+
+
+ /** Creates a new instance of Operation. */
+ private Operation(String name, boolean isLocal, boolean isRegion, byte opType, int opDetails) {
+ this.name = name;
+ this.isLocal = isLocal;
+ this.isRegion = isRegion;
+ this.opType = opType;
+ this.opDetails = opDetails;
+ this.ordinal = nextOrdinal++;
+ VALUES[this.ordinal] = this;
+ }
+
+ /** Return the Operation represented by specified ordinal */
+ public static Operation fromOrdinal(byte ordinal) {
+ return VALUES[ordinal];
+ }
+
+
+ /**
+ * Returns true if this operation created a new entry.
+ */
+ public boolean isCreate() {
+ return this.opType == OP_TYPE_CREATE && isEntry();
+ }
+
+ /**
+ * Returns true if this operation updated an existing entry.
+ */
+ public boolean isUpdate() {
+ return this.opType == OP_TYPE_UPDATE && isEntry();
+ }
+
+ /**
+ * Returns true if this operation gets the value for given key.
+ */
+ public boolean isGet() {
+ return this.opType == OP_TYPE_GET;
+ }
+
+ /**
+ * Returns true if this operation checks whether given key is present in region.
+ */
+ public boolean isContainsKey() {
+ return this.opType == OP_TYPE_CONTAINS_KEY;
+ }
+
+ /**
+ * Returns true if this operation checks whether given value is present in region.
+ */
+ public boolean isContainsValue() {
+ return this.opType == OP_TYPE_CONTAINS_VALUE;
+ }
+
+ /**
+ * Returns true if this operation checks whether value is present for the given key.
+ */
+ public boolean isContainsValueForKey() {
+ return this.opType == OP_TYPE_CONTAINS_VALUE_FOR_KEY;
+ }
+ /**
+ * Returns true if this operation is function execution operation.
+ */
+ public boolean isFunctionExecution() {
+ return this.opType == OP_TYPE_FUNCTION_EXECUTION;
+ }
+ /**
+ * Returns true if this operation gets the entry for given key.
+ */
+ public boolean isGetEntry() {
+ return this.opType == OP_TYPE_GET_ENTRY;
+ }
+ /**
+ * Returns true if the operation invalidated an entry.
+ */
+ public boolean isInvalidate() {
+ return this.opType == OP_TYPE_INVALIDATE && isEntry();
+ }
+
+ /**
+ * Returns true if the operation destroyed an entry.
+ */
+ public boolean isDestroy() {
+ return this.opType == OP_TYPE_DESTROY && isEntry();
+ }
+
+ /**
+ * Returns true if the operation cleared the region.
+ */
+ public boolean isClear() {
+ return this.opType == OP_TYPE_CLEAR;
+ }
+ /**
+ * Returns true if the operation closed the cache or a region.
+ */
+ public boolean isClose() {
+ return (this == REGION_CLOSE)
+ || (this == CACHE_CLOSE)
+ || (this == CACHE_RECONNECT)
+ || (this == FORCED_DISCONNECT);
+ }
+ /**
+ * Returns true if this operation was initiated by a putAll.
+ */
+ public boolean isPutAll() {
+ return (this.opDetails & OP_DETAILS_PUTALL) != 0;
+ }
+
+ /**
+ * Returns true if this operation was initiated by a removeAll.
+ * @see Region#removeAll(java.util.Collection)
+ * @since 8.1
+ */
+ public boolean isRemoveAll() {
+ return (this.opDetails & OP_DETAILS_REMOVEALL) != 0;
+ }
+
+ /**
+ * Returns true if the operation invalidated a region.
+ */
+ public boolean isRegionInvalidate() {
+ return this.opType == OP_TYPE_INVALIDATE && isRegion();
+ }
+ /**
+ * Returns true if the operation destroyed a region.
+ */
+ public boolean isRegionDestroy() {
+ return this.opType == OP_TYPE_DESTROY && isRegion();
+ }
+ /**
+ * Returns true if the operation applies to the entire region.
+ */
+ public boolean isRegion() {
+ return this.isRegion;
+ }
+ /**
+ * Returns true if the operation is limited to the local cache.
+ */
+ public boolean isLocal() {
+ return this.isLocal;
+ }
+ /**
+ * Returns true if the operation may be distributed.
+ */
+ public boolean isDistributed() {
+ return !isLocal();
+ }
+ /**
+ * Returns true if the operation applies to a single entry.
+ */
+ public boolean isEntry() {
+ return !isRegion();
+ }
+ /** Answer true if this operation resulted from expiration.
+ * @return true if this operation resulted from expiration
+ *
+ */
+ public boolean isExpiration() {
+ return (this.opDetails & OP_DETAILS_EXPIRE) != 0;
+ }
+
+ /**
+ * Answer true if this operation resulted from eviction
+ * @return true if this operatino resulted from eviction
+ */
+ public boolean isEviction() {
+ return (this.opDetails & OP_DETAILS_EVICT) != 0;
+ }
+
+ /** Returns true if this operation included a loader running in this cache.
+ * Note that this will be true even if the local loader called <code>netSearch</code>.
+ *
+ * If this operation is for a Partitioned Region, then true will be returned if the
+ * loader ran in the same VM as where the data is hosted. If true is returned, and {@link CacheEvent#isOriginRemote}
+ * is true, it means the data is not hosted locally, but the loader was run local to the data.
+ *
+ * @return true if this operation included a local loader execution
+ */
+ public boolean isLocalLoad() {
+ return (this.opDetails & OP_DETAILS_LOCAL_LOAD) != 0;
+ }
+
+ /** Returns true if this operation included a loader running that was remote
+ * from the cache that requested it, i.e., a netLoad. Note that the cache
+ * that requested the netLoad may not be this cache.
+ * @return true if this operation included a netLoad
+ */
+ public boolean isNetLoad() {
+ return (this.opDetails & OP_DETAILS_NET_LOAD) != 0;
+ }
+
+ /** Returns true if this operation included running a loader.
+ * @return true if isLocalLoad or isNetLoad
+ */
+ public boolean isLoad() {
+ return (this.opDetails & (OP_DETAILS_LOCAL_LOAD|OP_DETAILS_NET_LOAD)) != 0;
+ }
+
+ /** Returns true if this operation included a <code>netSearch</code>. If the <code>netSearch</code>
+ * was invoked by a loader however, this will return false and <code>isLocalLoad()</code>
+ * or <code>isNetLoad()</code> will return true instead.
+ *
+ * @return true if this operation included a netSearch
+ */
+ public boolean isNetSearch() {
+ return (this.opDetails & OP_DETAILS_SEARCH) != 0;
+ }
+
+ /**
+ * Returns true if this operation was a {@link #isNetSearch net search} or a
+ * {@link #isLoad load}.
+ * @return true if this operation include a netSearch or any type of load.
+ */
+ public boolean isSearchOrLoad() {
+ return (this.opDetails & (OP_DETAILS_SEARCH|OP_DETAILS_LOCAL_LOAD|OP_DETAILS_NET_LOAD)) != 0;
+ }
+
+ /**
+ * Returns true if this operation is a ConcurrentMap operation that
+ * guarantees the old value to be returned no matter what expense may
+ * be incurred in doing so.
+ * @return true if this operation has this guarantee
+ * @since 6.5
+ */
+ public boolean guaranteesOldValue() {
+ return (this.opDetails & OP_DETAILS_GUARANTEES_OLD_VALUE) != 0;
+ }
+
+ /**
+ * Returns the update operation that corresponds to this operation.
+ * For a create operation the corresponding update op is returned.
+ * For all other operations <code>this</code> is returned.
+ */
+ public Operation getCorrespondingUpdateOp() {
+ if (isCreate()) {
+ switch (this.opDetails) {
+ case OP_DETAILS_SEARCH:
+ return Operation.SEARCH_UPDATE;
+ case OP_DETAILS_LOCAL_LOAD:
+ return Operation.LOCAL_LOAD_UPDATE;
+ case OP_DETAILS_NET_LOAD:
+ return Operation.NET_LOAD_UPDATE;
+ case OP_DETAILS_PUTALL:
+ return Operation.PUTALL_UPDATE;
+ default:
+ return Operation.UPDATE;
+ }
+ } else {
+ return this;
+ }
+ }
+
+ /**
+ * Returns the create operation that corresponds to this operation.
+ * For an update operation the corresponding create op is returned.
+ * For all other operations <code>this</code> is returned.
+ */
+ public Operation getCorrespondingCreateOp() {
+ if (isUpdate()) {
+ switch (this.opDetails) {
+ case OP_DETAILS_SEARCH:
+ return Operation.SEARCH_CREATE;
+ case OP_DETAILS_LOCAL_LOAD:
+ return Operation.LOCAL_LOAD_CREATE;
+ case OP_DETAILS_NET_LOAD:
+ return Operation.NET_LOAD_CREATE;
+ case OP_DETAILS_PUTALL:
+ return Operation.PUTALL_CREATE;
+ default:
+ return Operation.CREATE;
+ }
+ } else {
+ return this;
+ }
+ }
+
+ /** Returns a string representation for this operation.
+ * @return the name of this operation.
+ */
+ @Override
+ public String toString() {
+ return this.name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/OperationAbortedException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/OperationAbortedException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/OperationAbortedException.java
new file mode 100644
index 0000000..b1d8987
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/OperationAbortedException.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 the operation that
+ * would have otherwise affected the cache has been aborted.
+ * Only subclasses are instantiated.
+ *
+ * @author Eric Zoerner
+ *
+ *
+ * @since 3.0
+ */
+public abstract class OperationAbortedException extends CacheRuntimeException {
+
+ /**
+ * Creates a new instance of <code>OperationAbortedException</code> without detail message.
+ */
+ public OperationAbortedException() {
+ }
+
+
+ /**
+ * Constructs an instance of <code>OperationAbortedException</code> with the specified detail message.
+ * @param msg the detail message
+ */
+ public OperationAbortedException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs an instance of <code>OperationAbortedException</code> with the specified detail message
+ * and cause.
+ * @param msg the detail message
+ * @param cause the causal Throwable
+ */
+ public OperationAbortedException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ /**
+ * Constructs an instance of <code>OperationAbortedException</code> with the specified cause.
+ * @param cause the causal Throwable
+ */
+ public OperationAbortedException(Throwable cause) {
+ super(cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributes.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributes.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributes.java
new file mode 100644
index 0000000..f2eb2b1
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributes.java
@@ -0,0 +1,162 @@
+/*=========================================================================
+ * 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.List;
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.PartitionResolver;
+import com.gemstone.gemfire.cache.partition.PartitionListener;
+
+/**
+ *
+ * Attributes that define the partitioned character of a Partitioned Region.
+ * This interface allows for the discovery of Partitioned Region attributes using
+ * {@link com.gemstone.gemfire.cache.RegionAttributes#getPartitionAttributes()} as well
+ * as the configuration of a Partitioned Region using {@link com.gemstone.gemfire.cache.AttributesFactory#setPartitionAttributes(PartitionAttributes)}.
+ *
+ * PartitionAttributes are created using the {@link com.gemstone.gemfire.cache.PartitionAttributesFactory}
+ *
+ * The default PartitionAttributes can be determined using {@link com.gemstone.gemfire.cache.PartitionAttributesFactory#create()} with out
+ * calling any of its mutator methods e.g. {@link com.gemstone.gemfire.cache.PartitionAttributesFactory#setLocalMaxMemory(int)}
+ *
+ * Also see {@link com.gemstone.gemfire.cache.DataPolicy#PARTITION}.
+ *
+ * @author rreja
+ * @since 5.0
+ *
+ */
+public interface PartitionAttributes<K,V>
+{
+ /**
+ * returns entryTimeToLive in ExpirationAttributes.
+ *
+ * @return expirationAttributes
+ */
+ // public ExpirationAttributes getEntryTimeToLive();
+
+ /**
+ * returns entryIdleTimeout in ExpirationAttributes.
+ *
+ * @return expirationAttributes
+ */
+ // public ExpirationAttributes getEntryIdleTimeout();
+
+ /**
+ * The number of Backups for an entry in PartitionedRegion. This value should
+ * be between 0 and 3 (for a total of 1 to 4 instances of the data).
+ * The default value is 0.
+ *
+ * @return redundantCopies.
+ */
+ public int getRedundantCopies();
+
+ /**
+ * This method returns the maximum total size of the region in megabytes.
+ * @deprecated use getTotalMaxMemory() instead
+ * @return total size in megabytes.
+ */
+ @Deprecated
+ public long getTotalSize();
+
+ /**
+ * This method returns the maximum total size of the region, in megabytes.
+ * Default value is Integer.MAX_VALUE.
+ * @return maximum size of the partitioned region, in megabytes
+ */
+ public long getTotalMaxMemory();
+
+ /**
+ * This method returns total number of buckets for a PartitionedRegion.
+ * Default number of buckets for a PartitionedRegion is 113.
+ *
+ * @return total number of buckets for a PartitionedRegion.
+ */
+ public int getTotalNumBuckets();
+
+ /**
+ * This method returns the maximum amount of local memory that can be used
+ * by the Region.
+ * By default, a PartitionedRegion can contribute 90% of the maximum memory allocated to a VM.
+ */
+ public int getLocalMaxMemory();
+
+ /**
+ * Returns name of the colocated PartitionedRegion's name
+ * @since 6.0
+ */
+ public String getColocatedWith();
+
+ /**
+ * This method returns local properties. There are currently no local
+ * properties defined that are not also deprecated.
+ *
+ * @deprecated use {@link #getLocalMaxMemory()} in GemFire 5.1 and later releases
+ * @return localProperties
+ */
+ @Deprecated
+ public Properties getLocalProperties();
+
+ /**
+ * This method returns global properties. There are currently no global
+ * properties defined that are not also deprecated.
+ *
+ * @deprecated use {@link #getTotalMaxMemory()} and {@link #getTotalNumBuckets()} in GemFire 5.1 and later releases
+ * @return globalProperties
+ */
+ @Deprecated
+ public Properties getGlobalProperties();
+
+ /**
+ * Returns the PartitionResolver set for custom partitioning
+ * @return <code>PartitionResolver</code> for the PartitionedRegion
+ * @since 6.0
+ */
+ public PartitionResolver<K,V> getPartitionResolver();
+
+ /**
+ * Returns the delay in milliseconds that
+ * existing members will wait before satisfying redundancy
+ * after another member crashes.
+ * Default value of recoveryDelay is -1 which indicates that redundancy won't
+ * be recovered if a member crashes.
+ *
+ * @since 6.0
+ */
+ public long getRecoveryDelay();
+
+ /**
+ * Returns the delay in milliseconds that a new
+ * member will wait before trying to satisfy redundancy
+ * of data hosted on other members.
+ * Default value is 0 which is to recover redundancy immediately when a new
+ * member is added.
+ *
+ * @since 6.0
+ */
+ public long getStartupRecoveryDelay();
+
+ /**
+ * Returns array of PartitionListener{s} configured on this partitioned region
+ *
+ * @see PartitionListener
+ * @return PartitionListener configured on this partitioned region
+ * @since 6.5
+ */
+ public PartitionListener[] getPartitionListeners();
+
+ /**
+ * Returns <code>FixedPartitionAttributes</code>'s list of local partitions
+ * defined on this Partitioned Region
+ *
+ * @since 6.6
+ */
+ public List<FixedPartitionAttributes> getFixedPartitionAttributes();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributesFactory.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributesFactory.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributesFactory.java
new file mode 100644
index 0000000..9dc4563
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionAttributesFactory.java
@@ -0,0 +1,445 @@
+/*
+ * =========================================================================
+ * 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 com.gemstone.gemfire.cache.partition.PartitionListener;
+import com.gemstone.gemfire.internal.cache.PartitionAttributesImpl;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+
+/**
+ * <p>
+ * A factory that creates instances of {@link PartitionAttributes} which are
+ * used to create a partitioned {@link Region}. The setter methods follow the
+ * self-return idiom so that they can be "chained" together with the
+ * {@link #create} method to create
+ * {@link PartitionAttributes}. For example:<br>
+ *
+ * <pre>
+ * PartitionAttributes pa = new PartitionAttributesFactory()
+ * .setRedundantCopies(1)
+ * .setLocalMaxMemory(1240)
+ * .create();
+ *
+ * final Region myRegion = new RegionFactory()
+ * .setPartitionAttributes(pa)
+ * .setKeyConstraint(String.class)
+ * .setValueConstraint(ArrayList.class)
+ * .create("myRegion");
+ * </pre>
+ *
+ * </p>
+ *
+ * <p>
+ * {@link PartitionAttributes} can also be defined in a declarative fashion using a
+ * <a href="package-summary.html#declarative">cache.xml</a> file. Here is an
+ * example of how to configure a Partitioned Region named "pRoot" whose
+ * {@link com.gemstone.gemfire.cache.Scope} is Distributed Ack, which maintains
+ * a {@link #setRedundantCopies(int) redundant copy} of any given
+ * {@link com.gemstone.gemfire.cache.Region.Entry}, configures a
+ * {@link com.gemstone.gemfire.cache.CacheLoader} implementation, and sets
+ * {@link #setGlobalProperties(Properties) global properties} as well as
+ * {@link #setLocalMaxMemory(int) local max memory to use}.
+ *
+ * <pre>
+ * <root-region name="pRoot">
+ * <region-attributes scope="distributed-ack" >
+ * <partition-attributes redundant-copies="1", local-max-memory="1240"/>
+ * </region-attributes>
+ * </root-region>
+ * </pre>
+ * </p>
+ *
+ * @see com.gemstone.gemfire.cache.PartitionAttributes
+ * @see com.gemstone.gemfire.cache.AttributesFactory#setPartitionAttributes(PartitionAttributes)
+ * @author rreja
+ * @author bruce
+ * @since 5.0
+ */
+public class PartitionAttributesFactory<K,V>
+{
+ private final PartitionAttributesImpl partitionAttributes = new PartitionAttributesImpl();
+
+ /**
+ * @deprecated - please use the {@link #setLocalMaxMemory(int)} method instead.<p>
+ * The {@link #setLocalProperties(Properties) local property} name that sets
+ * the maximum heap storage a VM contributes to a partitioned Region. When set
+ * to zero, the resulting Region reference allows access to the partitioned
+ * Region without any consuming any heap storage.
+ */
+ public static final String LOCAL_MAX_MEMORY_PROPERTY = "LOCAL_MAX_MEMORY";
+
+ /**
+ * Default local max memory value in megabytes. By default each partitioned
+ * Region can contribute 90% of the maximum memory allocated to a VM.
+ */
+ private static int computeMaxMem()
+ {
+ final long maxMemInMegabytes = Runtime.getRuntime().maxMemory() / (1024 * 1024);
+ final long maxMemoryToUse = (long) (maxMemInMegabytes * 0.90);
+ int ret;
+ if (maxMemoryToUse < Integer.MAX_VALUE) {
+ ret = (int) maxMemoryToUse;
+ if (ret < 1) {
+ ret = 1;
+ }
+ } else {
+ ret = Integer.MAX_VALUE;
+ }
+ return ret;
+ }
+
+ /**
+ * The default maximum amount of memory to be used by this region in this
+ * process, in megabytes.
+ */
+ public static final int LOCAL_MAX_MEMORY_DEFAULT = computeMaxMem();
+
+ /**
+ * @deprecated - use {@link #setTotalMaxMemory(long)} instead.<p>
+ * The {@link #setGlobalProperties(Properties) global property} name that
+ * defines the total maximum size for the partitioned Region.<p>
+ * <em>This setting must be the same in all processes using the Region.</em>
+ */
+ public static final String GLOBAL_MAX_MEMORY_PROPERTY = "GLOBAL_MAX_MEMORY";
+
+ /**
+ * Default maximum total size of the region across all processes, in megabytes.
+ */
+ public static final long GLOBAL_MAX_MEMORY_DEFAULT = Integer.MAX_VALUE;
+
+ /**
+ * @deprecated - please use {@link #setTotalNumBuckets(int)} instead.<p>
+ * <em>This setting must be the same in all processes using the Region.</em>
+ */
+ public static final String GLOBAL_MAX_BUCKETS_PROPERTY = "GLOBAL_MAX_BUCKETS"; // "GLOBAL_MAX_BUCKETS";
+
+ /**
+ * The default total number of buckets (113).
+ */
+ public static final int GLOBAL_MAX_BUCKETS_DEFAULT = 113;
+
+ public static final long RECOVERY_DELAY_DEFAULT = -1;
+
+ public static final long STARTUP_RECOVERY_DELAY_DEFAULT = 0;
+
+ /**
+ * Creates a new instance of PartitionAttributesFactory ready to create a
+ * <code>PartitionAttributes</code> with default settings.
+ */
+ public PartitionAttributesFactory() {
+ }
+
+ /**
+ * Creates a new instance of PartitionAttributesFactory ready to create a
+ * {@link PartitionAttributes} with the same settings as those in
+ * the specified {@link PartitionAttributes}
+ *
+ * @param pa the <code>PartitionAttributes</code> used to initialize this
+ * PartitionAttributesFactory
+ */
+ public PartitionAttributesFactory(PartitionAttributes pa) {
+ this.partitionAttributes.setAll(pa);
+
+ }
+
+ // CALLBACKS
+
+ /**
+ * Sets the number of extra copies of buckets desired. Extra copies allow for
+ * both high availability in the face of VM departure (intended or unintended)
+ * and and load balancing read operations.<p>
+ * <em>This setting must be the same in all processes using the Region.</em>
+ * Default number of redundant copies is 0.
+ *
+ * @param redundantCopies
+ * the number of redundant bucket copies, limited to values 0, 1, 2 and 3.
+ *
+ * @return this
+ */
+ public PartitionAttributesFactory<K,V> setRedundantCopies(int redundantCopies)
+ {
+ this.partitionAttributes.setRedundantCopies(redundantCopies);
+ return this;
+ }
+
+ /**
+ * Sets the cache writer for the next <code>PartitionAttributes</code>
+ * created. <i>Currently unsupported for the early access release.</i>
+ *
+ * @param cacheWriter
+ * the cache writer or null if no cache writer
+ * @return this
+ public PartitionAttributesFactory<K,V> setCacheWriter(CacheWriter cacheWriter)
+ {
+ this.partitionAttributes.setCacheWriter(cacheWriter);
+ return this;
+ }
+ */
+
+ /**
+ * Sets the maximum amount of memory, in megabytes, to be used by the
+ * region in this process. If not set, a default of
+ * 90% of available heap is used.
+ */
+ public PartitionAttributesFactory<K,V> setLocalMaxMemory(int mb) {
+ this.partitionAttributes.setLocalMaxMemory(mb);
+ return this;
+ }
+
+ /**
+ * Sets the maximum amount of memory, in megabytes, to be used by the
+ * region in all processes.<p>
+ * <em>This setting must be the same in all processes using the Region.</em>
+ * The default value is Integer.MAX_VALUE.
+ */
+ public PartitionAttributesFactory<K,V> setTotalMaxMemory(long mb) {
+ this.partitionAttributes.setTotalMaxMemory(mb);
+ return this;
+ }
+
+ /**
+ * Sets the total number of hash buckets to be used by the region in
+ * all processes.
+ * <p>
+ * <em>This setting must be the same in all processes using the Region.</em>
+ * <p>
+ * A bucket is the smallest unit of data management in a partitioned region.
+ * {@link com.gemstone.gemfire.cache.Region.Entry Entries} are stored in
+ * buckets and buckets may move from one VM to another. Buckets may also have
+ * copies, depending on {@link #setRedundantCopies(int) redundancy} to provide
+ * high availability in the face of VM failure.
+ * </p>
+ * <p>
+ * The number of buckets should be prime and as a rough guide at the least four
+ * times the number of partition VMs. However, there is significant overhead
+ * to managing a bucket, particularly for higher values of
+ * {@link #setRedundantCopies(int) redundancy}.
+ * </p>
+ * The default number of buckets for a PartitionedRegion is 113.
+ */
+ public PartitionAttributesFactory<K,V> setTotalNumBuckets(int numBuckets) {
+ this.partitionAttributes.setTotalNumBuckets(numBuckets);
+ return this;
+ }
+ /**
+ * Sets the <code>PartitionResolver</code> for the PartitionRegion.
+ */
+ public PartitionAttributesFactory<K,V> setPartitionResolver(
+ PartitionResolver<K,V> resolver) {
+ this.partitionAttributes.setPartitionResolver(resolver);
+ return this;
+ }
+ /**
+ * Sets the name of the PartitionRegion with which this newly created
+ * partitioned region is colocated
+ */
+ public PartitionAttributesFactory<K,V> setColocatedWith(String colocatedRegionFullPath) {
+ this.partitionAttributes.setColocatedWith(colocatedRegionFullPath);
+ return this;
+ }
+
+ /**
+ * Sets the delay in milliseconds that
+ * existing members will wait before satisfying redundancy
+ * after another member crashes.
+ * Default value is set to -1 which indicates
+ * that redundancy will not be recovered after a failure.
+ *
+ * @since 6.0
+ */
+ public PartitionAttributesFactory<K,V> setRecoveryDelay(long recoveryDelay) {
+ this.partitionAttributes.setRecoveryDelay(recoveryDelay);
+ return this;
+ }
+
+ /**
+ * Sets the delay in milliseconds that
+ * new members will wait before satisfying redundancy. -1 indicates
+ * that adding new members will not trigger redundancy recovery.
+ * The default (set to 0) is to recover redundancy immediately when a new
+ * member is added.
+ *
+ * @since 6.0
+ */
+ public PartitionAttributesFactory<K,V> setStartupRecoveryDelay(long startupRecoveryDelay) {
+ this.partitionAttributes.setStartupRecoveryDelay(startupRecoveryDelay);
+ return this;
+ }
+
+ /**
+ * adds a PartitionListener for the partitioned region.
+ *
+ * @param listener
+ * @return PartitionAttributeFactory
+ * @since 6.5
+ */
+ public PartitionAttributesFactory<K, V> addPartitionListener(
+ PartitionListener listener) {
+ if (listener == null) {
+ throw new IllegalArgumentException(
+ LocalizedStrings.PartitionAttributesFactory_PARTITION_LISTENER_PARAMETER_WAS_NULL
+ .toLocalizedString());
+ }
+ synchronized (this.partitionAttributes) {
+ this.partitionAttributes.addPartitionListener(listener);
+ }
+ return this;
+ }
+
+ /**
+ * Sets the <code>Properties</code> for the local instance the partitioned
+ * Region. Local properties define how the local instance of the partitioned
+ * region and any storage it may provide, behaves. There are currently no
+ * non-deprecated local properties.
+ * @deprecated use {@link #setLocalMaxMemory(int)} in GemFire 5.1 and later releases
+ * @param localProps
+ * @return PartitionAttributeFactory.
+ *
+ */
+ @Deprecated
+ public PartitionAttributesFactory<K,V> setLocalProperties(Properties localProps)
+ {
+ if (localProps == null) {
+ return this;
+ }
+ this.partitionAttributes.setLocalProperties(localProps);
+
+ return this;
+ }
+
+ /**
+ * Sets the global <code>Properties</code> for the next <code>PartitionAttributes</code>
+ * created. Global properties define how the entire partitioned Region behaves.
+ * <p>
+ * Note that global settings must be the same in all processes using the Region.
+ *
+ * @deprecated use {@link #setTotalMaxMemory(long)} and {@link #setTotalNumBuckets(int)} in GemFire 5.1 and later releases
+ * @param globalProps
+ * @return PartitionAttributeFactory.
+ *
+ * @see #GLOBAL_MAX_MEMORY_PROPERTY
+ */
+ @Deprecated
+ public PartitionAttributesFactory<K,V> setGlobalProperties(Properties globalProps)
+ {
+ this.partitionAttributes.setGlobalProperties(globalProps);
+ return this;
+ }
+
+ /**
+ * FixedPartitionAttributes defined for this partitioned region is added to
+ * PR attributes.
+ *
+ * @since 6.6
+ */
+ public PartitionAttributesFactory<K, V> addFixedPartitionAttributes(
+ FixedPartitionAttributes fpa) {
+ synchronized (this.partitionAttributes) {
+ this.partitionAttributes.addFixedPartitionAttributes(fpa);
+ return this;
+ }
+ }
+
+ // EXPIRATION ATTRIBUTES
+
+ /**
+ * Sets the idleTimeout expiration attributes for region entries for the next
+ * <code>PartitionAttributes</code> created.
+ *
+ * @param idleTimeout
+ * the idleTimeout ExpirationAttributes for entries in this region
+ * @throws IllegalArgumentException
+ * if idleTimeout is null
+ * @return PartitionAttributeFactory
+ */
+ /*
+ public PartitionAttributesFactory<K,V> setEntryIdleTimeout(
+ ExpirationAttributes idleTimeout)
+ {
+ if (idleTimeout == null) {
+ throw new IllegalArgumentException(LocalizedStrings.PartitionAttributesFactory_IDLETIMEOUT_MUST_NOT_BE_NULL.toLocalizedString());
+ }
+ this.partitionAttributes.entryIdleTimeoutExpiration = idleTimeout;
+ return this;
+ }
+ */
+
+ /**
+ * Sets the timeToLive expiration attributes for region entries for the next
+ * <code>PartitionAttributes</code> created.
+ *
+ * @param timeToLive
+ * the timeToLive ExpirationAttributes for entries in this region
+ * @throws IllegalArgumentException
+ * if timeToLive is null
+ */
+ /*
+ public PartitionAttributesFactory<K,V> setEntryTimeToLive(
+ ExpirationAttributes timeToLive)
+ {
+ if (timeToLive == null) {
+ throw new IllegalArgumentException(LocalizedStrings.PartitionAttributesFactory_TIMETOLIVE_MUST_NOT_BE_NULL.toLocalizedString());
+ }
+ this.partitionAttributes.entryTimeToLiveExpiration = timeToLive;
+ return this;
+ }
+ */
+
+ /**
+ * Enables/Disables local Caching for this node for region entries for the
+ * next <code>PartitionAttributes</code> created. Default is true.
+ *
+ * @param isLocalCache
+ * @return PartitionAttributesFactory
+ */
+ // TODO: Enable when we have local caching propertly implemented - mthomas
+ // 2/32/2006
+ // public PartitionAttributesFactory<K,V> enableLocalCaching(boolean isLocalCache)
+ // {
+ // this.partitionAttributes.localCaching = isLocalCache;
+ // return this;
+ // }
+ // DISTRIBUTION ATTRIBUTES
+ // FACTORY METHOD
+ /**
+ * Creates a <code>PartitionAttributes</code> with the current settings.
+ *
+ * @return the newly created <code>PartitionAttributes</code>
+ * @throws IllegalStateException
+ * if the current settings violate the <a
+ * href="#compatibility">compatibility rules </a>
+ */
+ @SuppressWarnings("unchecked")
+ public PartitionAttributes<K,V> create()
+ {
+ this.partitionAttributes.validateAttributes();
+// setDefaults(); [bruce] defaults are set in the PartitionedRegion when the
+// attributes are applied
+ return (PartitionAttributes<K,V>)this.partitionAttributes.clone();
+ }
+
+// /**
+// * This method sets the properties to their default values in preparation
+// * for returning a PartitionAttributes to the user. For example, if it
+// * doesn't have localMaxMemory, it would set it to
+// * LOCAL_MAX_MEMORY_DEFAULT.
+// *
+// */
+// private void setDefaults()
+// {
+// if (this.partitionAttributes.localProperties
+// .get(PartitionAttributesFactory.LOCAL_MAX_MEMORY_PROPERTY) == null) {
+// this.partitionAttributes.setLocalMaxMemory(PartitionAttributesFactory.LOCAL_MAX_MEMORY_DEFAULT);
+// }
+//
+// }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionResolver.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionResolver.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionResolver.java
new file mode 100755
index 0000000..61805dc
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionResolver.java
@@ -0,0 +1,76 @@
+/*
+ * =========================================================================
+ * 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;
+
+/**
+ * Implementers of interface <code>PartitionResolver</code> enable custom
+ * partitioning on the <code>PartitionedRegion</code>.<br>
+ * <p>
+ * 1. The Key class can implement PartitionResolver interface to
+ * enable custom partitioning OR <br>
+ * 2. Configure your own PartitionResolver class in partition attributes (For
+ * instance when the Key is a primitive type or String) Implement the
+ * appropriate equals - For all implementations, you need to be sure to code the
+ * class equals method so it properly verifies equality for the
+ * PartitionResolver implementation. This might mean verifying that class names
+ * are the same or that the returned routing objects are the same etc.. When you
+ * initiate the partitioned region on multiple nodes, GemFire uses the equals
+ * method to ensure you are using the same PartitionResolver implementation for
+ * all of the nodes for the region.
+ * </p>
+ * <p>
+ * GemFire uses the routing object's hashCode to determine where the data is
+ * being managed. Say, for example, you want to colocate all Trades by month and
+ * year.The key is implemented by TradeKey class which also implements the
+ * PartitionResolver interface.
+ * </p>
+ * public class TradeKey implements PartitionResolver {<br>
+ *     private String tradeID;<br>
+ *     private Month month ;<br>
+ *     private Year year ;<br>
+ *
+ *     public TradingKey(){ } <br>
+ *     public TradingKey(Month month, Year year){<br>
+ *         this.month = month;<br>
+ *         this.year = year;<br>
+ *     } <br>
+ *     public Object getRoutingObject(EntryOperation opDetails){<br>
+ *         return this.month + this.year;<br>
+ *     }<br> }<br>
+ *
+ * In the example above, all trade entries with the same month and year are
+ * guaranteed to be colocated.
+ * </p>
+ *
+ * @author Yogesh Mahajan
+ * @author Mitch Thomas
+ *
+ * @since 6.0
+ */
+public interface PartitionResolver<K,V> extends CacheCallback {
+
+ /**
+ * @param opDetails
+ * the detail of the entry operation e.g.
+ * {@link Region#get(Object)}
+ * @throws RuntimeException
+ * any exception thrown will terminate the operation and the
+ * exception will be passed to the calling thread.
+ * @return object associated with entry operation which allows the Partitioned
+ * Region to store associated data together
+ */
+ public Object getRoutingObject(EntryOperation<K,V> opDetails);
+
+ /**
+ * Returns the name of the PartitionResolver
+ *
+ * @return String name
+ */
+ public String getName();
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionDistributionException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionDistributionException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionDistributionException.java
new file mode 100644
index 0000000..b960582
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionDistributionException.java
@@ -0,0 +1,37 @@
+/*=========================================================================
+ * 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 a failure to perform a distributed operation on a Partitioned Region
+ * after multiple attempts.
+ *
+ * @since 5.1
+ * @author Mitch Thomas
+ */
+public class PartitionedRegionDistributionException extends
+ CacheRuntimeException
+{
+ private static final long serialVersionUID = -3004093739855972548L;
+
+ public PartitionedRegionDistributionException() {
+ super();
+ }
+
+ public PartitionedRegionDistributionException(String msg) {
+ super(msg);
+ }
+
+ public PartitionedRegionDistributionException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ public PartitionedRegionDistributionException(Throwable cause) {
+ super(cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/19459053/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionStorageException.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionStorageException.java b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionStorageException.java
new file mode 100644
index 0000000..4c97ffb
--- /dev/null
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/cache/PartitionedRegionStorageException.java
@@ -0,0 +1,87 @@
+/*=========================================================================
+ * 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;
+
+/**
+ *
+ * <h3>Description of the conditions under which this exception is thrown</h3>
+ * <p>
+ * When a <code>PartitionedRegionStorageException</code> message contains
+ * the string:
+ *
+ * <pre>
+ * There are not enough data store members to create a bucket.
+ * </pre>
+ *
+ * A new data store must be added to the partitioned region for future bucket creation.
+ * </p>
+ *
+ * <p>
+ * When a <code>PartitionedRegionStorageException</code> message contains
+ * the string:
+ *
+ * <pre>
+ * Too many data store members have refused the request to create a bucket.
+ * </pre>
+ *
+ * There are enough data stores, however some have refused possibly due to these
+ * conditions:
+ * <ol>
+ * <li>The amount of storage allocated to the partitioned region on that
+ * distributed member exceeds its localMaxMemory setting.</li>
+ * <li>The partitioned region instance on that distributed member has been
+ * closed or destroyed.</li>
+ * <li>The cache on that distributed member has been closed.</li>
+ * <li>The distributed system on that member has been disconnected.</li>
+ * </ol>
+ * </p>
+ *
+ * <p>
+ * When a <code>PartitionedRegionStorageException</code> message contains
+ * the string:
+ *
+ * <pre>
+ * Creation of a bucket for partitioned region failed in N attempts.
+ * </pre>
+ * If the number of attempts is lesser than the number of available
+ * data store members, contact GemFire support providing all logs and statistics files from
+ * all members containing the partitioned region. Otherwise, shutdown and then restart one
+ * or more of the data stores, given that it is safe to do so, for example when redundantCopies
+ * is greater than 0.
+ * </p>
+ *
+ *
+ * @see com.gemstone.gemfire.cache.PartitionAttributesFactory
+ * @since 5.0
+ */
+public class PartitionedRegionStorageException extends CacheRuntimeException {
+private static final long serialVersionUID = 5905463619475329732L;
+
+ /** Creates a new instance of PartitionedRegionStorageException */
+ public PartitionedRegionStorageException() {
+ }
+
+
+ /**
+ * Creates a new {@link PartitionedRegionStorageException} with a message.
+ * @param msg The string message for the PartitionedRegionStorageException.
+ */
+
+ public PartitionedRegionStorageException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a new {@link PartitionedRegionStorageException} with a message and Throwable cause.
+ * @param message The string message for the PartitionedRegionStorageException.
+ * @param cause Throwable cause for this {@link PartitionedRegionStorageException}.
+ */
+ public PartitionedRegionStorageException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}