Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
958471aa
Commit
958471aa
authored
Nov 11, 2016
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In transition from sink/source to endpoint
parent
d1324ce7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
32 deletions
+45
-32
libcaf_io/caf/io/basp_broker.hpp
libcaf_io/caf/io/basp_broker.hpp
+8
-14
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+18
-0
libcaf_io/src/middleman_actor.cpp
libcaf_io/src/middleman_actor.cpp
+5
-4
libcaf_io/test/datagram.cpp
libcaf_io/test/datagram.cpp
+14
-14
No files found.
libcaf_io/caf/io/basp_broker.hpp
View file @
958471aa
...
...
@@ -112,29 +112,22 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
// stores meta information for dgram endpoints
struct
endpoint_context
{
// stores information about remote datagram enpoints
struct
remote_endpoint
{
// local sink
datagram_sink_handle
sink
;
// ordering information
uint32_t
sequence_number_send
=
0
;
uint32_t
sequence_number_receive
=
0
;
// TODO: local buffer for ordering
uint16_t
remote_port
;
};
// our current processed BSAP header
basp
::
header
hdr
;
// local source
datagram_source_handle
source
;
endpoint_handle
hdl
;
// network-agnositc node identifier
node_id
id
;
// ports
uint16_t
remote_port
;
uint16_t
local_port
;
// pending operations to be performed after handshake completed
optional
<
response_promise
>
callback
;
// TODO: reliability things
// TODO:
ordering and
reliability things
};
void
set_context
(
connection_handle
hdl
);
void
set_context
(
datagram_source
_handle
hdl
);
void
set_context
(
endpoint
_handle
hdl
);
// pointer to ourselves
broker
*
self
;
...
...
@@ -144,10 +137,11 @@ struct basp_broker_state : proxy_registry::backend, basp::instance::callee {
// keeps context information for all open connections
std
::
unordered_map
<
connection_handle
,
connection_context
>
tcp_ctx
;
std
::
unordered_map
<
datagram_sink
_handle
,
endpoint_context
>
udp_ctx
;
std
::
unordered_map
<
endpoint
_handle
,
endpoint_context
>
udp_ctx
;
// points to the current context for callbacks such as `make_proxy`
connection_context
*
this_context
=
nullptr
;
endpoint_context
*
udp_context
=
nullptr
;
// stores handles to spawn servers for other nodes; these servers
// are spawned whenever the broker learns a new node ID and try to
...
...
libcaf_io/src/basp_broker.cpp
View file @
958471aa
...
...
@@ -465,6 +465,21 @@ void basp_broker_state::set_context(connection_handle hdl) {
this_context
=
&
i
->
second
;
}
void
basp_broker_state
::
set_context
(
endpoint_handle
hdl
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
auto
i
=
udp_ctx
.
find
(
hdl
);
if
(
i
==
udp_ctx
.
end
())
{
CAF_LOG_INFO
(
"create new BASP context:"
<<
CAF_ARG
(
hdl
));
i
=
udp_ctx
.
emplace
(
hdl
,
endpoint_context
{
basp
::
header
{
basp
::
message_type
::
client_handshake
,
0
,
0
,
0
,
none
,
none
,
invalid_actor_id
,
invalid_actor_id
},
hdl
,
none
,
0
,
0
,
none
}).
first
;
}
udp_context
=
&
i
->
second
;
}
/******************************************************************************
* basp_broker *
******************************************************************************/
...
...
@@ -525,6 +540,9 @@ behavior basp_broker::make_behavior() {
[
=
](
datagram_msg
&
msg
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
msg
.
handle
));
CAF_LOG_DEBUG
(
"Received new_datagram_msg: "
<<
CAF_ARG
(
msg
));
state
.
set_context
(
msg
.
handle
);
// auto& ctx = *state.udp_context;
//auto next = state.instance.handle(context(), msg, ctx.hdr, ...);
// TODO: implement this
// look for existing context or create a new one
// handle messge
...
...
libcaf_io/src/middleman_actor.cpp
View file @
958471aa
...
...
@@ -165,7 +165,8 @@ public:
}
else
if
(
std
::
distance
(
u
.
scheme
().
first
,
u
.
scheme
().
second
)
>=
3
&&
equal
(
std
::
begin
(
udp
),
std
::
end
(
udp
),
u
.
scheme
().
first
))
{
// connect to endpoint and initiate handhsake etc. (UDP)
auto
y
=
system
().
middleman
().
backend
().
new_datagram_sink
(
host
,
port
);
auto
y
=
system
().
middleman
().
backend
().
new_remote_endpoint
(
host
,
port
);
if
(
!
y
)
{
rp
.
deliver
(
std
::
move
(
y
.
error
()));
return
{};
...
...
@@ -256,11 +257,11 @@ private:
equal
(
u
.
scheme
().
first
,
u
.
scheme
().
second
,
std
::
begin
(
udp
)))
{
// UDP
auto
res
=
system
().
middleman
().
backend
().
new_
datagram_source
(
u
.
port_as_int
(),
=
system
().
middleman
().
backend
().
new_
local_endpoint
(
u
.
port_as_int
(),
in
,
reuse_addr
);
if
(
!
res
)
return
std
::
move
(
res
.
error
());
datagram_source
_handle
hdl
=
res
->
first
;
endpoint
_handle
hdl
=
res
->
first
;
actual_port
=
res
->
second
;
anon_send
(
broker_
,
publish_atom
::
value
,
hdl
,
actual_port
,
std
::
move
(
whom
),
std
::
move
(
sigs
));
...
...
libcaf_io/test/datagram.cpp
View file @
958471aa
...
...
@@ -73,33 +73,33 @@ behavior make_pong_behavior() {
CAF_TEST_FIXTURE_SCOPE
(
datagrams
,
fixture
)
CAF_TEST
(
test_
datagram_sinks
)
{
CAF_TEST
(
test_
remote_endpoint
)
{
auto
&
mp
=
client_side_mm
.
backend
();
auto
hdl
=
client_side_mm
.
named_broker
<
basp_broker
>
(
atom
(
"BASP"
));
auto
basp
=
static_cast
<
basp_broker
*>
(
actor_cast
<
abstract_actor
*>
(
hdl
));
CAF_MESSAGE
(
"Calling new_
datagram_sink
"
);
auto
res1
=
mp
.
new_
datagram_sink
(
host
,
port
+
0
);
CAF_MESSAGE
(
"Calling new_
remote_endpoint
"
);
auto
res1
=
mp
.
new_
remote_endpoint
(
host
,
port
+
0
);
CAF_REQUIRE
(
res1
);
CAF_MESSAGE
(
"Calling assign_
datagram_sink
"
);
auto
res2
=
mp
.
assign_
datagram_sink
(
basp
,
*
res1
);
CAF_MESSAGE
(
"Calling assign_
endpoint (on
\"
remote
\"
endpoint).
"
);
auto
res2
=
mp
.
assign_
endpoint
(
basp
,
*
res1
);
CAF_REQUIRE
(
res2
);
CAF_MESSAGE
(
"Calling add_
datagram_sink
"
);
auto
res3
=
mp
.
add_
datagram_sink
(
basp
,
host
,
port
+
1
);
CAF_MESSAGE
(
"Calling add_
remote_endpoint.
"
);
auto
res3
=
mp
.
add_
remote_endpoint
(
basp
,
host
,
port
+
1
);
CAF_REQUIRE
(
res3
);
}
CAF_TEST
(
test_
datagram_sources
)
{
CAF_TEST
(
test_
local_endpoint
)
{
auto
&
mp
=
client_side_mm
.
backend
();
auto
hdl
=
client_side_mm
.
named_broker
<
basp_broker
>
(
atom
(
"BASP"
));
auto
basp
=
static_cast
<
basp_broker
*>
(
actor_cast
<
abstract_actor
*>
(
hdl
));
CAF_MESSAGE
(
"Calling new_
datagram_source
"
);
auto
res1
=
mp
.
new_
datagram_source
(
port
+
0
);
CAF_MESSAGE
(
"Calling new_
local_endpoint.
"
);
auto
res1
=
mp
.
new_
local_endpoint
(
port
+
0
);
CAF_REQUIRE
(
res1
);
CAF_MESSAGE
(
"Calling assign_
datagram_source
"
);
auto
res2
=
mp
.
assign_
datagram_source
(
basp
,
res1
->
first
);
CAF_MESSAGE
(
"Calling assign_
endpoint (on
\"
local
\"
endpoint).
"
);
auto
res2
=
mp
.
assign_
endpoint
(
basp
,
res1
->
first
);
CAF_REQUIRE
(
res2
);
CAF_MESSAGE
(
"Calling add_
datagram_source
"
);
auto
res3
=
mp
.
add_
datagram_source
(
basp
,
port
+
1
,
nullptr
);
CAF_MESSAGE
(
"Calling add_
local_endpoint.
"
);
auto
res3
=
mp
.
add_
local_endpoint
(
basp
,
port
+
1
,
nullptr
);
CAF_REQUIRE
(
res3
);
}
...
...
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