Murtadha Hubail has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/1906

Change subject: [ASTERIXDB-2005][CLUS] Treat dataset rebalance to no nodes as 
drop
......................................................................

[ASTERIXDB-2005][CLUS] Treat dataset rebalance to no nodes as drop

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Drop dataset when rebalanced to empty target nodes

Change-Id: I46f687e6006cba952dbfa1fa7771c7c2b7c13472
---
M 
asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/RebalanceUtil.java
1 file changed, 18 insertions(+), 12 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/06/1906/1

diff --git 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/RebalanceUtil.java
 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/RebalanceUtil.java
index 4174685..1f08616 100644
--- 
a/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/RebalanceUtil.java
+++ 
b/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/RebalanceUtil.java
@@ -112,22 +112,28 @@
                 return;
             }
 
-            // Creates a node group for rebalance.
-            String nodeGroupName = 
DatasetUtil.createNodeGroupForNewDataset(sourceDataset.getDataverseName(),
-                    sourceDataset.getDatasetName(), 
sourceDataset.getRebalanceCount() + 1, targetNcNames,
-                    metadataProvider);
+            if (!targetNcNames.isEmpty()) {
+                // Creates a node group for rebalance.
+                String nodeGroupName = DatasetUtil
+                        
.createNodeGroupForNewDataset(sourceDataset.getDataverseName(), 
sourceDataset.getDatasetName(),
+                                sourceDataset.getRebalanceCount() + 1, 
targetNcNames, metadataProvider);
+                // The target dataset for rebalance.
+                targetDataset = 
sourceDataset.getTargetDatasetForRebalance(nodeGroupName);
 
-            // The target dataset for rebalance.
-            targetDataset = 
sourceDataset.getTargetDatasetForRebalance(nodeGroupName);
-
-            // Rebalances the source dataset into the target dataset.
-            rebalance(sourceDataset, targetDataset, metadataProvider, hcc, 
datasetRebalanceCallback);
-
-            // Complete the metadata transaction.
-            MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                // Rebalances the source dataset into the target dataset.
+                rebalance(sourceDataset, targetDataset, metadataProvider, hcc, 
datasetRebalanceCallback);
+            } else {
+                // if this the last NC in the cluster, just drop the dataset
+                dropDatasetFiles(sourceDataset, metadataProvider, hcc);
+                return;
+            }
+            LOGGER.fine("Rebalanced dataset: " + sourceDataset);
         } catch (Exception e) {
             abort(e, e, mdTxnCtx);
             throw e;
+        } finally {
+            // Complete the metadata transaction.
+            MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         }
 
         // Up to this point, since the bulk part of a rebalance operation is 
done,

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/1906
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46f687e6006cba952dbfa1fa7771c7c2b7c13472
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Murtadha Hubail <[email protected]>

Reply via email to