Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cameo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shervin Nourbakhsh
cameo
Commits
88324b5f
Commit
88324b5f
authored
5 years ago
by
legoc
Browse files
Options
Downloads
Patches
Plain Diff
Use request socket for Server
parent
1b041459
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cameo-api-cpp/src/cameo/Server.cpp
+20
-35
20 additions, 35 deletions
cameo-api-cpp/src/cameo/Server.cpp
with
20 additions
and
35 deletions
cameo-api-cpp/src/cameo/Server.cpp
+
20
−
35
View file @
88324b5f
...
...
@@ -24,6 +24,7 @@
#include
"ProtoType.h"
#include
"EventThread.h"
#include
"impl/StreamSocketImpl.h"
#include
"impl/RequestSocketImpl.h"
using
namespace
std
;
...
...
@@ -110,10 +111,7 @@ std::unique_ptr<application::Instance> Server::start(const std::string& name, Op
int
Server
::
getStreamPort
(
const
std
::
string
&
name
)
{
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_OUTPUT
);
string
strRequestData
=
m_impl
->
createOutputRequest
(
name
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_OUTPUT
),
m_impl
->
createOutputRequest
(
name
));
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -133,16 +131,13 @@ std::unique_ptr<application::Instance> Server::start(const std::string& name, co
try
{
if
(
outputStream
)
{
//
w
e connect to the stream port before starting the application
// so that we are sure that the ENDSTREAM message will be received even if the application terminates rapidly
//
W
e connect to the stream port before starting the application
// so that we are sure that the ENDSTREAM message will be received even if the application terminates rapidly
.
unique_ptr
<
OutputStreamSocket
>
socket
=
createOutputStreamSocket
(
getStreamPort
(
name
));
instance
->
setOutputStreamSocket
(
socket
);
}
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_START
);
string
strRequestData
=
m_impl
->
createStartRequest
(
name
,
args
,
application
::
This
::
getReference
());
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_START
),
m_impl
->
createStartRequest
(
name
,
args
,
application
::
This
::
getReference
()));
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -162,18 +157,18 @@ std::unique_ptr<application::Instance> Server::start(const std::string& name, co
Response
Server
::
stopApplicationAsynchronously
(
int
id
,
bool
immediately
)
const
{
string
strR
equestType
;
string
strR
equestData
;
string
r
equestType
Part
;
string
r
equestData
Part
;
if
(
immediately
)
{
strR
equestType
=
m_impl
->
createRequestType
(
PROTO_KILL
);
strR
equestData
=
m_impl
->
createKillRequest
(
id
);
r
equestType
Part
=
m_impl
->
createRequestType
(
PROTO_KILL
);
r
equestData
Part
=
m_impl
->
createKillRequest
(
id
);
}
else
{
strR
equestType
=
m_impl
->
createRequestType
(
PROTO_STOP
);
strR
equestData
=
m_impl
->
createStopRequest
(
id
);
r
equestType
Part
=
m_impl
->
createRequestType
(
PROTO_STOP
);
r
equestData
Part
=
m_impl
->
createStopRequest
(
id
);
}
unique_ptr
<
zmq
::
message_t
>
reply
=
m_
impl
->
tryRequestWithOnePartReply
(
strR
equestType
,
strR
equestData
,
m_serverEndpoin
t
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_
requestSocket
->
request
(
r
equestType
Part
,
r
equestData
Par
t
);
proto
::
RequestResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -187,9 +182,7 @@ application::InstanceArray Server::connectAll(const std::string& name, Option op
application
::
InstanceArray
instances
;
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_CONNECT
);
string
strRequestData
=
m_impl
->
createConnectRequest
(
name
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_CONNECT
),
m_impl
->
createConnectRequest
(
name
));
proto
::
ApplicationInfoListResponse
response
;
response
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -269,9 +262,7 @@ void Server::killAllAndWaitFor(const std::string& name) {
bool
Server
::
isAlive
(
int
id
)
const
{
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_ISALIVE
);
string
strRequestData
=
m_impl
->
createIsAliveRequest
(
id
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_ISALIVE
),
m_impl
->
createIsAliveRequest
(
id
));
proto
::
IsAliveResponse
isAliveResponse
;
isAliveResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -283,9 +274,7 @@ std::vector<application::Configuration> Server::getApplicationConfigurations() c
vector
<
application
::
Configuration
>
configVector
;
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_ALLAVAILABLE
);
string
strRequestData
=
m_impl
->
createAllAvailableRequest
();
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_ALLAVAILABLE
),
m_impl
->
createAllAvailableRequest
());
proto
::
AllAvailableResponse
allAvailableResponse
;
allAvailableResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -309,11 +298,9 @@ std::vector<application::Configuration> Server::getApplicationConfigurations() c
std
::
vector
<
application
::
Info
>
Server
::
getApplicationInfos
()
const
{
vector
<
application
::
Info
>
info
Vector
;
vector
<
application
::
Info
>
info
s
;
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_SHOWALL
);
string
strRequestData
=
m_impl
->
createShowAllRequest
();
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_SHOWALL
),
m_impl
->
createShowAllRequest
());
proto
::
ApplicationInfoListResponse
response
;
response
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
@@ -328,10 +315,10 @@ std::vector<application::Info> Server::getApplicationInfos() const {
info
.
pastapplicationstates
(),
info
.
args
());
info
Vector
.
push_back
(
applicationInfo
);
info
s
.
push_back
(
applicationInfo
);
}
return
info
Vector
;
return
info
s
;
}
std
::
vector
<
application
::
Info
>
Server
::
getApplicationInfos
(
const
std
::
string
&
name
)
const
{
...
...
@@ -355,10 +342,8 @@ std::unique_ptr<EventStreamSocket> Server::openEventStream() {
std
::
unique_ptr
<
application
::
Subscriber
>
Server
::
createSubscriber
(
int
id
,
const
std
::
string
&
publisherName
,
const
std
::
string
&
instanceName
)
const
{
string
strRequestType
=
m_impl
->
createRequestType
(
PROTO_CONNECTPUBLISHER
);
string
strRequestData
=
m_impl
->
createConnectPublisherRequest
(
id
,
publisherName
);
unique_ptr
<
zmq
::
message_t
>
reply
=
m_requestSocket
->
request
(
m_impl
->
createRequestType
(
PROTO_CONNECTPUBLISHER
),
m_impl
->
createConnectPublisherRequest
(
id
,
publisherName
));
unique_ptr
<
zmq
::
message_t
>
reply
=
m_impl
->
tryRequestWithOnePartReply
(
strRequestType
,
strRequestData
,
m_serverEndpoint
);
proto
::
PublisherResponse
requestResponse
;
requestResponse
.
ParseFromArray
((
*
reply
).
data
(),
(
*
reply
).
size
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment