diff --git a/core/src/main/java/io/atomix/core/Atomix.java b/core/src/main/java/io/atomix/core/Atomix.java index 4c29f32d81..e980ee5e02 100644 --- a/core/src/main/java/io/atomix/core/Atomix.java +++ b/core/src/main/java/io/atomix/core/Atomix.java @@ -34,9 +34,9 @@ import io.atomix.core.lock.DistributedLock; import io.atomix.core.map.AtomicCounterMap; import io.atomix.core.map.AtomicMap; -import io.atomix.core.map.AtomicTreeMap; +import io.atomix.core.map.AtomicNavigableMap; import io.atomix.core.map.DistributedMap; -import io.atomix.core.map.DistributedTreeMap; +import io.atomix.core.map.DistributedNavigableMap; import io.atomix.core.multimap.AtomicMultimap; import io.atomix.core.multimap.DistributedMultimap; import io.atomix.core.multiset.DistributedMultiset; @@ -355,8 +355,8 @@ public DistributedMap getMap(String name) { } @Override - public , V> DistributedTreeMap getTreeMap(String name) { - return primitives.getTreeMap(name); + public , V> DistributedNavigableMap getNavigableMap(String name) { + return primitives.getNavigableMap(name); } @Override @@ -375,8 +375,8 @@ public AtomicDocumentTree getAtomicDocumentTree(String name) { } @Override - public , V> AtomicTreeMap getAtomicTreeMap(String name) { - return primitives.getAtomicTreeMap(name); + public , V> AtomicNavigableMap getAtomicNavigableMap(String name) { + return primitives.getAtomicNavigableMap(name); } @Override diff --git a/core/src/main/java/io/atomix/core/PrimitivesService.java b/core/src/main/java/io/atomix/core/PrimitivesService.java index 8796007ff2..86e9a8d2e8 100644 --- a/core/src/main/java/io/atomix/core/PrimitivesService.java +++ b/core/src/main/java/io/atomix/core/PrimitivesService.java @@ -48,15 +48,15 @@ import io.atomix.core.map.AtomicMap; import io.atomix.core.map.AtomicMapBuilder; import io.atomix.core.map.AtomicMapType; -import io.atomix.core.map.AtomicTreeMap; -import io.atomix.core.map.AtomicTreeMapBuilder; -import io.atomix.core.map.AtomicTreeMapType; +import io.atomix.core.map.AtomicNavigableMap; +import io.atomix.core.map.AtomicNavigableMapBuilder; +import io.atomix.core.map.AtomicNavigableMapType; import io.atomix.core.map.DistributedMap; import io.atomix.core.map.DistributedMapBuilder; import io.atomix.core.map.DistributedMapType; -import io.atomix.core.map.DistributedTreeMap; -import io.atomix.core.map.DistributedTreeMapBuilder; -import io.atomix.core.map.DistributedTreeMapType; +import io.atomix.core.map.DistributedNavigableMap; +import io.atomix.core.map.DistributedNavigableMapBuilder; +import io.atomix.core.map.DistributedNavigableMapType; import io.atomix.core.multimap.AtomicMultimap; import io.atomix.core.multimap.AtomicMultimapBuilder; import io.atomix.core.multimap.AtomicMultimapType; @@ -146,8 +146,8 @@ default DistributedMapBuilder mapBuilder(String name, PrimitiveProt * @param value type * @return builder for a tree map */ - default , V> DistributedTreeMapBuilder treeMapBuilder(String name) { - return primitiveBuilder(name, DistributedTreeMapType.instance()); + default , V> DistributedNavigableMapBuilder navigableMapBuilder(String name) { + return primitiveBuilder(name, DistributedNavigableMapType.instance()); } /** @@ -159,8 +159,8 @@ default , V> DistributedTreeMapBuilder treeMapBuil * @param value type * @return builder for a tree map */ - default , V> DistributedTreeMapBuilder treeMapBuilder(String name, PrimitiveProtocol protocol) { - return primitiveBuilder(name, DistributedTreeMapType.instance(), protocol); + default , V> DistributedNavigableMapBuilder navigableMapBuilder(String name, PrimitiveProtocol protocol) { + return primitiveBuilder(name, DistributedNavigableMapType.instance(), protocol); } /** @@ -237,19 +237,19 @@ default AtomicDocumentTreeBuilder atomicDocumentTreeBuilder(String name, } /** - * Creates a new {@code AtomicTreeMapBuilder}. + * Creates a new {@code AtomicNavigableMapBuilder}. * * @param name the primitive name * @param key type * @param value type * @return builder for a async atomic tree map */ - default , V> AtomicTreeMapBuilder atomicTreeMapBuilder(String name) { - return primitiveBuilder(name, AtomicTreeMapType.instance()); + default , V> AtomicNavigableMapBuilder atomicNavigableMapBuilder(String name) { + return primitiveBuilder(name, AtomicNavigableMapType.instance()); } /** - * Creates a new {@code AtomicTreeMapBuilder}. + * Creates a new {@code AtomicNavigableMapBuilder}. * * @param name the primitive name * @param protocol the primitive protocol @@ -257,8 +257,8 @@ default , V> AtomicTreeMapBuilder atomicTreeMapBui * @param value type * @return builder for a async atomic tree map */ - default , V> AtomicTreeMapBuilder atomicTreeMapBuilder(String name, PrimitiveProtocol protocol) { - return primitiveBuilder(name, AtomicTreeMapType.instance(), protocol); + default , V> AtomicNavigableMapBuilder atomicNavigableMapBuilder(String name, PrimitiveProtocol protocol) { + return primitiveBuilder(name, AtomicNavigableMapType.instance(), protocol); } /** @@ -731,14 +731,14 @@ default TransactionBuilder transactionBuilder() { DistributedMap getMap(String name); /** - * Creates a new DistributedTreeMap. + * Creates a new DistributedNavigableMap. * * @param name the primitive name * @param key type * @param value type * @return a new distributed map */ - , V> DistributedTreeMap getTreeMap(String name); + , V> DistributedNavigableMap getNavigableMap(String name); /** * Creates a new DistributedMultimap. @@ -777,7 +777,7 @@ default TransactionBuilder transactionBuilder() { * @param value type * @return a new atomic tree map */ - , V> AtomicTreeMap getAtomicTreeMap(String name); + , V> AtomicNavigableMap getAtomicNavigableMap(String name); /** * Creates a new {@code AtomicTreeMap}. diff --git a/core/src/main/java/io/atomix/core/impl/CorePrimitivesService.java b/core/src/main/java/io/atomix/core/impl/CorePrimitivesService.java index 585338eaaf..8f23ea1376 100644 --- a/core/src/main/java/io/atomix/core/impl/CorePrimitivesService.java +++ b/core/src/main/java/io/atomix/core/impl/CorePrimitivesService.java @@ -43,12 +43,12 @@ import io.atomix.core.map.AtomicCounterMapType; import io.atomix.core.map.AtomicMap; import io.atomix.core.map.AtomicMapType; -import io.atomix.core.map.AtomicTreeMap; -import io.atomix.core.map.AtomicTreeMapType; +import io.atomix.core.map.AtomicNavigableMap; +import io.atomix.core.map.AtomicNavigableMapType; import io.atomix.core.map.DistributedMap; import io.atomix.core.map.DistributedMapType; -import io.atomix.core.map.DistributedTreeMap; -import io.atomix.core.map.DistributedTreeMapType; +import io.atomix.core.map.DistributedNavigableMap; +import io.atomix.core.map.DistributedNavigableMapType; import io.atomix.core.multimap.AtomicMultimap; import io.atomix.core.multimap.AtomicMultimapType; import io.atomix.core.multimap.DistributedMultimap; @@ -162,8 +162,8 @@ public DistributedMap getMap(String name) { } @Override - public , V> DistributedTreeMap getTreeMap(String name) { - return getPrimitive(name, DistributedTreeMapType.instance(), configService.getConfig(name)); + public , V> DistributedNavigableMap getNavigableMap(String name) { + return getPrimitive(name, DistributedNavigableMapType.instance(), configService.getConfig(name)); } @Override @@ -182,8 +182,8 @@ public AtomicDocumentTree getAtomicDocumentTree(String name) { } @Override - public , V> AtomicTreeMap getAtomicTreeMap(String name) { - return getPrimitive(name, AtomicTreeMapType.instance(), configService.getConfig(name)); + public , V> AtomicNavigableMap getAtomicNavigableMap(String name) { + return getPrimitive(name, AtomicNavigableMapType.instance(), configService.getConfig(name)); } @Override diff --git a/core/src/main/java/io/atomix/core/map/AsyncAtomicTreeMap.java b/core/src/main/java/io/atomix/core/map/AsyncAtomicTreeMap.java deleted file mode 100644 index ecc25f8704..0000000000 --- a/core/src/main/java/io/atomix/core/map/AsyncAtomicTreeMap.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2016-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.core.map; - -import io.atomix.primitive.DistributedPrimitive; - -import java.time.Duration; - -/** - * API for a distributed tree map implementation. - */ -public interface AsyncAtomicTreeMap, V> extends AsyncAtomicNavigableMap { - @Override - default AtomicTreeMap sync() { - return sync(Duration.ofMillis(DistributedPrimitive.DEFAULT_OPERATION_TIMEOUT_MILLIS)); - } - - @Override - AtomicTreeMap sync(Duration operationTimeout); -} diff --git a/core/src/main/java/io/atomix/core/map/AsyncDistributedTreeMap.java b/core/src/main/java/io/atomix/core/map/AsyncDistributedTreeMap.java deleted file mode 100644 index 29ecc50b74..0000000000 --- a/core/src/main/java/io/atomix/core/map/AsyncDistributedTreeMap.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2018-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.core.map; - -import java.time.Duration; - -/** - * Asynchronous distributed tree map. - */ -public interface AsyncDistributedTreeMap, V> extends AsyncDistributedNavigableMap { - @Override - default DistributedTreeMap sync() { - return sync(Duration.ofMillis(DEFAULT_OPERATION_TIMEOUT_MILLIS)); - } - - @Override - DistributedTreeMap sync(Duration operationTimeout); -} diff --git a/core/src/main/java/io/atomix/core/map/AtomicTreeMapBuilder.java b/core/src/main/java/io/atomix/core/map/AtomicNavigableMapBuilder.java similarity index 63% rename from core/src/main/java/io/atomix/core/map/AtomicTreeMapBuilder.java rename to core/src/main/java/io/atomix/core/map/AtomicNavigableMapBuilder.java index affed95913..623f5cc623 100644 --- a/core/src/main/java/io/atomix/core/map/AtomicTreeMapBuilder.java +++ b/core/src/main/java/io/atomix/core/map/AtomicNavigableMapBuilder.java @@ -20,11 +20,11 @@ import io.atomix.primitive.PrimitiveManagementService; /** - * Builder for {@link AtomicTreeMap}. + * Builder for {@link AtomicNavigableMap}. */ -public abstract class AtomicTreeMapBuilder, V> - extends PrimitiveBuilder, AtomicTreeMapConfig, AtomicTreeMap> { - public AtomicTreeMapBuilder(String name, AtomicTreeMapConfig config, PrimitiveManagementService managementService) { - super(AtomicTreeMapType.instance(), name, config, managementService); +public abstract class AtomicNavigableMapBuilder, V> + extends PrimitiveBuilder, AtomicNavigableMapConfig, AtomicNavigableMap> { + public AtomicNavigableMapBuilder(String name, AtomicNavigableMapConfig config, PrimitiveManagementService managementService) { + super(AtomicNavigableMapType.instance(), name, config, managementService); } } diff --git a/core/src/main/java/io/atomix/core/map/AtomicTreeMapConfig.java b/core/src/main/java/io/atomix/core/map/AtomicNavigableMapConfig.java similarity index 86% rename from core/src/main/java/io/atomix/core/map/AtomicTreeMapConfig.java rename to core/src/main/java/io/atomix/core/map/AtomicNavigableMapConfig.java index f775174058..605269848a 100644 --- a/core/src/main/java/io/atomix/core/map/AtomicTreeMapConfig.java +++ b/core/src/main/java/io/atomix/core/map/AtomicNavigableMapConfig.java @@ -21,9 +21,9 @@ /** * Consistent tree-map configuration. */ -public class AtomicTreeMapConfig extends PrimitiveConfig { +public class AtomicNavigableMapConfig extends PrimitiveConfig { @Override public PrimitiveType getType() { - return AtomicTreeMapType.instance(); + return AtomicNavigableMapType.instance(); } } diff --git a/core/src/main/java/io/atomix/core/map/AtomicTreeMapType.java b/core/src/main/java/io/atomix/core/map/AtomicNavigableMapType.java similarity index 66% rename from core/src/main/java/io/atomix/core/map/AtomicTreeMapType.java rename to core/src/main/java/io/atomix/core/map/AtomicNavigableMapType.java index da50594a9e..41be98774a 100644 --- a/core/src/main/java/io/atomix/core/map/AtomicTreeMapType.java +++ b/core/src/main/java/io/atomix/core/map/AtomicNavigableMapType.java @@ -15,8 +15,8 @@ */ package io.atomix.core.map; -import io.atomix.core.map.impl.DefaultAtomicTreeMapBuilder; -import io.atomix.core.map.impl.DefaultAtomicTreeMapService; +import io.atomix.core.map.impl.DefaultAtomicNavigableMapBuilder; +import io.atomix.core.map.impl.DefaultAtomicNavigableMapService; import io.atomix.primitive.PrimitiveManagementService; import io.atomix.primitive.PrimitiveType; import io.atomix.primitive.service.PrimitiveService; @@ -28,10 +28,10 @@ /** * Consistent tree map primitive type. */ -public class AtomicTreeMapType, V> - implements PrimitiveType, AtomicTreeMapConfig, AtomicTreeMap> { +public class AtomicNavigableMapType, V> + implements PrimitiveType, AtomicNavigableMapConfig, AtomicNavigableMap> { private static final String NAME = "atomic-tree-map"; - private static final AtomicTreeMapType INSTANCE = new AtomicTreeMapType(); + private static final AtomicNavigableMapType INSTANCE = new AtomicNavigableMapType(); /** * Returns a new consistent tree map type. @@ -41,7 +41,7 @@ public class AtomicTreeMapType, V> * @return a new consistent tree map type */ @SuppressWarnings("unchecked") - public static , V> AtomicTreeMapType instance() { + public static , V> AtomicNavigableMapType instance() { return INSTANCE; } @@ -57,17 +57,17 @@ public Namespace namespace() { @Override public PrimitiveService newService(ServiceConfig config) { - return new DefaultAtomicTreeMapService(); + return new DefaultAtomicNavigableMapService(); } @Override - public AtomicTreeMapConfig newConfig() { - return new AtomicTreeMapConfig(); + public AtomicNavigableMapConfig newConfig() { + return new AtomicNavigableMapConfig(); } @Override - public AtomicTreeMapBuilder newBuilder(String name, AtomicTreeMapConfig config, PrimitiveManagementService managementService) { - return new DefaultAtomicTreeMapBuilder<>(name, config, managementService); + public AtomicNavigableMapBuilder newBuilder(String name, AtomicNavigableMapConfig config, PrimitiveManagementService managementService) { + return new DefaultAtomicNavigableMapBuilder<>(name, config, managementService); } @Override diff --git a/core/src/main/java/io/atomix/core/map/AtomicTreeMap.java b/core/src/main/java/io/atomix/core/map/AtomicTreeMap.java deleted file mode 100644 index 36a2f6213e..0000000000 --- a/core/src/main/java/io/atomix/core/map/AtomicTreeMap.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2016-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.core.map; - -/** - * Tree map interface counterpart to {@link AsyncAtomicTreeMap}. - */ -public interface AtomicTreeMap, V> extends AtomicNavigableMap { - @Override - AsyncAtomicTreeMap async(); -} diff --git a/core/src/main/java/io/atomix/core/map/DistributedTreeMapBuilder.java b/core/src/main/java/io/atomix/core/map/DistributedNavigableMapBuilder.java similarity index 64% rename from core/src/main/java/io/atomix/core/map/DistributedTreeMapBuilder.java rename to core/src/main/java/io/atomix/core/map/DistributedNavigableMapBuilder.java index 48b938961d..cd59df09e3 100644 --- a/core/src/main/java/io/atomix/core/map/DistributedTreeMapBuilder.java +++ b/core/src/main/java/io/atomix/core/map/DistributedNavigableMapBuilder.java @@ -19,16 +19,16 @@ import io.atomix.primitive.PrimitiveManagementService; /** - * Builder for {@link DistributedTreeMap} instances. + * Builder for {@link DistributedNavigableMap} instances. * * @param type for map key * @param type for map value */ -public abstract class DistributedTreeMapBuilder, V> - extends CachedPrimitiveBuilder, DistributedTreeMapConfig, DistributedTreeMap> { +public abstract class DistributedNavigableMapBuilder, V> + extends CachedPrimitiveBuilder, DistributedNavigableMapConfig, DistributedNavigableMap> { - public DistributedTreeMapBuilder(String name, DistributedTreeMapConfig config, PrimitiveManagementService managementService) { - super(DistributedTreeMapType.instance(), name, config, managementService); + public DistributedNavigableMapBuilder(String name, DistributedNavigableMapConfig config, PrimitiveManagementService managementService) { + super(DistributedNavigableMapType.instance(), name, config, managementService); } /** @@ -36,7 +36,7 @@ public DistributedTreeMapBuilder(String name, DistributedTreeMapConfig config, P * * @return this builder */ - public DistributedTreeMapBuilder withNullValues() { + public DistributedNavigableMapBuilder withNullValues() { config.setNullValues(); return this; } @@ -47,7 +47,7 @@ public DistributedTreeMapBuilder withNullValues() { * @param nullValues whether null values are allowed * @return this builder */ - public DistributedTreeMapBuilder withNullValues(boolean nullValues) { + public DistributedNavigableMapBuilder withNullValues(boolean nullValues) { config.setNullValues(nullValues); return this; } diff --git a/core/src/main/java/io/atomix/core/map/DistributedTreeMapConfig.java b/core/src/main/java/io/atomix/core/map/DistributedNavigableMapConfig.java similarity index 86% rename from core/src/main/java/io/atomix/core/map/DistributedTreeMapConfig.java rename to core/src/main/java/io/atomix/core/map/DistributedNavigableMapConfig.java index ddef3510b8..ff283f206a 100644 --- a/core/src/main/java/io/atomix/core/map/DistributedTreeMapConfig.java +++ b/core/src/main/java/io/atomix/core/map/DistributedNavigableMapConfig.java @@ -21,7 +21,7 @@ /** * Distributed tree map configuration. */ -public class DistributedTreeMapConfig extends CachedPrimitiveConfig { +public class DistributedNavigableMapConfig extends CachedPrimitiveConfig { private boolean nullValues = false; @Override @@ -34,7 +34,7 @@ public PrimitiveType getType() { * * @return the map configuration */ - public DistributedTreeMapConfig setNullValues() { + public DistributedNavigableMapConfig setNullValues() { return setNullValues(true); } @@ -44,7 +44,7 @@ public DistributedTreeMapConfig setNullValues() { * @param nullValues whether null values are allowed * @return the map configuration */ - public DistributedTreeMapConfig setNullValues(boolean nullValues) { + public DistributedNavigableMapConfig setNullValues(boolean nullValues) { this.nullValues = nullValues; return this; } diff --git a/core/src/main/java/io/atomix/core/map/DistributedTreeMapType.java b/core/src/main/java/io/atomix/core/map/DistributedNavigableMapType.java similarity index 62% rename from core/src/main/java/io/atomix/core/map/DistributedTreeMapType.java rename to core/src/main/java/io/atomix/core/map/DistributedNavigableMapType.java index ed5679c176..886908d6ee 100644 --- a/core/src/main/java/io/atomix/core/map/DistributedTreeMapType.java +++ b/core/src/main/java/io/atomix/core/map/DistributedNavigableMapType.java @@ -15,8 +15,8 @@ */ package io.atomix.core.map; -import io.atomix.core.map.impl.DefaultDistributedTreeMapBuilder; -import io.atomix.core.map.impl.DefaultDistributedTreeMapService; +import io.atomix.core.map.impl.DefaultDistributedNavigableMapBuilder; +import io.atomix.core.map.impl.DefaultDistributedNavigableMapService; import io.atomix.primitive.PrimitiveManagementService; import io.atomix.primitive.PrimitiveType; import io.atomix.primitive.service.PrimitiveService; @@ -28,10 +28,10 @@ /** * Distributed tree map primitive type. */ -public class DistributedTreeMapType, V> implements PrimitiveType, DistributedTreeMapConfig, DistributedTreeMap> { +public class DistributedNavigableMapType, V> implements PrimitiveType, DistributedNavigableMapConfig, DistributedNavigableMap> { private static final String NAME = "treemap"; - private static final DistributedTreeMapType INSTANCE = new DistributedTreeMapType(); + private static final DistributedNavigableMapType INSTANCE = new DistributedNavigableMapType(); /** * Returns a new distributed tree map type. @@ -41,7 +41,7 @@ public class DistributedTreeMapType, V> implements Primi * @return a new distributed tree map type */ @SuppressWarnings("unchecked") - public static , V> DistributedTreeMapType instance() { + public static , V> DistributedNavigableMapType instance() { return INSTANCE; } @@ -52,22 +52,22 @@ public String name() { @Override public Namespace namespace() { - return AtomicTreeMapType.instance().namespace(); + return AtomicNavigableMapType.instance().namespace(); } @Override public PrimitiveService newService(ServiceConfig config) { - return new DefaultDistributedTreeMapService(); + return new DefaultDistributedNavigableMapService(); } @Override - public DistributedTreeMapConfig newConfig() { - return new DistributedTreeMapConfig(); + public DistributedNavigableMapConfig newConfig() { + return new DistributedNavigableMapConfig(); } @Override - public DistributedTreeMapBuilder newBuilder(String name, DistributedTreeMapConfig config, PrimitiveManagementService managementService) { - return new DefaultDistributedTreeMapBuilder<>(name, config, managementService); + public DistributedNavigableMapBuilder newBuilder(String name, DistributedNavigableMapConfig config, PrimitiveManagementService managementService) { + return new DefaultDistributedNavigableMapBuilder<>(name, config, managementService); } @Override diff --git a/core/src/main/java/io/atomix/core/map/DistributedTreeMap.java b/core/src/main/java/io/atomix/core/map/DistributedTreeMap.java deleted file mode 100644 index efccc0834a..0000000000 --- a/core/src/main/java/io/atomix/core/map/DistributedTreeMap.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2018-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.core.map; - -/** - * Distributed tree map. - */ -public interface DistributedTreeMap, V> extends DistributedNavigableMap { - @Override - AsyncDistributedTreeMap async(); -} diff --git a/core/src/main/java/io/atomix/core/map/impl/AbstractAtomicTreeMapService.java b/core/src/main/java/io/atomix/core/map/impl/AbstractAtomicNavigableMapService.java similarity index 97% rename from core/src/main/java/io/atomix/core/map/impl/AbstractAtomicTreeMapService.java rename to core/src/main/java/io/atomix/core/map/impl/AbstractAtomicNavigableMapService.java index 89b0b90168..5e2bbf2e7b 100644 --- a/core/src/main/java/io/atomix/core/map/impl/AbstractAtomicTreeMapService.java +++ b/core/src/main/java/io/atomix/core/map/impl/AbstractAtomicNavigableMapService.java @@ -17,7 +17,7 @@ package io.atomix.core.map.impl; import com.google.common.collect.Maps; -import io.atomix.core.map.AtomicTreeMapType; +import io.atomix.core.map.AtomicNavigableMapType; import io.atomix.core.transaction.TransactionId; import io.atomix.primitive.PrimitiveType; import io.atomix.primitive.session.SessionId; @@ -37,13 +37,13 @@ /** * Base class for tree map services. */ -public abstract class AbstractAtomicTreeMapService> extends AbstractAtomicMapService implements AtomicTreeMapService { +public abstract class AbstractAtomicNavigableMapService> extends AbstractAtomicMapService implements AtomicTreeMapService { private final Serializer serializer; - public AbstractAtomicTreeMapService(PrimitiveType primitiveType) { + public AbstractAtomicNavigableMapService(PrimitiveType primitiveType) { super(primitiveType); serializer = Serializer.using(Namespace.builder() - .register(AtomicTreeMapType.instance().namespace()) + .register(AtomicNavigableMapType.instance().namespace()) .register(SessionId.class) .register(TransactionId.class) .register(TransactionScope.class) diff --git a/core/src/main/java/io/atomix/core/map/impl/AsyncDistributedJavaTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/AsyncDistributedJavaTreeMap.java deleted file mode 100644 index db4be5d095..0000000000 --- a/core/src/main/java/io/atomix/core/map/impl/AsyncDistributedJavaTreeMap.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2018-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.core.map.impl; - -import io.atomix.core.map.AsyncDistributedTreeMap; -import io.atomix.core.map.DistributedTreeMap; -import io.atomix.primitive.protocol.PrimitiveProtocol; - -import java.time.Duration; -import java.util.NavigableMap; - -/** - * Asynchronous Java-backed tree map. - */ -public class AsyncDistributedJavaTreeMap, V> extends AsyncDistributedNavigableJavaMap implements AsyncDistributedTreeMap { - public AsyncDistributedJavaTreeMap(String name, PrimitiveProtocol protocol, NavigableMap map) { - super(name, protocol, map); - } - - @Override - public DistributedTreeMap sync(Duration operationTimeout) { - return new BlockingDistributedTreeMap<>(this, operationTimeout.toMillis()); - } -} diff --git a/core/src/main/java/io/atomix/core/map/impl/AtomicTreeMapProxy.java b/core/src/main/java/io/atomix/core/map/impl/AtomicNavigableMapProxy.java similarity index 93% rename from core/src/main/java/io/atomix/core/map/impl/AtomicTreeMapProxy.java rename to core/src/main/java/io/atomix/core/map/impl/AtomicNavigableMapProxy.java index 9730ae2994..9e3c3bd60e 100644 --- a/core/src/main/java/io/atomix/core/map/impl/AtomicTreeMapProxy.java +++ b/core/src/main/java/io/atomix/core/map/impl/AtomicNavigableMapProxy.java @@ -26,10 +26,8 @@ import io.atomix.core.iterator.AsyncIterator; import io.atomix.core.iterator.impl.ProxyIterator; import io.atomix.core.map.AsyncAtomicNavigableMap; -import io.atomix.core.map.AsyncAtomicTreeMap; import io.atomix.core.map.AtomicMapEventListener; import io.atomix.core.map.AtomicNavigableMap; -import io.atomix.core.map.AtomicTreeMap; import io.atomix.core.set.AsyncDistributedNavigableSet; import io.atomix.core.set.AsyncDistributedSet; import io.atomix.core.set.AsyncDistributedSortedSet; @@ -63,10 +61,10 @@ import static com.google.common.base.Preconditions.checkNotNull; /** - * Implementation of {@link AsyncAtomicTreeMap}. + * Implementation of {@link AsyncAtomicNavigableMap}. */ -public class AtomicTreeMapProxy> extends AbstractAtomicMapProxy, AtomicTreeMapService, K> implements AsyncAtomicTreeMap { - public AtomicTreeMapProxy(ProxyClient> proxy, PrimitiveRegistry registry) { +public class AtomicNavigableMapProxy> extends AbstractAtomicMapProxy, AtomicTreeMapService, K> implements AsyncAtomicNavigableMap { + public AtomicNavigableMapProxy(ProxyClient> proxy, PrimitiveRegistry registry) { super(proxy, registry); } @@ -199,8 +197,8 @@ public AsyncDistributedNavigableSet descendingKeySet() { } @Override - public AtomicTreeMap sync(Duration operationTimeout) { - return new BlockingAtomicTreeMap<>(this, operationTimeout.toMillis()); + public AtomicNavigableMap sync(Duration operationTimeout) { + return new BlockingAtomicNavigableMap<>(this, operationTimeout.toMillis()); } protected abstract class SubSet implements AsyncPrimitive { @@ -218,17 +216,17 @@ public SubSet(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { @Override public String name() { - return AtomicTreeMapProxy.this.name(); + return AtomicNavigableMapProxy.this.name(); } @Override public PrimitiveType type() { - return AtomicTreeMapProxy.this.type(); + return AtomicNavigableMapProxy.this.type(); } @Override public PrimitiveProtocol protocol() { - return AtomicTreeMapProxy.this.protocol(); + return AtomicNavigableMapProxy.this.protocol(); } protected boolean isInBounds(K key) { @@ -257,7 +255,7 @@ protected boolean isInUpperBounds(K key) { @Override public CompletableFuture close() { - return AtomicTreeMapProxy.this.close(); + return AtomicNavigableMapProxy.this.close(); } } @@ -419,7 +417,7 @@ public CompletableFuture remove(K element) { if (!isInBounds(element)) { return CompletableFuture.completedFuture(false); } - return AtomicTreeMapProxy.this.remove(element).thenApply(Objects::nonNull); + return AtomicNavigableMapProxy.this.remove(element).thenApply(Objects::nonNull); } @Override @@ -480,14 +478,14 @@ public CompletableFuture addListener(CollectionEventListener listener) } }; listenerMap.put(listener, mapListener); - return AtomicTreeMapProxy.this.addListener(mapListener); + return AtomicNavigableMapProxy.this.addListener(mapListener); } @Override public CompletableFuture removeListener(CollectionEventListener listener) { AtomicMapEventListener mapListener = listenerMap.remove(listener); if (mapListener != null) { - return AtomicTreeMapProxy.this.removeListener(mapListener); + return AtomicNavigableMapProxy.this.removeListener(mapListener); } return CompletableFuture.completedFuture(null); } @@ -509,7 +507,7 @@ public CompletableFuture rollback(TransactionId transactionId) { @Override public CompletableFuture close() { - return AtomicTreeMapProxy.this.close(); + return AtomicNavigableMapProxy.this.close(); } @Override @@ -676,7 +674,7 @@ public CompletableFuture size() { @Override public CompletableFuture containsKey(K key) { - return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicTreeMapProxy.this.containsKey(key); + return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicNavigableMapProxy.this.containsKey(key); } @Override @@ -686,38 +684,38 @@ public CompletableFuture containsValue(byte[] value) { @Override public CompletableFuture> get(K key) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.get(key); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.get(key); } @Override public CompletableFuture>> getAllPresent(Iterable keys) { - return AtomicTreeMapProxy.this.getAllPresent(Lists.newArrayList(keys).stream().filter(this::isInBounds).collect(Collectors.toList())); + return AtomicNavigableMapProxy.this.getAllPresent(Lists.newArrayList(keys).stream().filter(this::isInBounds).collect(Collectors.toList())); } @Override public CompletableFuture> getOrDefault(K key, byte[] defaultValue) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.getOrDefault(key, defaultValue); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.getOrDefault(key, defaultValue); } @Override public CompletableFuture> computeIf( K key, Predicate condition, BiFunction remappingFunction) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.computeIf(key, condition, remappingFunction); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.computeIf(key, condition, remappingFunction); } @Override public CompletableFuture> put(K key, byte[] value, Duration ttl) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.put(key, value, ttl); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.put(key, value, ttl); } @Override public CompletableFuture> putAndGet(K key, byte[] value, Duration ttl) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.putAndGet(key, value, ttl); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.putAndGet(key, value, ttl); } @Override public CompletableFuture> remove(K key) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.remove(key); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.remove(key); } @Override @@ -742,32 +740,32 @@ public AsyncDistributedSet>> entrySet() { @Override public CompletableFuture> putIfAbsent(K key, byte[] value, Duration ttl) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.putIfAbsent(key, value, ttl); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.putIfAbsent(key, value, ttl); } @Override public CompletableFuture remove(K key, byte[] value) { - return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicTreeMapProxy.this.remove(key, value); + return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicNavigableMapProxy.this.remove(key, value); } @Override public CompletableFuture remove(K key, long version) { - return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicTreeMapProxy.this.remove(key, version); + return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicNavigableMapProxy.this.remove(key, version); } @Override public CompletableFuture> replace(K key, byte[] value) { - return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicTreeMapProxy.this.replace(key, value); + return !isInBounds(key) ? CompletableFuture.completedFuture(null) : AtomicNavigableMapProxy.this.replace(key, value); } @Override public CompletableFuture replace(K key, byte[] oldValue, byte[] newValue) { - return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicTreeMapProxy.this.replace(key, oldValue, newValue); + return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicNavigableMapProxy.this.replace(key, oldValue, newValue); } @Override public CompletableFuture replace(K key, long oldVersion, byte[] newValue) { - return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicTreeMapProxy.this.replace(key, oldVersion, newValue); + return !isInBounds(key) ? CompletableFuture.completedFuture(false) : AtomicNavigableMapProxy.this.replace(key, oldVersion, newValue); } @Override @@ -778,7 +776,7 @@ public synchronized CompletableFuture addListener(AtomicMapEventListener addListener(AtomicMapEventListener removeListener(AtomicMapEventListener listener) { AtomicMapEventListener boundedListener = listenerMap.remove(listener); if (boundedListener != null) { - return AtomicTreeMapProxy.this.removeListener(boundedListener); + return AtomicNavigableMapProxy.this.removeListener(boundedListener); } return CompletableFuture.completedFuture(null); } @Override public CompletableFuture prepare(TransactionLog> transactionLog) { - return AtomicTreeMapProxy.this.prepare(transactionLog); + return AtomicNavigableMapProxy.this.prepare(transactionLog); } @Override public CompletableFuture commit(TransactionId transactionId) { - return AtomicTreeMapProxy.this.commit(transactionId); + return AtomicNavigableMapProxy.this.commit(transactionId); } @Override public CompletableFuture rollback(TransactionId transactionId) { - return AtomicTreeMapProxy.this.rollback(transactionId); + return AtomicNavigableMapProxy.this.rollback(transactionId); } @Override @@ -887,7 +885,7 @@ public CompletableFuture addListener(CollectionEventListener addListener(CollectionEventListener removeListener(CollectionEventListener>> listener) { AtomicMapEventListener boundedListener = listenerMap.remove(listener); if (boundedListener != null) { - return AtomicTreeMapProxy.this.removeListener(boundedListener); + return AtomicNavigableMapProxy.this.removeListener(boundedListener); } return CompletableFuture.completedFuture(null); } @@ -928,7 +926,7 @@ public CompletableFuture rollback(TransactionId transactionId) { @Override public CompletableFuture close() { - return AtomicTreeMapProxy.this.close(); + return AtomicNavigableMapProxy.this.close(); } @Override @@ -1011,7 +1009,7 @@ public CompletableFuture addListener(CollectionEventListener addListener(CollectionEventListener removeListener(CollectionEventListener> listener) { AtomicMapEventListener boundedListener = listenerMap.remove(listener); if (boundedListener != null) { - return AtomicTreeMapProxy.this.removeListener(boundedListener); + return AtomicNavigableMapProxy.this.removeListener(boundedListener); } return CompletableFuture.completedFuture(null); } diff --git a/core/src/main/java/io/atomix/core/map/impl/BlockingAtomicTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/BlockingAtomicTreeMap.java deleted file mode 100644 index f652555de9..0000000000 --- a/core/src/main/java/io/atomix/core/map/impl/BlockingAtomicTreeMap.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2016-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.core.map.impl; - -import io.atomix.core.map.AsyncAtomicTreeMap; -import io.atomix.core.map.AtomicTreeMap; - -/** - * Default implementation of {@code AtomicTreeMap}. - * - * @param type of key. - * @param type of value. - */ -public class BlockingAtomicTreeMap, V> extends BlockingAtomicNavigableMap implements AtomicTreeMap { - - private final AsyncAtomicTreeMap asyncMap; - - public BlockingAtomicTreeMap(AsyncAtomicTreeMap asyncMap, long operationTimeoutMillis) { - super(asyncMap, operationTimeoutMillis); - this.asyncMap = asyncMap; - } - - @Override - public AsyncAtomicTreeMap async() { - return asyncMap; - } -} \ No newline at end of file diff --git a/core/src/main/java/io/atomix/core/map/impl/BlockingDistributedTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/BlockingDistributedTreeMap.java deleted file mode 100644 index 2105faadaa..0000000000 --- a/core/src/main/java/io/atomix/core/map/impl/BlockingDistributedTreeMap.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2016-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.core.map.impl; - -import io.atomix.core.map.AsyncDistributedTreeMap; -import io.atomix.core.map.DistributedTreeMap; - -/** - * Blocking implementation of {@code DistributedTreeMap}. - * - * @param type of key. - * @param type of value. - */ -public class BlockingDistributedTreeMap, V> extends BlockingDistributedNavigableMap implements DistributedTreeMap { - - private final long operationTimeoutMillis; - private final AsyncDistributedTreeMap asyncMap; - - public BlockingDistributedTreeMap(AsyncDistributedTreeMap asyncMap, long operationTimeoutMillis) { - super(asyncMap, operationTimeoutMillis); - this.asyncMap = asyncMap; - this.operationTimeoutMillis = operationTimeoutMillis; - } - - @Override - public AsyncDistributedTreeMap async() { - return asyncMap; - } -} \ No newline at end of file diff --git a/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicTreeMapBuilder.java b/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicNavigableMapBuilder.java similarity index 62% rename from core/src/main/java/io/atomix/core/map/impl/DefaultAtomicTreeMapBuilder.java rename to core/src/main/java/io/atomix/core/map/impl/DefaultAtomicNavigableMapBuilder.java index 29e1764d7a..e18eb6f7ad 100644 --- a/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicTreeMapBuilder.java +++ b/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicNavigableMapBuilder.java @@ -15,10 +15,10 @@ */ package io.atomix.core.map.impl; -import io.atomix.core.map.AsyncAtomicTreeMap; -import io.atomix.core.map.AtomicTreeMap; -import io.atomix.core.map.AtomicTreeMapBuilder; -import io.atomix.core.map.AtomicTreeMapConfig; +import io.atomix.core.map.AsyncAtomicNavigableMap; +import io.atomix.core.map.AtomicNavigableMap; +import io.atomix.core.map.AtomicNavigableMapBuilder; +import io.atomix.core.map.AtomicNavigableMapConfig; import io.atomix.primitive.PrimitiveManagementService; import io.atomix.primitive.protocol.PrimitiveProtocol; import io.atomix.primitive.service.ServiceConfig; @@ -27,25 +27,25 @@ import java.util.concurrent.CompletableFuture; /** - * Default {@link AsyncAtomicTreeMap} builder. + * Default {@link io.atomix.core.map.AsyncAtomicNavigableMap} builder. * * @param type for map value */ -public class DefaultAtomicTreeMapBuilder, V> extends AtomicTreeMapBuilder { - public DefaultAtomicTreeMapBuilder(String name, AtomicTreeMapConfig config, PrimitiveManagementService managementService) { +public class DefaultAtomicNavigableMapBuilder, V> extends AtomicNavigableMapBuilder { + public DefaultAtomicNavigableMapBuilder(String name, AtomicNavigableMapConfig config, PrimitiveManagementService managementService) { super(name, config, managementService); } @Override @SuppressWarnings("unchecked") - public CompletableFuture> buildAsync() { + public CompletableFuture> buildAsync() { PrimitiveProtocol protocol = protocol(); return newProxy(AtomicTreeMapService.class, new ServiceConfig()) - .thenCompose(proxy -> new AtomicTreeMapProxy(proxy, managementService.getPrimitiveRegistry()).connect()) + .thenCompose(proxy -> new AtomicNavigableMapProxy(proxy, managementService.getPrimitiveRegistry()).connect()) .thenApply(map -> { Serializer serializer = protocol.serializer(); - return new TranscodingAsyncAtomicTreeMap( - (AsyncAtomicTreeMap) map, + return new TranscodingAsyncAtomicNavigableMap( + (AsyncAtomicNavigableMap) map, value -> serializer.encode(value), bytes -> serializer.decode(bytes)) .sync(); diff --git a/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicTreeMapService.java b/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicNavigableMapService.java similarity index 72% rename from core/src/main/java/io/atomix/core/map/impl/DefaultAtomicTreeMapService.java rename to core/src/main/java/io/atomix/core/map/impl/DefaultAtomicNavigableMapService.java index a0c4b54941..e506417706 100644 --- a/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicTreeMapService.java +++ b/core/src/main/java/io/atomix/core/map/impl/DefaultAtomicNavigableMapService.java @@ -15,13 +15,13 @@ */ package io.atomix.core.map.impl; -import io.atomix.core.map.AtomicTreeMapType; +import io.atomix.core.map.AtomicNavigableMapType; /** * Default atomic tree map service. */ -public class DefaultAtomicTreeMapService> extends AbstractAtomicTreeMapService { - public DefaultAtomicTreeMapService() { - super(AtomicTreeMapType.instance()); +public class DefaultAtomicNavigableMapService> extends AbstractAtomicNavigableMapService { + public DefaultAtomicNavigableMapService() { + super(AtomicNavigableMapType.instance()); } } diff --git a/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedTreeMapBuilder.java b/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedNavigableMapBuilder.java similarity index 58% rename from core/src/main/java/io/atomix/core/map/impl/DefaultDistributedTreeMapBuilder.java rename to core/src/main/java/io/atomix/core/map/impl/DefaultDistributedNavigableMapBuilder.java index 81c5c5fbdd..859e8a9dee 100644 --- a/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedTreeMapBuilder.java +++ b/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedNavigableMapBuilder.java @@ -15,14 +15,14 @@ */ package io.atomix.core.map.impl; -import io.atomix.core.map.AsyncDistributedTreeMap; -import io.atomix.core.map.DistributedTreeMap; -import io.atomix.core.map.DistributedTreeMapBuilder; -import io.atomix.core.map.DistributedTreeMapConfig; +import io.atomix.core.map.AsyncDistributedNavigableMap; +import io.atomix.core.map.DistributedNavigableMap; +import io.atomix.core.map.DistributedNavigableMapBuilder; +import io.atomix.core.map.DistributedNavigableMapConfig; import io.atomix.primitive.PrimitiveManagementService; import io.atomix.primitive.protocol.GossipProtocol; import io.atomix.primitive.protocol.PrimitiveProtocol; -import io.atomix.primitive.protocol.map.TreeMapProtocolProvider; +import io.atomix.primitive.protocol.map.NavigableMapProtocolProvider; import io.atomix.primitive.proxy.ProxyClient; import io.atomix.primitive.service.ServiceConfig; import io.atomix.utils.concurrent.Futures; @@ -33,34 +33,34 @@ /** * Default distributed tree map builder. */ -public class DefaultDistributedTreeMapBuilder, V> extends DistributedTreeMapBuilder { - public DefaultDistributedTreeMapBuilder(String name, DistributedTreeMapConfig config, PrimitiveManagementService managementService) { +public class DefaultDistributedNavigableMapBuilder, V> extends DistributedNavigableMapBuilder { + public DefaultDistributedNavigableMapBuilder(String name, DistributedNavigableMapConfig config, PrimitiveManagementService managementService) { super(name, config, managementService); } @Override @SuppressWarnings("unchecked") - public CompletableFuture> buildAsync() { + public CompletableFuture> buildAsync() { PrimitiveProtocol protocol = protocol(); if (protocol instanceof GossipProtocol) { - if (protocol instanceof TreeMapProtocolProvider) { + if (protocol instanceof NavigableMapProtocolProvider) { return managementService.getPrimitiveCache().getPrimitive(name, () -> - CompletableFuture.completedFuture(((TreeMapProtocolProvider) protocol).newTreeMapProtocol(name, managementService)) - .thenApply(set -> new GossipDistributedTreeMap<>(name, protocol, set))) - .thenApply(AsyncDistributedTreeMap::sync); + CompletableFuture.completedFuture(((NavigableMapProtocolProvider) protocol).newNavigableMapProtocol(name, managementService)) + .thenApply(set -> new GossipDistributedNavigableMap<>(name, protocol, set))) + .thenApply(AsyncDistributedNavigableMap::sync); } else { return Futures.exceptionalFuture(new UnsupportedOperationException("Sets are not supported by the provided gossip protocol")); } } else { return newProxy(AtomicTreeMapService.class, new ServiceConfig()) - .thenCompose(proxy -> new AtomicTreeMapProxy((ProxyClient) proxy, managementService.getPrimitiveRegistry()).connect()) + .thenCompose(proxy -> new AtomicNavigableMapProxy((ProxyClient) proxy, managementService.getPrimitiveRegistry()).connect()) .thenApply(map -> { Serializer serializer = protocol.serializer(); - return new TranscodingAsyncAtomicTreeMap( + return new TranscodingAsyncAtomicNavigableMap( map, value -> serializer.encode(value), bytes -> serializer.decode(bytes)); - }).thenApply(atomicTreeMap -> new DelegatingAsyncDistributedTreeMap<>(atomicTreeMap).sync()); + }).thenApply(atomicMap -> new DelegatingAsyncDistributedNavigableMap<>(atomicMap).sync()); } } } diff --git a/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedTreeMapService.java b/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedNavigableMapService.java similarity index 71% rename from core/src/main/java/io/atomix/core/map/impl/DefaultDistributedTreeMapService.java rename to core/src/main/java/io/atomix/core/map/impl/DefaultDistributedNavigableMapService.java index 707338637f..649ba8d41b 100644 --- a/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedTreeMapService.java +++ b/core/src/main/java/io/atomix/core/map/impl/DefaultDistributedNavigableMapService.java @@ -15,13 +15,13 @@ */ package io.atomix.core.map.impl; -import io.atomix.core.map.DistributedTreeMapType; +import io.atomix.core.map.DistributedNavigableMapType; /** * Default distributed tree map service. */ -public class DefaultDistributedTreeMapService> extends AbstractAtomicTreeMapService { - public DefaultDistributedTreeMapService() { - super(DistributedTreeMapType.instance()); +public class DefaultDistributedNavigableMapService> extends AbstractAtomicNavigableMapService { + public DefaultDistributedNavigableMapService() { + super(DistributedNavigableMapType.instance()); } } diff --git a/core/src/main/java/io/atomix/core/map/impl/DelegatingAsyncAtomicTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/DelegatingAsyncAtomicTreeMap.java deleted file mode 100644 index 83bfda9cf9..0000000000 --- a/core/src/main/java/io/atomix/core/map/impl/DelegatingAsyncAtomicTreeMap.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2016-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.core.map.impl; - -import io.atomix.core.collection.AsyncDistributedCollection; -import io.atomix.core.map.AsyncAtomicNavigableMap; -import io.atomix.core.map.AsyncAtomicTreeMap; -import io.atomix.core.map.AtomicMapEventListener; -import io.atomix.core.map.AtomicTreeMap; -import io.atomix.core.set.AsyncDistributedNavigableSet; -import io.atomix.core.set.AsyncDistributedSet; -import io.atomix.core.transaction.TransactionId; -import io.atomix.core.transaction.TransactionLog; -import io.atomix.primitive.impl.DelegatingAsyncPrimitive; -import io.atomix.primitive.protocol.PrimitiveProtocol; -import io.atomix.utils.time.Versioned; - -import java.time.Duration; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.function.BiFunction; -import java.util.function.Predicate; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * A {@link AsyncAtomicTreeMap} that delegates control to another instance - * of {@link AsyncAtomicTreeMap}. - */ -public class DelegatingAsyncAtomicTreeMap, V> - extends DelegatingAsyncPrimitive - implements AsyncAtomicTreeMap { - - private final AsyncAtomicTreeMap delegateMap; - - DelegatingAsyncAtomicTreeMap(AsyncAtomicTreeMap delegateMap) { - super(delegateMap); - this.delegateMap = checkNotNull(delegateMap, - "delegate map cannot be null"); - } - - @Override - public PrimitiveProtocol protocol() { - return delegateMap.protocol(); - } - - @Override - public CompletableFuture firstKey() { - return delegateMap.firstKey(); - } - - @Override - public CompletableFuture lastKey() { - return delegateMap.lastKey(); - } - - @Override - public CompletableFuture>> ceilingEntry(K key) { - return delegateMap.ceilingEntry(key); - } - - @Override - public CompletableFuture>> floorEntry(K key) { - return delegateMap.floorEntry(key); - } - - @Override - public CompletableFuture>> higherEntry(K key) { - return delegateMap.higherEntry(key); - } - - @Override - public CompletableFuture>> lowerEntry(K key) { - return delegateMap.lowerEntry(key); - } - - @Override - public CompletableFuture>> firstEntry() { - return delegateMap.firstEntry(); - } - - @Override - public CompletableFuture>> lastEntry() { - return delegateMap.lastEntry(); - } - - @Override - public CompletableFuture>> pollFirstEntry() { - return delegateMap.pollFirstEntry(); - } - - @Override - public CompletableFuture>> pollLastEntry() { - return delegateMap.pollLastEntry(); - } - - @Override - public CompletableFuture lowerKey(K key) { - return delegateMap.lowerKey(key); - } - - @Override - public CompletableFuture floorKey(K key) { - return delegateMap.floorKey(key); - } - - @Override - public CompletableFuture ceilingKey(K key) { - return delegateMap.ceilingKey(key); - } - - @Override - public CompletableFuture higherKey(K key) { - return delegateMap.higherKey(key); - } - - @Override - public AsyncAtomicNavigableMap descendingMap() { - return delegateMap.descendingMap(); - } - - @Override - public AsyncDistributedNavigableSet descendingKeySet() { - return delegateMap.descendingKeySet(); - } - - @Override - public AsyncDistributedNavigableSet navigableKeySet() { - return delegateMap.navigableKeySet(); - } - - @Override - public AsyncAtomicNavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { - return delegateMap.subMap(fromKey, fromInclusive, toKey, toInclusive); - } - - @Override - public AsyncAtomicNavigableMap headMap(K toKey, boolean inclusive) { - return delegateMap.headMap(toKey, inclusive); - } - - @Override - public AsyncAtomicNavigableMap tailMap(K fromKey, boolean inclusive) { - return delegateMap.tailMap(fromKey, inclusive); - } - - @Override - public CompletableFuture size() { - return delegateMap.size(); - } - - @Override - public CompletableFuture containsKey(K key) { - return delegateMap.containsKey(key); - } - - @Override - public CompletableFuture containsValue(V value) { - return delegateMap.containsValue(value); - } - - @Override - public CompletableFuture> get(K key) { - return delegateMap.get(key); - } - - @Override - public CompletableFuture>> getAllPresent(Iterable keys) { - return delegateMap.getAllPresent(keys); - } - - @Override - public CompletableFuture> getOrDefault(K key, V defaultValue) { - return delegateMap.getOrDefault(key, defaultValue); - } - - @Override - public CompletableFuture> computeIf( - K key, - Predicate condition, - BiFunction remappingFunction) { - return delegateMap.computeIf(key, condition, remappingFunction); - } - - @Override - public CompletableFuture> put(K key, V value, Duration ttl) { - return delegateMap.put(key, value, ttl); - } - - @Override - public CompletableFuture> putAndGet(K key, V value, Duration ttl) { - return delegateMap.putAndGet(key, value, ttl); - } - - @Override - public CompletableFuture> remove(K key) { - return delegateMap.remove(key); - } - - @Override - public CompletableFuture clear() { - return delegateMap.clear(); - } - - @Override - public AsyncDistributedSet keySet() { - return delegateMap.keySet(); - } - - @Override - public AsyncDistributedCollection> values() { - return delegateMap.values(); - } - - @Override - public AsyncDistributedSet>> entrySet() { - return delegateMap.entrySet(); - } - - @Override - public CompletableFuture> putIfAbsent(K key, V value, Duration ttl) { - return delegateMap.putIfAbsent(key, value, ttl); - } - - @Override - public CompletableFuture remove(K key, V value) { - return delegateMap.remove(key, value); - } - - @Override - public CompletableFuture remove(K key, long version) { - return delegateMap.remove(key, version); - } - - @Override - public CompletableFuture> replace(K key, V value) { - return delegateMap.replace(key, value); - } - - @Override - public CompletableFuture replace(K key, V oldValue, - V newValue) { - return delegateMap.replace(key, oldValue, newValue); - } - - @Override - public CompletableFuture replace(K key, long oldVersion, - V newValue) { - return delegateMap.replace(key, oldVersion, newValue); - } - - @Override - public CompletableFuture addListener( - AtomicMapEventListener listener, Executor executor) { - return delegateMap.addListener(listener, executor); - } - - @Override - public CompletableFuture removeListener( - AtomicMapEventListener listener) { - return delegateMap.removeListener(listener); - } - - @Override - public CompletableFuture prepare(TransactionLog> transactionLog) { - return delegateMap.prepare(transactionLog); - } - - @Override - public CompletableFuture commit(TransactionId transactionId) { - return delegateMap.commit(transactionId); - } - - @Override - public CompletableFuture rollback(TransactionId transactionId) { - return delegateMap.rollback(transactionId); - } - - @Override - public AtomicTreeMap sync(Duration operationTimeout) { - return new BlockingAtomicTreeMap<>(this, operationTimeout.toMillis()); - } -} diff --git a/core/src/main/java/io/atomix/core/map/impl/DelegatingAsyncDistributedTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/DelegatingAsyncDistributedTreeMap.java deleted file mode 100644 index d72155aec7..0000000000 --- a/core/src/main/java/io/atomix/core/map/impl/DelegatingAsyncDistributedTreeMap.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018-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.core.map.impl; - -import io.atomix.core.map.AsyncAtomicTreeMap; -import io.atomix.core.map.AsyncDistributedTreeMap; -import io.atomix.core.map.DistributedTreeMap; - -import java.time.Duration; - -/** - * Delegating asynchronous distributed tree map. - */ -public class DelegatingAsyncDistributedTreeMap, V> extends DelegatingAsyncDistributedNavigableMap implements AsyncDistributedTreeMap { - public DelegatingAsyncDistributedTreeMap(AsyncAtomicTreeMap atomicTreeMap) { - super(atomicTreeMap); - } - - @Override - public DistributedTreeMap sync(Duration timeout) { - return new BlockingDistributedTreeMap<>(this, timeout.toMillis()); - } -} diff --git a/core/src/main/java/io/atomix/core/map/impl/GossipDistributedTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/GossipDistributedNavigableMap.java similarity index 86% rename from core/src/main/java/io/atomix/core/map/impl/GossipDistributedTreeMap.java rename to core/src/main/java/io/atomix/core/map/impl/GossipDistributedNavigableMap.java index b4b70d8960..b9a322b4a1 100644 --- a/core/src/main/java/io/atomix/core/map/impl/GossipDistributedTreeMap.java +++ b/core/src/main/java/io/atomix/core/map/impl/GossipDistributedNavigableMap.java @@ -20,20 +20,20 @@ import io.atomix.core.map.MapEventListener; import io.atomix.primitive.protocol.PrimitiveProtocol; import io.atomix.primitive.protocol.map.MapProtocolEventListener; -import io.atomix.primitive.protocol.map.TreeMapProtocol; +import io.atomix.primitive.protocol.map.NavigableMapProtocol; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; /** - * Gossip-based distributed tree map. + * Gossip-based distributed navigable map. */ -public class GossipDistributedTreeMap, V> extends AsyncDistributedJavaTreeMap { - private final TreeMapProtocol map; +public class GossipDistributedNavigableMap, V> extends AsyncDistributedNavigableJavaMap { + private final NavigableMapProtocol map; private final Map, MapProtocolEventListener> listenerMap = Maps.newConcurrentMap(); - public GossipDistributedTreeMap(String name, PrimitiveProtocol protocol, TreeMapProtocol map) { + public GossipDistributedNavigableMap(String name, PrimitiveProtocol protocol, NavigableMapProtocol map) { super(name, protocol, map); this.map = map; } diff --git a/core/src/main/java/io/atomix/core/map/impl/TranscodingAsyncAtomicTreeMap.java b/core/src/main/java/io/atomix/core/map/impl/TranscodingAsyncAtomicTreeMap.java deleted file mode 100644 index a8ad6f8e86..0000000000 --- a/core/src/main/java/io/atomix/core/map/impl/TranscodingAsyncAtomicTreeMap.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2016-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.core.map.impl; - -import io.atomix.core.map.AsyncAtomicNavigableMap; -import io.atomix.core.map.AsyncAtomicTreeMap; -import io.atomix.core.map.AtomicTreeMap; - -import java.time.Duration; -import java.util.function.Function; - -/** - * An {@code AsyncConsistentTreeMap} that maps its operations to operations on - * a differently typed {@code AsyncConsistentTreeMap} by transcoding operation - * inputs and outputs. - * - * @param value type of other map - * @param value type of this map - */ -public class TranscodingAsyncAtomicTreeMap, V1, V2> extends TranscodingAsyncAtomicNavigableMap implements AsyncAtomicTreeMap { - public TranscodingAsyncAtomicTreeMap(AsyncAtomicNavigableMap backingMap, Function valueEncoder, Function valueDecoder) { - super(backingMap, valueEncoder, valueDecoder); - } - - @Override - public AtomicTreeMap sync(Duration operationTimeout) { - return new BlockingAtomicTreeMap<>(this, operationTimeout.toMillis()); - } -} diff --git a/core/src/test/java/io/atomix/core/map/AtomicTreeMapTest.java b/core/src/test/java/io/atomix/core/map/AtomicNavigableMapTest.java similarity index 97% rename from core/src/test/java/io/atomix/core/map/AtomicTreeMapTest.java rename to core/src/test/java/io/atomix/core/map/AtomicNavigableMapTest.java index 0fcc4069af..1b35ec3652 100644 --- a/core/src/test/java/io/atomix/core/map/AtomicTreeMapTest.java +++ b/core/src/test/java/io/atomix/core/map/AtomicNavigableMapTest.java @@ -19,7 +19,7 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import io.atomix.core.AbstractPrimitiveTest; -import io.atomix.core.map.impl.AtomicTreeMapProxy; +import io.atomix.core.map.impl.AtomicNavigableMapProxy; import io.atomix.utils.time.Versioned; import org.junit.Test; @@ -43,9 +43,9 @@ import static org.junit.Assert.fail; /** - * Unit tests for {@link AtomicTreeMapProxy}. + * Unit tests for {@link AtomicNavigableMapProxy}. */ -public abstract class AtomicTreeMapTest extends AbstractPrimitiveTest { +public abstract class AtomicNavigableMapTest extends AbstractPrimitiveTest { private final String four = "hello"; private final String three = "goodbye"; private final String two = "foo"; @@ -55,7 +55,7 @@ public abstract class AtomicTreeMapTest extends AbstractPrimitiveTest { /** * Tests of the functionality associated with the - * {@link AsyncAtomicTreeMap} interface + * {@link AsyncAtomicNavigableMap} interface * except transactions and listeners. */ @Test @@ -64,7 +64,7 @@ public void testBasicMapOperations() throws Throwable { //make sure that the previous section has been cleaned up, they serve //the secondary purpose of testing isEmpty but that is not their //primary purpose. - AsyncAtomicTreeMap map = createResource("basicTestMap"); + AsyncAtomicNavigableMap map = createResource("basicTestMap"); //test size map.size().thenAccept(result -> assertEquals(0, (int) result)).join(); map.isEmpty().thenAccept(result -> assertTrue(result)).join(); @@ -244,7 +244,7 @@ public void mapListenerTests() throws Throwable { final String value2 = "value2"; final String value3 = "value3"; - AsyncAtomicTreeMap map = createResource("treeMapListenerTestMap"); + AsyncAtomicNavigableMap map = createResource("treeMapListenerTestMap"); TestAtomicMapEventListener listener = new TestAtomicMapEventListener(); // add listener; insert new value into map and verify an INSERT event @@ -307,7 +307,7 @@ public void mapListenerTests() throws Throwable { @Test public void treeMapFunctionsTest() { - AsyncAtomicTreeMap map = createResource("treeMapFunctionTestMap"); + AsyncAtomicNavigableMap map = createResource("treeMapFunctionTestMap"); //Tests on empty map map.firstKey().thenAccept(result -> assertNull(result)).join(); map.lastKey().thenAccept(result -> assertNull(result)).join(); @@ -411,7 +411,7 @@ public void treeMapFunctionsTest() { @Test public void testTreeMapViews() { - AtomicTreeMap map = createResource("testTreeMapViews").sync(); + AtomicNavigableMap map = createResource("testTreeMapViews").sync(); assertTrue(map.isEmpty()); assertTrue(map.keySet().isEmpty()); @@ -486,7 +486,7 @@ public void testTreeMapViews() { @Test public void testSubMaps() throws Throwable { - AtomicTreeMap map = createResource("testSubMaps").sync(); + AtomicNavigableMap map = createResource("testSubMaps").sync(); for (char letter = 'a'; letter <= 'z'; letter++) { map.put(String.valueOf(letter), String.valueOf(letter)); @@ -615,7 +615,7 @@ public void testSubMaps() throws Throwable { @Test public void testKeySetOperations() throws Throwable { - AtomicTreeMap map = createResource("testKeySetOperations").sync(); + AtomicNavigableMap map = createResource("testKeySetOperations").sync(); try { map.navigableKeySet().first(); @@ -737,7 +737,7 @@ public void testKeySetOperations() throws Throwable { @Test public void testKeySetSubSets() throws Throwable { - AtomicTreeMap map = createResource("testKeySetSubSets").sync(); + AtomicNavigableMap map = createResource("testKeySetSubSets").sync(); for (char letter = 'a'; letter <= 'z'; letter++) { map.put(String.valueOf(letter), String.valueOf(letter)); @@ -850,9 +850,9 @@ public void testKeySetSubSets() throws Throwable { assertEquals(Sets.newHashSet(map.navigableKeySet()), Sets.newHashSet("h", "i", "j", "k", "n")); } - private AsyncAtomicTreeMap createResource(String mapName) { + private AsyncAtomicNavigableMap createResource(String mapName) { try { - return atomix().atomicTreeMapBuilder(mapName, protocol()).build().async(); + return atomix().atomicNavigableMapBuilder(mapName, protocol()).build().async(); } catch (Throwable e) { throw new RuntimeException(e.toString()); } diff --git a/core/src/test/java/io/atomix/core/map/DistributedTreeMapTest.java b/core/src/test/java/io/atomix/core/map/DistributedNavigableMapTest.java similarity index 93% rename from core/src/test/java/io/atomix/core/map/DistributedTreeMapTest.java rename to core/src/test/java/io/atomix/core/map/DistributedNavigableMapTest.java index 441693433a..9484c99bb5 100644 --- a/core/src/test/java/io/atomix/core/map/DistributedTreeMapTest.java +++ b/core/src/test/java/io/atomix/core/map/DistributedNavigableMapTest.java @@ -18,7 +18,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import io.atomix.core.AbstractPrimitiveTest; -import io.atomix.core.map.impl.AtomicTreeMapProxy; +import io.atomix.core.map.impl.AtomicNavigableMapProxy; import org.junit.Test; import java.util.Arrays; @@ -37,9 +37,9 @@ import static org.junit.Assert.assertTrue; /** - * Unit tests for {@link AtomicTreeMapProxy}. + * Unit tests for {@link AtomicNavigableMapProxy}. */ -public abstract class DistributedTreeMapTest extends AbstractPrimitiveTest { +public abstract class DistributedNavigableMapTest extends AbstractPrimitiveTest { private final String four = "hello"; private final String three = "goodbye"; private final String two = "foo"; @@ -48,7 +48,7 @@ public abstract class DistributedTreeMapTest extends AbstractPrimitiveTest { private final List all = Lists.newArrayList(one, two, three, four); /** - * Tests of the functionality associated with the {@link DistributedTreeMap} interface except transactions and + * Tests of the functionality associated with the {@link DistributedNavigableMap} interface except transactions and * listeners. */ @Test @@ -57,7 +57,7 @@ public void testBasicMapOperations() throws Throwable { //make sure that the previous section has been cleaned up, they serve //the secondary purpose of testing isEmpty but that is not their //primary purpose. - DistributedTreeMap map = atomix().treeMapBuilder("basicTestMap", protocol()).build(); + DistributedNavigableMap map = atomix().navigableMapBuilder("basicTestMap", protocol()).build(); assertEquals(0, map.size()); assertTrue(map.isEmpty()); @@ -115,7 +115,7 @@ public void mapListenerTests() throws Throwable { final String value2 = "value2"; final String value3 = "value3"; - DistributedTreeMap map = atomix().treeMapBuilder("treeMapListenerTestMap", protocol()).build(); + DistributedNavigableMap map = atomix().navigableMapBuilder("treeMapListenerTestMap", protocol()).build(); TestMapEventListener listener = new TestMapEventListener(); // add listener; insert new value into map and verify an INSERT event @@ -166,7 +166,7 @@ public void mapListenerTests() throws Throwable { @Test public void treeMapFunctionsTest() throws Throwable { - DistributedTreeMap map = atomix().treeMapBuilder("treeMapFunctionTestMap", protocol()).build(); + DistributedNavigableMap map = atomix().navigableMapBuilder("treeMapFunctionTestMap", protocol()).build(); //Tests on empty map assertNull(map.firstKey()); @@ -224,7 +224,7 @@ public void treeMapFunctionsTest() throws Throwable { @Test public void testTreeMapViews() throws Throwable { - DistributedTreeMap map = atomix().treeMapBuilder("testTreeMapViews", protocol()).build(); + DistributedNavigableMap map = atomix().navigableMapBuilder("testTreeMapViews", protocol()).build(); assertTrue(map.isEmpty()); assertTrue(map.keySet().isEmpty()); diff --git a/core/src/test/java/io/atomix/core/map/PrimaryBackupAtomicTreeMapTest.java b/core/src/test/java/io/atomix/core/map/PrimaryBackupAtomicNavigableMapTest.java similarity index 92% rename from core/src/test/java/io/atomix/core/map/PrimaryBackupAtomicTreeMapTest.java rename to core/src/test/java/io/atomix/core/map/PrimaryBackupAtomicNavigableMapTest.java index 73bd1412ba..5c13b68678 100644 --- a/core/src/test/java/io/atomix/core/map/PrimaryBackupAtomicTreeMapTest.java +++ b/core/src/test/java/io/atomix/core/map/PrimaryBackupAtomicNavigableMapTest.java @@ -21,7 +21,7 @@ /** * Primary-backup consistent tree map test. */ -public class PrimaryBackupAtomicTreeMapTest extends AtomicTreeMapTest { +public class PrimaryBackupAtomicNavigableMapTest extends AtomicNavigableMapTest { @Override protected PrimitiveProtocol protocol() { return MultiPrimaryProtocol.builder() diff --git a/core/src/test/java/io/atomix/core/map/PrimaryBackupDistributedTreeMapTest.java b/core/src/test/java/io/atomix/core/map/PrimaryBackupDistributedNavigableMapTest.java similarity index 91% rename from core/src/test/java/io/atomix/core/map/PrimaryBackupDistributedTreeMapTest.java rename to core/src/test/java/io/atomix/core/map/PrimaryBackupDistributedNavigableMapTest.java index dd70f32120..1c4c0b4cc3 100644 --- a/core/src/test/java/io/atomix/core/map/PrimaryBackupDistributedTreeMapTest.java +++ b/core/src/test/java/io/atomix/core/map/PrimaryBackupDistributedNavigableMapTest.java @@ -21,7 +21,7 @@ /** * Primary-backup distributed tree map test. */ -public class PrimaryBackupDistributedTreeMapTest extends DistributedTreeMapTest { +public class PrimaryBackupDistributedNavigableMapTest extends DistributedNavigableMapTest { @Override protected PrimitiveProtocol protocol() { return MultiPrimaryProtocol.builder() diff --git a/core/src/test/java/io/atomix/core/map/RaftAtomicTreeMapTest.java b/core/src/test/java/io/atomix/core/map/RaftAtomicNavigableMapTest.java similarity index 92% rename from core/src/test/java/io/atomix/core/map/RaftAtomicTreeMapTest.java rename to core/src/test/java/io/atomix/core/map/RaftAtomicNavigableMapTest.java index fdfc5ec296..db813baad4 100644 --- a/core/src/test/java/io/atomix/core/map/RaftAtomicTreeMapTest.java +++ b/core/src/test/java/io/atomix/core/map/RaftAtomicNavigableMapTest.java @@ -21,7 +21,7 @@ /** * Raft consistent tree map test. */ -public class RaftAtomicTreeMapTest extends AtomicTreeMapTest { +public class RaftAtomicNavigableMapTest extends AtomicNavigableMapTest { @Override protected PrimitiveProtocol protocol() { return MultiRaftProtocol.builder() diff --git a/core/src/test/java/io/atomix/core/map/RaftDistributedTreeMapTest.java b/core/src/test/java/io/atomix/core/map/RaftDistributedNavigableMapTest.java similarity index 91% rename from core/src/test/java/io/atomix/core/map/RaftDistributedTreeMapTest.java rename to core/src/test/java/io/atomix/core/map/RaftDistributedNavigableMapTest.java index 45a6775021..3048725978 100644 --- a/core/src/test/java/io/atomix/core/map/RaftDistributedTreeMapTest.java +++ b/core/src/test/java/io/atomix/core/map/RaftDistributedNavigableMapTest.java @@ -21,7 +21,7 @@ /** * Raft distributed tree map test. */ -public class RaftDistributedTreeMapTest extends DistributedTreeMapTest { +public class RaftDistributedNavigableMapTest extends DistributedNavigableMapTest { @Override protected PrimitiveProtocol protocol() { return MultiRaftProtocol.builder() diff --git a/primitive/src/main/java/io/atomix/primitive/protocol/map/TreeMapProtocol.java b/primitive/src/main/java/io/atomix/primitive/protocol/map/NavigableMapProtocol.java similarity index 85% rename from primitive/src/main/java/io/atomix/primitive/protocol/map/TreeMapProtocol.java rename to primitive/src/main/java/io/atomix/primitive/protocol/map/NavigableMapProtocol.java index 77d56ad02d..a6a8c4ef56 100644 --- a/primitive/src/main/java/io/atomix/primitive/protocol/map/TreeMapProtocol.java +++ b/primitive/src/main/java/io/atomix/primitive/protocol/map/NavigableMapProtocol.java @@ -18,7 +18,7 @@ import java.util.NavigableMap; /** - * Tree map protocol. + * Navigable map protocol. */ -public interface TreeMapProtocol extends MapProtocol, NavigableMap { +public interface NavigableMapProtocol extends MapProtocol, NavigableMap { } diff --git a/primitive/src/main/java/io/atomix/primitive/protocol/map/TreeMapProtocolProvider.java b/primitive/src/main/java/io/atomix/primitive/protocol/map/NavigableMapProtocolProvider.java similarity index 77% rename from primitive/src/main/java/io/atomix/primitive/protocol/map/TreeMapProtocolProvider.java rename to primitive/src/main/java/io/atomix/primitive/protocol/map/NavigableMapProtocolProvider.java index 3c24750625..25831dd14e 100644 --- a/primitive/src/main/java/io/atomix/primitive/protocol/map/TreeMapProtocolProvider.java +++ b/primitive/src/main/java/io/atomix/primitive/protocol/map/NavigableMapProtocolProvider.java @@ -19,17 +19,17 @@ import io.atomix.primitive.protocol.GossipProtocol; /** - * Tree map protocol provider. + * Navigable map protocol provider. */ -public interface TreeMapProtocolProvider extends GossipProtocol { +public interface NavigableMapProtocolProvider extends GossipProtocol { /** - * Returns a new tree map protocol. + * Returns a new navigable map protocol. * * @param name the map name * @param managementService the primitive management service * @return a new map protocol */ - TreeMapProtocol newTreeMapProtocol(String name, PrimitiveManagementService managementService); + NavigableMapProtocol newNavigableMapProtocol(String name, PrimitiveManagementService managementService); }