2 * Copyright (c) 2013 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
8 package org.opendaylight.bgpcep.pcep.topology.provider;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.SettableFuture;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.OperationResult;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.lsp.metadata.Metadata;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 final class PCEPRequest {
25 private static final Logger LOG = LoggerFactory.getLogger(PCEPRequest.class);
26 private final SettableFuture<OperationResult> future;
27 private final Metadata metadata;
28 private volatile State state;
30 PCEPRequest(final Metadata metadata) {
31 this.future = SettableFuture.create();
32 this.metadata = metadata;
33 this.state = State.UNSENT;
36 protected ListenableFuture<OperationResult> getFuture() {
40 public Metadata getMetadata() {
44 public State getState() {
48 public synchronized void done(final OperationResult result) {
49 if (state != State.DONE) {
50 LOG.debug("Request went from {} to {}", state, State.DONE);
56 public synchronized void sent() {
57 if (state == State.UNSENT) {
58 LOG.debug("Request went from {} to {}", state, State.UNACKED);
59 state = State.UNACKED;