blob: 354bca40b7abbacecced52f8c909350daa8720ba [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 /**
33 * Returns whether a given id maps to a partition owned by this
34 * instance.
35 *
36 * @param id id
37 * @param hasher function that maps id to a long value
38 * @return {@code true} if the id maps to a partition owned by this instance, otherwise {@code false}
39 */
40 <K> boolean isMine(K id, Function<K, Long> hasher);
41
42 /**
43 * Returns the owner for a given id.
44 *
45 * @param id id to query
46 * @param hasher function that maps id to a long value
47 * @return the leader node identifier
48 */
49 <K> NodeId getLeader(K id, Function<K, Long> hasher);
50}