agingade commented on a change in pull request #5124: URL: https://github.com/apache/geode/pull/5124#discussion_r427610264
########## File path: geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegionClearMessage.java ########## @@ -0,0 +1,289 @@ +/* + * 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.internal.cache; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.apache.geode.DataSerializer; +import org.apache.geode.cache.CacheException; +import org.apache.geode.cache.Operation; +import org.apache.geode.distributed.internal.ClusterDistributionManager; +import org.apache.geode.distributed.internal.DistributionManager; +import org.apache.geode.distributed.internal.DistributionMessage; +import org.apache.geode.distributed.internal.InternalDistributedSystem; +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.membership.InternalDistributedMember; +import org.apache.geode.internal.Assert; +import org.apache.geode.internal.NanoTimer; +import org.apache.geode.internal.cache.partitioned.PartitionMessage; +import org.apache.geode.internal.logging.log4j.LogMarker; +import org.apache.geode.internal.serialization.DeserializationContext; +import org.apache.geode.internal.serialization.SerializationContext; +import org.apache.geode.logging.internal.log4j.api.LogService; + +public class PartitionedRegionClearMessage extends PartitionMessage { + + public enum OperationType { + OP_LOCK_FOR_PR_CLEAR, OP_UNLOCK_FOR_PR_CLEAR, OP_PR_CLEAR, + } + + private Object cbArg; + + private OperationType op; + + private EventID eventID; + + private PartitionedRegion partitionedRegion; + + private Set<InternalDistributedMember> recipients; + + private ArrayList bucketsCleared; + + @Override + public EventID getEventID() { + return eventID; + } + + public PartitionedRegionClearMessage() {} + + PartitionedRegionClearMessage(Set recipients, PartitionedRegion region, + ReplyProcessor21 processor, PartitionedRegionClearMessage.OperationType operationType, + final RegionEventImpl event) { + super(recipients, region.getPRId(), processor); + this.recipients = recipients; + partitionedRegion = region; + op = operationType; + cbArg = event.getRawCallbackArgument(); + eventID = event.getEventId(); + } + + public OperationType getOp() { + return op; + } + + public void send() { + Assert.assertTrue(recipients != null, "ClearMessage NULL recipients set"); + setTransactionDistributed(partitionedRegion.getCache().getTxManager().isDistributed()); + partitionedRegion.getDistributionManager().putOutgoing(this); + } + + @Override + protected Throwable processCheckForPR(PartitionedRegion pr, + DistributionManager distributionManager) { + if (pr != null && !pr.getDistributionAdvisor().isInitialized()) { + Throwable thr = new ForceReattemptException( + String.format("%s : could not find partitioned region with Id %s", + distributionManager.getDistributionManagerId(), + pr.getRegionIdentifier())); + return thr; + } + return null; + } + + @Override + protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, + PartitionedRegion partitionedRegion, + long startTime) throws CacheException { + + if (partitionedRegion == null) { + return true; + } + + if (partitionedRegion.isDestroyed()) { Review comment: Thats not true; if the region is not destroyed, it returns false. line#1892 in LocalRegion.java. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org