cout << "[INFO] Sending a HandOff CONTROL message to \"" << ts_control_ep << "\"\n";
cout << "[INFO] HandOff request is " << msg << endl;
- // sending request
- restclient::RestClient client( ts_control_ep );
- restclient::response_t resp = client.do_post( "", msg ); // we already have the full path in ts_control_ep
-
- if( resp.status_code == 200 ) {
- // ============== DO SOMETHING USEFUL HERE ===============
- // Currently, we only print out the HandOff reply
- rapidjson::Document document;
- document.Parse( resp.body.c_str() );
- rapidjson::StringBuffer s;
- rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(s);
- document.Accept( writer );
- cout << "[INFO] HandOff reply is " << s.GetString() << endl;
+ try {
+ // sending request
+ restclient::RestClient client( ts_control_ep );
+ restclient::response_t resp = client.do_post( "", msg ); // we already have the full path in ts_control_ep
+
+ if( resp.status_code == 200 ) {
+ // ============== DO SOMETHING USEFUL HERE ===============
+ // Currently, we only print out the HandOff reply
+ rapidjson::Document document;
+ document.Parse( resp.body.c_str() );
+ rapidjson::StringBuffer s;
+ rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(s);
+ document.Accept( writer );
+ cout << "[INFO] HandOff reply is " << s.GetString() << endl;
+
+ } else {
+ cout << "[ERROR] Unexpected HTTP code " << resp.status_code << " from " << \
+ client.getBaseUrl() << \
+ "\n[ERROR] HTTP payload is " << resp.body.c_str() << endl;
+ }
+
+ } catch( const restclient::RestClientException &e ) {
+ cout << "[ERROR] " << e.what() << endl;
- } else {
- cout << "[ERROR] Unexpected HTTP code " << resp.status_code << " from " << \
- client.getBaseUrl() << \
- "\n[ERROR] HTTP payload is " << resp.body.c_str() << endl;
}
}
}
request->set_riccontrolackreqval( rc::RIC_CONTROL_ACK_UNKWON ); // not yet used in api.proto
+ cout << "[INFO] Sending gRPC control request to " << ts_control_ep << "\n" << request->DebugString();
+
grpc::Status status = rc_stub->SendRICControlReqServiceGrpc( &context, *request, &response );
if( status.ok() ) {
base_url = string( data );
}
- restclient::RestClient client( base_url );
-
- vector<string> nb_list = get_nodeb_list( client );
+ try {
+ restclient::RestClient client( base_url );
+
+ vector<string> nb_list = get_nodeb_list( client );
+
+ for( string nb : nb_list ) {
+ string full_path = string("/v1/nodeb/") + nb;
+ restclient::response_t response = client.do_get( full_path );
+ if( response.status_code != 200 ) {
+ if( response.body.empty() ) {
+ cout << "[ERROR] Unexpected HTTP code " << response.status_code << " from " << \
+ client.getBaseUrl() + full_path << endl;
+ } else {
+ cout << "[ERROR] Unexpected HTTP code " << response.status_code << " from " << \
+ client.getBaseUrl() + full_path << ". HTTP payload is " << response.body.c_str() << endl;
+ }
+ return false;
+ }
- for( string nb : nb_list ) {
- string full_path = string("/v1/nodeb/") + nb;
- restclient::response_t response = client.do_get( full_path );
- if( response.status_code != 200 ) {
- if( response.body.empty() ) {
- cout << "[ERROR] Unexpected HTTP code " << response.status_code << " from " << \
- client.getBaseUrl() + full_path << endl;
- } else {
- cout << "[ERROR] Unexpected HTTP code " << response.status_code << " from " << \
- client.getBaseUrl() + full_path << ". HTTP payload is " << response.body.c_str() << endl;
+ try {
+ NodebHandler handler;
+ Reader reader;
+ StringStream ss( response.body.c_str() );
+ reader.Parse( ss, handler );
+ } catch (...) {
+ cout << "[ERROR] Got an exception on parsing nodeb (stringstream read parse)\n";
+ return false;
}
- return false;
}
- try {
- NodebHandler handler;
- Reader reader;
- StringStream ss( response.body.c_str() );
- reader.Parse( ss, handler );
- } catch (...) {
- cout << "[ERROR] Got an exception on parsing nodeb (stringstream read parse)\n";
- return false;
- }
+ } catch( const restclient::RestClientException &e ) {
+ cout << "[ERROR] " << e.what() << endl;
+ return false;
}
return true;
rc_stub = rc::MsgComm::NewStub(channel, grpc::StubOptions());
}
- fprintf( stderr, "[TS xApp] listening on port %s\n", port );
+ fprintf( stderr, "[INFO] listening on port %s\n", port );
xfw = std::unique_ptr<Xapp>( new Xapp( port, true ) );
xfw->Add_msg_cb( A1_POLICY_REQ, policy_callback, NULL ); // msg type 20010