Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Remove unused code from SystemTagsManagerImpl #9532

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,23 +17,17 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Captain1653 marked this conversation as resolved.
Show resolved Hide resolved
import java.util.ServiceLoader;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.StreamSupport;

import io.helidon.common.HelidonServiceLoader;
import io.helidon.common.LazyValue;
import io.helidon.metrics.spi.MetricsProgrammaticConfig;

/**
Expand All @@ -49,11 +43,6 @@
*/
class SystemTagsManagerImpl implements SystemTagsManager {

private static final LazyValue<Collection<MetricsProgrammaticConfig>> METRICS_CONFIG_OVERRIDES =
LazyValue.create(() ->
HelidonServiceLoader.create(ServiceLoader.load(MetricsProgrammaticConfig.class))
.asList());

private static SystemTagsManagerImpl instance = new SystemTagsManagerImpl();

private static final Collection<Consumer<SystemTagsManager>> ON_CHANGE_SUBSCRIBERS = new ArrayList<>();
Expand Down Expand Up @@ -124,22 +113,6 @@ static SystemTagsManagerImpl createWithoutSaving(MetricsConfig metricsConfig) {
return new SystemTagsManagerImpl(metricsConfig);
}

/**
* Returns an {@link java.lang.Iterable} of the implied type representing the provided scope <em>if</em> scope tagging
* is active: the scope tag name is non-null and non-blank.
*
* @param scopeTagName scope tag name
* @param scope scope value
* @param factory factory method to accept the scope tag and the scope and return an instance of the implied type
* @param <T> type to which the scope tag and scope are converted
* @return iterable of the scope if the scope tag name is non-null and non-blank; an empty iterable otherwise
*/
static <T> Iterable<T> scopeIterable(String scopeTagName, String scope, BiFunction<String, String, T> factory) {
return scopeTagName != null && !scopeTagName.isBlank() && scope != null
? List.of(factory.apply(scopeTagName, scope))
: List.of();
}

@Override
public Optional<Tag> scopeTag(Optional<String> candidateScope) {
return scopeTagName == null
Expand Down Expand Up @@ -252,59 +225,4 @@ private Optional<String> scopeFromTags(Iterable<Tag> tags) {
: Optional.empty();
}

static class MultiIterable<T> implements Iterable<T> {

private final Iterable<T>[] iterables;

private MultiIterable(Iterable<T>... iterables) {
if (iterables.length == 0) {
throw new IllegalArgumentException("Must provide at least one Iterable");
}
this.iterables = iterables;
}

@Override
public Iterator<T> iterator() {
return new Iterator<T>() {

private int nextIndex = 0;
private Iterator<T> current = nextIterator();

@Override
public boolean hasNext() {
if (current.hasNext()) {
return true;
}

current = nextIterator();
return current.hasNext();
}

@Override
public T next() {
return current.next();
}

private Iterator<T> nextIterator() {
while (nextIndex < iterables.length) {
Iterator<T> candidateNextIterator = iterables[nextIndex].iterator();
if (candidateNextIterator.hasNext()) {
nextIndex++;
return candidateNextIterator;
}
nextIndex++;
}
return Collections.emptyIterator();
}
};
}

@Override
public void forEach(Consumer<? super T> action) {
for (Iterable<T> it : iterables) {
it.forEach(action);
}
}
}

}