Open Kilda Java Documentation
FlowAdapter.java
Go to the documentation of this file.
1
/* Copyright 2018 Telstra Open Source
2
*
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
package
org.openkilda.pce.api;
17
18
import
org
.
openkilda
.
messaging
.
Utils
;
19
import
org
.
openkilda
.
messaging
.
info
.
event
.
PathInfoData
;
20
import
org
.
openkilda
.
messaging
.
model
.
Flow
;
21
import
org
.
openkilda
.
messaging
.
model
.
SwitchId
;
22
import
org
.
openkilda
.
messaging
.
payload
.
flow
.
FlowState
;
23
24
import
org
.neo4j.driver.v1.Record;
25
26
import
java.io.IOException;
27
28
public
class
FlowAdapter
{
29
private
final
Flow
flow;
30
31
public
FlowAdapter
(Record dbRecord) {
32
String pathJson = dbRecord.get(
"path"
).asString().trim();
33
34
if
(pathJson.equals(
"null"
)) {
35
pathJson =
"{\"path\": [], \"latency_ns\": 0, \"timestamp\": 0}"
;
36
}
37
38
/*
39
* The 'clazz' value is stripped when storing in the database, but we need it in the string
40
* in order for MAPPER to do its thing. So, let's add it back in at the very beginning.
41
*/
42
String start = pathJson.substring(0, pathJson.length() - 1);
43
PathInfoData
path
;
44
pathJson = start +
", \"clazz\":\"org.openkilda.messaging.info.event.PathInfoData\"}"
;
45
46
try
{
47
path
=
Utils
.
MAPPER
.readValue(pathJson,
PathInfoData
.class);
48
}
catch
(IOException e) {
49
throw
new
IllegalArgumentException(String.format(
50
"Can\'t deserialize flow path: json=%s"
, pathJson), e);
51
}
52
53
flow =
new
Flow
(
54
dbRecord.get(
Utils
.
FLOW_ID
).asString(),
55
dbRecord.get(
"bandwidth"
).asInt(),
56
dbRecord.get(
"ignore_bandwidth"
).asBoolean(),
57
dbRecord.get(
"cookie"
).asLong(),
58
dbRecord.get(
"description"
).asString(),
59
dbRecord.get(
"last_updated"
).asString(),
60
new
SwitchId
(dbRecord.get(
"src_switch"
).asString()),
61
new
SwitchId
(dbRecord.get(
"dst_switch"
).asString()),
62
dbRecord.get(
"src_port"
).asInt(),
63
dbRecord.get(
"dst_port"
).asInt(),
64
dbRecord.get(
"src_vlan"
).asInt(),
65
dbRecord.get(
"dst_vlan"
).asInt(),
66
dbRecord.get(
"meter_id"
).asInt(),
67
dbRecord.get(
"transit_vlan"
).asInt(),
68
path
,
FlowState
.
CACHED
69
);
70
}
71
72
public
Flow
getFlow
() {
73
return
flow;
74
}
75
}
org.openkilda.messaging.payload.flow.FlowState.CACHED
CACHED
Definition:
FlowState.java:48
topologylistener.config.path
path
Definition:
config.py:23
org.openkilda.messaging.payload
Definition:
FeatureTogglePayload.java:16
org.openkilda.messaging.Utils.MAPPER
static final ObjectMapper MAPPER
Definition:
Utils.java:31
org.openkilda.messaging.payload.flow.FlowState
Definition:
FlowState.java:24
org.openkilda.messaging.model
Definition:
AbstractNetworkEndpoint.java:16
org.openkilda.messaging
Definition:
BaseMessage.java:16
org
org.openkilda.messaging.payload.flow
Definition:
FlowCacheSyncResults.java:16
org.openkilda.pce.api.FlowAdapter.FlowAdapter
FlowAdapter(Record dbRecord)
Definition:
FlowAdapter.java:31
org.openkilda.messaging.model.Flow
Definition:
Flow.java:42
org.openkilda.pce.api.FlowAdapter
Definition:
FlowAdapter.java:28
org.openkilda
org.openkilda.messaging.Utils
Definition:
Utils.java:27
org.openkilda.pce.api.FlowAdapter.getFlow
Flow getFlow()
Definition:
FlowAdapter.java:72
org.openkilda.messaging.info
Definition:
CacheTimeTag.java:15
org.openkilda.messaging.model.SwitchId
Definition:
SwitchId.java:29
org.openkilda.messaging.Utils.FLOW_ID
static final String FLOW_ID
Definition:
Utils.java:61
org.openkilda.messaging.info.event.PathInfoData
Definition:
PathInfoData.java:40
org.openkilda.messaging.info.event
Definition:
IslChangeType.java:16
open-kilda-develop
services
src
pce
src
main
java
org
openkilda
pce
api
FlowAdapter.java
Generated by
1.8.14