blob: 6e503efcecc1064393e05a16b1a32cecf1196d60 [file] [log] [blame]
Avantika-Huawei9e848e82016-09-01 12:12:42 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Avantika-Huawei9e848e82016-09-01 12:12:42 +05303 *
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 */
Ray Milkeyd1c34da2018-06-22 18:10:53 -070016package org.onosproject.pcep.server;
Avantika-Huawei9e848e82016-09-01 12:12:42 +053017
Ray Milkeyd1c34da2018-06-22 18:10:53 -070018import org.jboss.netty.channel.Channel;
19import org.onosproject.pcepio.protocol.PcepFactories;
20import org.onosproject.pcepio.protocol.PcepFactory;
21import org.onosproject.pcepio.protocol.PcepMessage;
22import org.onosproject.pcepio.protocol.PcepStateReport;
23import org.onosproject.pcepio.protocol.PcepVersion;
Avantika-Huawei9e848e82016-09-01 12:12:42 +053024
25import java.util.HashMap;
26import java.util.List;
27import java.util.Map;
28import java.util.concurrent.RejectedExecutionException;
29
Ray Milkeyd1c34da2018-06-22 18:10:53 -070030import static org.junit.Assert.assertNotNull;
Avantika-Huawei9e848e82016-09-01 12:12:42 +053031
32/**
33 * Representation of PCEP client adapter.
34 */
35public class PcepClientAdapter implements PcepClient {
36
37 private Channel channel;
38 protected String channelId;
39
40 private boolean connected;
41 private PccId pccId;
42 private ClientCapability capability;
43
44 private PcepVersion pcepVersion;
45 private PcepSyncStatus lspDbSyncStatus;
46 private PcepSyncStatus labelDbSyncStatus;
47 private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
48
49 /**
50 * Initialize instance with specified parameters.
51 *
52 * @param pccId PCC id
53 * @param pcepVersion PCEP message version
54 */
55 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;
Ray Milkeyd1c34da2018-06-22 18:10:53 -070092 }
Avantika-Huawei9e848e82016-09-01 12:12:42 +053093
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
114 public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
115 this.lspDbSyncStatus = syncStatus;
116 }
117
118 @Override
119 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;
131 }
132
133 @Override
134 public void setCapability(ClientCapability capability) {
135 this.capability = capability;
136 }
137
138 @Override
139 public ClientCapability capability() {
140 return capability;
141 }
142
143 @Override
144 public void addNode(PcepClient pc) {
145 }
146
147 @Override
148 public void deleteNode(PccId pccId) {
149 }
150
151 @Override
152 public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
153 lspDelegationInfo.put(lspKey, dFlag);
154 }
155
156 @Override
157 public Boolean delegationInfo(LspKey lspKey) {
158 return lspDelegationInfo.get(lspKey);
159 }
160
161 @Override
162 public void initializeSyncMsgList(PccId pccId) {
163 // TODO Auto-generated method stub
164
165 }
166
167 @Override
168 public List<PcepStateReport> getSyncMsgList(PccId pccId) {
169 // TODO Auto-generated method stub
170 return null;
171 }
172
173 @Override
174 public void removeSyncMsgList(PccId pccId) {
175 // TODO Auto-generated method stub
176
177 }
178
179 @Override
180 public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) {
181 // TODO Auto-generated method stub
182
183 }
184}