You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/10/21 18:13:14 UTC

[GitHub] [phoenix] yanxinyi commented on a change in pull request #928: PHOENIX-6192 : Use tenant connection to resolve tenant views in syncUpdateCacheFreqAllIndexes()

yanxinyi commented on a change in pull request #928:
URL: https://github.com/apache/phoenix/pull/928#discussion_r509540735



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTable2IT.java
##########
@@ -0,0 +1,216 @@
+/*
+ * 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 org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.UpgradeUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Map;
+
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createBaseTable;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createView;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.createViewIndex;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getConnection;
+import static org.apache.phoenix.end2end.GlobalConnectionTenantTableIT.getTenantConnection;
+import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class GlobalConnectionTenantTable2IT extends BaseTest {
+
+    private static final String SCHEMA_NAME = "SCHEMA2";
+    private static final String TABLE_NAME = generateUniqueName();
+    private static final String TENANT_NAME = "TENANT2";
+    private static final String VIEW1_NAME = "VIEW1";
+    private static final String VIEW1_INDEX_NAME = "INDEX1";
+    private static final String VIEW_INDEX_COL = "v2";
+    public static final String TABLE_INDEX = "TABLE_INDEX";
+    public static final String VIEW2_NAME = "VIEW2";
+    public static final String VIEW2_INDEX_NAME = "INDEX2";
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+        createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null);
+        createViewIndex(getConnection(), SCHEMA_NAME, TABLE_INDEX, TABLE_NAME, VIEW_INDEX_COL);
+        try (Connection conn = getTenantConnection(TENANT_NAME)) {
+            createView(conn, SCHEMA_NAME, VIEW1_NAME, TABLE_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW1_INDEX_NAME, VIEW1_NAME, VIEW_INDEX_COL);
+            createView(conn, SCHEMA_NAME, VIEW2_NAME, VIEW1_NAME);
+            createViewIndex(conn, SCHEMA_NAME, VIEW2_INDEX_NAME, VIEW2_NAME, VIEW_INDEX_COL);
+        }
+    }
+
+    @Test
+    public void testSyncCacheFreqWithTenantView() throws Exception {
+        try (Connection conn = getConnection()) {
+            ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT UPDATE_CACHE_FREQUENCY FROM SYSTEM.CATALOG WHERE TABLE_NAME='"
+                    + TABLE_NAME + "'");
+            rs.next();
+            long cacheFreq = rs.getLong(1);
+            assertEquals(0, cacheFreq);
+
+            updateCacheFreq(conn, null, TABLE_NAME, 500);

Review comment:
       nit: maybe use tableNameFreqVal instead of entering a numerical value?




----------------------------------------------------------------
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:
users@infra.apache.org