@Override
  public boolean clear(ConsumerGroup consumerGroup) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExt.setInstanceName(Helper.getInstanceName());
    try {
      defaultMQAdminExt.start();
      List<ConsumerGroupHosting> consumerGroupHostingList =
          consumerGroupMapper.queryHosting(
              consumerGroup.getId(), new int[] {Status.ACTIVE.getId()}, 0, 0, null);
      if (null != consumerGroupHostingList && !consumerGroupHostingList.isEmpty()) {
        for (ConsumerGroupHosting hosting : consumerGroupHostingList) {
          defaultMQAdminExt.deleteSubscriptionGroup(
              hosting.getBroker().getAddress(), consumerGroup.getGroupName());
        }
      } else {
        Set<String> masterSet =
            CommandUtil.fetchMasterAddrByClusterName(
                defaultMQAdminExt, consumerGroup.getClusterName());

        if (null != masterSet && !masterSet.isEmpty()) {
          for (String brokerAddress : masterSet) {
            defaultMQAdminExt.deleteSubscriptionGroup(
                brokerAddress, consumerGroup.getGroupName(), 15000L);
          }
        }
      }
    } catch (Exception e) {
      System.out.println("DELETE CONSUMER GROUP ON BROKER FAILED!" + e);
      return false;
    } finally {
      defaultMQAdminExt.shutdown();
    }

    return true;
  }
  @Override
  public void execute(CommandLine commandLine, Options options) {
    DefaultMQAdminExt adminExt = new DefaultMQAdminExt();
    adminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
    try {
      // groupName
      String groupName = commandLine.getOptionValue('g').trim();

      if (commandLine.hasOption('b')) {
        String addr = commandLine.getOptionValue('b').trim();
        adminExt.start();

        adminExt.deleteSubscriptionGroup(addr, groupName);
        System.out.printf(
            "delete subscription group [%s] from broker [%s] success.\n", groupName, addr);

        return;
      } else if (commandLine.hasOption('c')) {
        String clusterName = commandLine.getOptionValue('c').trim();
        adminExt.start();

        Set<String> masterSet = CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
        for (String master : masterSet) {
          adminExt.deleteSubscriptionGroup(master, groupName);
          System.out.printf(
              "delete subscription group [%s] from broker [%s] in cluster [%s] success.\n",
              groupName, master, clusterName);
        }

        return;
      }

      ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      adminExt.shutdown();
    }
  }