Committed by
Gerrit Code Review
APIs for accessing/administering storage partitions + API for creating distributed primitives
Change-Id: I54ec3a76fdbdd09a57d283a8bd041a05d6e362c5
Showing
6 changed files
with
297 additions
and
0 deletions
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.store.primitives; | ||
17 | + | ||
18 | +import org.onosproject.store.service.AsyncAtomicCounter; | ||
19 | +import org.onosproject.store.service.AsyncAtomicValue; | ||
20 | +import org.onosproject.store.service.AsyncConsistentMap; | ||
21 | +import org.onosproject.store.service.AsyncDistributedSet; | ||
22 | +import org.onosproject.store.service.DistributedQueue; | ||
23 | +import org.onosproject.store.service.Serializer; | ||
24 | + | ||
25 | +/** | ||
26 | + * Interface for entity that can create instances of different distributed primitives. | ||
27 | + */ | ||
28 | +public interface DistributedPrimitiveCreator { | ||
29 | + | ||
30 | + /** | ||
31 | + * Creates a new {@code AsyncConsistentMap}. | ||
32 | + * | ||
33 | + * @param name map name | ||
34 | + * @param serializer serializer to use for serializing/deserializing map entries | ||
35 | + * @param <K> key type | ||
36 | + * @param <V> value type | ||
37 | + * @return map | ||
38 | + */ | ||
39 | + <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(String name, Serializer serializer); | ||
40 | + | ||
41 | + /** | ||
42 | + * Creates a new {@code AsyncAtomicCounter}. | ||
43 | + * | ||
44 | + * @param name counter name | ||
45 | + * @return counter | ||
46 | + */ | ||
47 | + AsyncAtomicCounter newAsyncCounter(String name); | ||
48 | + | ||
49 | + /** | ||
50 | + * Creates a new {@code AsyncAtomicValue}. | ||
51 | + * | ||
52 | + * @param name value name | ||
53 | + * @param serializer serializer to use for serializing/deserializing value type | ||
54 | + * @param <V> value type | ||
55 | + * @return value | ||
56 | + */ | ||
57 | + <V> AsyncAtomicValue<V> newAsyncAtomicValue(String name, Serializer serializer); | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a new {@code DistributedQueue}. | ||
61 | + * | ||
62 | + * @param name queue name | ||
63 | + * @param serializer serializer to use for serializing/deserializing queue entries | ||
64 | + * @param <E> queue entry type | ||
65 | + * @return queue | ||
66 | + */ | ||
67 | + <E> DistributedQueue<E> newDistributedQueue(String name, Serializer serializer); | ||
68 | + | ||
69 | + /** | ||
70 | + * Creates a new {@code AsyncDistributedSet}. | ||
71 | + * | ||
72 | + * @param name set name | ||
73 | + * @param serializer serializer to use for serializing/deserializing set entries | ||
74 | + * @param <E> set entry type | ||
75 | + * @return set | ||
76 | + */ | ||
77 | + <E> AsyncDistributedSet<E> newAsyncDistributedSet(String name, Serializer serializer); | ||
78 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.store.primitives; | ||
17 | + | ||
18 | +import java.util.concurrent.CompletableFuture; | ||
19 | + | ||
20 | +import org.onosproject.cluster.PartitionId; | ||
21 | + | ||
22 | +/** | ||
23 | + * Administrative interface for partition membership changes. | ||
24 | + */ | ||
25 | +public interface PartitionAdminService { | ||
26 | + | ||
27 | + /** | ||
28 | + * Leaves a partition. | ||
29 | + * | ||
30 | + * @param partitionId partition identifier | ||
31 | + * @return future that is completed when the operation completes. | ||
32 | + */ | ||
33 | + CompletableFuture<Void> leave(PartitionId partitionId); | ||
34 | + | ||
35 | + /** | ||
36 | + * Joins a partition. | ||
37 | + * | ||
38 | + * @param partitionId partition identifier | ||
39 | + * @return future that is completed when the operation completes. | ||
40 | + */ | ||
41 | + CompletableFuture<Void> join(PartitionId partitionId); | ||
42 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.store.primitives; | ||
17 | + | ||
18 | +import org.onosproject.cluster.Partition; | ||
19 | +import org.onosproject.event.AbstractEvent; | ||
20 | + | ||
21 | +/** | ||
22 | + * Describes partition-related event. | ||
23 | + */ | ||
24 | +public class PartitionEvent extends AbstractEvent<PartitionEvent.Type, Partition> { | ||
25 | + | ||
26 | + /** | ||
27 | + * Type of partition-related events. | ||
28 | + */ | ||
29 | + public enum Type { | ||
30 | + | ||
31 | + /** | ||
32 | + * Signifies that a partition has been administratively updated. | ||
33 | + */ | ||
34 | + UPDATED, | ||
35 | + | ||
36 | + /** | ||
37 | + * Signifies that a partition has been successfully opened. | ||
38 | + */ | ||
39 | + OPENED, | ||
40 | + | ||
41 | + /** | ||
42 | + * Signifies that a partition has been successfully closed. | ||
43 | + */ | ||
44 | + CLOSED, | ||
45 | + | ||
46 | + /** | ||
47 | + * Signifies that a partition is available for operations. | ||
48 | + */ | ||
49 | + AVAILABLE, | ||
50 | + | ||
51 | + /** | ||
52 | + * Signifies that a partition is unavailable for operations. | ||
53 | + */ | ||
54 | + UNAVAILABLE, | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Creates an event of a given type and for the specified partition and time. | ||
59 | + * | ||
60 | + * @param type partition event type | ||
61 | + * @param subject event partition subject | ||
62 | + * @param time occurrence time | ||
63 | + */ | ||
64 | + protected PartitionEvent(Type type, Partition subject, long time) { | ||
65 | + super(type, subject, time); | ||
66 | + } | ||
67 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.store.primitives; | ||
17 | + | ||
18 | +import org.onosproject.event.EventListener; | ||
19 | + | ||
20 | +/** | ||
21 | + * Entity capable of receiving partition-related events. | ||
22 | + */ | ||
23 | +public interface PartitionEventListener extends EventListener<PartitionEvent> { | ||
24 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.store.primitives; | ||
17 | + | ||
18 | +import java.util.Set; | ||
19 | + | ||
20 | +import org.onosproject.cluster.NodeId; | ||
21 | +import org.onosproject.cluster.PartitionId; | ||
22 | +import org.onosproject.event.ListenerService; | ||
23 | + | ||
24 | +/** | ||
25 | + * Service used for accessing information about storage partitions. | ||
26 | + */ | ||
27 | +public interface PartitionService extends ListenerService<PartitionEvent, PartitionEventListener> { | ||
28 | + | ||
29 | + /** | ||
30 | + * Returns the total number of partitions. | ||
31 | + * | ||
32 | + * @return number of partitions | ||
33 | + */ | ||
34 | + int getNumberOfPartitions(); | ||
35 | + | ||
36 | + /** | ||
37 | + * Returns the set of controller nodes configured to be members of a partition. | ||
38 | + * | ||
39 | + * @param partitionId partition identifier | ||
40 | + * @return set of node identifiers | ||
41 | + */ | ||
42 | + Set<NodeId> getConfiguredMembers(PartitionId partitionId); | ||
43 | + | ||
44 | + /** | ||
45 | + * Returns the set of controller nodes that are the current active members of a partition. | ||
46 | + * | ||
47 | + * @param partitionId partition identifier | ||
48 | + * @return set of node identifiers | ||
49 | + */ | ||
50 | + Set<NodeId> getActiveMembersMembers(PartitionId partitionId); | ||
51 | + | ||
52 | + /** | ||
53 | + * Returns the identifiers of all partitions. | ||
54 | + * | ||
55 | + * @return set of partition identifiers | ||
56 | + */ | ||
57 | + Set<PartitionId> getAllPartitionIds(); | ||
58 | + | ||
59 | + /** | ||
60 | + * Returns a DistributedPrimitiveCreator that can create primitives hosted on a partition. | ||
61 | + * | ||
62 | + * @param partitionId partition identifier | ||
63 | + * @return distributed primitive creator | ||
64 | + */ | ||
65 | + DistributedPrimitiveCreator getDistributedPrimitiveCreator(PartitionId partitionId); | ||
66 | +} |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Interfaces for creating various distributed primitives. | ||
19 | + */ | ||
20 | +package org.onosproject.store.primitives; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment