http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryHeap.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryHeap.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryHeap.java index 6071836..3364a6e 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryHeap.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryHeap.java @@ -17,6 +17,7 @@ package org.apache.geode.internal.cache; import java.util.UUID; public abstract class VersionedThinRegionEntryHeap extends VersionedThinRegionEntry { + public VersionedThinRegionEntryHeap(RegionEntryContext context, Object value) { super(context, value); } @@ -29,7 +30,7 @@ public abstract class VersionedThinRegionEntryHeap extends VersionedThinRegionEn } private static class VersionedThinRegionEntryHeapFactory implements RegionEntryFactory { - public final RegionEntry createEntry(RegionEntryContext context, Object key, Object value) { + public RegionEntry createEntry(RegionEntryContext context, Object key, Object value) { if (InlineKeyHelper.INLINE_REGION_KEYS) { Class<?> keyClass = key.getClass(); if (keyClass == Integer.class) { @@ -54,7 +55,7 @@ public abstract class VersionedThinRegionEntryHeap extends VersionedThinRegionEn return new VersionedThinRegionEntryHeapObjectKey(context, key, value); } - public final Class getEntryClass() { + public Class getEntryClass() { // The class returned from this method is used to estimate the memory size. // This estimate will not take into account the memory saved by inlining the keys. return VersionedThinRegionEntryHeapObjectKey.class;
http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryOffHeap.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryOffHeap.java b/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryOffHeap.java index 21c1806..f225bac 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryOffHeap.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/VersionedThinRegionEntryOffHeap.java @@ -18,6 +18,7 @@ import java.util.UUID; public abstract class VersionedThinRegionEntryOffHeap extends VersionedThinRegionEntry implements OffHeapRegionEntry { + public VersionedThinRegionEntryOffHeap(RegionEntryContext context, Object value) { super(context, value); } @@ -30,7 +31,7 @@ public abstract class VersionedThinRegionEntryOffHeap extends VersionedThinRegio } private static class VersionedThinRegionEntryOffHeapFactory implements RegionEntryFactory { - public final RegionEntry createEntry(RegionEntryContext context, Object key, Object value) { + public RegionEntry createEntry(RegionEntryContext context, Object key, Object value) { if (InlineKeyHelper.INLINE_REGION_KEYS) { Class<?> keyClass = key.getClass(); if (keyClass == Integer.class) { @@ -57,7 +58,7 @@ public abstract class VersionedThinRegionEntryOffHeap extends VersionedThinRegio return new VersionedThinRegionEntryOffHeapObjectKey(context, key, value); } - public final Class getEntryClass() { + public Class getEntryClass() { // The class returned from this method is used to estimate the memory size. // This estimate will not take into account the memory saved by inlining the keys. return VersionedThinRegionEntryOffHeapObjectKey.class; http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/control/ResourceAdvisor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/control/ResourceAdvisor.java b/geode-core/src/main/java/org/apache/geode/internal/cache/control/ResourceAdvisor.java index da0c190..1f328ff 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/control/ResourceAdvisor.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/control/ResourceAdvisor.java @@ -436,7 +436,7 @@ public class ResourceAdvisor extends DistributionAdvisor { }); } - public final boolean isHeapCritical(final InternalDistributedMember member) { + public boolean isHeapCritical(final InternalDistributedMember member) { ResourceManagerProfile rmp = (ResourceManagerProfile) getProfile(member); return rmp != null ? rmp.getHeapState().isCritical() : false; } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLockIdImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLockIdImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLockIdImpl.java index 0fd607c..b1e5bab 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLockIdImpl.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/locks/TXLockIdImpl.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.internal.cache.locks; import org.apache.geode.internal.DataSerializableFixedID; @@ -25,11 +24,11 @@ import org.apache.geode.distributed.internal.membership.*; /** * Identifies a group of transaction locks. - * */ public class TXLockIdImpl implements TXLockId, DataSerializableFixedID { private static final long serialVersionUID = 8579214625084490134L; + /** DistributionManager id for this member */ private InternalDistributedMember memberId; @@ -122,7 +121,7 @@ public class TXLockIdImpl implements TXLockId, DataSerializableFixedID { out.writeInt(this.id); } - public static final TXLockIdImpl createFromData(DataInput in) + public static TXLockIdImpl createFromData(DataInput in) throws IOException, ClassNotFoundException { TXLockIdImpl result = new TXLockIdImpl(); result.fromData(in); @@ -131,7 +130,6 @@ public class TXLockIdImpl implements TXLockId, DataSerializableFixedID { @Override public Version[] getSerializationVersions() { - // TODO Auto-generated method stub return null; } } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/lru/LRUAlgorithm.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/lru/LRUAlgorithm.java b/geode-core/src/main/java/org/apache/geode/internal/cache/lru/LRUAlgorithm.java index 9b69c7e..b07a124 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/lru/LRUAlgorithm.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/lru/LRUAlgorithm.java @@ -16,13 +16,16 @@ package org.apache.geode.internal.cache.lru; import org.apache.geode.InternalGemFireException; import org.apache.geode.StatisticsFactory; -import org.apache.geode.cache.*; +import org.apache.geode.cache.CacheCallback; +import org.apache.geode.cache.EvictionAction; +import org.apache.geode.cache.Region; import org.apache.geode.internal.cache.BucketRegion; import org.apache.geode.internal.cache.PlaceHolderDiskRegion; import org.apache.geode.internal.i18n.LocalizedStrings; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.Serializable; +import java.util.Properties; /** * Eviction controllers that extend this class evict the least recently used (LRU) entry in the @@ -67,8 +70,6 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone */ public static final String EVICTION_ACTION = "eviction-action"; - //////////////////////// Instance Fields /////////////////////// - /** What to do upon eviction */ protected EvictionAction evictionAction; @@ -79,7 +80,6 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone private transient EnableLRU helper; protected BucketRegion bucketRegion; - ///////////////////////// Constructors ///////////////////////// /** * Creates a new <code>LRUAlgorithm</code> with the given {@linkplain EvictionAction eviction @@ -91,8 +91,6 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone this.helper = createLRUHelper(); } - /////////////////////// Instance Methods /////////////////////// - /** * Used to hook up a bucketRegion late during disk recover. */ @@ -131,7 +129,7 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone * For internal use only. Returns a helper object used internally by the GemFire cache * implementation. */ - public final EnableLRU getLRUHelper() { + public EnableLRU getLRUHelper() { synchronized (this) { // Synchronize with readObject/writeObject to avoid race // conditions with copy sharing. See bug 31047. @@ -154,24 +152,6 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone } } - // public void writeExternal(ObjectOutput out) - // throws IOException { - // out.writeObject(this.evictionAction); - // } - - // public void readExternal(ObjectInput in) - // throws IOException, ClassNotFoundException { - // String evictionAction = (String) in.readObject(); - // this.setEvictionAction(evictionAction); - // } - - // protected Object readResolve() throws ObjectStreamException { - // if (this.helper == null) { - // this.helper = createLRUHelper(); - // } - // return this; - // } - /** * Creates a new <code>LRUHelper</code> tailed for this LRU algorithm implementation. */ @@ -241,11 +221,7 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone return true; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - * + /** * Note that we just need to make sure that equal objects return equal hashcodes; nothing really * elaborate is done here. */ @@ -262,8 +238,6 @@ public abstract class LRUAlgorithm implements CacheCallback, Serializable, Clone @Override public abstract String toString(); - ////////////////////// Inner Classes ////////////////////// - /** * A partial implementation of the <code>EnableLRU</code> interface that contains code common to * all <code>LRUAlgorithm</code>s. http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessage.java index 8d164c8..c4a3fbd 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/BucketBackupMessage.java @@ -44,7 +44,7 @@ public class BucketBackupMessage extends PartitionMessage { private int bucketId; /** - * Empty contstructor provided for {@link org.apache.geode.DataSerializer} + * Empty constructor provided for {@link org.apache.geode.DataSerializer} */ public BucketBackupMessage() { super(); @@ -73,7 +73,7 @@ public class BucketBackupMessage extends PartitionMessage { * of the initialization */ @Override - protected final boolean failIfRegionMissing() { + protected boolean failIfRegionMissing() { return false; } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessage.java index f1633bd..c9d7d70 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/DeposePrimaryBucketMessage.java @@ -98,8 +98,8 @@ public class DeposePrimaryBucketMessage extends PartitionMessage { } @Override - protected final boolean operateOnPartitionedRegion(DistributionManager dm, - PartitionedRegion region, long startTime) throws ForceReattemptException { + protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion region, + long startTime) throws ForceReattemptException { BucketAdvisor bucketAdvisor = region.getRegionAdvisor().getBucketAdvisor(this.bucketId); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessage.java index 664ebe7..1072576 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchEntryMessage.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.internal.cache.partitioned; import java.io.DataInput; @@ -85,7 +84,6 @@ public class FetchEntryMessage extends PartitionMessage { * @param recipient the member that the getEntry message is sent to * @param r the PartitionedRegion for which getEntry was performed upon * @param key the object to which the value should be feteched - * @param access * @return the processor used to fetch the returned value associated with the key * @throws ForceReattemptException if the peer is no longer available */ @@ -109,11 +107,6 @@ public class FetchEntryMessage extends PartitionMessage { fromData(in); } - // final public int getProcessorType() - // { - // return DistributionManager.PARTITIONED_REGION_EXECUTOR; - // } - @Override public boolean isSevereAlertCompatible() { // allow forced-disconnect processing for all cache op messages @@ -121,7 +114,7 @@ public class FetchEntryMessage extends PartitionMessage { } @Override - protected final boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, + protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws ForceReattemptException { // FetchEntryMessage is used in refreshing client caches during interest list recovery, // so don't be too verbose or hydra tasks may time out @@ -209,7 +202,7 @@ public class FetchEntryMessage extends PartitionMessage { return s; } - public final void setKey(Object key) { + public void setKey(Object key) { this.key = key; } @@ -322,9 +315,7 @@ public class FetchEntryMessage extends PartitionMessage { } /** - * A processor to capture the value returned by - * {@link org.apache.geode.internal.cache.partitioned.FetchEntryMessage.FetchEntryReplyMessage} - * + * A processor to capture the value returned by {@link FetchEntryMessage.FetchEntryReplyMessage} */ public static class FetchEntryResponse extends PartitionResponse { private volatile EntrySnapshot returnValue; @@ -356,13 +347,10 @@ public class FetchEntryMessage extends PartitionMessage { /** * @return Object associated with the key that was sent in the get message - * @throws EntryNotFoundException * @throws ForceReattemptException if the peer is no longer available - * @throws EntryNotFoundException */ public EntrySnapshot waitForResponse() throws EntryNotFoundException, ForceReattemptException { try { - // waitForRepliesUninterruptibly(); waitForCacheException(); } catch (ForceReattemptException e) { e.checkKey(key); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessage.java index 21dfa8d..523186d 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/FetchPartitionDetailsMessage.java @@ -99,8 +99,8 @@ public class FetchPartitionDetailsMessage extends PartitionMessage { } @Override - protected final boolean operateOnPartitionedRegion(DistributionManager dm, - PartitionedRegion region, long startTime) throws ForceReattemptException { + protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion region, + long startTime) throws ForceReattemptException { PartitionMemberInfoImpl details = (PartitionMemberInfoImpl) region.getRedundancyProvider() .buildPartitionMemberDetails(this.internal, this.loadProbe); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessage.java index 6f18013..2d2b3c4 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/MoveBucketMessage.java @@ -47,7 +47,6 @@ import org.apache.geode.internal.logging.log4j.LogMarker; * Usage: MoveBucketResponse response = MoveBucketMessage.send( InternalDistributedMember, * PartitionedRegion, int bucketId); if (response != null && response.waitForResponse()) { // bucket * was moved } - * */ public class MoveBucketMessage extends PartitionMessage { private static final Logger logger = LogService.getLogger(); @@ -106,8 +105,8 @@ public class MoveBucketMessage extends PartitionMessage { } @Override - protected final boolean operateOnPartitionedRegion(DistributionManager dm, - PartitionedRegion region, long startTime) throws ForceReattemptException { + protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion region, + long startTime) throws ForceReattemptException { PartitionedRegionDataStore dataStore = region.getDataStore(); boolean moved = dataStore.moveBucket(this.bucketId, this.source, true); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/PartitionMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/PartitionMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/PartitionMessage.java index 6b59f51..8c27107 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/PartitionMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/PartitionMessage.java @@ -184,24 +184,17 @@ public abstract class PartitionMessage extends DistributionMessage this.isTransactionDistributed = other.isTransactionDistributed; } - /* - * (non-Javadoc) - * - * @see org.apache.geode.internal.cache.TransactionMessage#getTXOriginatorClient() - */ public InternalDistributedMember getTXOriginatorClient() { return txMemberId; } - public final InternalDistributedMember getMemberToMasqueradeAs() { + public InternalDistributedMember getMemberToMasqueradeAs() { if (txMemberId == null) { return getSender(); } return txMemberId; } - - /** * Severe alert processing enables suspect processing at the ack-wait-threshold and issuing of a * severe alert at the end of the ack-severe-alert-threshold. Some messages should not support @@ -669,11 +662,6 @@ public abstract class PartitionMessage extends DistributionMessage // subclasses that support routing to clients should reimplement this method } - /* - * public void appendOldValueToMessage(EntryEventImpl event) { - * - * } - */ /** * @return the txUniqId */ http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessage.java index 7ee54d8..1898461 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveAllPRMessage.java @@ -342,7 +342,6 @@ public class RemoveAllPRMessage extends PartitionMessageWithDirectReply { @Override protected Object clone() throws CloneNotSupportedException { - // TODO Auto-generated method stub return super.clone(); } @@ -629,9 +628,8 @@ public class RemoveAllPRMessage extends PartitionMessageWithDirectReply { RemoveAllReplyMessage.send(member, procId, getReplySender(dm), this.result, this.versions, ex); } - @Override - protected final void appendFields(StringBuilder buff) { + protected void appendFields(StringBuilder buff) { super.appendFields(buff); buff.append("; removeAllPRDataSize=").append(removeAllPRDataSize).append("; bucketId=") .append(bucketId); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessage.java index a8ff068..6650549 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/RemoveBucketMessage.java @@ -45,7 +45,6 @@ import org.apache.geode.internal.logging.log4j.LogMarker; * Usage: RemoveBucketResponse response = RemoveBucketMessage.send( InternalDistributedMember, * PartitionedRegion, int bucketId); if (response != null && response.waitForResponse()) { // bucket * was removed } - * */ public class RemoveBucketMessage extends PartitionMessage { private static final Logger logger = LogService.getLogger(); @@ -53,7 +52,6 @@ public class RemoveBucketMessage extends PartitionMessage { private int bucketId; private boolean forceRemovePrimary; - /** * Empty constructor to satisfy {@link DataSerializer} requirements */ @@ -103,8 +101,8 @@ public class RemoveBucketMessage extends PartitionMessage { } @Override - protected final boolean operateOnPartitionedRegion(DistributionManager dm, - PartitionedRegion region, long startTime) throws ForceReattemptException { + protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion region, + long startTime) throws ForceReattemptException { PartitionedRegionDataStore dataStore = region.getDataStore(); boolean removed = dataStore.removeBucket(this.bucketId, this.forceRemovePrimary); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/SizeMessage.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/SizeMessage.java b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/SizeMessage.java index 0c6aea8..a6c9707 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/SizeMessage.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/partitioned/SizeMessage.java @@ -110,7 +110,7 @@ public class SizeMessage extends PartitionMessage { * of the initialization */ @Override - protected final boolean failIfRegionMissing() { + protected boolean failIfRegionMissing() { return false; } @@ -154,10 +154,6 @@ public class SizeMessage extends PartitionMessage { sizes = ds.getSizeForLocalBuckets(); } } - // if (logger.isTraceEnabled(LogMarker.DM)) { - // l.fine(getClass().getName() + " send sizes back using processorId: " - // + getProcessorId()); - // } r.getPrStats().endPartitionMessagesProcessing(startTime); SizeReplyMessage.send(getSender(), getProcessorId(), dm, sizes); } // datastore exists @@ -270,7 +266,7 @@ public class SizeMessage extends PartitionMessage { @Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); - this.bucketSizes = (Map<Integer, SizeEntry>) DataSerializer.readObject(in); + this.bucketSizes = DataSerializer.readObject(in); } @Override http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientUpdater.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientUpdater.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientUpdater.java index 728abf7..291db65 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientUpdater.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientUpdater.java @@ -1872,11 +1872,11 @@ public class CacheClientUpdater extends Thread implements ClientUpdater, Disconn this.stats.close(); } - public final void incReceivedBytes(long v) { + public void incReceivedBytes(long v) { this.stats.incLong(receivedBytesId, v); } - public final void incSentBytes(long v) { + public void incSentBytes(long v) { // noop since we never send messages } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Part.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Part.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Part.java index 889980f..cfe812c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Part.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/Part.java @@ -34,14 +34,15 @@ import org.apache.geode.internal.offheap.StoredObject; * to edge requests * * @see Message - * * @since GemFire 2.0.2 */ public class Part { + private static final byte BYTE_CODE = 0; private static final byte OBJECT_CODE = 1; private Version version; + /** * Used to represent and empty byte array for bug 36279 * @@ -68,7 +69,6 @@ public class Part { this.typeCode = tc; } - public void clear() { if (this.part != null) { if (this.part instanceof HeapDataOutputStream) { @@ -249,7 +249,6 @@ public class Part { | ((((long) bytes[6]) << 8) & 0x000000000000FF00l) | (bytes[7] & 0x00000000000000FFl); } - public byte[] getSerializedForm() { if (this.part == null) { return null; @@ -291,7 +290,7 @@ public class Part { * * @param buf the buffer to use if any data needs to be copied to one */ - public final void writeTo(OutputStream out, ByteBuffer buf) throws IOException { + public void writeTo(OutputStream out, ByteBuffer buf) throws IOException { if (getLength() > 0) { if (this.part instanceof byte[]) { byte[] bytes = (byte[]) this.part; @@ -436,19 +435,6 @@ public class Part { sb.append("partCode="); sb.append(typeCodeToString(this.typeCode)); sb.append(" partLength=" + getLength()); - // sb.append(" partBytes="); - // byte[] b = getSerializedForm(); - // if (b == null) { - // sb.append("null"); - // } - // else { - // sb.append("("); - // for (int i = 0; i < b.length; i ++) { - // sb.append(Integer.toString(b[i])); - // sb.append(" "); - // } - // sb.append(")"); - // } return sb.toString(); } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java index 39f30d6..f8771f7 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/parallel/ParallelGatewaySenderQueue.java @@ -904,28 +904,6 @@ public class ParallelGatewaySenderQueue implements RegionQueue { throw new UnsupportedOperationException(); } - /** - * TODO: Optimization needed. We are creating 1 array list for each peek!! - * - * @return BucketRegionQueue - */ - private final BucketRegionQueue getRandomBucketRegionQueue() { - PartitionedRegion prQ = getRandomShadowPR(); - if (prQ != null) { - final PartitionedRegionDataStore ds = prQ.getDataStore(); - final List<Integer> buckets = new ArrayList<Integer>(ds.getAllLocalPrimaryBucketIds()); - if (buckets.isEmpty()) - return null; - final int index = new Random().nextInt(buckets.size()); - final int brqId = buckets.get(index); - final BucketRegionQueue brq = (BucketRegionQueue) ds.getLocalBucketById(brqId); - if (brq.isReadyForPeek()) { - return brq; - } - } - return null; - } - protected boolean areLocalBucketQueueRegionsPresent() { boolean bucketsAvailable = false; for (PartitionedRegion prQ : this.userRegionNameToshadowPRMap.values()) { http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java index d38b2c7..b23615a 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/BatchDestroyOperation.java @@ -126,13 +126,6 @@ public class BatchDestroyOperation extends DistributedCacheOperation { } } } - // Non-optimized way - // for (Long k : (Set<Long>)rgn.keys()) { - // if (k > this.tailKey) { - // continue; - // } - // rgn.localDestroy(k, RegionQueue.WAN_QUEUE_TOKEN); - // } this.appliedOperation = true; } catch (CacheWriterException e) { throw new Error( @@ -147,8 +140,7 @@ public class BatchDestroyOperation extends DistributedCacheOperation { @Override @Retained - protected final InternalCacheEvent createEvent(DistributedRegion rgn) - throws EntryNotFoundException { + protected InternalCacheEvent createEvent(DistributedRegion rgn) throws EntryNotFoundException { EntryEventImpl ev = createEntryEvent(rgn); boolean evReturned = false; try { http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreation.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreation.java index 9501666..9eb6dfe 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreation.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheTransactionManagerCreation.java @@ -28,24 +28,20 @@ import org.apache.geode.internal.i18n.LocalizedStrings; /** * Represents a {@link CacheTransactionManager} that is created declaratively. * - * * @since GemFire 4.0 */ public class CacheTransactionManagerCreation implements CacheTransactionManager { - /////////////////////// Instance Fields /////////////////////// - /** The TransactionListener instance set using the cache's CacheTransactionManager */ private final ArrayList txListeners = new ArrayList(); + private TransactionWriter writer = null; - /////////////////////// Constructors /////////////////////// /** * Creates a new <code>CacheTransactionManagerCreation</code> */ public CacheTransactionManagerCreation() {} - ////////////////////// Instance Methods ////////////////////// public TransactionListener setListener(TransactionListener newListener) { TransactionListener result = getListener(); this.txListeners.clear(); @@ -78,7 +74,7 @@ public class CacheTransactionManagerCreation implements CacheTransactionManager return result; } - public final TransactionListener getListener() { + public TransactionListener getListener() { if (this.txListeners.isEmpty()) { return null; } else if (this.txListeners.size() == 1) { @@ -120,7 +116,7 @@ public class CacheTransactionManagerCreation implements CacheTransactionManager .toLocalizedString()); } - public final void setWriter(TransactionWriter writer) { + public void setWriter(TransactionWriter writer) { this.writer = writer; } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlVersion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlVersion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlVersion.java index 413fc4a..460f107 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlVersion.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlVersion.java @@ -19,12 +19,13 @@ import java.util.HashMap; /** * {@link Enum} for Cache XML versions. Resolves issues with old String based comparisons. Under the * old String comparison version "8.1" was older than "8_0" and "10.0" was older than "9.0". - * + * <p> + * TODO future - replace constants in CacheXml with this Enum completely * * @since GemFire 8.1 */ -// TODO future - replace constants in CacheXml with this Enum completely public enum CacheXmlVersion { + GEMFIRE_3_0(CacheXml.VERSION_3_0, CacheXml.PUBLIC_ID_3_0, CacheXml.SYSTEM_ID_3_0, null, null), GEMFIRE_4_0(CacheXml.VERSION_4_0, CacheXml.PUBLIC_ID_4_0, CacheXml.SYSTEM_ID_4_0, null, null), GEMFIRE_4_1(CacheXml.VERSION_4_1, CacheXml.PUBLIC_ID_4_1, CacheXml.SYSTEM_ID_4_1, null, null), @@ -132,7 +133,7 @@ public enum CacheXmlVersion { * @throws IllegalArgumentException if version does not exist. * @since GemFire 8.1 */ - public static final CacheXmlVersion valueForVersion(final String version) { + public static CacheXmlVersion valueForVersion(final String version) { final CacheXmlVersion cacheXmlVersion = valuesForVersion.get(version); if (null == cacheXmlVersion) { throw new IllegalArgumentException("No enum constant " http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2.java b/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2.java index 728cab4..410ca0c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/DefaultEntityResolver2.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.internal.cache.xmlcache; import java.io.IOException; @@ -26,12 +25,12 @@ import org.apache.geode.internal.ClassPathLoader; /** * Default behavior for EntityResolver2 implementations. - * + * <p> + * UnitTest PivotalEntityResolverJUnitTest and DefaultEntityResolver2Test * * @since GemFire 8.1 */ -// UnitTest PivotalEntityResolverJUnitTest -abstract public class DefaultEntityResolver2 implements EntityResolver2 { +public abstract class DefaultEntityResolver2 implements EntityResolver2 { @Override public InputSource resolveEntity(final String publicId, final String systemId) @@ -58,7 +57,7 @@ abstract public class DefaultEntityResolver2 implements EntityResolver2 { * @return InputSource if resource found, otherwise null. * @since GemFire 8.1 */ - protected final InputSource getClassPathInputSource(final String publicId, final String systemId, + protected InputSource getClassPathInputSource(final String publicId, final String systemId, final String path) { final InputStream stream = ClassPathLoader.getLatest().getResourceAsStream(getClass(), path); if (null == stream) { http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java index 3d375ad..71f491c 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java +++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveWriter.java @@ -140,7 +140,7 @@ public class StatArchiveWriter implements StatArchiveFormat, SampleHandler { * * @throws GemFireIOException if the archive file could not be closed. */ - public final void close() { + public void close() { try { this.dataOut.flush(); if (this.trace) { @@ -176,7 +176,7 @@ public class StatArchiveWriter implements StatArchiveFormat, SampleHandler { * Returns the number of bytes written so far to this archive. This does not take compression into * account. */ - public final long bytesWritten() { + public long bytesWritten() { return this.dataOut.getBytesWritten(); } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java index e59821d..4e450c7 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java +++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/Connection.java @@ -14,52 +14,82 @@ */ package org.apache.geode.internal.tcp; +import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT; + import org.apache.geode.CancelException; import org.apache.geode.SystemFailure; import org.apache.geode.cache.CacheClosedException; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.distributed.DistributedSystemDisconnectedException; -import org.apache.geode.distributed.internal.*; +import org.apache.geode.distributed.internal.ConflationKey; +import org.apache.geode.distributed.internal.DM; +import org.apache.geode.distributed.internal.DMStats; +import org.apache.geode.distributed.internal.DirectReplyProcessor; +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.distributed.internal.DistributionConfigImpl; +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.distributed.internal.DistributionMessage; +import org.apache.geode.distributed.internal.DistributionStats; +import org.apache.geode.distributed.internal.ReplyException; +import org.apache.geode.distributed.internal.ReplyMessage; +import org.apache.geode.distributed.internal.ReplyProcessor21; +import org.apache.geode.distributed.internal.ReplySender; import org.apache.geode.distributed.internal.direct.DirectChannel; import org.apache.geode.distributed.internal.membership.InternalDistributedMember; import org.apache.geode.distributed.internal.membership.MembershipManager; import org.apache.geode.i18n.StringId; -import org.apache.geode.internal.*; +import org.apache.geode.internal.Assert; +import org.apache.geode.internal.ByteArrayDataInput; +import org.apache.geode.internal.DSFIDFactory; +import org.apache.geode.internal.InternalDataSerializer; +import org.apache.geode.internal.SystemTimer; import org.apache.geode.internal.SystemTimer.SystemTimerTask; +import org.apache.geode.internal.Version; import org.apache.geode.internal.i18n.LocalizedStrings; import org.apache.geode.internal.logging.LogService; import org.apache.geode.internal.logging.LoggingThreadGroup; import org.apache.geode.internal.logging.log4j.AlertAppender; import org.apache.geode.internal.logging.log4j.LocalizedMessage; -import org.apache.geode.internal.net.*; +import org.apache.geode.internal.net.SocketCreator; import org.apache.geode.internal.tcp.MsgReader.Header; import org.apache.geode.internal.util.concurrent.ReentrantSemaphore; import org.apache.logging.log4j.Logger; -import java.io.*; -import java.net.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InterruptedIOException; +import java.io.OutputStream; +import java.net.ConnectException; +import java.net.Inet6Address; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketException; +import java.net.SocketTimeoutException; import java.nio.ByteBuffer; import java.nio.channels.CancelledKeyException; import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedSelectorException; import java.nio.channels.SocketChannel; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import static org.apache.geode.distributed.ConfigurationProperties.*; - /** - * <p> * Connection is a socket holder that sends and receives serialized message objects. A Connection * may be closed to preserve system resources and will automatically be reopened when it's needed. - * </p> - * + * * @since GemFire 2.0 - * */ - public class Connection implements Runnable { private static final Logger logger = LogService.getLogger(); @@ -153,6 +183,7 @@ public class Connection implements Runnable { */ private static final boolean DOMINO_THREAD_OWNED_SOCKETS = Boolean.getBoolean("p2p.ENABLE_DOMINO_THREAD_OWNED_SOCKETS"); + private final static ThreadLocal isDominoThread = new ThreadLocal(); // return true if this thread is a reader thread @@ -214,22 +245,13 @@ public class Connection implements Runnable { } }; - // /** - // * name of sender thread thread. Useful in finding out why a reader - // * thread was created. Add sending of the name in handshakes and - // * add it to the name of the reader thread (the code is there but commented out) - // */ - // private String senderName = null; - - // If we are a sender then we want to know if the receiver on the - // other end is willing to have its messages queued. The following - // four "async" inst vars come from his handshake response. /** * How long to wait if receiver will not accept a message before we go into queue mode. * * @since GemFire 4.2.2 */ private int asyncDistributionTimeout = 0; + /** * How long to wait, with the receiver not accepting any messages, before kicking the receiver out * of the distributed system. Ignored if asyncDistributionTimeout is zero. @@ -237,6 +259,7 @@ public class Connection implements Runnable { * @since GemFire 4.2.2 */ private int asyncQueueTimeout = 0; + /** * How much queued data we can have, with the receiver not accepting any messages, before kicking * the receiver out of the distributed system. Ignored if asyncDistributionTimeout is zero. @@ -245,6 +268,7 @@ public class Connection implements Runnable { * @since GemFire 4.2.2 */ private long asyncMaxQueueSize = 0; + /** * True if an async queue is already being filled. */ @@ -256,9 +280,6 @@ public class Connection implements Runnable { */ private final Map conflatedKeys = new HashMap(); - // private final Queue outgoingQueue = new LinkedBlockingQueue(); - - // NOTE: LinkedBlockingQueue has a bug in which removes from the queue // cause future offer to increase the size without adding anything to the queue. // So I've changed from this backport class to a java.util.LinkedList @@ -298,13 +319,6 @@ public class Connection implements Runnable { /** message reader thread */ private volatile Thread readerThread; - // /** - // * When a thread owns the outLock and is writing to the socket, it must - // * be placed in this variable so that it can be interrupted should the - // * socket need to be closed. - // */ - // private volatile Thread writerThread; - /** whether the reader thread is, or should be, running */ volatile boolean stopped = true; @@ -330,9 +344,6 @@ public class Connection implements Runnable { */ private SystemTimer.SystemTimerTask ackTimeoutTask; - // State for ackTimeoutTask: transmissionStartTime, ackWaitTimeout, ackSATimeout, - // ackConnectionGroup, ackThreadName - /** * millisecond clock at the time message transmission started, if doing forced-disconnect * processing @@ -354,7 +365,6 @@ public class Connection implements Runnable { /** name of thread that we're currently performing an operation in (may be null) */ String ackThreadName; - /** the buffer used for NIO message receipt */ ByteBuffer nioInputBuffer; @@ -514,7 +524,6 @@ public class Connection implements Runnable { } } c.waitForHandshake(); - // sendHandshakeReplyOK(); c.finishedConnecting = true; return c; } @@ -540,8 +549,6 @@ public class Connection implements Runnable { try { socket.setTcpNoDelay(true); socket.setKeepAlive(true); - // socket.setSoLinger(true, (Integer.valueOf(System.getProperty("p2p.lingerTime", - // "5000"))).intValue()); setSendBufferSize(socket, SMALL_BUFFER_SIZE); setReceiveBufferSize(socket); } catch (SocketException e) { @@ -922,17 +929,6 @@ public class Connection implements Runnable { os.writeLong(this.uniqueId); Version.CURRENT.writeOrdinal(os, true); os.writeInt(dominoCount.get() + 1); - // this writes the sending member + thread name that is stored in senderName - // on the receiver to show the cause of reader thread creation - // if (dominoCount.get() > 0) { - // os.writeUTF(Thread.currentThread().getName()); - // } else { - // String name = owner.getDM().getConfig().getName(); - // if (name == null) { - // name = "pid="+OSProcess.getId(); - // } - // os.writeUTF("["+name+"] "+Thread.currentThread().getName()); - // } os.flush(); byte[] msg = baos.toByteArray(); @@ -1268,8 +1264,6 @@ public class Connection implements Runnable { this.socket = channel.socket(); } else { if (TCPConduit.useSSL) { - // socket = javax.net.ssl.SSLSocketFactory.getDefault() - // .createSocket(remoteAddr.getInetAddress(), remoteAddr.getPort()); int socketBufferSize = sharedResource ? SMALL_BUFFER_SIZE : this.owner.getConduit().tcpBufferSize; this.socket = owner.getConduit().getSocketCreator().connectForServer( @@ -3283,7 +3277,7 @@ public class Connection implements Runnable { * @param forceAsync true if we need to force a blocking async write. * @throws ConnectionException if the conduit has stopped */ - protected final void nioWriteFully(SocketChannel channel, ByteBuffer buffer, boolean forceAsync, + protected void nioWriteFully(SocketChannel channel, ByteBuffer buffer, boolean forceAsync, DistributionMessage msg) throws IOException, ConnectionException { final DMStats stats = this.owner.getConduit().stats; if (!this.sharedResource) { @@ -3356,7 +3350,6 @@ public class Connection implements Runnable { protected static final byte STATE_RECEIVED_ACK = 4; /** the connection is in use and is reading a message */ protected static final byte STATE_READING = 5; - /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /** set to true if we exceeded the ack-wait-threshold waiting for a response */ @@ -3378,7 +3371,6 @@ public class Connection implements Runnable { this.connectionState = STATE_READING_ACK; } - boolean origSocketInUse = this.socketInUse; this.socketInUse = true; MsgReader msgReader = null; @@ -3474,7 +3466,6 @@ public class Connection implements Runnable { } } - /** * processes the current NIO buffer. If there are complete messages in the buffer, they are * deserialized and passed to TCPConduit for further processing @@ -3916,14 +3907,10 @@ public class Connection implements Runnable { } private void setThreadName(int dominoNumber) { - Thread.currentThread().setName( - // (!this.sharedResource && this.senderName != null? ("<"+this.senderName+"> -> - // ") : "") + - // "[" + name + "] "+ - "P2P message reader for " + this.remoteAddr + " " + (this.sharedResource ? "" : "un") - + "shared" + " " + (this.preserveOrder ? "" : "un") + "ordered" + " uid=" - + this.uniqueId + (dominoNumber > 0 ? (" dom #" + dominoNumber) : "") + " port=" - + this.socket.getPort()); + Thread.currentThread().setName("P2P message reader for " + this.remoteAddr + " " + + (this.sharedResource ? "" : "un") + "shared" + " " + (this.preserveOrder ? "" : "un") + + "ordered" + " uid=" + this.uniqueId + (dominoNumber > 0 ? (" dom #" + dominoNumber) : "") + + " port=" + this.socket.getPort()); } private void compactOrResizeBuffer(int messageLength) { http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/management/internal/IdentityConverter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/IdentityConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/IdentityConverter.java index ce5ba45..4063457 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/IdentityConverter.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/IdentityConverter.java @@ -21,10 +21,9 @@ import javax.management.openmbean.OpenType; /** * Converter for classes where the open data is identical to the original data. This is true for any * of the SimpleType types, and for an any-dimension array of those - * - * */ public class IdentityConverter extends OpenTypeConverter { + IdentityConverter(Type targetType, OpenType openType, Class openClass) { super(targetType, openType, openClass); } @@ -33,7 +32,7 @@ public class IdentityConverter extends OpenTypeConverter { return true; } - final Object toNonNullOpenValue(Object value) { + Object toNonNullOpenValue(Object value) { return value; } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/management/internal/OpenTypeConverter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/OpenTypeConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/OpenTypeConverter.java index 4fdf291..0fb2b39 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/OpenTypeConverter.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/OpenTypeConverter.java @@ -76,13 +76,12 @@ import org.apache.geode.management.ManagementException; * * Apart from simple types, arrays, and collections, Java types are converted through introspection * into CompositeType - * - * */ public abstract class OpenTypeConverter { private final Type targetType; - /* + + /** * The Java class corresponding to getOpenType(). This is the class named by * getOpenType().getClassName(), except that it may be a primitive type or an array of primitive * type. @@ -113,9 +112,7 @@ public abstract class OpenTypeConverter { /** * Convert an instance of openClass into an instance of targetType. * - * @param value * @return the java type object - * @throws InvalidObjectException */ public Object fromOpenValue(Object value) throws InvalidObjectException { if (value == null) @@ -129,8 +126,6 @@ public abstract class OpenTypeConverter { /** * Throw an appropriate InvalidObjectException if we will not be able to convert back from the * open data to the original Java object. - * - * @throws InvalidObjectException */ void checkReconstructible() throws InvalidObjectException { // subclasses can override @@ -139,9 +134,7 @@ public abstract class OpenTypeConverter { /** * Convert an instance of targetType into an instance of openClass. * - * @param value * @return open class object - * @throws OpenDataException */ Object toOpenValue(Object value) throws OpenDataException { if (value == null) @@ -153,7 +146,6 @@ public abstract class OpenTypeConverter { abstract Object toNonNullOpenValue(Object value) throws OpenDataException; /** - * * @return True if and only if this OpenTypeConverter's toOpenValue and fromOpenValue methods are * the identity function. */ @@ -174,8 +166,6 @@ public abstract class OpenTypeConverter { } /** - * - * @param type * @return a converter corresponding to a type */ private static synchronized OpenTypeConverter getConverter(Type type) { @@ -192,9 +182,6 @@ public abstract class OpenTypeConverter { /** * Put the converter in the map to avoid future creation - * - * @param type - * @param conv */ private static synchronized void putConverter(Type type, OpenTypeConverter conv) { WeakReference<OpenTypeConverter> wr = new WeakReference<OpenTypeConverter>(conv); @@ -206,7 +193,7 @@ public abstract class OpenTypeConverter { preDefinedConverters.add(conv); } - /** + /* * Static block to initialize pre defined convertor */ static { @@ -250,10 +237,7 @@ public abstract class OpenTypeConverter { } /** - * - * @param objType * @return the converter for the given Java type, creating it if necessary - * @throws OpenDataException */ public static synchronized OpenTypeConverter toConverter(Type objType) throws OpenDataException { @@ -281,10 +265,7 @@ public abstract class OpenTypeConverter { } /** - * - * @param objType - * @return the open type converrter for a given type - * @throws OpenDataException + * @return the open type converter for a given type */ private static OpenTypeConverter makeConverter(Type objType) throws OpenDataException { @@ -346,6 +327,7 @@ public abstract class OpenTypeConverter { } protected static final String[] keyArray = {"key"}; + protected static final String[] keyValueArray = {"key", "value"}; private static OpenTypeConverter makeTabularConverter(Type objType, boolean sortedMap, @@ -363,16 +345,14 @@ public abstract class OpenTypeConverter { } /** - * Supprted types are List<E>, Set<E>, SortedSet<E>, Map<K,V>, SortedMap<K,V>. + * Supported types are List<E>, Set<E>, SortedSet<E>, Map<K,V>, SortedMap<K,V>. * * Subclasses of the above types wont be supported as deserialize info wont be there. * * Queue<E> won't be supported as Queue is more of a functional data structure rather than a data * holder * - * @param objType - * @return the open type converrter for a given type - * @throws OpenDataException + * @return the open type converter for a given type */ private static OpenTypeConverter makeParameterizedConverter(ParameterizedType objType) throws OpenDataException { @@ -402,10 +382,7 @@ public abstract class OpenTypeConverter { } /** - * - * @param c * @return the open type converrter for a given type - * @throws OpenDataException */ private static OpenTypeConverter makeCompositeConverter(Class c) throws OpenDataException { @@ -456,8 +433,6 @@ public abstract class OpenTypeConverter { /** * Converts from a CompositeData to an instance of the targetClass Various subclasses override its * functionality. - * - * */ protected static abstract class CompositeBuilder { CompositeBuilder(Class targetClass, String[] itemNames) { @@ -477,10 +452,8 @@ public abstract class OpenTypeConverter { * If the subclass should be appropriate but there is a problem, then the method throws * InvalidObjectException. * - * @param getters * @return If the subclass is appropriate for targetClass, then the method returns null. If the * subclass is not appropriate, then the method returns an explanation of why not. - * @throws InvalidObjectException */ abstract String applicable(Method[] getters) throws InvalidObjectException; @@ -493,12 +466,7 @@ public abstract class OpenTypeConverter { } /** - * - * @param cd - * @param itemNames - * @param converters * @return Actual java types from the composite type - * @throws InvalidObjectException */ abstract Object fromCompositeData(CompositeData cd, String[] itemNames, OpenTypeConverter[] converters) throws InvalidObjectException; @@ -509,8 +477,6 @@ public abstract class OpenTypeConverter { /** * Builder if the target class has a method "public static from(CompositeData)" - * - * */ protected static class CompositeBuilderViaFrom extends CompositeBuilder { @@ -545,8 +511,8 @@ public abstract class OpenTypeConverter { } } - final Object fromCompositeData(CompositeData cd, String[] itemNames, - OpenTypeConverter[] converters) throws InvalidObjectException { + Object fromCompositeData(CompositeData cd, String[] itemNames, OpenTypeConverter[] converters) + throws InvalidObjectException { try { return fromMethod.invoke(null, cd); } catch (Exception e) { @@ -566,8 +532,6 @@ public abstract class OpenTypeConverter { * are candidate builders. Instead, the "applicable" method will return an explanatory string, and * the other builders will be skipped. If all the getters are OK, then the "applicable" method * will return an empty string and the other builders will be tried. - * - * */ protected static class CompositeBuilderCheckGetters extends CompositeBuilder { CompositeBuilderCheckGetters(Class targetClass, String[] itemNames, @@ -604,8 +568,6 @@ public abstract class OpenTypeConverter { /** * Builder if the target class has a setter for every getter - * - * */ protected static class CompositeBuilderViaSetters extends CompositeBuilder { @@ -664,8 +626,6 @@ public abstract class OpenTypeConverter { /** * Builder if the target class has a constructor that is annotated with @ConstructorProperties so * we can derive the corresponding getters. - * - * */ protected static class CompositeBuilderViaConstructor extends CompositeBuilder { @@ -848,8 +808,6 @@ public abstract class OpenTypeConverter { * Builder if the target class is an interface and contains no methods other than getters. Then we * can make an instance using a dynamic proxy that forwards the getters to the source * CompositeData - * - * */ protected static class CompositeBuilderViaProxy extends CompositeBuilder { @@ -882,8 +840,7 @@ public abstract class OpenTypeConverter { return null; } - final Object fromCompositeData(CompositeData cd, String[] itemNames, - OpenTypeConverter[] converters) { + Object fromCompositeData(CompositeData cd, String[] itemNames, OpenTypeConverter[] converters) { final Class targetClass = getTargetClass(); return Proxy.newProxyInstance(targetClass.getClassLoader(), new Class[] {targetClass}, new CompositeDataInvocationHandler(cd)); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/management/internal/cli/json/TypedJson.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/json/TypedJson.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/json/TypedJson.java index fd9461f..107ac0b 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/json/TypedJson.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/json/TypedJson.java @@ -42,8 +42,6 @@ import org.apache.geode.pdx.PdxInstance; * * Although it has limited functionality,still a simple use of add() method should suffice for most * of the simple JSON use cases. - * - * */ public class TypedJson { @@ -137,7 +135,6 @@ public class TypedJson { } } - } } } @@ -150,9 +147,7 @@ public class TypedJson { } } - /** - * * User can build on this object by adding Objects against a key. * * TypedJson result = new TypedJson(); result.add(KEY,object); If users add more objects against @@ -218,7 +213,6 @@ public class TypedJson { commanate = false; addComma = true; } - } writer.write('}'); @@ -312,7 +306,7 @@ public class TypedJson { return false; } - final void writeVal(Writer w, Object value) throws IOException { + void writeVal(Writer w, Object value) throws IOException { w.write('{'); addVal(w, value); w.write('}'); @@ -325,7 +319,6 @@ public class TypedJson { if (shouldVisitChildren(object)) { visitChildrens(w, object, true); } - } void writeKeyValue(Writer w, Object key, Object value, Class type) throws IOException { @@ -379,7 +372,6 @@ public class TypedJson { } void writeArray(Writer w, Object object) throws IOException { - if (commanate) { w.write(","); } @@ -419,7 +411,6 @@ public class TypedJson { for (int i = 0; i < length && elements < queryCollectionsDepth; i += 1) { Object item = Array.get(object, i); items.add(item); - } return items; } @@ -463,7 +454,6 @@ public class TypedJson { endType(w, rootClazz); } catch (IOException e) { } - } void startKey(Writer writer, String key) throws IOException { @@ -478,7 +468,6 @@ public class TypedJson { if (key != null) { writer.write('}'); } - } List<Object> visitSpecialObjects(Writer w, Object object, boolean write) throws IOException { @@ -563,8 +552,6 @@ public class TypedJson { } else { elements.add(fieldValue); } - - } if (write) w.write('}'); @@ -593,7 +580,6 @@ public class TypedJson { return elements; } - if (object instanceof Region.Entry) { Region.Entry entry = (Region.Entry) object; Object key = entry.getKey(); @@ -608,11 +594,9 @@ public class TypedJson { elements.add(value); } - return elements; } - return elements; } @@ -627,7 +611,6 @@ public class TypedJson { /** * Handle some special GemFire classes. We don't want to expose some of the internal classes. * Hence corresponding interface or external classes should be shown. - * */ String internalToExternal(Class clazz, Object value) { if (value != null && value instanceof Region.Entry) { http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java index cef8cab..b3fae18 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/domain/Link.java @@ -77,7 +77,7 @@ public class Link implements Comparable<Link>, Serializable { return href; } - public final void setHref(final URI href) { + public void setHref(final URI href) { assert href != null : "The Link href URI cannot be null!"; this.href = href; } @@ -87,7 +87,7 @@ public class Link implements Comparable<Link>, Serializable { return method; } - public final void setMethod(final HttpMethod method) { + public void setMethod(final HttpMethod method) { this.method = ObjectUtils.defaultIfNull(method, DEFAULT_HTTP_METHOD); } @@ -96,7 +96,7 @@ public class Link implements Comparable<Link>, Serializable { return relation; } - public final void setRelation(final String relation) { + public void setRelation(final String relation) { assert !StringUtils.isBlank(relation) : "The Link relation (rel) must be specified!"; this.relation = relation; } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java index ea9c81c..43657b9 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/web/http/ClientHttpRequest.java @@ -117,7 +117,7 @@ public class ClientHttpRequest implements HttpRequest { * @return the Link encapsulating the URI and method for the client's HTTP request. * @see org.apache.geode.management.internal.web.domain.Link */ - public final Link getLink() { + public Link getLink() { return link; } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/main/java/org/apache/geode/redis/internal/executor/AbstractScanExecutor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/redis/internal/executor/AbstractScanExecutor.java b/geode-core/src/main/java/org/apache/geode/redis/internal/executor/AbstractScanExecutor.java index 0eb6dca..716c3f4 100755 --- a/geode-core/src/main/java/org/apache/geode/redis/internal/executor/AbstractScanExecutor.java +++ b/geode-core/src/main/java/org/apache/geode/redis/internal/executor/AbstractScanExecutor.java @@ -20,7 +20,6 @@ import java.util.regex.Pattern; import org.apache.geode.redis.internal.org.apache.hadoop.fs.GlobPattern; - public abstract class AbstractScanExecutor extends AbstractExecutor { protected final String ERROR_CURSOR = "Invalid cursor"; @@ -39,9 +38,10 @@ public abstract class AbstractScanExecutor extends AbstractExecutor { * @param pattern A glob pattern. * @return A regex pattern to recognize the given glob pattern. */ - protected final Pattern convertGlobToRegex(String pattern) { - if (pattern == null) + protected Pattern convertGlobToRegex(String pattern) { + if (pattern == null) { return null; + } return GlobPattern.compile(pattern); } } http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/DataSerializerTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/DataSerializerTest.java b/geode-core/src/test/java/org/apache/geode/DataSerializerTest.java new file mode 100644 index 0000000..e550981 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/DataSerializerTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.EventID; +import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class DataSerializerTest { + + @Test + public void shouldBeMockable() throws Exception { + DataSerializer mockDataSerializer = mock(DataSerializer.class); + EventID mockEventID = mock(EventID.class); + ClientProxyMembershipID mockClientProxyMembershipID = mock(ClientProxyMembershipID.class); + + when(mockDataSerializer.getEventId()).thenReturn(mockEventID); + when(mockDataSerializer.getContext()).thenReturn(mockClientProxyMembershipID); + + mockDataSerializer.setEventId(mockEventID); + mockDataSerializer.setContext(mockClientProxyMembershipID); + + verify(mockDataSerializer, times(1)).setEventId(mockEventID); + verify(mockDataSerializer, times(1)).setContext(mockClientProxyMembershipID); + + assertThat(mockDataSerializer.getEventId()).isSameAs(mockEventID); + assertThat(mockDataSerializer.getContext()).isSameAs(mockClientProxyMembershipID); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/InstantiatorTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/InstantiatorTest.java b/geode-core/src/test/java/org/apache/geode/InstantiatorTest.java new file mode 100644 index 0000000..6a20872 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/InstantiatorTest.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.EventID; +import org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class InstantiatorTest { + + @Test + public void shouldBeMockable() throws Exception { + Instantiator mockInstantiator = mock(Instantiator.class); + EventID mockEventID = mock(EventID.class); + ClientProxyMembershipID mockClientProxyMembershipID = mock(ClientProxyMembershipID.class); + + when(mockInstantiator.getInstantiatedClass()).thenReturn(null); + when(mockInstantiator.getId()).thenReturn(0); + when(mockInstantiator.getEventId()).thenReturn(mockEventID); + when(mockInstantiator.getContext()).thenReturn(mockClientProxyMembershipID); + + mockInstantiator.setEventId(mockEventID); + mockInstantiator.setContext(mockClientProxyMembershipID); + + verify(mockInstantiator, times(1)).setEventId(mockEventID); + verify(mockInstantiator, times(1)).setContext(mockClientProxyMembershipID); + + assertThat(mockInstantiator.getEventId()).isSameAs(mockEventID); + assertThat(mockInstantiator.getContext()).isSameAs(mockClientProxyMembershipID); + assertThat(mockInstantiator.getInstantiatedClass()).isNull(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/admin/RegionSubRegionSnapshotTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/admin/RegionSubRegionSnapshotTest.java b/geode-core/src/test/java/org/apache/geode/admin/RegionSubRegionSnapshotTest.java new file mode 100644 index 0000000..10c0beb --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/admin/RegionSubRegionSnapshotTest.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.admin; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.util.Collections; + +@Category(UnitTest.class) +public class RegionSubRegionSnapshotTest { + + @Test + public void shouldBeMockable() throws Exception { + RegionSubRegionSnapshot mockRegionSubRegionSnapshot = mock(RegionSubRegionSnapshot.class); + RegionSubRegionSnapshot mockRegionSubRegionSnapshotParent = mock(RegionSubRegionSnapshot.class); + + when(mockRegionSubRegionSnapshot.getEntryCount()).thenReturn(0); + when(mockRegionSubRegionSnapshot.getName()).thenReturn("name"); + when(mockRegionSubRegionSnapshot.getSubRegionSnapshots()).thenReturn(Collections.emptySet()); + when(mockRegionSubRegionSnapshot.getParent()).thenReturn(mockRegionSubRegionSnapshotParent); + + mockRegionSubRegionSnapshot.setEntryCount(1); + mockRegionSubRegionSnapshot.setName("NAME"); + mockRegionSubRegionSnapshot.setSubRegionSnapshots(null); + mockRegionSubRegionSnapshot.setParent(null); + + verify(mockRegionSubRegionSnapshot, times(1)).setEntryCount(1); + verify(mockRegionSubRegionSnapshot, times(1)).setName("NAME"); + verify(mockRegionSubRegionSnapshot, times(1)).setSubRegionSnapshots(null); + verify(mockRegionSubRegionSnapshot, times(1)).setParent(null); + + assertThat(mockRegionSubRegionSnapshot.getEntryCount()).isEqualTo(0); + assertThat(mockRegionSubRegionSnapshot.getName()).isEqualTo("name"); + assertThat(mockRegionSubRegionSnapshot.getSubRegionSnapshots()) + .isEqualTo(Collections.emptySet()); + assertThat(mockRegionSubRegionSnapshot.getParent()).isSameAs(mockRegionSubRegionSnapshotParent); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/cache/ConnectionPoolFactoryJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/ConnectionPoolFactoryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/ConnectionPoolFactoryJUnitTest.java index 18af019..b81c08f 100755 --- a/geode-core/src/test/java/org/apache/geode/cache/ConnectionPoolFactoryJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache/ConnectionPoolFactoryJUnitTest.java @@ -106,7 +106,7 @@ public class ConnectionPoolFactoryJUnitTest { } @Test - public final void testCreateDefaultAndInvalidAndLegitAttributes() { + public void testCreateDefaultAndInvalidAndLegitAttributes() { PoolFactory cpf = PoolManager.createFactory(); ((PoolFactoryImpl) cpf).setStartDisabled(true); http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/cache/DiskAccessExceptionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/DiskAccessExceptionTest.java b/geode-core/src/test/java/org/apache/geode/cache/DiskAccessExceptionTest.java new file mode 100644 index 0000000..31019f7 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/cache/DiskAccessExceptionTest.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.cache; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class DiskAccessExceptionTest { + + @Test + public void shouldBeMockable() throws Exception { + DiskAccessException mockDiskAccessException = mock(DiskAccessException.class); + when(mockDiskAccessException.isRemote()).thenReturn(true); + assertThat(mockDiskAccessException.isRemote()).isTrue(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/cache/client/internal/AbstractOpTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/client/internal/AbstractOpTest.java b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AbstractOpTest.java new file mode 100644 index 0000000..ef1f514 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/cache/client/internal/AbstractOpTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.cache.client.internal; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.apache.geode.internal.cache.tier.sockets.Message; +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class AbstractOpTest { + + @Test + public void shouldBeMockable() throws Exception { + AbstractOp mockAbstractOp = mock(AbstractOp.class); + Object mockObject = mock(Object.class); + when(mockAbstractOp.processObjResponse(any(), anyString())).thenReturn(mockObject); + assertThat(mockAbstractOp.processObjResponse(mock(Message.class), "string")) + .isEqualTo(mockObject); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionExceptionTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionExceptionTest.java b/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionExceptionTest.java new file mode 100644 index 0000000..daa90ba --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/cache/execute/FunctionExceptionTest.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package org.apache.geode.cache.execute; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +@Category(UnitTest.class) +public class FunctionExceptionTest { + + @Test + public void shouldBeMockable() throws Exception { + FunctionException mockFunctionException = mock(FunctionException.class); + Exception cause = new Exception(); + List<Exception> exceptions = new ArrayList<>(); + exceptions.add(cause); + + when(mockFunctionException.getExceptions()).thenReturn(Collections.emptyList()); + + mockFunctionException.addException(cause); + mockFunctionException.addExceptions(exceptions); + + verify(mockFunctionException, times(1)).addException(cause); + verify(mockFunctionException, times(1)).addExceptions(exceptions); + + assertThat(mockFunctionException.getExceptions()).isEmpty(); + } +} http://git-wip-us.apache.org/repos/asf/geode/blob/f0218047/geode-core/src/test/java/org/apache/geode/cache/query/functional/PdxOrderByJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/cache/query/functional/PdxOrderByJUnitTest.java b/geode-core/src/test/java/org/apache/geode/cache/query/functional/PdxOrderByJUnitTest.java index 9655ab4..7a106b5 100644 --- a/geode-core/src/test/java/org/apache/geode/cache/query/functional/PdxOrderByJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/cache/query/functional/PdxOrderByJUnitTest.java @@ -195,7 +195,7 @@ public class PdxOrderByJUnitTest { } - final public Region createRegion(String name, String rootName, RegionAttributes attrs) + public Region createRegion(String name, String rootName, RegionAttributes attrs) throws CacheException { Region root = getRootRegion(rootName); if (root == null) { @@ -220,11 +220,11 @@ public class PdxOrderByJUnitTest { return root.createSubregion(name, attrs); } - public final Region getRootRegion(String rootName) { + public Region getRootRegion(String rootName) { return CacheUtils.getRegion(rootName); } - public final Region createRootRegion(String rootName, RegionAttributes attrs) + public Region createRootRegion(String rootName, RegionAttributes attrs) throws RegionExistsException, TimeoutException { return ((GemFireCacheImpl) CacheUtils.getCache()).createRegion(rootName, attrs); }