Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery
/
mde
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dcc59bb1
authored
Dec 06, 2016
by
Eli Ben Baruch
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
mde - phase 1 : traffic and parking support
parent
bb23f01d
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
64 additions
and
120 deletions
cfg/adapter.ge.parking.json
cfg/adapter.ge.traffic.json
cfg/adapters.json
cfg/service.ge.traffic.json
cfg/services.json
docker-compose.yml
src/main/java/logic/adapter/BaseAdapter.java
src/main/java/logic/adapter/HttpAdapter/HttpAdapter.java
src/main/java/logic/webSocket/WebSocketConnection.java
src/main/java/logic/webSocket/WebSocketEventListener.java
src/main/java/logic/webSocket/WebSocketManager.java
cfg/adapter.ge.parking.json
View file @
dcc59bb1
...
@@ -34,6 +34,10 @@
...
@@ -34,6 +34,10 @@
},
{
},
{
"name"
:
"q"
,
"name"
:
"q"
,
"value"
:
"location-type:PARKING_SPOT"
"value"
:
"location-type:PARKING_SPOT"
},
{
"name"
:
"size"
,
"value"
:
"30"
}],
}],
"headers"
:
[],
"headers"
:
[],
"content"
:
null
"content"
:
null
...
...
cfg/adapter.ge.traffic.json
View file @
dcc59bb1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"config"
:
{
"config"
:
{
"metaDataConfig"
:
"logic.adapter.HttpAdapter.model.HttpAdapterConfig"
,
"metaDataConfig"
:
"logic.adapter.HttpAdapter.model.HttpAdapterConfig"
,
"configHttpRequestParams"
:
{
"configHttpRequestParams"
:
{
"baseUrl"
:
"ie-
parking
.run.aws-usw02-pr.ice.predix.io/"
,
"baseUrl"
:
"ie-
traffic
.run.aws-usw02-pr.ice.predix.io/"
,
"basePath"
:
"v1/"
,
"basePath"
:
"v1/"
,
"headers"
:
[{
"headers"
:
[{
"name"
:
"predix-zone-id"
,
"name"
:
"predix-zone-id"
,
...
@@ -21,20 +21,19 @@
...
@@ -21,20 +21,19 @@
}
}
}
}
},
},
"flows"
:
[{
"flows"
:
[
{
"action"
:
{
"action"
:
{
"metaDataActionClass"
:
"logic.adapter.HttpAdapter.action.SimpleHttpAction"
,
"metaDataActionClass"
:
"logic.adapter.HttpAdapter.action.SimpleHttpAction"
,
"params"
:
{
"params"
:
{
"id"
:
"GetAllTrafficLanes
"
,
"id"
:
"subscribe
"
,
"httpMethod"
:
"GET"
,
"httpMethod"
:
"GET"
,
"path"
:
"locations/search
"
,
"path"
:
"assets/$mdeKey/live-events
"
,
"queryParams"
:
[{
"queryParams"
:
[{
"name"
:
"bbox"
,
"name"
:
"event-types"
,
"value"
:
"32.123:-117,32.723179:-117.172655"
"value"
:
"TFEVT"
},
{
}
"name"
:
"q"
,
],
"value"
:
"location-type:TRAFFIC_LANES"
}],
"headers"
:
[],
"headers"
:
[],
"content"
:
null
"content"
:
null
}
}
...
@@ -45,104 +44,19 @@
...
@@ -45,104 +44,19 @@
"actions"
:
[{
"actions"
:
[{
"metaDataActionClass"
:
"logic.adapter.action.ExtractValueAction"
,
"metaDataActionClass"
:
"logic.adapter.action.ExtractValueAction"
,
"params"
:
{
"params"
:
{
"path"
:
"/_embedded/locations"
,
"path"
:
"/url"
,
"valueType"
:
"ARRAY-NODE"
}
},
{
"metaDataActionClass"
:
"logic.adapter.action.JsonConvertAction"
,
"params"
:
{
"intermediateOperations"
:
[{
"metaDataOperationClass"
:
"logic.adapter.HttpAdapter.model.MapJsonToStringOperation"
,
"operationParams"
:
{
"action"
:
{
"metaDataActionClass"
:
"logic.adapter.action.ExtractValueAction"
,
"params"
:
{
"path"
:
"/_links/self/href"
,
"valueType"
:
"STRING"
"valueType"
:
"STRING"
}
}
}
}
},
{
"metaDataOperationClass"
:
"logic.adapter.HttpAdapter.model.MapStringToJsonOperation"
,
"operationParams"
:
{
"action"
:
{
"metaDataActionClass"
:
"logic.adapter.HttpAdapter.action.SimpleHttpAction"
,
"params"
:
{
"id"
:
"getLocationDetails"
,
"httpMethod"
:
"GET"
,
"path"
:
"locations/$id"
,
"queryParams"
:
null
,
"headers"
:
[],
"content"
:
null
}
},
"id"
:
"lastToken"
}
},
{
"metaDataOperationClass"
:
"logic.adapter.HttpAdapter.model.MapJsonToJsonOperation"
,
"operationParams"
:
{
"action"
:
{
"metaDataActionClass"
:
"logic.adapter.action.JsonPatchAction"
,
"params"
:
{
"fileInput"
:
null
,
"filePatch"
:
"trafficLaneJsonPatch.json"
}
}
}
}],
"terminateOperation"
:
null
}
}]
},
"onError"
:
{
"actionsInput"
:
"CONTENT"
,
"actions"
:
[]
}
}
},
{
"action"
:
{
"metaDataActionClass"
:
"logic.adapter.HttpAdapter.action.SimpleHttpAction"
,
"params"
:
{
"id"
:
"getLocationDetails"
,
"httpMethod"
:
"GET"
,
"path"
:
"locations/$id"
,
"queryParams"
:
[],
"headers"
:
[],
"content"
:
null
}
},
"onResponse"
:
{
"onSuccess"
:
{
"actionsInput"
:
"CONTENT"
,
"actions"
:
[]
},
"onError"
:
{
"actionsInput"
:
"CONTENT"
,
"actions"
:
[]
}
}
},
},
{
{
"action"
:
{
"metaDataActionClass"
:
"logic.adapter.HttpAdapter.action.WebSocketAction"
,
"metaDataActionClass"
:
"logic.adapter.HttpAdapter.action.SimpleHttpAction"
,
"params"
:
{
"params"
:
{
"id"
:
"subscribe"
,
"headers"
:[{
"httpMethod"
:
"GET"
,
"name"
:
"predix-zone-id"
,
"path"
:
"assets/$id/live-events"
,
"value"
:
"b6fc22b6-ad71-423e-867b-a1b197f6cfc2"
"queryParams"
:
[{
}]
"name"
:
"event-types"
,
"value"
:
"TFEVT"
}
],
"headers"
:
[],
"content"
:
null
}
}
},
}]
"onResponse"
:
{
"onSuccess"
:
{
"actionsInput"
:
"CONTENT"
,
"actions"
:
[]
},
},
"onError"
:
{
"onError"
:
{
"actionsInput"
:
"CONTENT"
,
"actionsInput"
:
"CONTENT"
,
...
...
cfg/adapters.json
View file @
dcc59bb1
...
@@ -2,5 +2,9 @@
...
@@ -2,5 +2,9 @@
"adapters"
:
[{
"adapters"
:
[{
"id"
:
"adapter.ge.parking"
,
"id"
:
"adapter.ge.parking"
,
"type"
:
"HttpAdapter"
"type"
:
"HttpAdapter"
},
{
"id"
:
"adapter.ge.traffic"
,
"type"
:
"HttpAdapter"
}]
}]
}
}
\ No newline at end of file
cfg/service.ge.traffic.json
0 → 100644
View file @
dcc59bb1
{
"apiList"
:
[
{
"apiIn"
:
"subscribe/$mde-id/$uid"
,
"method"
:
"POST"
,
"actions"
:
[{
"adapterId"
:
"adapter.ge.traffic"
,
"apiOut"
:
"subscribe"
}]
}
]
}
cfg/services.json
View file @
dcc59bb1
{
{
"services"
:
[
{
"id"
:
"ge.parking"
}
]
"services"
:
[
{
"id"
:
"ge.parking"
}
,
{
"id"
:
"ge.traffic"
}
]
}
}
\ No newline at end of file
docker-compose.yml
View file @
dcc59bb1
...
@@ -8,4 +8,5 @@ mde:
...
@@ -8,4 +8,5 @@ mde:
-
"
8200:8000"
-
"
8200:8000"
-
"
50040:50040"
-
"
50040:50040"
extra_hosts
:
extra_hosts
:
-
"
transportation:172.16.1.151"
-
"
parking:172.16.1.244"
-
"
parking:172.16.1.244"
\ No newline at end of file
src/main/java/logic/adapter/BaseAdapter.java
View file @
dcc59bb1
...
@@ -14,7 +14,7 @@ import java.lang.reflect.TypeVariable;
...
@@ -14,7 +14,7 @@ import java.lang.reflect.TypeVariable;
*/
*/
public
abstract
class
BaseAdapter
<
T
extends
BaseFlow
,
TypeIn
/*must be as TypeIn of BaseFlow*/
,
public
abstract
class
BaseAdapter
<
T
extends
BaseFlow
,
TypeIn
/*must be as TypeIn of BaseFlow*/
,
TypeOut
/*must be as TypeOut of BaseFlow*/
>
{
TypeOut
/*must be as TypeOut of BaseFlow*/
>
{
pr
ivate
String
adapterId
=
null
;
pr
otected
String
adapterId
=
null
;
private
AdapterModel
<
T
>
model
;
private
AdapterModel
<
T
>
model
;
public
ILogger
getLogger
()
{
public
ILogger
getLogger
()
{
...
...
src/main/java/logic/adapter/HttpAdapter/HttpAdapter.java
View file @
dcc59bb1
...
@@ -57,13 +57,25 @@ public class HttpAdapter extends BaseAdapter<HttpFlow, RequestParams, SimpleHttp
...
@@ -57,13 +57,25 @@ public class HttpAdapter extends BaseAdapter<HttpFlow, RequestParams, SimpleHttp
httpClient
=
new
SimpleHttpClient
();
httpClient
=
new
SimpleHttpClient
();
httpClient
.
Initialize
(
100
);
httpClient
.
Initialize
(
100
);
//parking
List
<
NameValueParam
>
headers
=
new
ArrayList
<>();
List
<
NameValueParam
>
headers
=
new
ArrayList
<>();
NameValueParam
header
=
new
NameValueParam
();
NameValueParam
header
=
new
NameValueParam
();
if
(
this
.
adapterId
.
equals
(
"adapter.ge.parking"
))
{
//parking
header
.
setName
(
"predix-zone-id"
);
header
.
setName
(
"predix-zone-id"
);
header
.
setValue
(
"c54e3e63-8dc6-425e-a533-64e061f64023"
);
header
.
setValue
(
"c54e3e63-8dc6-425e-a533-64e061f64023"
);
headers
.
add
(
header
);
headers
.
add
(
header
);
this
.
webSocketManager
=
new
WebSocketManager
(
authClient
,
headers
);
}
//traffic
else
if
(
this
.
adapterId
.
equals
(
"adapter.ge.traffic"
)){
header
.
setName
(
"predix-zone-id"
);
header
.
setValue
(
"b6fc22b6-ad71-423e-867b-a1b197f6cfc2"
);
headers
.
add
(
header
);
}
this
.
webSocketManager
=
new
WebSocketManager
(
authClient
,
headers
,
adapterId
);
this
.
setModelReferences
();
this
.
setModelReferences
();
...
@@ -150,9 +162,6 @@ public class HttpAdapter extends BaseAdapter<HttpFlow, RequestParams, SimpleHttp
...
@@ -150,9 +162,6 @@ public class HttpAdapter extends BaseAdapter<HttpFlow, RequestParams, SimpleHttp
}
}
}
}
}
}
// this.setHttpActionsReferences(actionsListOnSuccess.getActions());
// actionsListOnError = onHttpResponse.getOnError();
// this.setHttpActionsReferences(actionsListOnError.getActions());
}
}
}
}
}
}
...
@@ -176,12 +185,6 @@ public class HttpAdapter extends BaseAdapter<HttpFlow, RequestParams, SimpleHttp
...
@@ -176,12 +185,6 @@ public class HttpAdapter extends BaseAdapter<HttpFlow, RequestParams, SimpleHttp
operation
.
getOperationParams
().
setAdapterReferences
(
config
.
getConfigHttpRequestParams
(),
operation
.
getOperationParams
().
setAdapterReferences
(
config
.
getConfigHttpRequestParams
(),
httpClient
,
httpClient
,
authClient
);
authClient
);
// if (operation.getOperationParams().getClass().isInstance(MapOperationParams.class)){
// BaseAction baseAction = ((MapOperationParams)operation.getOperationParams()).getAction();
// if (baseAction.getType().equals(SimpleHttpAction.TYPE))
// ((SimpleHttpAction)baseAction).setAdapterReferences(config.getConfigHttpRequestParams(),
// httpClient,
// authClient);
}
}
}
}
...
...
src/main/java/logic/webSocket/WebSocketConnection.java
View file @
dcc59bb1
...
@@ -15,6 +15,7 @@ import java.util.List;
...
@@ -15,6 +15,7 @@ import java.util.List;
* Created by eli on 12/4/16.
* Created by eli on 12/4/16.
*/
*/
public
class
WebSocketConnection
extends
Thread
{
public
class
WebSocketConnection
extends
Thread
{
private
final
String
adapterId
;
private
final
String
uid
;
private
final
String
uid
;
private
final
OnEventDetails
details
;
private
final
OnEventDetails
details
;
private
final
String
connectionId
;
private
final
String
connectionId
;
...
@@ -33,13 +34,14 @@ public class WebSocketConnection extends Thread {
...
@@ -33,13 +34,14 @@ public class WebSocketConnection extends Thread {
private
boolean
dontStop
;
private
boolean
dontStop
;
public
WebSocketConnection
(
String
connectionId
,
public
WebSocketConnection
(
String
adapterId
,
String
connectionId
,
String
uid
,
String
uid
,
String
webSocketUrl
,
String
webSocketUrl
,
final
OAuth2Client
auth2Client
,
final
OAuth2Client
auth2Client
,
List
<
NameValueParam
>
httpHeaders
,
List
<
NameValueParam
>
httpHeaders
,
OnEventDetails
details
)
throws
IOException
,
ErrorLoginException
,
WebSocketException
{
OnEventDetails
details
)
throws
IOException
,
ErrorLoginException
,
WebSocketException
{
super
();
super
();
this
.
adapterId
=
adapterId
;
this
.
dontStop
=
true
;
this
.
dontStop
=
true
;
this
.
factory
=
new
WebSocketFactory
();
this
.
factory
=
new
WebSocketFactory
();
this
.
connectionId
=
connectionId
;
this
.
connectionId
=
connectionId
;
...
@@ -75,7 +77,7 @@ public class WebSocketConnection extends Thread {
...
@@ -75,7 +77,7 @@ public class WebSocketConnection extends Thread {
webSocket
.
addHeader
(
header
.
getName
(),
header
.
getValue
());
webSocket
.
addHeader
(
header
.
getName
(),
header
.
getValue
());
}
}
}
}
this
.
eventListener
=
new
WebSocketEventListener
(
connectionId
,
this
.
uid
,
details
,
null
);
this
.
eventListener
=
new
WebSocketEventListener
(
adapterId
,
connectionId
,
this
.
uid
,
details
,
null
);
webSocket
.
addListener
(
eventListener
);
webSocket
.
addListener
(
eventListener
);
webSocket
.
setPingInterval
(
50
*
1000
);
webSocket
.
setPingInterval
(
50
*
1000
);
...
...
src/main/java/logic/webSocket/WebSocketEventListener.java
View file @
dcc59bb1
This diff is collapsed.
Click to expand it.
src/main/java/logic/webSocket/WebSocketManager.java
View file @
dcc59bb1
...
@@ -17,12 +17,14 @@ import java.util.Map;
...
@@ -17,12 +17,14 @@ import java.util.Map;
*/
*/
public
class
WebSocketManager
{
public
class
WebSocketManager
{
private
String
adapterId
;
private
Map
<
String
,
WebSocketConnection
>
webSocketConnections
;
private
Map
<
String
,
WebSocketConnection
>
webSocketConnections
;
private
List
<
NameValueParam
>
defaultHeaders
;
private
List
<
NameValueParam
>
defaultHeaders
;
private
OAuth2Client
auth2Client
;
private
OAuth2Client
auth2Client
;
public
WebSocketManager
(
OAuth2Client
oAuth2Client
,
List
<
NameValueParam
>
defaultHeaders
)
public
WebSocketManager
(
OAuth2Client
oAuth2Client
,
List
<
NameValueParam
>
defaultHeaders
,
String
adapterId
)
{
{
this
.
adapterId
=
adapterId
;
this
.
webSocketConnections
=
new
HashMap
<>();
this
.
webSocketConnections
=
new
HashMap
<>();
this
.
defaultHeaders
=
defaultHeaders
;
this
.
defaultHeaders
=
defaultHeaders
;
this
.
auth2Client
=
oAuth2Client
;
this
.
auth2Client
=
oAuth2Client
;
...
@@ -50,7 +52,7 @@ public class WebSocketManager {
...
@@ -50,7 +52,7 @@ public class WebSocketManager {
String
key
=
sb
.
toString
();
String
key
=
sb
.
toString
();
WebSocketConnection
webSocketConnection
;
WebSocketConnection
webSocketConnection
;
if
(!
webSocketConnections
.
containsKey
(
connectionId
))
{
if
(!
webSocketConnections
.
containsKey
(
connectionId
))
{
webSocketConnection
=
new
WebSocketConnection
(
connectionId
,
uid
,
webSocketUrl
,
auth2Client
,
defaultHeaders
,
details
);
webSocketConnection
=
new
WebSocketConnection
(
adapterId
,
connectionId
,
uid
,
webSocketUrl
,
auth2Client
,
defaultHeaders
,
details
);
synchronized
(
webSocketConnection
){
synchronized
(
webSocketConnection
){
webSocketConnection
.
start
();
webSocketConnection
.
start
();
webSocketConnection
.
wait
();
webSocketConnection
.
wait
();
...
@@ -61,7 +63,6 @@ public class WebSocketManager {
...
@@ -61,7 +63,6 @@ public class WebSocketManager {
System
.
out
.
println
(
"websocket created successfully: "
+
connectionId
+
" "
+
"uid="
+
uid
+
" "
+
details
.
toString
());
System
.
out
.
println
(
"websocket created successfully: "
+
connectionId
+
" "
+
"uid="
+
uid
+
" "
+
details
.
toString
());
}
}
}
}
}
}
else
{
else
{
webSocketConnection
=
webSocketConnections
.
get
(
connectionId
);
webSocketConnection
=
webSocketConnections
.
get
(
connectionId
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment