blob: 5b010f5133d9bf96958ab875e2c83fc76eef37b5 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
2 * Copyright 2015 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 */
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;
24import org.onosproject.pcep.controller.PccId;
25import org.onosproject.pcep.controller.PcepClient;
26import org.onosproject.pcepio.protocol.PcepFactories;
27import org.onosproject.pcepio.protocol.PcepFactory;
28import org.onosproject.pcepio.protocol.PcepMessage;
29import org.onosproject.pcepio.protocol.PcepVersion;
30
31public class PcepClientAdapter implements PcepClient {
32
33 private Channel channel;
34 protected String channelId;
35
36 private boolean connected;
37 private PccId pccId;
38
39 private PcepVersion pcepVersion;
40
41 public void init(PccId pccId, PcepVersion pcepVersion) {
42 this.pccId = pccId;
43 this.pcepVersion = pcepVersion;
44 }
45
46 @Override
47 public final void disconnectClient() {
48 this.channel.close();
49 }
50
51 @Override
52 public final void sendMessage(PcepMessage m) {
53 }
54
55 @Override
56 public final void sendMessage(List<PcepMessage> msgs) {
57 try {
58 PcepMessage pcepMsg = msgs.get(0);
59 assertNotNull("PCEP MSG should be created.", pcepMsg);
60 } catch (RejectedExecutionException e) {
61 throw e;
62 }
63 }
64
65 @Override
66 public final boolean isConnected() {
67 return this.connected;
68 }
69
70 @Override
71 public String channelId() {
72 return channelId;
73 }
74
75 @Override
76 public final PccId getPccId() {
77 return this.pccId;
78 };
79
80 @Override
81 public final String getStringId() {
82 return this.pccId.toString();
83 }
84
85 @Override
86 public final void handleMessage(PcepMessage m) {
87 }
88
89 @Override
90 public boolean isOptical() {
91 return false;
92 }
93
94 @Override
95 public PcepFactory factory() {
96 return PcepFactories.getFactory(pcepVersion);
97 }
98
99 @Override
100 public final boolean isSyncComplete() {
101 return false;
102 }
103
104 @Override
105 public final void setIsSyncComplete(boolean value) {
106 }
107}