package u0; import g1.a; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; import n0.c; import n0.d; import n0.p; import u0.d; import x0.e; /* compiled from: AwsSdkMetrics */ public enum a { ; public static final String AWS_CREDENTAIL_PROPERTIES_FILE = "credentialFile"; public static final String CLOUDWATCH_REGION = "cloudwatchRegion"; private static final boolean DEFAULT_METRICS_ENABLED; private static final String DEFAULT_METRIC_COLLECTOR_FACTORY = "com.amazonaws.metrics.internal.cloudwatch.DefaultMetricCollectorFactory"; public static final String DEFAULT_METRIC_NAMESPACE = "AWSSDK/Java"; public static final String EXCLUDE_MACHINE_METRICS = "excludeMachineMetrics"; public static final String HOST_METRIC_NAME = "hostMetricName"; public static final String INCLUDE_PER_HOST_METRICS = "includePerHostMetrics"; public static final String JVM_METRIC_NAME = "jvmMetricName"; private static final String MBEAN_OBJECT_NAME = ("com.amazonaws.management:type=" + a.class.getSimpleName()); public static final String METRIC_NAME_SPACE = "metricNameSpace"; public static final String METRIC_QUEUE_SIZE = "metricQueueSize"; public static final String QUEUE_POLL_TIMEOUT_MILLI = "getQueuePollTimeoutMilli"; private static final int QUEUE_POLL_TIMEOUT_MILLI_MINUMUM = 1000; private static final b REGISTRY = new b(); public static final String USE_SINGLE_METRIC_NAMESPACE = "useSingleMetricNamespace"; private static volatile String credentialFile; private static volatile d credentialProvider; private static boolean dirtyEnabling; private static volatile String hostMetricName; private static volatile String jvmMetricName; private static volatile boolean machineMetricsExcluded; /* renamed from: mc reason: collision with root package name */ private static volatile d f135425mc; private static volatile String metricNameSpace; private static volatile Integer metricQueueSize; private static volatile boolean perHostMetricsIncluded; private static volatile Long queuePollTimeoutMilli; private static volatile e region; private static volatile boolean singleMetricNamespace; /* renamed from: u0.a$a reason: collision with other inner class name */ /* compiled from: AwsSdkMetrics */ public static class C2193a implements d { /* renamed from: a reason: collision with root package name */ public final /* synthetic */ p f135426a; public C2193a(p pVar) { this.f135426a = pVar; } @Override // n0.d public c getCredentials() { return this.f135426a; } } /* compiled from: AwsSdkMetrics */ public static class b { /* renamed from: a reason: collision with root package name */ public final Set<f> f135427a; /* renamed from: b reason: collision with root package name */ public volatile Set<f> f135428b; public b() { HashSet hashSet = new HashSet(); this.f135427a = hashSet; hashSet.add(a.EnumC0942a.ClientExecuteTime); hashSet.add(a.EnumC0942a.Exception); hashSet.add(a.EnumC0942a.HttpClientRetryCount); hashSet.add(a.EnumC0942a.HttpRequestTime); hashSet.add(a.EnumC0942a.RequestCount); hashSet.add(a.EnumC0942a.RetryCount); hashSet.add(a.EnumC0942a.HttpClientSendRequestTime); hashSet.add(a.EnumC0942a.HttpClientReceiveResponseTime); hashSet.add(a.EnumC0942a.HttpClientPoolAvailableCount); hashSet.add(a.EnumC0942a.HttpClientPoolLeasedCount); hashSet.add(a.EnumC0942a.HttpClientPoolPendingCount); hashSet.add(g1.c.HttpClientGetConnectionTime); f(); } public boolean a(f fVar) { boolean add; synchronized (this.f135427a) { add = this.f135427a.add(fVar); if (add) { f(); } } return add; } public <T extends f> boolean b(Collection<T> collection) { boolean addAll; synchronized (this.f135427a) { addAll = this.f135427a.addAll(collection); if (addAll) { f(); } } return addAll; } public Set<f> c() { return this.f135428b; } public boolean d(f fVar) { boolean remove; synchronized (this.f135427a) { remove = this.f135427a.remove(fVar); if (remove) { f(); } } return remove; } /* JADX WARNING: Code restructure failed: missing block: B:5:0x0009, code lost: if (r3.size() == 0) goto L_0x000b; */ public <T extends f> void e(Collection<T> collection) { synchronized (this.f135427a) { if (collection != null) { } if (this.f135427a.size() != 0) { if (collection == null) { collection = Collections.emptyList(); } this.f135427a.clear(); if (!b(collection)) { f(); } } } } public final void f() { this.f135428b = Collections.unmodifiableSet(new HashSet(this.f135427a)); } } /* access modifiers changed from: public */ static { metricNameSpace = DEFAULT_METRIC_NAMESPACE; String property = System.getProperty("com.amazonaws.sdk.enableDefaultMetrics"); boolean z14 = property != null; DEFAULT_METRICS_ENABLED = z14; if (z14) { boolean z15 = false; boolean z16 = false; boolean z17 = false; for (String str : property.split(",")) { String trim = str.trim(); if (!z15 && EXCLUDE_MACHINE_METRICS.equals(trim)) { z15 = true; } else if (!z16 && INCLUDE_PER_HOST_METRICS.equals(trim)) { z16 = true; } else if (z17 || !USE_SINGLE_METRIC_NAMESPACE.equals(trim)) { String[] split = trim.split("="); if (split.length == 2) { String trim2 = split[0].trim(); String trim3 = split[1].trim(); try { if (AWS_CREDENTAIL_PROPERTIES_FILE.equals(trim2)) { setCredentialFile0(trim3); } else if (CLOUDWATCH_REGION.equals(trim2)) { region = e.fromName(trim3); } else if (METRIC_QUEUE_SIZE.equals(trim2)) { Integer num = new Integer(trim3); if (num.intValue() >= 1) { metricQueueSize = num; } else { throw new IllegalArgumentException("metricQueueSize must be at least 1"); } } else if (QUEUE_POLL_TIMEOUT_MILLI.equals(trim2)) { Long l14 = new Long(trim3); if (l14.intValue() >= 1000) { queuePollTimeoutMilli = l14; } else { throw new IllegalArgumentException("getQueuePollTimeoutMilli must be at least 1000"); } } else if (METRIC_NAME_SPACE.equals(trim2)) { metricNameSpace = trim3; } else if (JVM_METRIC_NAME.equals(trim2)) { jvmMetricName = trim3; } else if (HOST_METRIC_NAME.equals(trim2)) { hostMetricName = trim3; } else { t0.d.b(a.class).h("Ignoring unrecognized parameter: " + trim); } } catch (Exception e14) { t0.d.b(a.class).d("Ignoring failure", e14); } } else { continue; } } else { z17 = true; } } machineMetricsExcluded = z15; perHostMetricsIncluded = z16; singleMetricNamespace = z17; } } public static boolean add(f fVar) { if (fVar == null) { return false; } return REGISTRY.a(fVar); } public static <T extends f> boolean addAll(Collection<T> collection) { if (collection == null || collection.size() == 0) { return false; } return REGISTRY.b(collection); } public static void disableMetrics() { setMetricCollector(d.f135432a); } public static synchronized boolean enableDefaultMetrics() { synchronized (a.class) { if (f135425mc == null || !f135425mc.c()) { if (!dirtyEnabling) { dirtyEnabling = true; try { d a14 = ((d.b) Class.forName(DEFAULT_METRIC_COLLECTOR_FACTORY).newInstance()).a(); if (a14 != null) { setMetricCollector(a14); dirtyEnabling = false; return true; } } catch (Exception e14) { t0.d.b(a.class).f("Failed to enable the default metrics", e14); } catch (Throwable th3) { dirtyEnabling = false; throw th3; } dirtyEnabling = false; } else { throw new IllegalStateException("Reentrancy is not allowed"); } } return false; } } public static String getCredentailFile() { return credentialFile; } public static n0.d getCredentialProvider() { StackTraceElement[] stackTrace; for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) { if (stackTraceElement.getClassName().equals(DEFAULT_METRIC_COLLECTOR_FACTORY)) { return credentialProvider; } } SecurityException securityException = new SecurityException(); t0.d.b(a.class).f("Illegal attempt to access the credential provider", securityException); throw securityException; } public static String getHostMetricName() { return hostMetricName; } public static d getInternalMetricCollector() { return f135425mc; } public static String getJvmMetricName() { return jvmMetricName; } public static <T extends d> T getMetricCollector() { if (f135425mc == null && isDefaultMetricsEnabled()) { enableDefaultMetrics(); } return f135425mc == null ? (T) d.f135432a : (T) f135425mc; } public static String getMetricNameSpace() { return metricNameSpace; } public static Integer getMetricQueueSize() { return metricQueueSize; } public static Set<f> getPredefinedMetrics() { return REGISTRY.c(); } public static Long getQueuePollTimeoutMilli() { return queuePollTimeoutMilli; } public static e getRegion() { return region; } public static <T extends g> T getRequestMetricCollector() { if (f135425mc == null && isDefaultMetricsEnabled()) { enableDefaultMetrics(); } return f135425mc == null ? (T) g.f135434a : (T) f135425mc.a(); } public static <T extends h> T getServiceMetricCollector() { if (f135425mc == null && isDefaultMetricsEnabled()) { enableDefaultMetrics(); } return f135425mc == null ? (T) h.f135435a : (T) f135425mc.b(); } public static boolean isDefaultMetricsEnabled() { return DEFAULT_METRICS_ENABLED; } public static boolean isMachineMetricExcluded() { return machineMetricsExcluded; } public static boolean isMetricsEnabled() { d dVar = f135425mc; return dVar != null && dVar.c(); } public static boolean isPerHostMetricEnabled() { String str; if (perHostMetricsIncluded) { return true; } String str2 = hostMetricName; if (str2 == null) { str = ""; } else { str = str2.trim(); } if (str.length() > 0) { return true; } return false; } public static boolean isPerHostMetricIncluded() { return perHostMetricsIncluded; } public static boolean isSingleMetricNamespace() { return singleMetricNamespace; } public static boolean remove(f fVar) { if (fVar == null) { return false; } return REGISTRY.d(fVar); } public static <T extends f> void set(Collection<T> collection) { REGISTRY.e(collection); } public static void setCredentialFile(String str) throws IOException { setCredentialFile0(str); } private static void setCredentialFile0(String str) throws IOException { p pVar = new p(new File(str)); synchronized (a.class) { credentialProvider = new C2193a(pVar); credentialFile = str; } } public static synchronized void setCredentialProvider(n0.d dVar) { synchronized (a.class) { credentialProvider = dVar; } } public static void setHostMetricName(String str) { hostMetricName = str; } public static void setJvmMetricName(String str) { jvmMetricName = str; } public static void setMachineMetricsExcluded(boolean z14) { machineMetricsExcluded = z14; } public static synchronized void setMetricCollector(d dVar) { synchronized (a.class) { d dVar2 = f135425mc; f135425mc = dVar; if (dVar2 != null) { dVar2.d(); } } } public static void setMetricNameSpace(String str) { if (str == null || str.trim().length() == 0) { throw new IllegalArgumentException(); } metricNameSpace = str; } public static void setMetricQueueSize(Integer num) { metricQueueSize = num; } public static void setPerHostMetricsIncluded(boolean z14) { perHostMetricsIncluded = z14; } public static void setQueuePollTimeoutMilli(Long l14) { queuePollTimeoutMilli = l14; } public static void setRegion(e eVar) { region = eVar; } public static void setSingleMetricNamespace(boolean z14) { singleMetricNamespace = z14; } }