Change ClusterSingletonServiceService.closeServiceInstance()
[mdsal.git] / singleton-service / mdsal-singleton-common-api / src / main / java / org / opendaylight / mdsal / singleton / common / api / ClusterSingletonService.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.mdsal.singleton.common.api;
10
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.yangtools.concepts.Identifiable;
13
14 /**
15  * {@link ClusterSingletonService} interface represents a single cluster service instance. It has to implement
16  * every service (RPCs or Applications) which would like to be instantiated on same Cluster Node. Grouping is
17  * realized by ServiceGroupIdentifier. Servicies with same ServiceGroupIdentifier have to run on same Cluster
18  * Node. ServiceGroupIdentifier must not change during whole {@link ClusterSingletonService} lifecycle.
19  */
20 public interface ClusterSingletonService extends Identifiable<ServiceGroupIdentifier> {
21
22     /**
23      * This method is invoked to instantiate an underlying service instance when
24      * ownership has been granted for the service entity.
25      */
26     void instantiateServiceInstance();
27
28     /**
29      * This method is invoked to close the underlying service instance when ownership has been lost
30      * for the service entity. If the act of closing the instance may perform blocking operations or
31      * take some time, it should be done asynchronously to avoid blocking the current thread.
32      *
33      * @return a ListenableFuture that is completed when the underlying instance close operation is complete.
34      */
35     ListenableFuture<? extends Object> closeServiceInstance();
36
37 }