/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.service.MetricsSummaryBin
 *  com.l7tech.objectmodel.Goid
 */
package com.l7tech.server.wsdm;

import com.l7tech.gateway.common.service.MetricsSummaryBin;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.wsdm.util.ISO8601Duration;
import java.net.URL;

public class MetricsRequestContext {
    private final long a;
    private final long b;
    private final long c;
    private final long d;
    private final long e;
    private final long f;
    private final long g;
    private final boolean h;
    private final Goid i;
    private final long j;
    private final long k;
    private final long l;
    private final long m;
    private final float n;
    private final String o;
    private final URL p;
    private final String q;
    private static final String[] r;

    public MetricsRequestContext(MetricsSummaryBin metricsSummaryBin, boolean bl2, URL uRL, long l2) {
        this.h = bl2;
        this.i = metricsSummaryBin.getServiceGoid();
        this.p = uRL;
        this.a = (long)metricsSummaryBin.getAverageFrontendResponseTime();
        this.o = ISO8601Duration.durationFromSecs(l2 / 1000L);
        this.b = (long)metricsSummaryBin.getLastAverageFrontendResponseTime();
        this.m = metricsSummaryBin.getLastAttemptedRequest();
        this.c = metricsSummaryBin.getMinFrontendResponseTime() == null ? 0L : (long)metricsSummaryBin.getMinFrontendResponseTime().intValue();
        this.d = metricsSummaryBin.getMaxFrontendResponseTime() == null ? 0L : (long)metricsSummaryBin.getMaxFrontendResponseTime().intValue();
        this.e = metricsSummaryBin.getNumPolicyViolation() + metricsSummaryBin.getNumRoutingFailure();
        this.g = metricsSummaryBin.getNumAttemptedRequest();
        this.f = metricsSummaryBin.getNumCompletedRequest();
        this.l = metricsSummaryBin.getPeriodStart();
        this.n = metricsSummaryBin.getNumAttemptedRequest() == 0 ? 100.0f : (1.0f - (float)metricsSummaryBin.getNumRoutingFailure() / (float)metricsSummaryBin.getNumAttemptedRequest()) * 100.0f;
        this.j = metricsSummaryBin.getSumFrontendResponseTime();
        double d10 = 0.0;
        double d11 = (double)l2 / 1000.0;
        if (d11 > 0.0) {
            d10 = (double)metricsSummaryBin.getNumAttemptedRequest() / d11;
        }
        String[] stringArray = r;
        String string = stringArray[2];
        double d12 = d10;
        if (d10 <= 1.0 && d11 > 60.0) {
            d10 = (double)metricsSummaryBin.getNumAttemptedRequest() / (d11 / 60.0);
            string = stringArray[0];
            d12 = d10;
            if (d10 <= 1.0 && d11 > 3600.0) {
                d10 = (double)metricsSummaryBin.getNumAttemptedRequest() / (d11 / 3600.0);
                string = stringArray[1];
                d12 = d10;
            }
        }
        this.q = string;
        this.k = (long)d12;
    }

    public long getAvgResponseTime() {
        return this.a;
    }

    public long getLastResponseTime() {
        return this.b;
    }

    public long getMinResponseTime() {
        return this.c;
    }

    public long getMaxResponseTime() {
        return this.d;
    }

    public long getNrFailedRequests() {
        return this.e;
    }

    public long getNrSuccessRequests() {
        return this.f;
    }

    public long getNrRequests() {
        return this.g;
    }

    public boolean isOperational() {
        return this.h;
    }

    public Goid getServiceId() {
        return this.i;
    }

    public long getServiceTime() {
        return this.j;
    }

    public long getThroughput() {
        return this.k;
    }

    public long getPeriodStart() {
        return this.l;
    }

    public long getLastUpdated() {
        return this.m;
    }

    public String getDuration() {
        return this.o;
    }

    public URL getIncomingURL() {
        return this.p;
    }

    public String getThrouputPeriod() {
        return this.q;
    }

    public float getAvailability() {
        return this.n;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[3];
        int n2 = 0;
        String string = "\u0018\u0012=\t\u0004\u0018\u0012=\f\u0004\u0018\u0012=\u0017";
        int n3 = "\u0018\u0012=\t\u0004\u0018\u0012=\f\u0004\u0018\u0012=\u0017".length();
        int n4 = 4;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = MetricsRequestContext.a(122, MetricsRequestContext.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                r = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x62);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 50;
                    case 1 -> 60;
                    case 2 -> 118;
                    case 3 -> 62;
                    case 4 -> 42;
                    case 5 -> 47;
                    default -> 98;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

