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

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

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


##########
phoenix-core/src/main/java/org/apache/phoenix/exception/StaleMetadataCacheException.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.exception;
+
+import java.sql.SQLException;
+
+/**
+ * Indicates metadata cache is stale.
+ */
+public class StaleMetadataCacheException extends SQLException {
+    private static final long serialVersionUID = 1L;
+    private static SQLExceptionCode code = 
SQLExceptionCode.STALE_METADATA_CACHE_EXCEPTION;

Review Comment:
   nit: `final`



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

Review Comment:
   nit: description



##########
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:
   good to pass `fullTableName` as argument to avoid calling 
`SchemaUtil#getTableName` twice: in 
`PhoenixRegionServerEndpoint#validateLastDDLTimestamp` as well as here?





> Create new regionserver coprocessor named PhoenixRegionServerCoprocessor in 
> Phoenix
> -----------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6988
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6988
>             Project: Phoenix
>          Issue Type: Sub-task
>          Components: core
>            Reporter: Rushabh Shah
>            Assignee: Rushabh Shah
>            Priority: Major
>
> -Rename ReplicationSinkEndpoint to PhoenixRegionServerCoprocessor so that we 
> can add all the phoenix regionserver co-proc methods in just 1 class.-
> Earlier I thought to rename ReplicationSinkCompatEndpoint  to 
> PhoenixRegionServerCoprocessor but then looking at the code, there are some 
> complexities. ReplicationSinkEndpoint extends ReplicationSinkCompatEndpoint 
> which is defined in hbase-compat module and it is implemented in different 
> hbase-compat modules. The new co-proc is phoenix native co-proc and don't 
> need any compatibility guarantees. So I created a new regionserver coproc in 
> phoenix-core module.



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

Reply via email to