![JAR search and dependency download from the Maven repository](/logo.png)
org.opensearch.indices.breaker.AllCircuitBreakerStats Maven / Gradle / Ivy
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
package org.opensearch.indices.breaker;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.common.xcontent.ToXContentFragment;
import org.opensearch.common.xcontent.XContentBuilder;
import java.io.IOException;
/**
* Stats class encapsulating all of the different circuit breaker stats
*/
public class AllCircuitBreakerStats implements Writeable, ToXContentFragment {
private final CircuitBreakerStats[] allStats;
public AllCircuitBreakerStats(CircuitBreakerStats[] allStats) {
this.allStats = allStats;
}
public AllCircuitBreakerStats(StreamInput in) throws IOException {
allStats = in.readArray(CircuitBreakerStats::new, CircuitBreakerStats[]::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeArray(allStats);
}
public CircuitBreakerStats[] getAllStats() {
return this.allStats;
}
public CircuitBreakerStats getStats(String name) {
for (CircuitBreakerStats stats : allStats) {
if (stats.getName().equals(name)) {
return stats;
}
}
return null;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(Fields.BREAKERS);
for (CircuitBreakerStats stats : allStats) {
if (stats != null) {
stats.toXContent(builder, params);
}
}
builder.endObject();
return builder;
}
static final class Fields {
static final String BREAKERS = "breakers";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy