Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 16 | package org.onosproject.provider.pcep.tunnel.impl; |
| 17 | |
| 18 | import static org.junit.Assert.assertNotNull; |
| 19 | |
| 20 | import java.util.List; |
| 21 | import java.util.concurrent.RejectedExecutionException; |
| 22 | |
| 23 | import org.jboss.netty.channel.Channel; |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 24 | import org.onosproject.pcep.controller.ClientCapability; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 25 | import org.onosproject.pcep.controller.PccId; |
| 26 | import org.onosproject.pcep.controller.PcepClient; |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 27 | import org.onosproject.pcep.controller.PcepSyncStatus; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 28 | import org.onosproject.pcepio.protocol.PcepFactories; |
| 29 | import org.onosproject.pcepio.protocol.PcepFactory; |
| 30 | import org.onosproject.pcepio.protocol.PcepMessage; |
| 31 | import org.onosproject.pcepio.protocol.PcepVersion; |
| 32 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 33 | /** |
| 34 | * Representation of PCEP client adapter. |
| 35 | */ |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 36 | public class PcepClientAdapter implements PcepClient { |
| 37 | |
| 38 | private Channel channel; |
| 39 | protected String channelId; |
| 40 | |
| 41 | private boolean connected; |
| 42 | private PccId pccId; |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 43 | private ClientCapability capability; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 44 | |
| 45 | private PcepVersion pcepVersion; |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 46 | private PcepSyncStatus lspDbSyncStatus; |
| 47 | private PcepSyncStatus labelDbSyncStatus; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 48 | |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 49 | /** |
| 50 | * Initialize instance with specified parameters. |
| 51 | * |
| 52 | * @param pccId PCC id |
| 53 | * @param pcepVersion PCEP message version |
| 54 | */ |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 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 |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 114 | public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { |
| 115 | this.lspDbSyncStatus = syncStatus; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | @Override |
Avantika-Huawei | 7f7376a | 2016-05-11 17:07:50 +0530 | [diff] [blame] | 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; |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 131 | } |
Priyanka B | d2b2888 | 2016-04-04 16:57:04 +0530 | [diff] [blame] | 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 | } |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 142 | |
| 143 | @Override |
| 144 | public void addNode(PcepClient pc) { |
| 145 | } |
| 146 | |
| 147 | @Override |
| 148 | public void deleteNode(PccId pccId) { |
| 149 | } |
Phanendra Manda | 972ee9e | 2015-08-21 19:08:20 +0530 | [diff] [blame] | 150 | } |