[
https://issues.apache.org/jira/browse/PHOENIX-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17739743#comment-17739743
]
ASF GitHub Bot commented on PHOENIX-6943:
-----------------------------------------
shahrs87 commented on code in PR #1610:
URL: https://github.com/apache/phoenix/pull/1610#discussion_r1251321107
##########
phoenix-core/src/main/java/org/apache/phoenix/cache/ServerMetadataCache.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cache;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.coprocessor.generated.DDLTimestampMaintainersProtos;
+import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.thirdparty.com.google.common.cache.Cache;
+import org.apache.phoenix.thirdparty.com.google.common.cache.CacheBuilder;
+import org.apache.phoenix.thirdparty.com.google.common.cache.RemovalListener;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.QueryUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB;
+
+/**
+ * This manages the cache for all the objects(data table, views, indexes) on
each region server.
+ * Currently, it only stores LAST_DDL_TIMESTAMP in the cache.
+ */
+public class ServerMetadataCache {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ServerMetadataCache.class);
+ private static final String PHOENIX_COPROC_REGIONSERVER_CACHE_TTL_MS =
"phoenix.coprocessor.regionserver.cahe.ttl.ms";
+ // Keeping default cache expiry for 30 mins since we won't have stale
entry for more than 30 mins.
+ private static final long DEFAULT_PHOENIX_COPROC_REGIONSERVER_CACHE_TTL_MS
= 30 * 60 * 1000; // 30 mins
+ private static volatile ServerMetadataCache INSTANCE;
+ private Configuration conf;
+ // key is the combination of <tenantID, schema name, table name>, value is
the lastDDLTimestamp
+ private final Cache<ImmutableBytesPtr, Long> lastDDLTimestampMap;
+
+ /**
+ * Creates/gets an instance of ServerMetadataCache.
+ * @param env RegionCoprocessorEnvironment
+ * @return cache
+ */
+ public static ServerMetadataCache getInstance(RegionCoprocessorEnvironment
env) {
+ ServerMetadataCache result = INSTANCE;
+ if (result == null) {
+ synchronized (ServerMetadataCache.class) {
Review Comment:
Is this comment just informational? or are you expecting some changes in the
code? @jpisaac
> Add MetadaCache on each region server.
> --------------------------------------
>
> Key: PHOENIX-6943
> URL: https://issues.apache.org/jira/browse/PHOENIX-6943
> Project: Phoenix
> Issue Type: Sub-task
> Components: core
> Reporter: Rushabh Shah
> Assignee: Rushabh Shah
> Priority: Major
> Fix For: 5.2.0
>
>
> Design doc
> [here|https://docs.google.com/document/d/1ZIu7TyzI7aDhgMOWa7mbUmwbFNbiPVwpWjb6QisT4ng/edit#heading=h.fa8lnra4hvey].
--
This message was sent by Atlassian Jira
(v8.20.10#820010)