Raise EOS unsuccessful request reporting to error
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / entityownership / DistributedEntityOwnershipListenerRegistration.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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 package org.opendaylight.controller.cluster.datastore.entityownership;
9
10 import com.google.common.base.MoreObjects.ToStringHelper;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
13 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
14 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
15
16 /**
17  * Implementation of EntityOwnershipListenerRegistration.
18  *
19  * @author Thomas Pantelis
20  */
21 class DistributedEntityOwnershipListenerRegistration extends AbstractObjectRegistration<DOMEntityOwnershipListener>
22         implements DOMEntityOwnershipListenerRegistration {
23     private final DistributedEntityOwnershipService service;
24     private final String entityType;
25
26     DistributedEntityOwnershipListenerRegistration(final DOMEntityOwnershipListener listener, final String entityType,
27             final DistributedEntityOwnershipService service) {
28         super(listener);
29         this.entityType = Preconditions.checkNotNull(entityType, "entityType cannot be null");
30         this.service = Preconditions.checkNotNull(service, "DOMEntityOwnershipListener cannot be null");
31     }
32
33     @Override
34     protected void removeRegistration() {
35         service.unregisterListener(getEntityType(), getInstance());
36     }
37
38     @Override
39     public String getEntityType() {
40         return entityType;
41     }
42
43     @Override
44     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
45         return toStringHelper.add("entityType", entityType);
46     }
47 }