source.addChild(current);
}
}
public void truncateAndFlush(Context ctx, long timestamp) {
MessageTree tree = ctx.m_tree;
Stack<Transaction> stack = ctx.m_stack;
Message message = tree.getMessage();
if (message instanceof DefaultTransaction) {
String id = tree.getMessageId();
String rootId = tree.getRootMessageId();
String childId = nextMessageId();
DefaultTransaction source = (DefaultTransaction) message;
DefaultTransaction target = new DefaultTransaction(source.getType(), source.getName(),
DefaultMessageManager.this);
target.setTimestamp(source.getTimestamp());
target.setDurationInMicros(source.getDurationInMicros());
target.addData(source.getData().toString());
target.setStatus(Message.SUCCESS);
migrateMessage(stack, source, target, 1);
for (int i = stack.size() - 1; i >= 0; i--) {
DefaultTransaction t = (DefaultTransaction) stack.get(i);
t.setTimestamp(timestamp);
}
DefaultEvent next = new DefaultEvent("RemoteCall", "Next");
next.addData(childId);
next.setStatus(Message.SUCCESS);
target.addChild(next);
// tree is the parent, and m_tree is the child.
MessageTree t = tree.copy();
t.setMessage(target);
ctx.m_tree.setMessageId(childId);
ctx.m_tree.setParentMessageId(id);
ctx.m_tree.setRootMessageId(rootId != null ? rootId : id);