shahrs87 commented on code in PR #1654:
URL: https://github.com/apache/phoenix/pull/1654#discussion_r1299236970


##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/VerifyLastDDLTimestamp.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.coprocessor;
+
+import java.io.IOException;
+import java.sql.SQLException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.cache.ServerMetadataCache;
+import org.apache.phoenix.exception.StaleMetadataCacheException;
+import org.apache.phoenix.util.SchemaUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Client provides last DDL timestamp of tables/views/indexes included in 
read/write operation
+ * This verifies that client has the latest version of LAST_DDL_TIMESTAMP 
version.
+ * If client's provided LAST_DDL_TIMESTAMP is less than what is present in 
SYSTEM.CATALOG
+ * then it throws StaleMetadataCacheException.
+ */
+public class VerifyLastDDLTimestamp {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(VerifyLastDDLTimestamp.class);
+
+    private VerifyLastDDLTimestamp() {
+        // Not to be instantiated.
+    }
+
+    /**
+     * Verify that LAST_DDL_TIMESTAMP provided by the client is up to date. If 
it is stale it will
+     * throw StaleMetadataCacheException.
+     *
+     * @param tenantID               tenant id
+     * @param schemaName             schema name
+     * @param tableName              table name
+     * @param clientLastDDLTimestamp last ddl timestamp provided by client
+     * @param conf                   configuration
+     * @throws IOException
+     */
+    public static void verifyLastDDLTimestamp(Configuration conf, byte[] 
tenantID,
+            byte[] schemaName, byte[] tableName, long clientLastDDLTimestamp) 
throws SQLException {
+        ServerMetadataCache cache = ServerMetadataCache.getInstance(conf);
+        String fullTableName = SchemaUtil.getTableName(schemaName, tableName);

Review Comment:
   But we still need byte[] tablename separately. However I need fullTableName 
only when the timestamp is stale which should be rare. So I have moved creating 
fullTableName only in exception block.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to