Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.provider.pcep.topology.impl; |
| 17 | |
| 18 | import static org.junit.Assert.assertNotNull; |
| 19 | |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 20 | import java.util.HashMap; |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 21 | import java.util.List; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 22 | import java.util.Map; |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 23 | import java.util.concurrent.RejectedExecutionException; |
| 24 | |
| 25 | import org.jboss.netty.channel.Channel; |
| 26 | import org.onosproject.pcep.controller.ClientCapability; |
| 27 | import org.onosproject.pcep.controller.PccId; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 28 | import org.onosproject.pcep.controller.LspKey; |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 29 | import org.onosproject.pcep.controller.PcepClient; |
| 30 | import org.onosproject.pcep.controller.PcepSyncStatus; |
| 31 | import org.onosproject.pcepio.protocol.PcepFactories; |
| 32 | import org.onosproject.pcepio.protocol.PcepFactory; |
| 33 | import org.onosproject.pcepio.protocol.PcepMessage; |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 34 | import org.onosproject.pcepio.protocol.PcepStateReport; |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 35 | import org.onosproject.pcepio.protocol.PcepVersion; |
| 36 | |
| 37 | /** |
| 38 | * Representation of PCEP client adapter. |
| 39 | */ |
| 40 | public class PcepClientAdapter implements PcepClient { |
| 41 | |
| 42 | private Channel channel; |
| 43 | protected String channelId; |
| 44 | |
| 45 | private boolean connected; |
| 46 | private PccId pccId; |
| 47 | private ClientCapability capability; |
| 48 | |
| 49 | private PcepVersion pcepVersion; |
| 50 | private PcepSyncStatus lspDbSyncStatus; |
| 51 | private PcepSyncStatus labelDbSyncStatus; |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 52 | private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>(); |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * Initialize instance with specified parameters. |
| 56 | * |
| 57 | * @param pccId PCC id |
| 58 | * @param pcepVersion PCEP message version |
| 59 | */ |
| 60 | public void init(PccId pccId, PcepVersion pcepVersion) { |
| 61 | this.pccId = pccId; |
| 62 | this.pcepVersion = pcepVersion; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public final void disconnectClient() { |
| 67 | this.channel.close(); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public final void sendMessage(PcepMessage m) { |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public final void sendMessage(List<PcepMessage> msgs) { |
| 76 | try { |
| 77 | PcepMessage pcepMsg = msgs.get(0); |
| 78 | assertNotNull("PCEP MSG should be created.", pcepMsg); |
| 79 | } catch (RejectedExecutionException e) { |
| 80 | throw e; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public final boolean isConnected() { |
| 86 | return this.connected; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public String channelId() { |
| 91 | return channelId; |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public final PccId getPccId() { |
| 96 | return this.pccId; |
| 97 | }; |
| 98 | |
| 99 | @Override |
| 100 | public final String getStringId() { |
| 101 | return this.pccId.toString(); |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public final void handleMessage(PcepMessage m) { |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public boolean isOptical() { |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | @Override |
| 114 | public PcepFactory factory() { |
| 115 | return PcepFactories.getFactory(pcepVersion); |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { |
| 120 | this.lspDbSyncStatus = syncStatus; |
| 121 | } |
| 122 | |
| 123 | @Override |
| 124 | public PcepSyncStatus lspDbSyncStatus() { |
| 125 | return lspDbSyncStatus; |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { |
| 130 | this.labelDbSyncStatus = syncStatus; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public PcepSyncStatus labelDbSyncStatus() { |
| 135 | return labelDbSyncStatus; |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public void setCapability(ClientCapability capability) { |
| 140 | this.capability = capability; |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public ClientCapability capability() { |
| 145 | return capability; |
| 146 | } |
| 147 | |
| 148 | @Override |
| 149 | public void addNode(PcepClient pc) { |
| 150 | } |
| 151 | |
| 152 | @Override |
| 153 | public void deleteNode(PccId pccId) { |
| 154 | } |
Priyanka B | 413fbe8 | 2016-05-26 11:44:45 +0530 | [diff] [blame] | 155 | |
| 156 | @Override |
| 157 | public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) { |
| 158 | lspDelegationInfo.put(lspKey, dFlag); |
| 159 | } |
| 160 | |
| 161 | @Override |
| 162 | public Boolean delegationInfo(LspKey lspKey) { |
| 163 | return lspDelegationInfo.get(lspKey); |
| 164 | } |
Avantika-Huawei | d1e36bd | 2016-05-26 12:47:16 +0530 | [diff] [blame] | 165 | |
| 166 | @Override |
| 167 | public void initializeSyncMsgList(PccId pccId) { |
| 168 | // TODO Auto-generated method stub |
| 169 | |
| 170 | } |
| 171 | |
| 172 | @Override |
| 173 | public List<PcepStateReport> getSyncMsgList(PccId pccId) { |
| 174 | // TODO Auto-generated method stub |
| 175 | return null; |
| 176 | } |
| 177 | |
| 178 | @Override |
| 179 | public void removeSyncMsgList(PccId pccId) { |
| 180 | // TODO Auto-generated method stub |
| 181 | |
| 182 | } |
| 183 | |
| 184 | @Override |
| 185 | public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { |
| 186 | // TODO Auto-generated method stub |
| 187 | |
| 188 | } |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 189 | } |