提交 17c07d3b 编写于 作者: H heyanlong

fix register fail

上级 3538f0f5
......@@ -41,14 +41,14 @@ if test "$PHP_SKYWALKING" != "no"; then
protoc -I ./src/protocol-5 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-5/*.proto
)
AC_OUTPUT_COMMANDS(
protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/common/*.proto
protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/register/*.proto
protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/language-agent-v2/*.proto
protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/common/*.proto
protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/register/*.proto
protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/language-agent-v2/*.proto
)
dnl AC_OUTPUT_COMMANDS(
dnl protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/common/*.proto
dnl protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/register/*.proto
dnl protoc -I ./src/protocol-6 --cpp_out=./src/grpc ./src/protocol-6/language-agent-v2/*.proto
dnl protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/common/*.proto
dnl protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/register/*.proto
dnl protoc -I ./src/protocol-6 --grpc_out=./src/grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./src/protocol-6/language-agent-v2/*.proto
dnl )
AC_OUTPUT_COMMANDS(
mv src/grpc/ApplicationRegisterService.grpc.pb.cc src/grpc/ApplicationRegisterService-grpc.pb.cc
......@@ -88,10 +88,6 @@ if test "$PHP_SKYWALKING" != "no"; then
src/grpc/NetworkAddressRegisterService.pb.cc \
src/grpc/TraceSegmentService-grpc.pb.cc \
src/grpc/TraceSegmentService.pb.cc \
src/grpc/common/common-grpc.pb.cc \
src/grpc/common/common.pb.cc \
src/grpc/register/Register-grpc.pb.cc \
src/grpc/register/Register.pb.cc \
, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_ADD_BUILD_DIR($ext_builddir/src/grpc)
......
......@@ -54,8 +54,9 @@
extern int applicationCodeRegister(char *grpc_server, char *code);
extern int registerInstance(char *grpc_server, int appId, long registertime, char *osname, char *hostname,
extern int registerInstance(char *grpc_server, int appId, char *uuid, long registertime, char *osname, char *hostname,
int processno, char *ipv4s);
extern char *uuid();
/* If you declare any globals in php_skywalking.h uncomment this:
*/
......@@ -738,9 +739,10 @@ static void module_init() {
long millisecond = zend_atol(l_millisecond, strlen(l_millisecond));
efree(l_millisecond);
char *uid = uuid();
i = 0;
do {
application_instance = registerInstance(SKYWALKING_G(grpc), application_id, millisecond, SKY_OS_NAME,
application_instance = registerInstance(SKYWALKING_G(grpc), application_id, uid, millisecond, SKY_OS_NAME,
hostname, getpid(),
ipv4s);
if(application_instance == -100000) {
......
......@@ -41,8 +41,9 @@ using grpc::ClientWriter;
extern "C" int applicationCodeRegister(char *grpc_server, char *code);
extern "C" int
registerInstance(char *grpc_server, int appId, long registertime, char *osname, char *hostname,
registerInstance(char *grpc_server, int appId, char *uuid, long registertime, char *osname, char *hostname,
int processno, char *ipv4s);
extern "C" char* uuid();
class GreeterClient {
public:
......@@ -75,7 +76,7 @@ public:
return -100000;
}
int registerInstance(int applicationid, long registertime, char *osname, char *hostname, int processno,
int registerInstance(int applicationid, char *uuid, long registertime, char *osname, char *hostname, int processno,
char *ipv4s) {
std::unique_ptr <InstanceDiscoveryService::Stub> stub_;
......@@ -83,9 +84,8 @@ public:
ApplicationInstance request;
boost::uuids::uuid uuid = boost::uuids::random_generator()();
request.set_agentuuid(boost::uuids::to_string(uuid));
request.set_agentuuid(uuid);
request.set_applicationid(applicationid);
request.set_registertime(registertime);
......@@ -129,8 +129,16 @@ int applicationCodeRegister(char *grpc_server, char *code) {
}
int
registerInstance(char *grpc_server, int appId, long registertime, char *osname, char *hostname,
registerInstance(char *grpc_server, int appId, char *uuid, long registertime, char *osname, char *hostname,
int processno, char *ipv4s) {
GreeterClient greeter(grpc::CreateChannel(grpc_server, grpc::InsecureChannelCredentials()));
return greeter.registerInstance(appId, registertime, osname, hostname, processno, ipv4s);
return greeter.registerInstance(appId, uuid, registertime, osname, hostname, processno, ipv4s);
}
char *uuid() {
boost::uuids::uuid uuid = boost::uuids::random_generator()();
std::string str = boost::uuids::to_string(uuid);
char *cstr = new char[str.length() + 1];
strcpy(cstr, str.c_str());
return cstr;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册