From 272285b33f29f2b9035eec174115092293295f8d Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 2 Mar 2023 14:20:00 +0100 Subject: [PATCH] Remove atomix.utils.serializer.serializers This entire package is only used by Namespace, which in turn is unused. Remove it to reduce clutter. JIRA: CONTROLLER-2072 Change-Id: I162e4c6d783d49cb4a209706e193e6d8dc0a0638 Signed-off-by: Robert Varga --- third-party/atomix/storage/pom.xml | 2 +- .../atomix/utils/serializer/Namespaces.java | 112 ------------------ .../serializers/ArraysAsListSerializer.java | 49 -------- .../serializers/ImmutableListSerializer.java | 62 ---------- .../serializers/ImmutableMapSerializer.java | 69 ----------- .../serializers/ImmutableSetSerializer.java | 62 ---------- .../serializer/serializers/package-info.java | 20 ---- 7 files changed, 1 insertion(+), 375 deletions(-) delete mode 100644 third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/Namespaces.java delete mode 100644 third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ArraysAsListSerializer.java delete mode 100644 third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableListSerializer.java delete mode 100644 third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableMapSerializer.java delete mode 100644 third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableSetSerializer.java delete mode 100644 third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/package-info.java diff --git a/third-party/atomix/storage/pom.xml b/third-party/atomix/storage/pom.xml index 110a87e18e..f9a5279470 100644 --- a/third-party/atomix/storage/pom.xml +++ b/third-party/atomix/storage/pom.xml @@ -133,7 +133,7 @@ io.atomix.storage.journal.*, - io.atomix.utils.serializer.*, + io.atomix.utils.serializer, com.esotericsoftware.kryo.*;version=4.0.2 diff --git a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/Namespaces.java b/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/Namespaces.java deleted file mode 100644 index f2daecd235..0000000000 --- a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/Namespaces.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2014-present Open Networking Foundation - * - * Licensed 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. - */ -package io.atomix.utils.serializer; - -import com.google.common.collect.HashMultiset; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Multisets; -import com.google.common.collect.Sets; -import io.atomix.utils.serializer.serializers.ArraysAsListSerializer; -import io.atomix.utils.serializer.serializers.ImmutableListSerializer; -import io.atomix.utils.serializer.serializers.ImmutableMapSerializer; -import io.atomix.utils.serializer.serializers.ImmutableSetSerializer; - -import java.time.Duration; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Optional; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArraySet; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; - -public final class Namespaces { - public static final int BASIC_MAX_SIZE = 50; - public static final Namespace BASIC = Namespace.builder() - .nextId(Namespace.FLOATING_ID) - .register(byte[].class) - .register(AtomicBoolean.class) - .register(AtomicInteger.class) - .register(AtomicLong.class) - .register(new ImmutableListSerializer(), - ImmutableList.class, - ImmutableList.of(1).getClass(), - ImmutableList.of(1, 2).getClass(), - ImmutableList.of(1, 2, 3).subList(1, 3).getClass()) - .register(new ImmutableSetSerializer(), - ImmutableSet.class, - ImmutableSet.of().getClass(), - ImmutableSet.of(1).getClass(), - ImmutableSet.of(1, 2).getClass()) - .register(new ImmutableMapSerializer(), - ImmutableMap.class, - ImmutableMap.of().getClass(), - ImmutableMap.of("a", 1).getClass(), - ImmutableMap.of("R", 2, "D", 2).getClass()) - .register(Collections.unmodifiableSet(Collections.emptySet()).getClass()) - .register(HashMap.class) - .register(ConcurrentHashMap.class) - .register(CopyOnWriteArraySet.class) - .register( - ArrayList.class, - LinkedList.class, - HashSet.class, - LinkedHashSet.class, - ArrayDeque.class - ) - .register(HashMultiset.class) - .register(Multisets.immutableEntry("", 0).getClass()) - .register(Sets.class) - .register(Maps.immutableEntry("a", "b").getClass()) - .register(new ArraysAsListSerializer(), Arrays.asList().getClass()) - .register(Collections.singletonList(1).getClass()) - .register(Duration.class) - .register(Collections.emptySet().getClass()) - .register(Optional.class) - .register(Collections.emptyList().getClass()) - .register(Collections.singleton(Object.class).getClass()) - .register(Properties.class) - .register(int[].class) - .register(long[].class) - .register(short[].class) - .register(double[].class) - .register(float[].class) - .register(char[].class) - .register(String[].class) - .register(boolean[].class) - .register(Object[].class) - .build("BASIC"); - - /** - * Kryo registration Id for user custom registration. - */ - public static final int BEGIN_USER_CUSTOM_ID = 500; - - // not to be instantiated - private Namespaces() { - } -} diff --git a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ArraysAsListSerializer.java b/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ArraysAsListSerializer.java deleted file mode 100644 index 9e8dbd6068..0000000000 --- a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ArraysAsListSerializer.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2014-present Open Networking Foundation - * - * Licensed 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. - */ - -package io.atomix.utils.serializer.serializers; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.Serializer; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.io.Output; - -import java.util.ArrayList; -import java.util.List; - -/** - * Kryo Serializer for {@link java.util.Arrays#asList(Object...)}. - */ -public final class ArraysAsListSerializer extends Serializer> { - - @Override - public void write(Kryo kryo, Output output, List object) { - output.writeInt(object.size(), true); - for (Object elm : object) { - kryo.writeClassAndObject(output, elm); - } - } - - @Override - public List read(Kryo kryo, Input input, Class> type) { - final int size = input.readInt(true); - List list = new ArrayList<>(size); - for (int i = 0; i < size; ++i) { - list.add(kryo.readClassAndObject(input)); - } - return list; - } -} diff --git a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableListSerializer.java b/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableListSerializer.java deleted file mode 100644 index 3853ef6838..0000000000 --- a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableListSerializer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2014-present Open Networking Foundation - * - * Licensed 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. - */ -package io.atomix.utils.serializer.serializers; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.Serializer; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.io.Output; -import com.google.common.collect.ImmutableList; - -/** - * Creates {@link ImmutableList} serializer instance. - */ -public class ImmutableListSerializer extends Serializer> { - - /** - * Creates {@link ImmutableList} serializer instance. - */ - public ImmutableListSerializer() { - // non-null, immutable - super(false, true); - } - - @Override - public void write(Kryo kryo, Output output, ImmutableList object) { - output.writeInt(object.size()); - for (Object e : object) { - kryo.writeClassAndObject(output, e); - } - } - - @Override - public ImmutableList read(Kryo kryo, Input input, - Class> type) { - final int size = input.readInt(); - switch (size) { - case 0: - return ImmutableList.of(); - case 1: - return ImmutableList.of(kryo.readClassAndObject(input)); - default: - Object[] elms = new Object[size]; - for (int i = 0; i < size; ++i) { - elms[i] = kryo.readClassAndObject(input); - } - return ImmutableList.copyOf(elms); - } - } -} diff --git a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableMapSerializer.java b/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableMapSerializer.java deleted file mode 100644 index f3b9ce5424..0000000000 --- a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableMapSerializer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2014-present Open Networking Foundation - * - * Licensed 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. - */ -package io.atomix.utils.serializer.serializers; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.Serializer; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.io.Output; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; - -import java.util.Map.Entry; - -/** - * Kryo Serializer for {@link ImmutableMap}. - */ -public class ImmutableMapSerializer extends Serializer> { - - /** - * Creates {@link ImmutableMap} serializer instance. - */ - public ImmutableMapSerializer() { - // non-null, immutable - super(false, true); - } - - @Override - public void write(Kryo kryo, Output output, ImmutableMap object) { - output.writeInt(object.size()); - for (Entry e : object.entrySet()) { - kryo.writeClassAndObject(output, e.getKey()); - kryo.writeClassAndObject(output, e.getValue()); - } - } - - @Override - public ImmutableMap read(Kryo kryo, Input input, - Class> type) { - final int size = input.readInt(); - switch (size) { - case 0: - return ImmutableMap.of(); - case 1: - return ImmutableMap.of(kryo.readClassAndObject(input), - kryo.readClassAndObject(input)); - - default: - Builder builder = ImmutableMap.builder(); - for (int i = 0; i < size; ++i) { - builder.put(kryo.readClassAndObject(input), - kryo.readClassAndObject(input)); - } - return builder.build(); - } - } -} diff --git a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableSetSerializer.java b/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableSetSerializer.java deleted file mode 100644 index 6887c5400d..0000000000 --- a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/ImmutableSetSerializer.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2014-present Open Networking Foundation - * - * Licensed 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. - */ -package io.atomix.utils.serializer.serializers; - -import com.esotericsoftware.kryo.Kryo; -import com.esotericsoftware.kryo.Serializer; -import com.esotericsoftware.kryo.io.Input; -import com.esotericsoftware.kryo.io.Output; -import com.google.common.collect.ImmutableSet; - -/** - * Kryo Serializer for {@link ImmutableSet}. - */ -public class ImmutableSetSerializer extends Serializer> { - - /** - * Creates {@link ImmutableSet} serializer instance. - */ - public ImmutableSetSerializer() { - // non-null, immutable - super(false, true); - } - - @Override - public void write(Kryo kryo, Output output, ImmutableSet object) { - output.writeInt(object.size()); - for (Object e : object) { - kryo.writeClassAndObject(output, e); - } - } - - @Override - public ImmutableSet read(Kryo kryo, Input input, - Class> type) { - final int size = input.readInt(); - switch (size) { - case 0: - return ImmutableSet.of(); - case 1: - return ImmutableSet.of(kryo.readClassAndObject(input)); - default: - Object[] elms = new Object[size]; - for (int i = 0; i < size; ++i) { - elms[i] = kryo.readClassAndObject(input); - } - return ImmutableSet.copyOf(elms); - } - } -} diff --git a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/package-info.java b/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/package-info.java deleted file mode 100644 index c6f31507ec..0000000000 --- a/third-party/atomix/storage/src/main/java/io/atomix/utils/serializer/serializers/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2019-present Open Networking Foundation - * - * Licensed 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. - */ - -/** - * Common serializer implementations. - */ -package io.atomix.utils.serializer.serializers; -- 2.36.6