2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.mdsal.singleton.common.api;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.yangtools.concepts.Identifiable;
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.
20 public interface ClusterSingletonService extends Identifiable<ServiceGroupIdentifier> {
23 * This method is invoked to instantiate an underlying service instance when
24 * ownership has been granted for the service entity.
26 void instantiateServiceInstance();
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.
33 * @return a ListenableFuture that is completed when the underlying instance close operation is complete.
35 ListenableFuture<? extends Object> closeServiceInstance();