blob: 8f9c3c4962a26145d211ebd7e70b36d13943d8a0 [file] [log] [blame]
Priyanka B94395bf2016-05-21 18:39:46 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
3 *
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 */
16package org.onosproject.provider.pcep.topology.impl;
17
18import static org.junit.Assert.assertNotNull;
19
Priyanka B413fbe82016-05-26 11:44:45 +053020import java.util.HashMap;
Priyanka B94395bf2016-05-21 18:39:46 +053021import java.util.List;
Priyanka B413fbe82016-05-26 11:44:45 +053022import java.util.Map;
Priyanka B94395bf2016-05-21 18:39:46 +053023import java.util.concurrent.RejectedExecutionException;
24
25import org.jboss.netty.channel.Channel;
26import org.onosproject.pcep.controller.ClientCapability;
27import org.onosproject.pcep.controller.PccId;
Priyanka B413fbe82016-05-26 11:44:45 +053028import org.onosproject.pcep.controller.LspKey;
Priyanka B94395bf2016-05-21 18:39:46 +053029import org.onosproject.pcep.controller.PcepClient;
30import org.onosproject.pcep.controller.PcepSyncStatus;
31import org.onosproject.pcepio.protocol.PcepFactories;
32import org.onosproject.pcepio.protocol.PcepFactory;
33import org.onosproject.pcepio.protocol.PcepMessage;
34import org.onosproject.pcepio.protocol.PcepVersion;
35
36/**
37 * Representation of PCEP client adapter.
38 */
39public class PcepClientAdapter implements PcepClient {
40
41 private Channel channel;
42 protected String channelId;
43
44 private boolean connected;
45 private PccId pccId;
46 private ClientCapability capability;
47
48 private PcepVersion pcepVersion;
49 private PcepSyncStatus lspDbSyncStatus;
50 private PcepSyncStatus labelDbSyncStatus;
Priyanka B413fbe82016-05-26 11:44:45 +053051 private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
Priyanka B94395bf2016-05-21 18:39:46 +053052
53 /**
54 * Initialize instance with specified parameters.
55 *
56 * @param pccId PCC id
57 * @param pcepVersion PCEP message version
58 */
59 public void init(PccId pccId, PcepVersion pcepVersion) {
60 this.pccId = pccId;
61 this.pcepVersion = pcepVersion;
62 }
63
64 @Override
65 public final void disconnectClient() {
66 this.channel.close();
67 }
68
69 @Override
70 public final void sendMessage(PcepMessage m) {
71 }
72
73 @Override
74 public final void sendMessage(List<PcepMessage> msgs) {
75 try {
76 PcepMessage pcepMsg = msgs.get(0);
77 assertNotNull("PCEP MSG should be created.", pcepMsg);
78 } catch (RejectedExecutionException e) {
79 throw e;
80 }
81 }
82
83 @Override
84 public final boolean isConnected() {
85 return this.connected;
86 }
87
88 @Override
89 public String channelId() {
90 return channelId;
91 }
92
93 @Override
94 public final PccId getPccId() {
95 return this.pccId;
96 };
97
98 @Override
99 public final String getStringId() {
100 return this.pccId.toString();
101 }
102
103 @Override
104 public final void handleMessage(PcepMessage m) {
105 }
106
107 @Override
108 public boolean isOptical() {
109 return false;
110 }
111
112 @Override
113 public PcepFactory factory() {
114 return PcepFactories.getFactory(pcepVersion);
115 }
116
117 @Override
118 public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
119 this.lspDbSyncStatus = syncStatus;
120 }
121
122 @Override
123 public PcepSyncStatus lspDbSyncStatus() {
124 return lspDbSyncStatus;
125 }
126
127 @Override
128 public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) {
129 this.labelDbSyncStatus = syncStatus;
130 }
131
132 @Override
133 public PcepSyncStatus labelDbSyncStatus() {
134 return labelDbSyncStatus;
135 }
136
137 @Override
138 public void setCapability(ClientCapability capability) {
139 this.capability = capability;
140 }
141
142 @Override
143 public ClientCapability capability() {
144 return capability;
145 }
146
147 @Override
148 public void addNode(PcepClient pc) {
149 }
150
151 @Override
152 public void deleteNode(PccId pccId) {
153 }
Priyanka B413fbe82016-05-26 11:44:45 +0530154
155 @Override
156 public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
157 lspDelegationInfo.put(lspKey, dFlag);
158 }
159
160 @Override
161 public Boolean delegationInfo(LspKey lspKey) {
162 return lspDelegationInfo.get(lspKey);
163 }
Priyanka B94395bf2016-05-21 18:39:46 +0530164}