Fix broken test, H2TreeIndex#destroy and H2TreeIndex#asyncDestroy refactoring - Fixes
@@ -533,32 +533,21 @@ public class H2TreeIndex extends H2TreeIndexBase {
/** {@inheritDoc} */
@Override public void destroy(boolean rmvIdx) {
- try {
- if (cctx.affinityNode() && rmvIdx) {
- assert cctx.shared().database().checkpointLockIsHeldByThread();
-
- for (int i = 0; i < segments.length; i++) {
- H2Tree tree = segments[i];
-
- tree.destroy();
-
- dropMetaPage(i);
- }
-
- ctx.metric().remove(stats.metricRegistryName());
- }
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException(e);
- }
- finally {
- if (msgLsnr != null)
- ctx.io().removeMessageListener(msgTopic, msgLsnr);
- }
+ destroy0(rmvIdx, false);
}
/** {@inheritDoc} */
@Override public void asyncDestroy(boolean rmvIdx) {
+ destroy0(rmvIdx, true);
+ }
+
+ /**
+ * Internal method for destroying index with async option.
+ *
+ * @param rmvIdx Flag remove.
+ * @param async Destroy asynchronously.
+ */
+ private void destroy0(boolean rmvIdx, boolean async) {
try {
if (cctx.affinityNode() && rmvIdx) {
assert cctx.shared().database().checkpointLockIsHeldByThread();
@@ -569,14 +558,21 @@ public class H2TreeIndex extends H2TreeIndexBase {
for (int i = 0; i < segments.length; i++) {
H2Tree tree = segments[i];
+ if (async) {
tree.markDestroyed();
rootPages.add(tree.getMetaPageId());
trees.add(tree);
+ }
+ else
+ tree.destroy();
dropMetaPage(i);
}
+ ctx.metric().remove(stats.metricRegistryName());
+
+ if (async) {
DurableBackgroundTask task = new DurableBackgroundCleanupIndexTreeTask(
rootPages,
trees,
@@ -589,6 +585,7 @@ public class H2TreeIndex extends H2TreeIndexBase {
cctx.kernalContext().durableBackgroundTasksProcessor().startDurableBackgroundTask(task, cctx.config());
}
}
+ }
catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
