git commit: PHOENIX-1173: MutableIndexFailureIT.java doesn't finish sometimes or is flappy.

2014-08-15 Thread jeffreyz
Repository: phoenix
Updated Branches:
  refs/heads/3.0 19dc23aa5 - 71cc23c8f


PHOENIX-1173: MutableIndexFailureIT.java doesn't finish sometimes or is flappy.


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

Branch: refs/heads/3.0
Commit: 71cc23c8fa03694db1816cf8e3f5d0bb3f391ccb
Parents: 19dc23a
Author: Jeffrey Zhong jeffr...@apache.org
Authored: Fri Aug 15 14:02:51 2014 -0700
Committer: Jeffrey Zhong jeffr...@apache.org
Committed: Fri Aug 15 14:02:51 2014 -0700

--
 .../apache/phoenix/coprocessor/MetaDataEndpointImpl.java| 2 ++
 .../apache/phoenix/coprocessor/MetaDataRegionObserver.java  | 9 ++---
 2 files changed, 8 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/71cc23c8/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 07d4cc8..9cb3b89 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -1207,6 +1207,8 @@ public class MetaDataEndpointImpl extends 
BaseEndpointCoprocessor implements Met
 dataTableKey = SchemaUtil.getTableKey(tenantId, 
schemaName, dataTableKV.getValue());
 }
 if(dataTableKey != null) {
+// make a copy of tableMetadata
+tableMetadata = new ArrayListMutation(tableMetadata);
 // insert an empty KV to trigger time stamp update on 
data table row
 Put p = new Put(dataTableKey);
 p.add(TABLE_FAMILY_BYTES, 
QueryConstants.EMPTY_COLUMN_BYTES, timeStamp, ByteUtil.EMPTY_BYTE_ARRAY);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/71cc23c8/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 2820e59..1526a98 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -24,6 +24,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.logging.Log;
@@ -64,14 +67,14 @@ import org.apache.phoenix.util.SchemaUtil;
  */
 public class MetaDataRegionObserver extends BaseRegionObserver {
 public static final Log LOG = 
LogFactory.getLog(MetaDataRegionObserver.class);
-protected Timer scheduleTimer = new Timer(true);
+protected ScheduledThreadPoolExecutor executor = new 
ScheduledThreadPoolExecutor(1);
 private boolean enableRebuildIndex = 
QueryServicesOptions.DEFAULT_INDEX_FAILURE_HANDLING_REBUILD;
 private long rebuildIndexTimeInterval = 
QueryServicesOptions.DEFAULT_INDEX_FAILURE_HANDLING_REBUILD_INTERVAL;
   
 @Override
 public void preClose(final ObserverContextRegionCoprocessorEnvironment c,
 boolean abortRequested) {
-scheduleTimer.cancel();
+executor.shutdownNow();
 
GlobalCache.getInstance(c.getEnvironment()).getMetaDataCache().invalidateAll();
 }
 
@@ -112,7 +115,7 @@ public class MetaDataRegionObserver extends 
BaseRegionObserver {
 // starts index rebuild schedule work
 BuildIndexScheduleTask task = new 
BuildIndexScheduleTask(e.getEnvironment());
 // run scheduled task every 10 secs
-scheduleTimer.schedule(task, 1, rebuildIndexTimeInterval);
+executor.scheduleAtFixedRate(task, 1, 
rebuildIndexTimeInterval, TimeUnit.MILLISECONDS);
 } catch (ClassNotFoundException ex) {
 LOG.error(BuildIndexScheduleTask cannot start!, ex);
 }



git commit: PHOENIX-1173: MutableIndexFailureIT.java doesn't finish sometimes or is flappy.

2014-08-15 Thread jeffreyz
Repository: phoenix
Updated Branches:
  refs/heads/master 367662dc8 - ebb6a7adb


PHOENIX-1173: MutableIndexFailureIT.java doesn't finish sometimes or is flappy.


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

Branch: refs/heads/master
Commit: ebb6a7adb9134eb2413950796bd5f4e80a250e7d
Parents: 367662d
Author: Jeffrey Zhong jeffr...@apache.org
Authored: Fri Aug 15 14:02:51 2014 -0700
Committer: Jeffrey Zhong jeffr...@apache.org
Committed: Fri Aug 15 16:05:55 2014 -0700

--
 .../apache/phoenix/coprocessor/MetaDataEndpointImpl.java| 2 ++
 .../apache/phoenix/coprocessor/MetaDataRegionObserver.java  | 9 ++---
 2 files changed, 8 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ebb6a7ad/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index b99483b..5b43a90 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -1508,6 +1508,8 @@ public class MetaDataEndpointImpl extends 
MetaDataProtocol implements Coprocesso
 dataTableKey = SchemaUtil.getTableKey(tenantId, 
schemaName, dataTableKV.getValue());
 }
 if(dataTableKey != null) {
+// make a copy of tableMetadata
+tableMetadata = new ArrayListMutation(tableMetadata);
 // insert an empty KV to trigger time stamp update on 
data table row
 Put p = new Put(dataTableKey);
 p.add(TABLE_FAMILY_BYTES, 
QueryConstants.EMPTY_COLUMN_BYTES, timeStamp, ByteUtil.EMPTY_BYTE_ARRAY);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ebb6a7ad/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 6ce0148..822ced8 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -28,6 +28,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.logging.Log;
@@ -65,14 +68,14 @@ import org.apache.phoenix.util.SchemaUtil;
  */
 public class MetaDataRegionObserver extends BaseRegionObserver {
 public static final Log LOG = 
LogFactory.getLog(MetaDataRegionObserver.class);
-protected Timer scheduleTimer = new Timer(true);
+protected ScheduledThreadPoolExecutor executor = new 
ScheduledThreadPoolExecutor(1);
 private boolean enableRebuildIndex = 
QueryServicesOptions.DEFAULT_INDEX_FAILURE_HANDLING_REBUILD;
 private long rebuildIndexTimeInterval = 
QueryServicesOptions.DEFAULT_INDEX_FAILURE_HANDLING_REBUILD_INTERVAL;
   
 @Override
 public void preClose(final ObserverContextRegionCoprocessorEnvironment c,
 boolean abortRequested) {
-scheduleTimer.cancel();
+executor.shutdownNow();
 
GlobalCache.getInstance(c.getEnvironment()).getMetaDataCache().invalidateAll();
 }
 
@@ -113,7 +116,7 @@ public class MetaDataRegionObserver extends 
BaseRegionObserver {
 // starts index rebuild schedule work
 BuildIndexScheduleTask task = new 
BuildIndexScheduleTask(e.getEnvironment());
 // run scheduled task every 10 secs
-scheduleTimer.schedule(task, 1, rebuildIndexTimeInterval);
+executor.scheduleAtFixedRate(task, 1, 
rebuildIndexTimeInterval, TimeUnit.MILLISECONDS);
 } catch (ClassNotFoundException ex) {
 LOG.error(BuildIndexScheduleTask cannot start!, ex);
 }