Skip to content

Commit

Permalink
fix pro-node initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Sep 10, 2024
1 parent d68bade commit f2e2f29
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 32 deletions.
11 changes: 6 additions & 5 deletions cpp/tools/build_ppc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ default_version="v1.1.0"
compatibility_version=${default_version}
command="deploy"

disable_ra2018="false"
disable_ra2018="true"

LOG_WARN() {
local content=${1}
Expand Down Expand Up @@ -420,9 +420,9 @@ generate_node_config_ini() {
; the threadPoolSize
thread_count = 4
; the gatewayService endpoint information
service.gateway_target =
gateway_target =
; the components
service.components =
components =
nodeid=${nodeid}
[crypto]
Expand Down Expand Up @@ -524,8 +524,9 @@ generate_node_config_ini() {
; MB
max_log_file_size=200
; LineID, TimeStamp, ProcessID, ThreadName, ThreadID and Message
format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
enable_rotate_by_hour=false
;format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
format=%Severity%|%TimeStamp%|%Message%
enable_rotate_by_hour=true
log_name_pattern=ppcs-psi4ef.log
; Y,m,d,H,M,S are supported, N is the sequence number log_%Y%m%d.%H%M%S.%N.log
rotate_name_pattern=log_%Y%m%d.%H%M.log
Expand Down
5 changes: 3 additions & 2 deletions cpp/tools/build_wedpr_cem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,9 @@ generate_config_ini() {
; MB
max_log_file_size=200
; LineID, TimeStamp, ProcessID, ThreadName, ThreadID and Message
format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
enable_rotate_by_hour=false
;format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
format=%Severity%|%TimeStamp%|%Message%
enable_rotate_by_hour=true
log_name_pattern=ppcs-psi4ef.log
; Y,m,d,H,M,S are supported, N is the sequence number log_%Y%m%d.%H%M%S.%N.log
rotate_name_pattern=log_%Y%m%d.%H%M.log
Expand Down
4 changes: 2 additions & 2 deletions cpp/tools/ppc-builder/conf/config-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ holding_msg_minutes = 30
# configuration for the ppc-node
[[agency.node]]
# disable the ra2018 psi or not, default enable ra2018
disable_ra2018 = false
disable_ra2018 = true
deploy_ip=["127.0.0.1:2"]
# node name, Notice: node_name in the same agency and group must be unique
node_name = "node0"
Expand Down Expand Up @@ -128,7 +128,7 @@ holding_msg_minutes = 30
# configuration for the ppc-node
[[agency.node]]
# disable the ra2018 psi or not, default enable ra2018
disable_ra2018 = false
disable_ra2018 = true
deploy_ip=["127.0.0.1:2"]
# node name, Notice: node_name in the same agency and group must be unique
node_name = "node0"
Expand Down
8 changes: 4 additions & 4 deletions cpp/tools/ppc-builder/src/config/ppc_node_config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,18 @@ def __generate_transport_config__(self, config_content, node_config, node_id, de
; the threadPoolSize
thread_count = 4
; the gatewayService endpoint information
service.gateway_target =
gateway_target =
; the components
service.components =
components =
nodeid=
"""
section = "transport"
config_content[section]["listen_ip"] = node_config.grpc_listen_ip
config_content[section]["listen_port"] = str(
node_config.grpc_listen_port)
config_content[section]["host_ip"] = deploy_ip
config_content[section]["service.gateway_target"] = node_config.gateway_config.gateway_grpc_target
config_content[section]["service.components"] = node_config.components
config_content[section]["gateway_target"] = node_config.gateway_config.gateway_grpc_target
config_content[section]["components"] = node_config.components
config_content[section]["nodeid"] = node_id

def __generate_ra2018psi_config__(self, config_content, ra2018psi_config):
Expand Down
5 changes: 3 additions & 2 deletions cpp/tools/ppc-builder/src/tpl/config.ini.gateway
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
; MB
max_log_file_size=200
; LineID, TimeStamp, ProcessID, ThreadName, ThreadID and Message
format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
enable_rotate_by_hour=false
;format=%Severity%|ppcs-gateway|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
format=%Severity%|%TimeStamp%|%Message%
enable_rotate_by_hour=true
log_name_pattern=ppcs-gateway.log
; Y,m,d,H,M,S are supported, N is the sequence number log_%Y%m%d.%H%M%S.%N.log
rotate_name_pattern=log_%Y%m%d.%H%M.log
Expand Down
11 changes: 6 additions & 5 deletions cpp/tools/ppc-builder/src/tpl/config.ini.node
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
; the private key path for the psi-server
private_key_path = conf/node.pem
; disable the ra2018 or not, default enable ra2018
disable_ra2018 = false
disable_ra2018 = true
; the path that allows programs to access
; data_location = data
; task_timeout_minutes = 180
Expand Down Expand Up @@ -38,9 +38,9 @@
; the threadPoolSize
thread_count = 4
; the gatewayService endpoint information
service.gateway_target =
gateway_target =
; the components
service.components =
components =
nodeid=

[storage]
Expand Down Expand Up @@ -101,8 +101,9 @@
; MB
max_log_file_size=200
; LineID, TimeStamp, ProcessID, ThreadName, ThreadID and Message
format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
enable_rotate_by_hour=false
;format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
format=%Severity%|%TimeStamp%|%Message%
enable_rotate_by_hour=true
log_name_pattern=ppcs-psi4ef.log
; Y,m,d,H,M,S are supported, N is the sequence number log_%Y%m%d.%H%M%S.%N.log
rotate_name_pattern=log_%Y%m%d.%H%M.log
Expand Down
2 changes: 1 addition & 1 deletion cpp/wedpr-computing/ppc-cem/tests/data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
max_log_file_size=200
; LineID, TimeStamp, ProcessID, ThreadName, ThreadID and Message
#format=%Severity%|ppcs-psi4ef|system-id|%TimeStamp%|%ThreadName%-%ThreadID%|%Message%
#enable_rotate_by_hour=false
#enable_rotate_by_hour=true
#log_name_pattern=ppcs-psi4ef.log
; Y,m,d,H,M,S are supported, N is the sequence number log_%Y%m%d.%H%M%S.%N.log
#rotate_name_pattern=log_%Y%m%d.%H%M.log
Expand Down
8 changes: 4 additions & 4 deletions cpp/wedpr-helper/ppc-tools/src/config/PPCConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ void PPCConfig::loadFrontConfig(bool requireTransport,

loadEndpointConfig(m_frontConfig->mutableSelfEndPoint(), true, "transport", pt);
// the gateway targets
auto gatewayTargets = pt.get<std::string>("transport.service.gateway_target", "");
auto gatewayTargets = pt.get<std::string>("transport.gateway_target", "");
if (gatewayTargets.empty())
{
BOOST_THROW_EXCEPTION(InvalidConfig() << errinfo_comment(
"Must specify the transport.service.gateway_target!"));
BOOST_THROW_EXCEPTION(
InvalidConfig() << errinfo_comment("Must specify the transport.gateway_target!"));
}
// the components
auto components = pt.get<std::string>("transport.service.components", "");
auto components = pt.get<std::string>("transport.components", "");
boost::split(m_frontConfig->mutableComponents(), components, boost::is_any_of(","));
}

Expand Down
14 changes: 8 additions & 6 deletions cpp/wedpr-transport/sdk/ProTransportImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ using namespace ppc::sdk;
ProTransportImpl::ProTransportImpl(ppc::front::FrontConfig::Ptr config, int keepAlivePeriodMs)
: m_config(std::move(config)), m_keepAlivePeriodMs(keepAlivePeriodMs)
{
// default enable health-check
auto grpcServerConfig = std::make_shared<GrpcServerConfig>(config->selfEndPoint(), true);
// Note: since the config has been moved away, should not use the `config`, use `m_config`
// instead default enable health-check
auto grpcServerConfig = std::make_shared<GrpcServerConfig>(m_config->selfEndPoint(), true);
m_server = std::make_shared<GrpcServer>(grpcServerConfig);

FrontFactory frontFactory;
m_gateway =
std::make_shared<GatewayClient>(m_config->grpcConfig(), m_config->gatewayGrpcTarget());
m_front = frontFactory.build(std::make_shared<NodeInfoFactory>(),
std::make_shared<MessagePayloadBuilderImpl>(),
std::make_shared<MessageOptionalHeaderBuilderImpl>(), m_gateway, config);
std::make_shared<MessageOptionalHeaderBuilderImpl>(), m_gateway, m_config);

auto msgBuilder =
std::make_shared<MessageBuilderImpl>(std::make_shared<MessageHeaderBuilderImpl>());
auto frontService = std::make_shared<FrontServer>(msgBuilder, m_front);
frontService->setHealthCheckService(m_server->server()->GetHealthCheckService());
m_frontService = std::make_shared<FrontServer>(msgBuilder, m_front);
// register the frontService
m_server->registerService(frontService);
m_server->registerService(m_frontService);
}

void ProTransportImpl::start()
Expand All @@ -65,6 +65,8 @@ void ProTransportImpl::start()
});
m_timer->start();
m_server->start();
// Note: the server is inited after start
m_frontService->setHealthCheckService(m_server->server()->GetHealthCheckService());
m_front->start();
}

Expand Down
4 changes: 3 additions & 1 deletion cpp/wedpr-transport/sdk/ProTransportImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
namespace ppc::protocol
{
class GrpcServer;
}
class FrontServer;
} // namespace ppc::protocol


namespace ppc::sdk
Expand All @@ -44,6 +45,7 @@ class ProTransportImpl : public Transport, public std::enable_shared_from_this<P
protected:
ppc::front::FrontConfig::Ptr m_config;
std::shared_ptr<ppc::protocol::GrpcServer> m_server;
std::shared_ptr<ppc::protocol::FrontServer> m_frontService;
int m_keepAlivePeriodMs;
std::shared_ptr<bcos::Timer> m_timer;
};
Expand Down

0 comments on commit f2e2f29

Please sign in to comment.