Madan Jampani
Committed by Gerrit Code Review

APIs for accessing/administering storage partitions + API for creating distributed primitives

Change-Id: I54ec3a76fdbdd09a57d283a8bd041a05d6e362c5
/*
* Copyright 2016 Open Networking Laboratory
*
* 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 org.onosproject.store.primitives;
import org.onosproject.store.service.AsyncAtomicCounter;
import org.onosproject.store.service.AsyncAtomicValue;
import org.onosproject.store.service.AsyncConsistentMap;
import org.onosproject.store.service.AsyncDistributedSet;
import org.onosproject.store.service.DistributedQueue;
import org.onosproject.store.service.Serializer;
/**
* Interface for entity that can create instances of different distributed primitives.
*/
public interface DistributedPrimitiveCreator {
/**
* Creates a new {@code AsyncConsistentMap}.
*
* @param name map name
* @param serializer serializer to use for serializing/deserializing map entries
* @param <K> key type
* @param <V> value type
* @return map
*/
<K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(String name, Serializer serializer);
/**
* Creates a new {@code AsyncAtomicCounter}.
*
* @param name counter name
* @return counter
*/
AsyncAtomicCounter newAsyncCounter(String name);
/**
* Creates a new {@code AsyncAtomicValue}.
*
* @param name value name
* @param serializer serializer to use for serializing/deserializing value type
* @param <V> value type
* @return value
*/
<V> AsyncAtomicValue<V> newAsyncAtomicValue(String name, Serializer serializer);
/**
* Creates a new {@code DistributedQueue}.
*
* @param name queue name
* @param serializer serializer to use for serializing/deserializing queue entries
* @param <E> queue entry type
* @return queue
*/
<E> DistributedQueue<E> newDistributedQueue(String name, Serializer serializer);
/**
* Creates a new {@code AsyncDistributedSet}.
*
* @param name set name
* @param serializer serializer to use for serializing/deserializing set entries
* @param <E> set entry type
* @return set
*/
<E> AsyncDistributedSet<E> newAsyncDistributedSet(String name, Serializer serializer);
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* 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 org.onosproject.store.primitives;
import java.util.concurrent.CompletableFuture;
import org.onosproject.cluster.PartitionId;
/**
* Administrative interface for partition membership changes.
*/
public interface PartitionAdminService {
/**
* Leaves a partition.
*
* @param partitionId partition identifier
* @return future that is completed when the operation completes.
*/
CompletableFuture<Void> leave(PartitionId partitionId);
/**
* Joins a partition.
*
* @param partitionId partition identifier
* @return future that is completed when the operation completes.
*/
CompletableFuture<Void> join(PartitionId partitionId);
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* 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 org.onosproject.store.primitives;
import org.onosproject.cluster.Partition;
import org.onosproject.event.AbstractEvent;
/**
* Describes partition-related event.
*/
public class PartitionEvent extends AbstractEvent<PartitionEvent.Type, Partition> {
/**
* Type of partition-related events.
*/
public enum Type {
/**
* Signifies that a partition has been administratively updated.
*/
UPDATED,
/**
* Signifies that a partition has been successfully opened.
*/
OPENED,
/**
* Signifies that a partition has been successfully closed.
*/
CLOSED,
/**
* Signifies that a partition is available for operations.
*/
AVAILABLE,
/**
* Signifies that a partition is unavailable for operations.
*/
UNAVAILABLE,
}
/**
* Creates an event of a given type and for the specified partition and time.
*
* @param type partition event type
* @param subject event partition subject
* @param time occurrence time
*/
protected PartitionEvent(Type type, Partition subject, long time) {
super(type, subject, time);
}
}
\ No newline at end of file
/*
* Copyright 2016 Open Networking Laboratory
*
* 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 org.onosproject.store.primitives;
import org.onosproject.event.EventListener;
/**
* Entity capable of receiving partition-related events.
*/
public interface PartitionEventListener extends EventListener<PartitionEvent> {
}
/*
* Copyright 2016 Open Networking Laboratory
*
* 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 org.onosproject.store.primitives;
import java.util.Set;
import org.onosproject.cluster.NodeId;
import org.onosproject.cluster.PartitionId;
import org.onosproject.event.ListenerService;
/**
* Service used for accessing information about storage partitions.
*/
public interface PartitionService extends ListenerService<PartitionEvent, PartitionEventListener> {
/**
* Returns the total number of partitions.
*
* @return number of partitions
*/
int getNumberOfPartitions();
/**
* Returns the set of controller nodes configured to be members of a partition.
*
* @param partitionId partition identifier
* @return set of node identifiers
*/
Set<NodeId> getConfiguredMembers(PartitionId partitionId);
/**
* Returns the set of controller nodes that are the current active members of a partition.
*
* @param partitionId partition identifier
* @return set of node identifiers
*/
Set<NodeId> getActiveMembersMembers(PartitionId partitionId);
/**
* Returns the identifiers of all partitions.
*
* @return set of partition identifiers
*/
Set<PartitionId> getAllPartitionIds();
/**
* Returns a DistributedPrimitiveCreator that can create primitives hosted on a partition.
*
* @param partitionId partition identifier
* @return distributed primitive creator
*/
DistributedPrimitiveCreator getDistributedPrimitiveCreator(PartitionId partitionId);
}
/*
* Copyright 2016 Open Networking Laboratory
*
* 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.
*/
/**
* Interfaces for creating various distributed primitives.
*/
package org.onosproject.store.primitives;
\ No newline at end of file