| /* |
| * 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.rocketmq.console.model; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| import org.apache.rocketmq.client.trace.TraceBean; |
| import org.apache.rocketmq.client.trace.TraceContext; |
| import org.apache.rocketmq.console.util.MsgTraceDecodeUtil; |
| |
| public class MessageTraceView { |
| |
| private String msgId; |
| private String tags; |
| private String keys; |
| private String storeHost; |
| private int costTime; |
| private String msgType; |
| private String offSetMsgId; |
| private long timeStamp; |
| private String topic; |
| private String groupName; |
| private String status; |
| |
| public static List<MessageTraceView> decodeFromTraceTransData(String key,String messageBody) { |
| List<MessageTraceView> messageTraceViewList = new ArrayList<MessageTraceView>(); |
| if (messageBody == null || messageBody.length() <= 0) { |
| return messageTraceViewList; |
| } |
| |
| List<TraceContext> traceContextList = MsgTraceDecodeUtil.decoderFromTraceDataString(messageBody); |
| |
| for (TraceContext context : traceContextList) { |
| MessageTraceView messageTraceView = new MessageTraceView(); |
| TraceBean traceBean = context.getTraceBeans().get(0); |
| if (!traceBean.getMsgId().equals(key)) { |
| continue; |
| } |
| messageTraceView.setCostTime(context.getCostTime()); |
| messageTraceView.setGroupName(context.getGroupName()); |
| if (context.isSuccess()) { |
| messageTraceView.setStatus("Sucess"); |
| } |
| else { |
| messageTraceView.setStatus("failed"); |
| } |
| messageTraceView.setKeys(traceBean.getKeys()); |
| messageTraceView.setMsgId(traceBean.getMsgId()); |
| messageTraceView.setTags(traceBean.getTags()); |
| messageTraceView.setTopic(traceBean.getTopic()); |
| messageTraceView.setMsgType(context.getTraceType().name()); |
| messageTraceView.setOffSetMsgId(traceBean.getOffsetMsgId()); |
| messageTraceView.setTimeStamp(context.getTimeStamp()); |
| messageTraceView.setStoreHost(traceBean.getStoreHost()); |
| messageTraceViewList.add(messageTraceView); |
| } |
| return messageTraceViewList; |
| } |
| |
| public String getMsgId() { |
| return msgId; |
| } |
| |
| public void setMsgId(String msgId) { |
| this.msgId = msgId; |
| } |
| |
| public String getTags() { |
| return tags; |
| } |
| |
| public void setTags(String tags) { |
| this.tags = tags; |
| } |
| |
| public String getKeys() { |
| return keys; |
| } |
| |
| public void setKeys(String keys) { |
| this.keys = keys; |
| } |
| |
| public String getStoreHost() { |
| return storeHost; |
| } |
| |
| public void setStoreHost(String storeHost) { |
| this.storeHost = storeHost; |
| } |
| |
| public int getCostTime() { |
| return costTime; |
| } |
| |
| public void setCostTime(int costTime) { |
| this.costTime = costTime; |
| } |
| |
| public String getMsgType() { |
| return msgType; |
| } |
| |
| public void setMsgType(String msgType) { |
| this.msgType = msgType; |
| } |
| |
| public String getOffSetMsgId() { |
| return offSetMsgId; |
| } |
| |
| public void setOffSetMsgId(String offSetMsgId) { |
| this.offSetMsgId = offSetMsgId; |
| } |
| |
| public long getTimeStamp() { |
| return timeStamp; |
| } |
| |
| public void setTimeStamp(long timeStamp) { |
| this.timeStamp = timeStamp; |
| } |
| |
| public String getGroupName() { |
| return groupName; |
| } |
| |
| public void setGroupName(String groupName) { |
| this.groupName = groupName; |
| } |
| |
| public String getTopic() { |
| return topic; |
| } |
| |
| public void setTopic(String topic) { |
| this.topic = topic; |
| } |
| |
| public String getStatus() { |
| return status; |
| } |
| |
| public void setStatus(String status) { |
| this.status = status; |
| } |
| } |