/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.RequestId
 *  com.l7tech.util.RandomUtil
 */
package com.l7tech.server;

import com.l7tech.gateway.common.RequestId;
import com.l7tech.server.ServerConfig;
import com.l7tech.server.audit.AuditLogFormatter;
import com.l7tech.util.RandomUtil;
import java.util.concurrent.atomic.AtomicLong;

public class RequestIdGenerator {
    private final AtomicLong a = new AtomicLong();
    private final AtomicLong b = new AtomicLong();
    private static final RequestIdGenerator c = new RequestIdGenerator();
    static final long d = 0x3FFFFFFFFFFFFFFFL;

    public static RequestId next() {
        return c.a();
    }

    RequestId a() {
        long l2 = this.a.get();
        long l3 = this.b.incrementAndGet();
        if (l3 > 0x3FFFFFFFFFFFFFFFL && AuditLogFormatter.isFormatDefault()) {
            this.a.compareAndSet(l2, System.currentTimeMillis());
            this.b.compareAndSet(l3, 0L);
        }
        return new RequestId(l2, l3);
    }

    private RequestIdGenerator() {
        if (AuditLogFormatter.isFormatJson()) {
            this.a(RandomUtil.nextLong(), RandomUtil.nextLong());
        } else {
            this.a(ServerConfig.getInstance().getServerBootTime(), 0L);
        }
    }

    RequestIdGenerator(long l2, long l3) {
        this.a(l2, l3);
    }

    private void a(long l2, long l3) {
        this.a.set(l2);
        this.b.set(l3);
    }
}

