[ 
https://issues.apache.org/jira/browse/PHOENIX-6968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17770523#comment-17770523
 ] 

ASF GitHub Bot commented on PHOENIX-6968:
-----------------------------------------

ranganathg commented on code in PR #1691:
URL: https://github.com/apache/phoenix/pull/1691#discussion_r1341622874


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/FailingPhoenixRegionServerEndpoint.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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.phoenix.end2end;
+
+import com.google.protobuf.RpcCallback;
+import com.google.protobuf.RpcController;
+import org.apache.phoenix.coprocessor.PhoenixRegionServerEndpoint;
+import org.apache.phoenix.coprocessor.generated.RegionServerEndpointProtos;
+import org.apache.phoenix.protobuf.ProtobufUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+import static 
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS;
+import static 
org.apache.phoenix.coprocessor.MetaDataEndpointImpl.PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS_DEFAULT;
+
+public class FailingPhoenixRegionServerEndpoint extends 
PhoenixRegionServerEndpoint {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(FailingPhoenixRegionServerEndpoint.class);
+
+    private boolean throwException;
+    private boolean shouldSleep;
+
+    @Override
+    public void invalidateServerMetadataCache(RpcController controller,
+            RegionServerEndpointProtos.InvalidateServerMetadataCacheRequest 
request,
+            
RpcCallback<RegionServerEndpointProtos.InvalidateServerMetadataCacheResponse> 
done) {
+        long metadataCacheInvalidationTimeoutMs = conf.getLong(
+                PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS,
+                PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS_DEFAULT);
+
+        if (throwException == true) {
+            IOException ioe = new IOException("On purpose");
+            ProtobufUtil.setControllerException(controller, ioe);
+            return;
+        } else if (shouldSleep) {
+            try {
+                // Sleeping for 2 seconds more than 
metadataCacheInvalidationTimeoutMs.
+                Thread.sleep(metadataCacheInvalidationTimeoutMs + 2000);
+            } catch (InterruptedException e) {
+                LOGGER.warn("Exception while sleeping in 
FailingPhoenixRegionServerEndpoint", e);
+            }
+        } else {
+            LOGGER.info("Invalidating server metadata cache");

Review Comment:
   should there be a call to invalidateServerMetadataCache() in the base class? 
how does the cache get invalidated without any call?





> Create PhoenixRegionServerEndpoint#invalidateCache method to invalidate cache.
> ------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6968
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6968
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Rushabh Shah
>            Assignee: Rushabh Shah
>            Priority: Major
>
> Whenever we update metadata (like alter table add column, drop table), we 
> need to invalidate metadata cache entry (introduced by PHOENIX-6943) on all 
> the regionservers which has that cache entry. First step would be to issue an 
> invalidate command on all the regionservers irrespective of whether that 
> regionserver has the cache entry. We can further optimize by invalidating 
> only on RS that has that cache entry.
> In PHOENIX-6988 we created PhoenixRegionServerEndpoint implementing 
> RegionServerCoprocessor. We can create a new method in this co-proc something 
> like invalidateCache(CacheEntry) to invalidate cache for a given 
> table/view/index.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to