This is an automated email from the ASF dual-hosted git repository.

karan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/master by this push:
     new f3bd1e4affb remove reset-cluster tool (#18246)
f3bd1e4affb is described below

commit f3bd1e4affbc53fc9d3b45b7f018ea01d08a69cd
Author: Clint Wylie <[email protected]>
AuthorDate: Tue Jul 15 06:44:32 2025 -0700

    remove reset-cluster tool (#18246)
---
 docs/operations/reset-cluster.md                   |  58 +-----
 .../src/main/java/org/apache/druid/cli/Main.java   |   1 -
 .../java/org/apache/druid/cli/ResetCluster.java    | 202 ---------------------
 3 files changed, 4 insertions(+), 257 deletions(-)

diff --git a/docs/operations/reset-cluster.md b/docs/operations/reset-cluster.md
index b6dac868ab3..476a68ef865 100644
--- a/docs/operations/reset-cluster.md
+++ b/docs/operations/reset-cluster.md
@@ -23,57 +23,7 @@ title: "reset-cluster tool"
   -->
 
 
-The `reset-cluster` tool can be used to completely wipe out Apache Druid 
cluster state stored on Metadata and Deep storage. This is
-intended to be used in dev/test environments where you typically want to reset 
the cluster before running
-the test suite.
-`reset-cluster` automatically figures out necessary information from Druid 
cluster configuration. So the java classpath
-used in the command must have all the necessary druid configuration files.
-
-It can be run in one of the following ways.
-
-```
-java -classpath "/my/druid/lib/*" -Ddruid.extensions.loadList="[]" 
org.apache.druid.cli.Main \
-  tools reset-cluster \
-  [--metadataStore] \
-  [--segmentFiles] \
-  [--taskLogs] \
-  [--hadoopWorkingPath]
-```
-
-or
-
-```
-java -classpath "/my/druid/lib/*" -Ddruid.extensions.loadList="[]" 
org.apache.druid.cli.Main \
-  tools reset-cluster \
-  --all
-```
-
-Usage documentation can be printed by running following command.
-
-```
-$ java -classpath "/my/druid/lib/*" -Ddruid.extensions.loadList="[]" 
org.apache.druid.cli.Main help tools reset-cluster
-
-NAME
-        druid tools reset-cluster - Cleanup all persisted state from metadata
-        and deep storage.
-
-SYNOPSIS
-        druid tools reset-cluster [--all] [--hadoopWorkingPath]
-                [--metadataStore] [--segmentFiles] [--taskLogs]
-
-OPTIONS
-        --all
-            delete all state stored in metadata and deep storage
-
-        --hadoopWorkingPath
-            delete hadoopWorkingPath
-
-        --metadataStore
-            delete all records in metadata storage
-
-        --segmentFiles
-            delete all segment files from deep storage
-
-        --taskLogs
-            delete all tasklogs
-```
+In older versions of Apache Druid, `reset-cluster` was a tool that could wipe 
out Apache Druid cluster state stored in
+metadata and deep storage, intended primarily for use in dev and test 
environments. However, this tool was prone to
+becoming out of sync with the codebase since it was not used in practice 
during dev and testing, and could not cover
+all cleanup cases when extensions were involved. It was removed in Druid 
35.0.0.
diff --git a/services/src/main/java/org/apache/druid/cli/Main.java 
b/services/src/main/java/org/apache/druid/cli/Main.java
index ffd60410b07..425c16250b8 100644
--- a/services/src/main/java/org/apache/druid/cli/Main.java
+++ b/services/src/main/java/org/apache/druid/cli/Main.java
@@ -74,7 +74,6 @@ public class Main
         PullDependencies.class,
         CreateTables.class,
         DumpSegment.class,
-        ResetCluster.class,
         ValidateSegments.class,
         ExportMetadata.class
     );
diff --git a/services/src/main/java/org/apache/druid/cli/ResetCluster.java 
b/services/src/main/java/org/apache/druid/cli/ResetCluster.java
deleted file mode 100644
index 16958398a82..00000000000
--- a/services/src/main/java/org/apache/druid/cli/ResetCluster.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.druid.cli;
-
-import com.github.rvesse.airline.annotations.Command;
-import com.github.rvesse.airline.annotations.Option;
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.Module;
-import org.apache.druid.guice.DruidProcessingModule;
-import org.apache.druid.guice.IndexingServiceTaskLogsModule;
-import org.apache.druid.guice.JsonConfigProvider;
-import org.apache.druid.guice.QueryRunnerFactoryModule;
-import org.apache.druid.guice.QueryableModule;
-import org.apache.druid.guice.annotations.Self;
-import org.apache.druid.indexing.common.config.TaskConfig;
-import org.apache.druid.indexing.common.task.HadoopTask;
-import org.apache.druid.java.util.common.logger.Logger;
-import org.apache.druid.metadata.MetadataStorageConnector;
-import org.apache.druid.metadata.MetadataStorageTablesConfig;
-import org.apache.druid.segment.loading.DataSegmentKiller;
-import org.apache.druid.server.DruidNode;
-import org.apache.druid.tasklogs.TaskLogKiller;
-
-import java.util.List;
-
-/**
- * Clean-up all Druid state from Metadata and Deep Storage
- */
-@Command(
-    name = "reset-cluster",
-    description = "Cleanup all persisted state from metadata and deep storage."
-)
-public class ResetCluster extends GuiceRunnable
-{
-  private static final Logger log = new Logger(ResetCluster.class);
-
-  @Option(name = "--all", description = "delete all state stored in metadata 
and deep storage")
-  private boolean all;
-
-  @Option(name = "--metadataStore", description = "delete all records in 
metadata storage")
-  private boolean metadataStore;
-
-  @Option(name = "--segmentFiles", description = "delete all segment files 
from deep storage")
-  private boolean segmentFiles;
-
-  @Option(name = "--taskLogs", description = "delete all tasklogs")
-  private boolean taskLogs;
-
-  @Option(name = "--hadoopWorkingPath", description = "delete 
hadoopWorkingPath")
-  private boolean hadoopWorkingPath;
-
-
-  public ResetCluster()
-  {
-    super(log);
-  }
-
-  @Override
-  protected List<? extends Module> getModules()
-  {
-    return ImmutableList.of(
-        // It's unknown if those modules are required in ResetCluster.
-        // Maybe some of those modules could be removed.
-        // See https://github.com/apache/druid/pull/4429#discussion_r123603498
-        new DruidProcessingModule(),
-        new QueryableModule(),
-        new QueryRunnerFactoryModule(),
-        binder -> {
-          JsonConfigProvider.bindInstance(
-              binder,
-              Key.get(DruidNode.class, Self.class),
-              new DruidNode("tools", "localhost", false, -1, null, true, false)
-          );
-          JsonConfigProvider.bind(binder, "druid.indexer.task", 
TaskConfig.class);
-        },
-        new IndexingServiceTaskLogsModule()
-    );
-  }
-
-  @Override
-  public void run()
-  {
-    if (all) {
-      metadataStore = segmentFiles = taskLogs = hadoopWorkingPath = true;
-    }
-
-    final Injector injector = makeInjector();
-
-    if (metadataStore) {
-      resetMetadataStore(injector);
-    }
-
-    if (segmentFiles) {
-      deleteAllSegmentFiles(injector);
-    }
-
-    if (taskLogs) {
-      deleteAllTaskLogs(injector);
-    }
-
-    if (hadoopWorkingPath) {
-      deleteIndexerHadoopWorkingDir(injector);
-    }
-  }
-
-  private void resetMetadataStore(Injector injector)
-  {
-    
log.info("===========================================================================");
-    log.info("Deleting all Records from Metadata Storage.");
-    
log.info("===========================================================================");
-
-    MetadataStorageConnector connector = 
injector.getInstance(MetadataStorageConnector.class);
-    MetadataStorageTablesConfig tablesConfig = 
injector.getInstance(MetadataStorageTablesConfig.class);
-
-    String[] tables = new String[]{
-        tablesConfig.getDataSourceTable(),
-        tablesConfig.getPendingSegmentsTable(),
-        tablesConfig.getSegmentsTable(),
-        tablesConfig.getRulesTable(),
-        tablesConfig.getConfigTable(),
-        tablesConfig.getTasksTable(),
-        tablesConfig.getTaskLockTable(),
-        tablesConfig.getTaskLogTable(),
-        tablesConfig.getAuditTable(),
-        tablesConfig.getSupervisorTable()
-    };
-
-    for (String table : tables) {
-      connector.deleteAllRecords(table);
-    }
-  }
-
-  private void deleteAllSegmentFiles(Injector injector)
-  {
-    try {
-      
log.info("===========================================================================");
-      log.info("Deleting all Segment Files.");
-      
log.info("===========================================================================");
-
-      DataSegmentKiller segmentKiller = 
injector.getInstance(DataSegmentKiller.class);
-      segmentKiller.killAll();
-    }
-    catch (Exception ex) {
-      log.error(ex, "Failed to cleanup Segment Files.");
-    }
-  }
-
-  private void deleteAllTaskLogs(Injector injector)
-  {
-    try {
-      
log.info("===========================================================================");
-      log.info("Deleting all TaskLogs.");
-      
log.info("===========================================================================");
-
-      TaskLogKiller taskLogKiller = injector.getInstance(TaskLogKiller.class);
-      taskLogKiller.killAll();
-    }
-    catch (Exception ex) {
-      log.error(ex, "Failed to cleanup TaskLogs.");
-    }
-  }
-
-  private void deleteIndexerHadoopWorkingDir(Injector injector)
-  {
-    try {
-      
log.info("===========================================================================");
-      log.info("Deleting hadoopWorkingPath.");
-      
log.info("===========================================================================");
-
-      TaskConfig taskConfig = injector.getInstance(TaskConfig.class);
-      HadoopTask.invokeForeignLoader(
-          "org.apache.druid.indexer.HadoopWorkingDirCleaner",
-          new String[]{
-              taskConfig.getHadoopWorkingPath()
-          },
-          HadoopTask.buildClassLoader(null, 
taskConfig.getDefaultHadoopCoordinates())
-      );
-    }
-    catch (Exception ex) {
-      log.error(ex, "Failed to cleanup indexer hadoop working directory.");
-    }
-  }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to