phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [3/3] phoenix git commit: PHOENIX-2885 Set default value for UPDATE_CACHE_FREQUENCY (Maddineni Sukumar)
Date Fri, 02 Jun 2017 17:26:16 GMT
PHOENIX-2885 Set default value for UPDATE_CACHE_FREQUENCY (Maddineni Sukumar)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ca4febbd
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ca4febbd
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ca4febbd

Branch: refs/heads/4.x-HBase-1.1
Commit: ca4febbd24aacd8cf2eb4bb0b6310ca60d43ae45
Parents: dd18d04
Author: James Taylor <jamestaylor@apache.org>
Authored: Fri Jun 2 09:29:23 2017 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Fri Jun 2 10:25:04 2017 -0700

----------------------------------------------------------------------
 .../apache/phoenix/end2end/CreateTableIT.java   | 48 ++++++++++++++++++++
 .../org/apache/phoenix/query/QueryServices.java |  3 ++
 .../phoenix/query/QueryServicesOptions.java     |  3 ++
 .../apache/phoenix/schema/MetaDataClient.java   |  6 ++-
 4 files changed, 58 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca4febbd/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
index f10c6d9..4d10e0f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateTableIT.java
@@ -53,6 +53,7 @@ import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.TestUtil;
+import org.junit.Assert;
 import org.junit.Test;
 
 
@@ -660,4 +661,51 @@ public class CreateTableIT extends BaseClientManagedTimeIT {
 
         }
     }
+
+    @Test
+    public void testCreateTableWithUpdateCacheFrequencyAttrib() throws Exception {
+      Connection connection = null;
+      String TABLE_NAME = "UPDATECACHEDEFAULTVALUE";
+      try {
+        Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
+        connection = DriverManager.getConnection(getUrl(), props);
+
+        //Assert update cache frequency to default value zero
+        connection.createStatement().execute(
+          "create table "+TABLE_NAME+" (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+        String readSysCatQuery =
+            "select TABLE_NAME,UPDATE_CACHE_FREQUENCY from SYSTEM.CATALOG where "
+            + "TABLE_NAME = '"+TABLE_NAME+"'  AND TABLE_TYPE='u'";
+        ResultSet rs = connection.createStatement().executeQuery(readSysCatQuery);
+        Assert.assertTrue(rs.next());
+        Assert.assertEquals(0, rs.getLong(2));
+        connection.createStatement().execute("drop table "+TABLE_NAME);
+        connection.close();
+
+        //Assert update cache frequency to configured default value 10sec
+        int defaultUpdateCacheFrequency = 10000;
+        props.put(QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, ""+defaultUpdateCacheFrequency);
+        connection = DriverManager.getConnection(getUrl(), props);
+        connection.createStatement().execute(
+            "create table "+TABLE_NAME+" (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+        rs = connection.createStatement().executeQuery(readSysCatQuery);
+        Assert.assertTrue(rs.next());
+        Assert.assertEquals(defaultUpdateCacheFrequency, rs.getLong(2));
+        connection.createStatement().execute("drop table "+TABLE_NAME);
+
+        //Assert update cache frequency to table specific  value 30sec
+        int tableSpecificUpdateCacheFrequency = 30000;
+        connection.createStatement().execute(
+          "create table "+TABLE_NAME+" (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) "
+              + "UPDATE_CACHE_FREQUENCY="+tableSpecificUpdateCacheFrequency);
+        rs = connection.createStatement().executeQuery(readSysCatQuery);
+        Assert.assertTrue(rs.next());
+        Assert.assertEquals(tableSpecificUpdateCacheFrequency, rs.getLong(2));
+      } finally {
+        if(connection!=null){
+          connection.createStatement().execute("drop table if exists "+TABLE_NAME);
+          connection.close();
+        }
+      }
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca4febbd/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
index 6b856ac..4f6e4c4 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java
@@ -260,6 +260,9 @@ public interface QueryServices extends SQLCloseable {
     // whether to enable server side RS -> RS calls for upsert select statements
     public static final String ENABLE_SERVER_UPSERT_SELECT ="phoenix.client.enable.server.upsert.select";
 
+    //Update Cache Frequency default config attribute
+    public static final String DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB  = "phoenix.default.update.cache.frequency";
+
     /**
      * Get executor service used for parallel scans
      */

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca4febbd/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index a6a7f9e..dc33af9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -289,6 +289,9 @@ public class QueryServicesOptions {
     public static final boolean DEFAULT_STATS_COLLECTION_ENABLED = true;
     public static final boolean DEFAULT_USE_STATS_FOR_PARALLELIZATION = true;
 
+    //default update cache frequency
+    public static final int DEFAULT_UPDATE_CACHE_FREQUENCY = 0;
+
     @SuppressWarnings("serial")
     public static final Set<String> DEFAULT_QUERY_SERVER_SKIP_WORDS = new HashSet<String>()
{
       {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ca4febbd/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 75e6b0c..1c8a215 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -983,7 +983,8 @@ public class MetaDataClient {
         populatePropertyMaps(statement.getProps(), tableProps, commonFamilyProps);
 
         boolean isAppendOnlySchema = false;
-        long updateCacheFrequency = 0;
+        long updateCacheFrequency = connection.getQueryServices().getProps().getLong(
+            QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, QueryServicesOptions.DEFAULT_UPDATE_CACHE_FREQUENCY);
         if (parent==null) {
 	        Boolean appendOnlySchemaProp = (Boolean) TableProperty.APPEND_ONLY_SCHEMA.getValue(tableProps);
 	        if (appendOnlySchemaProp != null) {
@@ -1931,7 +1932,8 @@ public class MetaDataClient {
             if (disableWALProp != null) {
                 disableWAL = disableWALProp;
             }
-            long updateCacheFrequency = 0;
+            long updateCacheFrequency = connection.getQueryServices().getProps().getLong(
+                QueryServices.DEFAULT_UPDATE_CACHE_FREQUENCY_ATRRIB, QueryServicesOptions.DEFAULT_UPDATE_CACHE_FREQUENCY);
             Long updateCacheFrequencyProp = (Long) TableProperty.UPDATE_CACHE_FREQUENCY.getValue(tableProps);
             if (updateCacheFrequencyProp != null) {
                 updateCacheFrequency = updateCacheFrequencyProp;


Mime
View raw message