Removed java11 source folders since JDK-11 is the baseline now (#2898)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
This commit is contained in:
parent
fc378c7256
commit
d61d170332
|
@ -32,48 +32,44 @@
|
||||||
|
|
||||||
package org.opensearch.common.collect;
|
package org.opensearch.common.collect;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public class List {
|
public class List {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable list containing zero elements.
|
* Delegates to the Java9 {@code List.of()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code List}'s element type
|
* @param <T> the {@code List}'s element type
|
||||||
* @return an empty {@code List}
|
* @return an empty {@code List}
|
||||||
*/
|
*/
|
||||||
public static <T> java.util.List<T> of() {
|
public static <T> java.util.List<T> of() {
|
||||||
return Collections.emptyList();
|
return java.util.List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable list containing one element.
|
* Delegates to the Java9 {@code List.of()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code List}'s element type
|
* @param <T> the {@code List}'s element type
|
||||||
* @param e1 the single element
|
* @param e1 the single element
|
||||||
* @return a {@code List} containing the specified element
|
* @return a {@code List} containing the specified element
|
||||||
*/
|
*/
|
||||||
public static <T> java.util.List<T> of(T e1) {
|
public static <T> java.util.List<T> of(T e1) {
|
||||||
return Collections.singletonList(e1);
|
return java.util.List.of(e1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable list containing two elements.
|
* Delegates to the Java9 {@code List.of()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code List}'s element type
|
* @param <T> the {@code List}'s element type
|
||||||
* @param e1 the first element
|
* @param e1 the single element
|
||||||
* @param e2 the second element
|
|
||||||
* @return a {@code List} containing the specified element
|
* @return a {@code List} containing the specified element
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> java.util.List<T> of(T e1, T e2) {
|
public static <T> java.util.List<T> of(T e1, T e2) {
|
||||||
return List.of((T[]) new Object[] { e1, e2 });
|
return java.util.List.of(e1, e2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable list containing an arbitrary number of elements.
|
* Delegates to the Java9 {@code List.of()} method.
|
||||||
*
|
*
|
||||||
* @param entries the elements to be contained in the list
|
* @param entries the elements to be contained in the list
|
||||||
* @param <T> the {@code List}'s element type
|
* @param <T> the {@code List}'s element type
|
||||||
|
@ -82,25 +78,17 @@ public class List {
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
@SuppressWarnings("varargs")
|
@SuppressWarnings("varargs")
|
||||||
public static <T> java.util.List<T> of(T... entries) {
|
public static <T> java.util.List<T> of(T... entries) {
|
||||||
switch (entries.length) {
|
return java.util.List.of(entries);
|
||||||
case 0:
|
|
||||||
return List.of();
|
|
||||||
case 1:
|
|
||||||
return List.of(entries[0]);
|
|
||||||
default:
|
|
||||||
return Collections.unmodifiableList(Arrays.asList(entries));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable {@code List} containing the elements of the given {@code Collection} in iteration order.
|
* Delegates to the Java9 {@code List.copyOf()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code List}'s element type
|
* @param <T> the {@code List}'s element type
|
||||||
* @param coll a {@code Collection} from which elements are drawn, must be non-null
|
* @param coll a {@code Collection} from which elements are drawn, must be non-null
|
||||||
* @return a {@code List} containing the elements of the given {@code Collection}
|
* @return a {@code List} containing the elements of the given {@code Collection}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> java.util.List<T> copyOf(Collection<? extends T> coll) {
|
public static <T> java.util.List<T> copyOf(Collection<? extends T> coll) {
|
||||||
return (java.util.List<T>) List.of(coll.toArray());
|
return java.util.List.copyOf(coll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,70 +32,66 @@
|
||||||
|
|
||||||
package org.opensearch.common.collect;
|
package org.opensearch.common.collect;
|
||||||
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class Map {
|
public class Map {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing one mapping.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of() {
|
public static <K, V> java.util.Map<K, V> of() {
|
||||||
return Collections.emptyMap();
|
return java.util.Map.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing one mapping.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1) {
|
||||||
return Collections.singletonMap(k1, v1);
|
return java.util.Map.of(k1, v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing two mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2) {
|
||||||
return mapN(k1, v1, k2, v2);
|
return java.util.Map.of(k1, v1, k2, v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing three mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing four mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing five mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing six mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing seven mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
|
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing eight mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(
|
public static <K, V> java.util.Map<K, V> of(
|
||||||
K k1,
|
K k1,
|
||||||
|
@ -115,11 +111,11 @@ public class Map {
|
||||||
K k8,
|
K k8,
|
||||||
V v8
|
V v8
|
||||||
) {
|
) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing nine mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(
|
public static <K, V> java.util.Map<K, V> of(
|
||||||
K k1,
|
K k1,
|
||||||
|
@ -141,11 +137,11 @@ public class Map {
|
||||||
K k9,
|
K k9,
|
||||||
V v9
|
V v9
|
||||||
) {
|
) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing ten mappings.
|
* Delegates to the Java9 {@code Map.of()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map<K, V> of(
|
public static <K, V> java.util.Map<K, V> of(
|
||||||
K k1,
|
K k1,
|
||||||
|
@ -169,68 +165,30 @@ public class Map {
|
||||||
K k10,
|
K k10,
|
||||||
V v10
|
V v10
|
||||||
) {
|
) {
|
||||||
return mapN(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10);
|
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10);
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static <K, V> java.util.Map<K, V> mapN(Object... objects) {
|
|
||||||
if (objects.length % 2 != 0) {
|
|
||||||
throw new IllegalStateException("Must provide an even number of arguments to Map::of method");
|
|
||||||
}
|
|
||||||
switch (objects.length) {
|
|
||||||
case 0:
|
|
||||||
return Map.of();
|
|
||||||
case 2:
|
|
||||||
return Map.of((K) objects[0], (V) objects[1]);
|
|
||||||
default:
|
|
||||||
HashMap<K, V> map = new HashMap<>();
|
|
||||||
for (int k = 0; k < objects.length / 2; k++) {
|
|
||||||
map.put((K) objects[k * 2], (V) objects[k * 2 + 1]);
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableMap(map);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable map containing keys and values extracted from the given entries.
|
* Delegates to the Java9 {@code Map.ofEntries()} method.
|
||||||
*
|
|
||||||
* @param <K> the {@code Map}'s key type
|
|
||||||
* @param <V> the {@code Map}'s value type
|
|
||||||
* @param entries {@code Map.Entry}s containing the keys and values from which the map is populated
|
|
||||||
* @return a {@code Map} containing the specified mappings
|
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
|
@SuppressWarnings("varargs")
|
||||||
public static <K, V> java.util.Map<K, V> ofEntries(java.util.Map.Entry<? extends K, ? extends V>... entries) {
|
public static <K, V> java.util.Map<K, V> ofEntries(java.util.Map.Entry<? extends K, ? extends V>... entries) {
|
||||||
if (entries.length == 0) {
|
return java.util.Map.ofEntries(entries);
|
||||||
return Collections.emptyMap();
|
|
||||||
} else if (entries.length == 1) {
|
|
||||||
return Collections.singletonMap(entries[0].getKey(), entries[0].getValue());
|
|
||||||
} else {
|
|
||||||
HashMap<K, V> map = new HashMap<>();
|
|
||||||
for (java.util.Map.Entry<? extends K, ? extends V> entry : entries) {
|
|
||||||
map.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableMap(map);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable Map.Entry for the provided key and value.
|
* Delegates to the Java9 {@code Map.entry()} method.
|
||||||
*/
|
*/
|
||||||
public static <K, V> java.util.Map.Entry<K, V> entry(K k, V v) {
|
public static <K, V> java.util.Map.Entry<K, V> entry(K k, V v) {
|
||||||
return new AbstractMap.SimpleImmutableEntry<>(k, v);
|
return java.util.Map.entry(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable {@code Map} containing the entries of the given {@code Map}.
|
* Delegates to the Java10 {@code Map.copyOf()} method.
|
||||||
*
|
|
||||||
* @param <K> the {@code Map}'s key type
|
|
||||||
* @param <V> the {@code Map}'s value type
|
|
||||||
* @param map a {@code Map} from which entries are drawn, must be non-null
|
|
||||||
* @return a {@code Map} containing the entries of the given {@code Map}
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
||||||
public static <K, V> java.util.Map<K, V> copyOf(java.util.Map<? extends K, ? extends V> map) {
|
public static <K, V> java.util.Map<K, V> copyOf(java.util.Map<? extends K, ? extends V> map) {
|
||||||
return (java.util.Map<K, V>) Map.ofEntries(map.entrySet().toArray(new java.util.Map.Entry[0]));
|
return java.util.Map.copyOf(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,49 +32,45 @@
|
||||||
|
|
||||||
package org.opensearch.common.collect;
|
package org.opensearch.common.collect;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class Set {
|
public class Set {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable set containing zero elements.
|
* Delegates to the Java9 {@code Set.of()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code Set}'s element type
|
* @param <T> the {@code Set}'s element type
|
||||||
* @return an empty {@code Set}
|
* @return an empty {@code Set}
|
||||||
*/
|
*/
|
||||||
public static <T> java.util.Set<T> of() {
|
public static <T> java.util.Set<T> of() {
|
||||||
return Collections.emptySet();
|
return java.util.Set.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable set containing one element.
|
* Delegates to the Java9 {@code Set.of()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code Set}'s element type
|
* @param <T> the {@code Set}'s element type
|
||||||
* @param e1 the single element
|
* @param e1 the single element
|
||||||
* @return a {@code Set} containing the specified element
|
* @return a {@code Set} containing the specified element
|
||||||
*/
|
*/
|
||||||
public static <T> java.util.Set<T> of(T e1) {
|
public static <T> java.util.Set<T> of(T e1) {
|
||||||
return Collections.singleton(e1);
|
return java.util.Set.of(e1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable set containing two elements.
|
* Delegates to the Java9 {@code Set.of()} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code Set}'s element type
|
* @param <T> the {@code Set}'s element type
|
||||||
* @param e1 the first element
|
* @param e1 the first element
|
||||||
* @param e2 the second element
|
* @param e2 the second element
|
||||||
* @return a {@code Set} containing the specified element
|
* @return a {@code Set} containing the specified element
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> java.util.Set<T> of(T e1, T e2) {
|
public static <T> java.util.Set<T> of(T e1, T e2) {
|
||||||
return Set.of((T[]) new Object[] { e1, e2 });
|
return java.util.Set.of(e1, e2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable set containing an arbitrary number of elements.
|
* Delegates to the Java9 {@code Set.of()} method.
|
||||||
*
|
*
|
||||||
* @param entries the elements to be contained in the set
|
* @param entries the elements to be contained in the set
|
||||||
* @param <T> the {@code Set}'s element type
|
* @param <T> the {@code Set}'s element type
|
||||||
|
@ -83,27 +79,17 @@ public class Set {
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
@SuppressWarnings("varargs")
|
@SuppressWarnings("varargs")
|
||||||
public static <T> java.util.Set<T> of(T... entries) {
|
public static <T> java.util.Set<T> of(T... entries) {
|
||||||
switch (entries.length) {
|
return java.util.Set.of(entries);
|
||||||
case 0:
|
|
||||||
return Set.of();
|
|
||||||
case 1:
|
|
||||||
return Set.of(entries[0]);
|
|
||||||
default:
|
|
||||||
return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(entries)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an unmodifiable {@code Set} containing the elements of the given Collection.
|
* Delegates to the Java10 {@code Set.copyOf} method.
|
||||||
*
|
*
|
||||||
* @param <T> the {@code Set}'s element type
|
* @param <T> the {@code Set}'s element type
|
||||||
* @param coll a {@code Collection} from which elements are drawn, must be non-null
|
* @param coll a {@code Collection} from which elements are drawn, must be non-null
|
||||||
* @return a {@code Set} containing the elements of the given {@code Collection}
|
* @return a {@code Set} containing the elements of the given {@code Collection}
|
||||||
* @throws NullPointerException if coll is null, or if it contains any nulls
|
|
||||||
* @since 10
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> java.util.Set<T> copyOf(Collection<? extends T> coll) {
|
public static <T> java.util.Set<T> copyOf(Collection<? extends T> coll) {
|
||||||
return (java.util.Set<T>) Set.of(new HashSet<>(coll).toArray());
|
return java.util.Set.copyOf(coll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,20 +38,15 @@ import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple utility methods for file and stream copying.
|
* Simple utility methods for file and stream copying.
|
||||||
* All copy methods use a block size of 4096 bytes,
|
* All copy methods close all affected streams when done.
|
||||||
* and close all affected streams when done.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Mainly for use within the framework,
|
* Mainly for use within the framework,
|
||||||
* but also useful for application code.
|
* but also useful for application code.
|
||||||
*/
|
*/
|
||||||
public class Streams {
|
public abstract class Streams {
|
||||||
|
|
||||||
private static final ThreadLocal<byte[]> buffer = ThreadLocal.withInitial(() -> new byte[8 * 1024]);
|
private static final ThreadLocal<byte[]> buffer = ThreadLocal.withInitial(() -> new byte[8 * 1024]);
|
||||||
|
|
||||||
private Streams() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the contents of the given InputStream to the given OutputStream. Optionally, closes both streams when done.
|
* Copy the contents of the given InputStream to the given OutputStream. Optionally, closes both streams when done.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.common.collect;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class List {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code List.of()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code List}'s element type
|
|
||||||
* @return an empty {@code List}
|
|
||||||
*/
|
|
||||||
public static <T> java.util.List<T> of() {
|
|
||||||
return java.util.List.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code List.of()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code List}'s element type
|
|
||||||
* @param e1 the single element
|
|
||||||
* @return a {@code List} containing the specified element
|
|
||||||
*/
|
|
||||||
public static <T> java.util.List<T> of(T e1) {
|
|
||||||
return java.util.List.of(e1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code List.of()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code List}'s element type
|
|
||||||
* @param e1 the single element
|
|
||||||
* @return a {@code List} containing the specified element
|
|
||||||
*/
|
|
||||||
public static <T> java.util.List<T> of(T e1, T e2) {
|
|
||||||
return java.util.List.of(e1, e2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code List.of()} method.
|
|
||||||
*
|
|
||||||
* @param entries the elements to be contained in the list
|
|
||||||
* @param <T> the {@code List}'s element type
|
|
||||||
* @return an unmodifiable list containing the specified elements.
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
@SuppressWarnings("varargs")
|
|
||||||
public static <T> java.util.List<T> of(T... entries) {
|
|
||||||
return java.util.List.of(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code List.copyOf()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code List}'s element type
|
|
||||||
* @param coll a {@code Collection} from which elements are drawn, must be non-null
|
|
||||||
* @return a {@code List} containing the elements of the given {@code Collection}
|
|
||||||
*/
|
|
||||||
public static <T> java.util.List<T> copyOf(Collection<? extends T> coll) {
|
|
||||||
return java.util.List.copyOf(coll);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,194 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.common.collect;
|
|
||||||
|
|
||||||
public class Map {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of() {
|
|
||||||
return java.util.Map.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1) {
|
|
||||||
return java.util.Map.of(k1, v1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(
|
|
||||||
K k1,
|
|
||||||
V v1,
|
|
||||||
K k2,
|
|
||||||
V v2,
|
|
||||||
K k3,
|
|
||||||
V v3,
|
|
||||||
K k4,
|
|
||||||
V v4,
|
|
||||||
K k5,
|
|
||||||
V v5,
|
|
||||||
K k6,
|
|
||||||
V v6,
|
|
||||||
K k7,
|
|
||||||
V v7,
|
|
||||||
K k8,
|
|
||||||
V v8
|
|
||||||
) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(
|
|
||||||
K k1,
|
|
||||||
V v1,
|
|
||||||
K k2,
|
|
||||||
V v2,
|
|
||||||
K k3,
|
|
||||||
V v3,
|
|
||||||
K k4,
|
|
||||||
V v4,
|
|
||||||
K k5,
|
|
||||||
V v5,
|
|
||||||
K k6,
|
|
||||||
V v6,
|
|
||||||
K k7,
|
|
||||||
V v7,
|
|
||||||
K k8,
|
|
||||||
V v8,
|
|
||||||
K k9,
|
|
||||||
V v9
|
|
||||||
) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.of()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> of(
|
|
||||||
K k1,
|
|
||||||
V v1,
|
|
||||||
K k2,
|
|
||||||
V v2,
|
|
||||||
K k3,
|
|
||||||
V v3,
|
|
||||||
K k4,
|
|
||||||
V v4,
|
|
||||||
K k5,
|
|
||||||
V v5,
|
|
||||||
K k6,
|
|
||||||
V v6,
|
|
||||||
K k7,
|
|
||||||
V v7,
|
|
||||||
K k8,
|
|
||||||
V v8,
|
|
||||||
K k9,
|
|
||||||
V v9,
|
|
||||||
K k10,
|
|
||||||
V v10
|
|
||||||
) {
|
|
||||||
return java.util.Map.of(k1, v1, k2, v2, k3, v3, k4, v4, k5, v5, k6, v6, k7, v7, k8, v8, k9, v9, k10, v10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.ofEntries()} method.
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
@SuppressWarnings("varargs")
|
|
||||||
public static <K, V> java.util.Map<K, V> ofEntries(java.util.Map.Entry<? extends K, ? extends V>... entries) {
|
|
||||||
return java.util.Map.ofEntries(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Map.entry()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map.Entry<K, V> entry(K k, V v) {
|
|
||||||
return java.util.Map.entry(k, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java10 {@code Map.copyOf()} method.
|
|
||||||
*/
|
|
||||||
public static <K, V> java.util.Map<K, V> copyOf(java.util.Map<? extends K, ? extends V> map) {
|
|
||||||
return java.util.Map.copyOf(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.common.collect;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class Set {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Set.of()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code Set}'s element type
|
|
||||||
* @return an empty {@code Set}
|
|
||||||
*/
|
|
||||||
public static <T> java.util.Set<T> of() {
|
|
||||||
return java.util.Set.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Set.of()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code Set}'s element type
|
|
||||||
* @param e1 the single element
|
|
||||||
* @return a {@code Set} containing the specified element
|
|
||||||
*/
|
|
||||||
public static <T> java.util.Set<T> of(T e1) {
|
|
||||||
return java.util.Set.of(e1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Set.of()} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code Set}'s element type
|
|
||||||
* @param e1 the first element
|
|
||||||
* @param e2 the second element
|
|
||||||
* @return a {@code Set} containing the specified element
|
|
||||||
*/
|
|
||||||
public static <T> java.util.Set<T> of(T e1, T e2) {
|
|
||||||
return java.util.Set.of(e1, e2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java9 {@code Set.of()} method.
|
|
||||||
*
|
|
||||||
* @param entries the elements to be contained in the set
|
|
||||||
* @param <T> the {@code Set}'s element type
|
|
||||||
* @return an unmodifiable set containing the specified elements.
|
|
||||||
*/
|
|
||||||
@SafeVarargs
|
|
||||||
@SuppressWarnings("varargs")
|
|
||||||
public static <T> java.util.Set<T> of(T... entries) {
|
|
||||||
return java.util.Set.of(entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delegates to the Java10 {@code Set.copyOf} method.
|
|
||||||
*
|
|
||||||
* @param <T> the {@code Set}'s element type
|
|
||||||
* @param coll a {@code Collection} from which elements are drawn, must be non-null
|
|
||||||
* @return a {@code Set} containing the elements of the given {@code Collection}
|
|
||||||
*/
|
|
||||||
public static <T> java.util.Set<T> copyOf(Collection<? extends T> coll) {
|
|
||||||
return java.util.Set.copyOf(coll);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.core.internal.io;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple utility methods for file and stream copying.
|
|
||||||
* All copy methods close all affected streams when done.
|
|
||||||
* <p>
|
|
||||||
* Mainly for use within the framework,
|
|
||||||
* but also useful for application code.
|
|
||||||
*/
|
|
||||||
public abstract class Streams {
|
|
||||||
|
|
||||||
private static final ThreadLocal<byte[]> buffer = ThreadLocal.withInitial(() -> new byte[8 * 1024]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy the contents of the given InputStream to the given OutputStream. Optionally, closes both streams when done.
|
|
||||||
*
|
|
||||||
* @param in the stream to copy from
|
|
||||||
* @param out the stream to copy to
|
|
||||||
* @param close whether to close both streams after copying
|
|
||||||
* @param buffer buffer to use for copying
|
|
||||||
* @return the number of bytes copied
|
|
||||||
* @throws IOException in case of I/O errors
|
|
||||||
*/
|
|
||||||
public static long copy(final InputStream in, final OutputStream out, byte[] buffer, boolean close) throws IOException {
|
|
||||||
Exception err = null;
|
|
||||||
try {
|
|
||||||
long byteCount = 0;
|
|
||||||
int bytesRead;
|
|
||||||
while ((bytesRead = in.read(buffer)) != -1) {
|
|
||||||
out.write(buffer, 0, bytesRead);
|
|
||||||
byteCount += bytesRead;
|
|
||||||
}
|
|
||||||
out.flush();
|
|
||||||
return byteCount;
|
|
||||||
} catch (IOException | RuntimeException e) {
|
|
||||||
err = e;
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
if (close) {
|
|
||||||
IOUtils.close(err, in, out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #copy(InputStream, OutputStream, byte[], boolean)
|
|
||||||
*/
|
|
||||||
public static long copy(final InputStream in, final OutputStream out, boolean close) throws IOException {
|
|
||||||
return copy(in, out, buffer.get(), close);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #copy(InputStream, OutputStream, byte[], boolean)
|
|
||||||
*/
|
|
||||||
public static long copy(final InputStream in, final OutputStream out, byte[] buffer) throws IOException {
|
|
||||||
return copy(in, out, buffer, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #copy(InputStream, OutputStream, byte[], boolean)
|
|
||||||
*/
|
|
||||||
public static long copy(final InputStream in, final OutputStream out) throws IOException {
|
|
||||||
return copy(in, out, buffer.get(), true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -32,31 +32,10 @@
|
||||||
|
|
||||||
package org.opensearch.monitor.jvm;
|
package org.opensearch.monitor.jvm;
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
|
|
||||||
class JvmPid {
|
class JvmPid {
|
||||||
|
|
||||||
private static final long PID;
|
|
||||||
|
|
||||||
static long getPid() {
|
static long getPid() {
|
||||||
return PID;
|
return ProcessHandle.current().pid();
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
PID = initializePid();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long initializePid() {
|
|
||||||
final String name = ManagementFactory.getRuntimeMXBean().getName();
|
|
||||||
try {
|
|
||||||
return Long.parseLong(name.split("@")[0]);
|
|
||||||
} catch (final NumberFormatException e) {
|
|
||||||
LogManager.getLogger(JvmPid.class).debug(new ParameterizedMessage("failed parsing PID from [{}]", name), e);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.monitor.jvm;
|
|
||||||
|
|
||||||
class JvmPid {
|
|
||||||
|
|
||||||
static long getPid() {
|
|
||||||
return ProcessHandle.current().pid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue