blob: 034deaaa9663a6b397c59f2622ccd38a364eb00b [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
20import java.util.List;
21import java.util.concurrent.RejectedExecutionException;
22
23import org.jboss.netty.channel.Channel;
24import org.onosproject.pcep.controller.ClientCapability;
25import org.onosproject.pcep.controller.PccId;
26import org.onosproject.pcep.controller.PcepClient;
27import org.onosproject.pcep.controller.PcepSyncStatus;
28import org.onosproject.pcepio.protocol.PcepFactories;
29import org.onosproject.pcepio.protocol.PcepFactory;
30import org.onosproject.pcepio.protocol.PcepMessage;
31import org.onosproject.pcepio.protocol.PcepVersion;
32
33/**
34 * Representation of PCEP client adapter.
35 */
36public class PcepClientAdapter implements PcepClient {
37
38 private Channel channel;
39 protected String channelId;
40
41 private boolean connected;
42 private PccId pccId;
43 private ClientCapability capability;
44
45 private PcepVersion pcepVersion;
46 private PcepSyncStatus lspDbSyncStatus;
47 private PcepSyncStatus labelDbSyncStatus;
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;
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
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}