Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add atomic/distributed sorted map primitives.
- Loading branch information
Showing
18 changed files
with
689 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
core/src/main/java/io/atomix/core/map/AtomicSortedMapBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.PrimitiveBuilder; | ||
import io.atomix.primitive.PrimitiveManagementService; | ||
|
||
/** | ||
* Builder for {@link AtomicSortedMap}. | ||
*/ | ||
public abstract class AtomicSortedMapBuilder<K extends Comparable<K>, V> | ||
extends PrimitiveBuilder<AtomicSortedMapBuilder<K, V>, AtomicSortedMapConfig, AtomicSortedMap<K, V>> { | ||
public AtomicSortedMapBuilder(String name, AtomicSortedMapConfig config, PrimitiveManagementService managementService) { | ||
super(AtomicSortedMapType.instance(), name, config, managementService); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
core/src/main/java/io/atomix/core/map/AtomicSortedMapConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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 io.atomix.primitive.PrimitiveType; | ||
import io.atomix.primitive.config.PrimitiveConfig; | ||
|
||
/** | ||
* Consistent sorted map configuration. | ||
*/ | ||
public class AtomicSortedMapConfig extends PrimitiveConfig<AtomicSortedMapConfig> { | ||
@Override | ||
public PrimitiveType getType() { | ||
return AtomicSortedMapType.instance(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
core/src/main/java/io/atomix/core/map/AtomicSortedMapType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright 2017-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.core.map.impl.DefaultAtomicNavigableMapService; | ||
import io.atomix.core.map.impl.DefaultAtomicSortedMapBuilder; | ||
import io.atomix.primitive.PrimitiveManagementService; | ||
import io.atomix.primitive.PrimitiveType; | ||
import io.atomix.primitive.service.PrimitiveService; | ||
import io.atomix.primitive.service.ServiceConfig; | ||
import io.atomix.utils.serializer.Namespace; | ||
|
||
import static com.google.common.base.MoreObjects.toStringHelper; | ||
|
||
/** | ||
* Consistent sorted map primitive type. | ||
*/ | ||
public class AtomicSortedMapType<K extends Comparable<K>, V> | ||
implements PrimitiveType<AtomicSortedMapBuilder<K, V>, AtomicSortedMapConfig, AtomicSortedMap<K, V>> { | ||
private static final String NAME = "atomic-sortedf-map"; | ||
private static final AtomicSortedMapType INSTANCE = new AtomicSortedMapType(); | ||
|
||
/** | ||
* Returns a new consistent tree map type. | ||
* | ||
* @param <K> the key type | ||
* @param <V> the value type | ||
* @return a new consistent tree map type | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public static <K extends Comparable<K>, V> AtomicSortedMapType<K, V> instance() { | ||
return INSTANCE; | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public Namespace namespace() { | ||
return AtomicMapType.instance().namespace(); | ||
} | ||
|
||
@Override | ||
public PrimitiveService newService(ServiceConfig config) { | ||
return new DefaultAtomicNavigableMapService<>(); | ||
} | ||
|
||
@Override | ||
public AtomicSortedMapConfig newConfig() { | ||
return new AtomicSortedMapConfig(); | ||
} | ||
|
||
@Override | ||
public AtomicSortedMapBuilder<K, V> newBuilder(String name, AtomicSortedMapConfig config, PrimitiveManagementService managementService) { | ||
return new DefaultAtomicSortedMapBuilder<>(name, config, managementService); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return toStringHelper(this) | ||
.add("name", name()) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.