blob: 3bcd94bc74566162e62afaa2b7a7ff6729b3ffa1 [file] [log] [blame]
Madan Jampani3b8101a2016-09-15 13:22:01 -07001/*
2 * Copyright 2016-present 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 */
16package org.onosproject.net.intent;
17
18import java.util.function.Function;
19
20import org.onosproject.cluster.NodeId;
21import org.onosproject.event.ListenerService;
22
23import com.google.common.annotations.Beta;
24
25/**
26 * Service for partitioning work, represented via a unique identifier, onto cluster nodes.
27 */
28@Beta
29public interface WorkPartitionService
30 extends ListenerService<WorkPartitionEvent, WorkPartitionEventListener> {
31
32 /**
Ray Milkeyef794342016-11-09 16:20:29 -080033 * Returns whether a given identifier maps to a partition owned by this
Madan Jampani3b8101a2016-09-15 13:22:01 -070034 * instance.
35 *
Ray Milkeyef794342016-11-09 16:20:29 -080036 * @param id identifier
37 * @param hasher function that maps identifier to a long value
38 * @param <K> entity type
39 * @return true if the identifier maps to a partition owned
40 * by this instance, otherwise false
Madan Jampani3b8101a2016-09-15 13:22:01 -070041 */
42 <K> boolean isMine(K id, Function<K, Long> hasher);
43
44 /**
Ray Milkeyef794342016-11-09 16:20:29 -080045 * Returns the owner for a given identifier.
Madan Jampani3b8101a2016-09-15 13:22:01 -070046 *
Ray Milkeyef794342016-11-09 16:20:29 -080047 * @param id identifier to query
Madan Jampani3b8101a2016-09-15 13:22:01 -070048 * @param hasher function that maps id to a long value
Ray Milkeyef794342016-11-09 16:20:29 -080049 * @param <K> entity type
Madan Jampani3b8101a2016-09-15 13:22:01 -070050 * @return the leader node identifier
51 */
52 <K> NodeId getLeader(K id, Function<K, Long> hasher);
53}