org.apache.rocketmq.common.admin.RollbackStats Java Examples

The following examples show how to use org.apache.rocketmq.common.admin.RollbackStats. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultMQAdminExtImplTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testResetOffset() throws Exception {

    TopicRouteData routeInfo = mqAdmin.examineTopicRouteInfo(topic);
    System.out.println();
    for (BrokerData brokerData : routeInfo.getBrokerDatas()) {
        System.out.println(brokerData);
    }
    System.out.println();
    for (QueueData data : routeInfo.getQueueDatas()) {
        MessageQueue mq = new MessageQueue(topic, data.getBrokerName(), 0);
        long offset = mqAdmin.searchOffset(mq, System.currentTimeMillis());
        System.out.println(data + ", offset:" + offset);
    }
    System.out.println();
    List<RollbackStats> r = mqAdmin.resetOffsetByTimestampOld(group, topic, System.currentTimeMillis(), true);
    for (RollbackStats rollbackStats : r) {
        System.out.println(rollbackStats);
    }

}
 
Example #2
Source File: DefaultMQAdminExtImplTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Test
public void testResetOffset() throws Exception {

    TopicRouteData routeInfo = mqAdmin.examineTopicRouteInfo(topic);
    System.out.println();
    for (BrokerData brokerData : routeInfo.getBrokerDatas()) {
        System.out.println(brokerData);
    }
    System.out.println();
    for (QueueData data : routeInfo.getQueueDatas()) {
        MessageQueue mq = new MessageQueue(topic, data.getBrokerName(), 0);
        long offset = mqAdmin.searchOffset(mq, System.currentTimeMillis());
        System.out.println(data + ", offset:" + offset);
    }
    System.out.println();
    List<RollbackStats> r = mqAdmin.resetOffsetByTimestampOld(group, topic, System.currentTimeMillis(), true);
    for (RollbackStats rollbackStats : r) {
        System.out.println(rollbackStats);
    }

}
 
Example #3
Source File: ResetOffsetByTimeOldCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic, long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #4
Source File: ResetOffsetByTimeOldCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic,
    long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #5
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue,
    OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #6
Source File: ResetOffsetByTimeOldCommand.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic, long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #7
Source File: ResetOffsetByTimeOldCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic,
    long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #8
Source File: DefaultMQAdminExtImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue, OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #9
Source File: ResetOffsetByTimeOldCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic,
    long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #10
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue,
    OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #11
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue, OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #12
Source File: ResetOffsetByTimeOldCommand.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic,
    long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #13
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue,
    OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #14
Source File: DefaultMQAdminExtImpl.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue,
    OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #15
Source File: ResetOffsetByTimeOldCommand.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic,
    long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #16
Source File: ResetOffsetByTimeOldCommand.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public static void resetOffset(DefaultMQAdminExt defaultMQAdminExt, String consumerGroup, String topic,
    long timestamp, boolean force,
    String timeStampStr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    List<RollbackStats> rollbackStatsList = defaultMQAdminExt.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
    System.out.printf(
        "rollback consumer offset by specified consumerGroup[%s], topic[%s], force[%s], timestamp(string)[%s], timestamp(long)[%s]%n",
        consumerGroup, topic, force, timeStampStr, timestamp);

    System.out.printf("%-20s  %-20s  %-20s  %-20s  %-20s  %-20s%n",
        "#brokerName",
        "#queueId",
        "#brokerOffset",
        "#consumerOffset",
        "#timestampOffset",
        "#rollbackOffset"
    );

    for (RollbackStats rollbackStats : rollbackStatsList) {
        System.out.printf("%-20s  %-20d  %-20d  %-20d  %-20d  %-20d%n",
            UtilAll.frontStringAtLeast(rollbackStats.getBrokerName(), 32),
            rollbackStats.getQueueId(),
            rollbackStats.getBrokerOffset(),
            rollbackStats.getConsumerOffset(),
            rollbackStats.getTimestampOffset(),
            rollbackStats.getRollbackOffset()
        );
    }
}
 
Example #17
Source File: DefaultMQAdminExtImpl.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private RollbackStats resetOffsetConsumeOffset(String brokerAddr, String consumeGroup, MessageQueue queue,
    OffsetWrapper offsetWrapper,
    long timestamp, boolean force) throws RemotingException, InterruptedException, MQBrokerException {
    long resetOffset;
    if (timestamp == -1) {

        resetOffset = this.mqClientInstance.getMQClientAPIImpl().getMaxOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timeoutMillis);
    } else {
        resetOffset =
            this.mqClientInstance.getMQClientAPIImpl().searchOffset(brokerAddr, queue.getTopic(), queue.getQueueId(), timestamp,
                timeoutMillis);
    }

    RollbackStats rollbackStats = new RollbackStats();
    rollbackStats.setBrokerName(queue.getBrokerName());
    rollbackStats.setQueueId(queue.getQueueId());
    rollbackStats.setBrokerOffset(offsetWrapper.getBrokerOffset());
    rollbackStats.setConsumerOffset(offsetWrapper.getConsumerOffset());
    rollbackStats.setTimestampOffset(resetOffset);
    rollbackStats.setRollbackOffset(offsetWrapper.getConsumerOffset());

    if (force || resetOffset <= offsetWrapper.getConsumerOffset()) {
        rollbackStats.setRollbackOffset(resetOffset);
        UpdateConsumerOffsetRequestHeader requestHeader = new UpdateConsumerOffsetRequestHeader();
        requestHeader.setConsumerGroup(consumeGroup);
        requestHeader.setTopic(queue.getTopic());
        requestHeader.setQueueId(queue.getQueueId());
        requestHeader.setCommitOffset(resetOffset);
        this.mqClientInstance.getMQClientAPIImpl().updateConsumerOffset(brokerAddr, requestHeader, timeoutMillis);
    }
    return rollbackStats;
}
 
Example #18
Source File: DefaultMQAdminExt.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
 
Example #19
Source File: MQAdminExt.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #20
Source File: MQAdminExt.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #21
Source File: DefaultMQAdminExt.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp,
    boolean force)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
 
Example #22
Source File: MQAdminExt.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #23
Source File: DefaultMQAdminExt.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
 
Example #24
Source File: DefaultMQAdminExt.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp,
    boolean force)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
 
Example #25
Source File: MQAdminExt.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #26
Source File: MQAdminExt.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #27
Source File: MQAdminExt.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #28
Source File: MQAdminExt.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp, boolean force)
throws RemotingException, MQBrokerException, InterruptedException, MQClientException;
 
Example #29
Source File: DefaultMQAdminExt.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp,
    boolean force)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}
 
Example #30
Source File: DefaultMQAdminExt.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public List<RollbackStats> resetOffsetByTimestampOld(String consumerGroup, String topic, long timestamp,
    boolean force)
    throws RemotingException, MQBrokerException, InterruptedException, MQClientException {
    return defaultMQAdminExtImpl.resetOffsetByTimestampOld(consumerGroup, topic, timestamp, force);
}