BUG-2208: PCC-MOCK Stateful Sync Opt
[bgpcep.git] / pcep / pcc-mock / src / main / java / org / opendaylight / protocol / pcep / pcc / mock / PCCTunnel.java
1 /*
2  * Copyright (c) 2015 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.protocol.pcep.pcc.mock;
10
11 import io.netty.util.Timeout;
12 import org.opendaylight.protocol.pcep.pcc.mock.api.LspType;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.reports.Path;
14
15 final class PCCTunnel {
16
17     private final byte[] pathName;
18     private final LspType type;
19     private int delegationHolder;
20     private Path lspState;
21     private Timeout redelegationTimeout;
22     private Timeout stateTimeout;
23
24     public PCCTunnel(final byte[] pathName, final int delegationHolder, final LspType type, final Path lspState) {
25         if (pathName != null) {
26             this.pathName = pathName.clone();
27         } else {
28             this.pathName = null;
29         }
30         this.delegationHolder = delegationHolder;
31         this.type = type;
32         this.lspState = lspState;
33     }
34
35     public byte[] getPathName() {
36         return this.pathName;
37     }
38
39     public int getDelegationHolder() {
40         return this.delegationHolder;
41     }
42
43     public void setDelegationHolder(final int delegationHolder) {
44         this.delegationHolder = delegationHolder;
45     }
46
47     public LspType getType() {
48         return this.type;
49     }
50
51     public Path getLspState() {
52         return this.lspState;
53     }
54
55     public void setLspState(final Path lspState) {
56         this.lspState = lspState;
57     }
58
59     public void setRedelegationTimeout(final Timeout redelegationTimeout) {
60         this.redelegationTimeout = redelegationTimeout;
61     }
62
63     public void setStateTimeout(final Timeout stateTimeout) {
64         this.stateTimeout = stateTimeout;
65     }
66
67     public void cancelTimeouts() {
68         if (this.redelegationTimeout != null) {
69             this.redelegationTimeout.cancel();
70         }
71         if (this.stateTimeout != null) {
72             this.stateTimeout.cancel();
73         }
74     }
75 }