vran-dev / PrettyZoo

😉 Pretty nice Zookeeper GUI, Support Win / Mac / Linux Platform
Apache License 2.0
3.11k stars 361 forks source link

[feat] format zxid fields switchable to hex string #297

Closed HotSince91 closed 1 year ago

HotSince91 commented 1 year ago

Zookeeper officially log , display or name zxid as hex string,so I format zxid related fields (exactly ephermalOwner, mZxid, pZxid, cZxid) to hex using source code from zookeeper (org.apache.zookeeper.cli.StatPrinter::print()) in the node info view.

package org.apache.zookeeper.cli;

import java.io.PrintStream;
import java.util.Date;
import org.apache.zookeeper.data.Stat;

/**
 * utility for printing stat values s
 */
public class StatPrinter {

    protected PrintStream out;

    public StatPrinter(PrintStream out) {
        this.out = out;
    }

    public void print(Stat stat) {
        out.println("cZxid = 0x" + Long.toHexString(stat.getCzxid()));
        out.println("ctime = " + new Date(stat.getCtime()).toString());
        out.println("mZxid = 0x" + Long.toHexString(stat.getMzxid()));
        out.println("mtime = " + new Date(stat.getMtime()).toString());
        out.println("pZxid = 0x" + Long.toHexString(stat.getPzxid()));
        out.println("cversion = " + stat.getCversion());
        out.println("dataVersion = " + stat.getVersion());
        out.println("aclVersion = " + stat.getAversion());
        out.println("ephemeralOwner = 0x" + Long.toHexString(stat.getEphemeralOwner()));
        out.println("dataLength = " + stat.getDataLength());
        out.println("numChildren = " + stat.getNumChildren());
    }

}

image

For backward compatiblility, these fields can also be switched back to long value when click on coodinate labels like ctime label do.

vran-dev commented 1 year ago

thx for your contribution, you need to fixed the code checkstyle before merge it @HotSince91

vran-dev commented 1 year ago

thx again