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:24:43 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/a7f9607b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a7f9607b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a7f9607b

Branch: refs/heads/4.x-HBase-0.98
Commit: a7f9607b8771195f38301bc904a39914411a0e62
Parents: c169802
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:23:18 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/a7f9607b/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/a7f9607b/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 57ac43f..4b871d5 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
@@ -254,6 +254,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/a7f9607b/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 7d88b57..c01e454 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
@@ -277,6 +277,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/a7f9607b/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 f69b5f9..32597a1 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
@@ -984,7 +984,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) {
@@ -1932,7 +1933,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