blob: efb4d955fa86bc066a3f009c50bd62baa7766464 [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;
27import org.onosproject.pcepio.protocol.PcepFactories;
28import org.onosproject.pcepio.protocol.PcepFactory;
29import org.onosproject.pcepio.protocol.PcepMessage;
30import org.onosproject.pcepio.protocol.PcepVersion;
31
Priyanka Bd2b28882016-04-04 16:57:04 +053032/**
33 * Representation of PCEP client adapter.
34 */
Phanendra Manda972ee9e2015-08-21 19:08:20 +053035public class PcepClientAdapter implements PcepClient {
36
37 private Channel channel;
38 protected String channelId;
39
40 private boolean connected;
41 private PccId pccId;
Priyanka Bd2b28882016-04-04 16:57:04 +053042 private ClientCapability capability;
Phanendra Manda972ee9e2015-08-21 19:08:20 +053043
44 private PcepVersion pcepVersion;
45
Priyanka Bd2b28882016-04-04 16:57:04 +053046 /**
47 * Initialize instance with specified parameters.
48 *
49 * @param pccId PCC id
50 * @param pcepVersion PCEP message version
51 */
Phanendra Manda972ee9e2015-08-21 19:08:20 +053052 public void init(PccId pccId, PcepVersion pcepVersion) {
53 this.pccId = pccId;
54 this.pcepVersion = pcepVersion;
55 }
56
57 @Override
58 public final void disconnectClient() {
59 this.channel.close();
60 }
61
62 @Override
63 public final void sendMessage(PcepMessage m) {
64 }
65
66 @Override
67 public final void sendMessage(List<PcepMessage> msgs) {
68 try {
69 PcepMessage pcepMsg = msgs.get(0);
70 assertNotNull("PCEP MSG should be created.", pcepMsg);
71 } catch (RejectedExecutionException e) {
72 throw e;
73 }
74 }
75
76 @Override
77 public final boolean isConnected() {
78 return this.connected;
79 }
80
81 @Override
82 public String channelId() {
83 return channelId;
84 }
85
86 @Override
87 public final PccId getPccId() {
88 return this.pccId;
89 };
90
91 @Override
92 public final String getStringId() {
93 return this.pccId.toString();
94 }
95
96 @Override
97 public final void handleMessage(PcepMessage m) {
98 }
99
100 @Override
101 public boolean isOptical() {
102 return false;
103 }
104
105 @Override
106 public PcepFactory factory() {
107 return PcepFactories.getFactory(pcepVersion);
108 }
109
110 @Override
111 public final boolean isSyncComplete() {
112 return false;
113 }
114
115 @Override
116 public final void setIsSyncComplete(boolean value) {
117 }
Priyanka Bd2b28882016-04-04 16:57:04 +0530118
119 @Override
120 public void setCapability(ClientCapability capability) {
121 this.capability = capability;
122 }
123
124 @Override
125 public ClientCapability capability() {
126 return capability;
127 }
Phanendra Manda972ee9e2015-08-21 19:08:20 +0530128}