blob: daf315a58788fdf1708033540640372c15fb7b41 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Phanendra Manda972ee9e2015-08-21 19:08:20 +053016package org.onosproject.provider.pcep.tunnel.impl;
17
18import static org.junit.Assert.assertNotNull;
19
20import java.util.List;
21import java.util.concurrent.RejectedExecutionException;
22
23import org.jboss.netty.channel.Channel;
Priyanka Bd2b28882016-04-04 16:57:04 +053024import org.onosproject.pcep.controller.ClientCapability;
Phanendra Manda972ee9e2015-08-21 19:08:20 +053025import org.onosproject.pcep.controller.PccId;
26import org.onosproject.pcep.controller.PcepClient;
Avantika-Huawei7f7376a2016-05-11 17:07:50 +053027import org.onosproject.pcep.controller.PcepSyncStatus;
Phanendra Manda972ee9e2015-08-21 19:08:20 +053028import org.onosproject.pcepio.protocol.PcepFactories;
29import org.onosproject.pcepio.protocol.PcepFactory;
30import org.onosproject.pcepio.protocol.PcepMessage;
31import org.onosproject.pcepio.protocol.PcepVersion;
32
Priyanka Bd2b28882016-04-04 16:57:04 +053033/**
34 * Representation of PCEP client adapter.
35 */
Phanendra Manda972ee9e2015-08-21 19:08:20 +053036public class PcepClientAdapter implements PcepClient {
37
38 private Channel channel;
39 protected String channelId;
40
41 private boolean connected;
42 private PccId pccId;
Priyanka Bd2b28882016-04-04 16:57:04 +053043 private ClientCapability capability;
Phanendra Manda972ee9e2015-08-21 19:08:20 +053044
45 private PcepVersion pcepVersion;
Avantika-Huawei7f7376a2016-05-11 17:07:50 +053046 private PcepSyncStatus lspDbSyncStatus;
47 private PcepSyncStatus labelDbSyncStatus;
Phanendra Manda972ee9e2015-08-21 19:08:20 +053048
Priyanka Bd2b28882016-04-04 16:57:04 +053049 /**
50 * Initialize instance with specified parameters.
51 *
52 * @param pccId PCC id
53 * @param pcepVersion PCEP message version
54 */
Phanendra Manda972ee9e2015-08-21 19:08:20 +053055 public void init(PccId pccId, PcepVersion pcepVersion) {
56 this.pccId = pccId;
57 this.pcepVersion = pcepVersion;
58 }
59
60 @Override
61 public final void disconnectClient() {
62 this.channel.close();
63 }
64
65 @Override
66 public final void sendMessage(PcepMessage m) {
67 }
68
69 @Override
70 public final void sendMessage(List<PcepMessage> msgs) {
71 try {
72 PcepMessage pcepMsg = msgs.get(0);
73 assertNotNull("PCEP MSG should be created.", pcepMsg);
74 } catch (RejectedExecutionException e) {
75 throw e;
76 }
77 }
78
79 @Override
80 public final boolean isConnected() {
81 return this.connected;
82 }
83
84 @Override
85 public String channelId() {
86 return channelId;
87 }
88
89 @Override
90 public final PccId getPccId() {
91 return this.pccId;
92 };
93
94 @Override
95 public final String getStringId() {
96 return this.pccId.toString();
97 }
98
99 @Override
100 public final void handleMessage(PcepMessage m) {
101 }
102
103 @Override
104 public boolean isOptical() {
105 return false;
106 }
107
108 @Override
109 public PcepFactory factory() {
110 return PcepFactories.getFactory(pcepVersion);
111 }
112
113 @Override
Avantika-Huawei7f7376a2016-05-11 17:07:50 +0530114 public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
115 this.lspDbSyncStatus = syncStatus;
Phanendra Manda972ee9e2015-08-21 19:08:20 +0530116 }
117
118 @Override
Avantika-Huawei7f7376a2016-05-11 17:07:50 +0530119 public PcepSyncStatus lspDbSyncStatus() {
120 return lspDbSyncStatus;
121 }
122
123 @Override
124 public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
125 this.labelDbSyncStatus = syncStatus;
126 }
127
128 @Override
129 public PcepSyncStatus labelDbSyncStatus() {
130 return labelDbSyncStatus;
Phanendra Manda972ee9e2015-08-21 19:08:20 +0530131 }
Priyanka Bd2b28882016-04-04 16:57:04 +0530132
133 @Override
134 public void setCapability(ClientCapability capability) {
135 this.capability = capability;
136 }
137
138 @Override
139 public ClientCapability capability() {
140 return capability;
141 }
Phanendra Manda972ee9e2015-08-21 19:08:20 +0530142}