Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mcproxy
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
Issue 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fork
mcproxy
Commits
22e61c7f
Commit
22e61c7f
authored
5 years ago
by
Jonas Höglund
Browse files
Options
Downloads
Patches
Plain Diff
Handle multiple upstream interfaces.
parent
3f07228a
No related branches found
No related tags found
No related merge requests found
Pipeline
#223
canceled
5 years ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mcproxy/include/parser/interface.hpp
+4
-0
4 additions, 0 deletions
mcproxy/include/parser/interface.hpp
mcproxy/src/parser/configuration.cpp
+32
-12
32 additions, 12 deletions
mcproxy/src/parser/configuration.cpp
mcproxy/src/parser/interface.cpp
+40
-0
40 additions, 0 deletions
mcproxy/src/parser/interface.cpp
with
76 additions
and
12 deletions
mcproxy/include/parser/interface.hpp
+
4
−
0
View file @
22e61c7f
...
@@ -220,6 +220,10 @@ public:
...
@@ -220,6 +220,10 @@ public:
const
std
::
string
&
get_instance_name
()
const
;
const
std
::
string
&
get_instance_name
()
const
;
const
std
::
list
<
std
::
shared_ptr
<
interface
>>&
get_upstreams
()
const
;
const
std
::
list
<
std
::
shared_ptr
<
interface
>>&
get_upstreams
()
const
;
const
std
::
list
<
std
::
shared_ptr
<
interface
>>&
get_downstreams
()
const
;
const
std
::
list
<
std
::
shared_ptr
<
interface
>>&
get_downstreams
()
const
;
bool
delete_upstream
(
const
std
::
shared_ptr
<
interface
>&
id
);
bool
delete_downstream
(
const
std
::
shared_ptr
<
interface
>&
id
);
int
get_upstream_count
()
const
;
int
get_downstream_count
()
const
;
const
std
::
list
<
std
::
shared_ptr
<
rule_binding
>>&
get_global_settings
()
const
;
const
std
::
list
<
std
::
shared_ptr
<
rule_binding
>>&
get_global_settings
()
const
;
int
get_table_number
()
const
;
int
get_table_number
()
const
;
bool
get_user_selected_table_number
()
const
;
bool
get_user_selected_table_number
()
const
;
...
...
This diff is collapsed.
Click to expand it.
mcproxy/src/parser/configuration.cpp
+
32
−
12
View file @
22e61c7f
...
@@ -212,25 +212,45 @@ void configuration::initalize_interfaces()
...
@@ -212,25 +212,45 @@ void configuration::initalize_interfaces()
};
};
for
(
auto
&
inst
:
def_set
)
{
for
(
auto
&
inst
:
def_set
)
{
auto
downstreams
=
inst
->
get_downstreams
();
for
(
auto
&
downstream
:
downstreams
)
{
try
{
add
(
downstream
);
}
catch
(
const
char
*
s
)
{
inst
->
delete_downstream
(
downstream
);
continue
;
}
}
try
{
if
(
inst
->
get_downstream_count
()
==
0
)
{
for
(
auto
&
downstream
:
inst
->
get_downstreams
())
{
m_inst_def_set
.
erase
(
inst
);
add
(
downstream
)
;
continue
;
}
}
for
(
auto
&
upstream
:
inst
->
get_upstreams
())
{
auto
upstreams
=
inst
->
get_upstreams
();
add
(
upstream
);
for
(
auto
&
upstream
:
upstreams
)
{
try
{
add
(
upstream
);
}
catch
(
const
char
*
s
)
{
inst
->
delete_upstream
(
upstream
);
continue
;
}
}
}
if
(
!
m_interfaces_map
.
insert
(
std
::
pair
<
std
::
string
,
std
::
shared_ptr
<
interfaces
>>
(
inst
->
get_instance_name
(),
result
)).
second
)
{
if
(
inst
->
get_upstream_count
()
==
0
)
{
HC_LOG_ERROR
(
"proxy instance "
<<
inst
->
get_instance_name
()
<<
" already exists"
);
m_inst_def_set
.
erase
(
inst
);
throw
"failed to add instance"
;
continue
;
}
}
}
catch
(
const
char
*
s
)
{
try
{
m_inst_def_set
.
erase
(
inst
);
if
(
!
m_interfaces_map
.
insert
(
std
::
pair
<
std
::
string
,
std
::
shared_ptr
<
interfaces
>>
(
inst
->
get_instance_name
(),
result
)).
second
)
{
continue
;
HC_LOG_ERROR
(
"proxy instance "
<<
inst
->
get_instance_name
()
<<
" already exists"
);
}
throw
"failed to add instance"
;
}
}
catch
(
const
char
*
s
)
{
m_inst_def_set
.
erase
(
inst
);
continue
;
}
}
}
if
(
m_inst_def_set
.
size
()
==
0
)
{
if
(
m_inst_def_set
.
size
()
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
mcproxy/src/parser/interface.cpp
+
40
−
0
View file @
22e61c7f
...
@@ -517,6 +517,46 @@ const std::list<std::shared_ptr<interface>>& instance_definition::get_downstream
...
@@ -517,6 +517,46 @@ const std::list<std::shared_ptr<interface>>& instance_definition::get_downstream
return
m_downstreams
;
return
m_downstreams
;
}
}
int
instance_definition
::
get_upstream_count
()
const
{
HC_LOG_TRACE
(
""
);
return
m_upstreams
.
size
();
}
int
instance_definition
::
get_downstream_count
()
const
{
HC_LOG_TRACE
(
""
);
return
m_downstreams
.
size
();
}
bool
instance_definition
::
delete_upstream
(
const
std
::
shared_ptr
<
interface
>&
id
)
{
std
::
list
<
std
::
shared_ptr
<
interface
>>::
iterator
i
;
HC_LOG_TRACE
(
""
);
for
(
i
=
m_upstreams
.
begin
();
i
!=
m_upstreams
.
end
();
++
i
)
{
if
(
id
==
*
i
)
{
m_upstreams
.
erase
(
i
);
return
true
;
}
}
return
false
;
}
bool
instance_definition
::
delete_downstream
(
const
std
::
shared_ptr
<
interface
>&
id
)
{
std
::
list
<
std
::
shared_ptr
<
interface
>>::
iterator
i
;
HC_LOG_TRACE
(
""
);
for
(
i
=
m_downstreams
.
begin
();
i
!=
m_downstreams
.
end
();
++
i
)
{
if
(
id
==
*
i
)
{
m_downstreams
.
erase
(
i
);
return
true
;
}
}
return
false
;
}
const
std
::
list
<
std
::
shared_ptr
<
rule_binding
>>&
instance_definition
::
get_global_settings
()
const
const
std
::
list
<
std
::
shared_ptr
<
rule_binding
>>&
instance_definition
::
get_global_settings
()
const
{
{
HC_LOG_TRACE
(
""
);
HC_LOG_TRACE
(
""
);
...
...
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