@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 boolean update(ConsumerGroup consumerGroup) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
    defaultMQAdminExt.setInstanceName(Helper.getInstanceName());
    try {
      defaultMQAdminExt.start();
      SubscriptionGroupConfig subscriptionGroupConfig = wrap(consumerGroup);
      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.createAndUpdateSubscriptionGroupConfig(
              hosting.getBroker().getAddress(), subscriptionGroupConfig);
        }
      } else {
        Set<String> masterSet =
            CommandUtil.fetchMasterAddrByClusterName(
                defaultMQAdminExt, consumerGroup.getClusterName());

        if (null != masterSet && !masterSet.isEmpty()) {
          for (String brokerAddress : masterSet) {
            defaultMQAdminExt.createAndUpdateSubscriptionGroupConfig(
                brokerAddress, subscriptionGroupConfig);
          }
        }
      }
    } catch (Exception e) {
      return false;
    } finally {
      defaultMQAdminExt.shutdown();
    }
    return true;
  }