Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Grpc Async Client Call #241

Merged
merged 56 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8b04635
initial comment for the grpc client async call change
zzxgzgz Apr 1, 2021
8f6756c
Added initial implementation for the async grpc client call
zzxgzgz Apr 8, 2021
2cb3615
initial comment for the grpc client async call change
zzxgzgz Apr 1, 2021
143561d
Added initial implementation for the async grpc client call
zzxgzgz Apr 8, 2021
be99522
trying to keep up with upstream master's code
zzxgzgz Apr 15, 2021
8722296
Modifed unit test code so that it is async.
zzxgzgz Apr 16, 2021
09b9249
Fixed weird request ID problem in grpc async client call test
zzxgzgz Apr 16, 2021
07ac23a
Added logs, and modified code in the effort of fixing the core dumped
zzxgzgz Apr 19, 2021
5f24657
Try to fix pointer problem
zzxgzgz Apr 19, 2021
317f91e
Try to fix pointer problem
zzxgzgz Apr 19, 2021
c2ac8ba
Added more code for a more proper exit of ACA
zzxgzgz Apr 20, 2021
e950320
try to fix core dumped caused by double free
zzxgzgz Apr 20, 2021
63800eb
try to improve speed by using normal unordered_map
zzxgzgz Apr 20, 2021
4ea3ee4
try to improve speed by diabling usleep for on-demand code
zzxgzgz Apr 20, 2021
8e5ee58
Added time to measure which call takes longest time
zzxgzgz Apr 20, 2021
6890d34
Added time to measure which call takes longest time
zzxgzgz Apr 20, 2021
6c7ec20
Added more time to sleep
zzxgzgz Apr 20, 2021
24cfc0c
Adjusted where on-demand engine sleeps
zzxgzgz Apr 20, 2021
b0eb021
Reverted back how much time on-damand engine sleeps
zzxgzgz Apr 20, 2021
6478223
Removed unused/commented code; added assert in DISABLED_grpc_client_c…
zzxgzgz Apr 26, 2021
6b6c82e
Try to let on-demand engine wait until goalstate is delivered and pro…
zzxgzgz Apr 27, 2021
790b5ea
Try to modify the hashmap used, and the way to wait for the goalstate
zzxgzgz Apr 27, 2021
fe1fc00
Improved how on-demand-engine wait
zzxgzgz Apr 27, 2021
4e871c3
Fixed check arp entry exist condition
zzxgzgz Apr 27, 2021
aeebf2b
Added time recording to see where the bottleneck is
zzxgzgz Apr 28, 2021
b59a55c
Minor printout adjustments
zzxgzgz Apr 28, 2021
f5e32f7
Try to find out why all uuid has the same timestamp in a map
zzxgzgz Apr 28, 2021
1ba9d76
Try to find out why all uuid has the same timestamp in a map
zzxgzgz Apr 28, 2021
632a4d0
Try to find out why all uuid has the same timestamp in a map
zzxgzgz Apr 28, 2021
7470a1a
Try to find out why all uuid has the same timestamp in a map
zzxgzgz Apr 28, 2021
2ff4cce
Try to use the old sleep method
zzxgzgz Apr 28, 2021
79b0caa
Check if it is the problem caused by incorrect map usage
zzxgzgz Apr 28, 2021
aa0ae9e
Check if it is the problem caused by incorrect map usage
zzxgzgz Apr 28, 2021
6f7fc30
Check if it is the problem caused by incorrect map usage
zzxgzgz Apr 29, 2021
d624dbd
Check if it is the problem caused by incorrect map usage
zzxgzgz Apr 29, 2021
dea6e0b
Merge branch 'grpc_client_async' of https://github.com/zzxgzgz/alcor-…
zzxgzgz Apr 29, 2021
0bbb113
Revert back to use unordered_map
zzxgzgz Apr 29, 2021
c8bba26
Revert back to use unordered_map
zzxgzgz Apr 29, 2021
8effbee
Add printout after adding into the map
zzxgzgz Apr 29, 2021
6ce9cbd
Changed the size of the copied void pointer to the size of packet
zzxgzgz Apr 29, 2021
7e2a039
Try to implement a smarter sleep
zzxgzgz Apr 29, 2021
9eaa0be
Removed unneeded code
zzxgzgz Apr 29, 2021
e49179f
Added comment for the packet void pointer
zzxgzgz Apr 30, 2021
b41b804
Revert aca_arp_responder's map to CTSL:HashMap
zzxgzgz Apr 30, 2021
b9cd70a
Added back the missing !
zzxgzgz Apr 30, 2021
00793c0
Address comments in the PR; added the 3rd thread in ACA_ON_DEMAND_ENG…
zzxgzgz May 3, 2021
73325ea
Trying to find out the reason of crashing
zzxgzgz May 3, 2021
4c1639c
Trying to find out the reason of crashing
zzxgzgz May 3, 2021
597dba0
Trying to find out the reason of crashing
zzxgzgz May 3, 2021
e97bc4d
Try to move back to unordered map
zzxgzgz May 3, 2021
a598170
Added comment && removed unused code
zzxgzgz May 3, 2021
6b1824a
Adjected lock when cleaning up the map; added max size for the map; a…
zzxgzgz May 4, 2021
3b968a4
Adjusted variables' names
zzxgzgz May 4, 2021
3780af2
Adjusted variables' names
zzxgzgz May 4, 2021
d510d94
Refactored on_demand function, in order to measure time for the whole…
zzxgzgz May 7, 2021
26d93f5
Added comment for use of unordered_map in on-demand engine
zzxgzgz May 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 60 additions & 63 deletions include/aca_arp_responder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ using namespace std;

namespace aca_arp_responder
{

#define ARP_ENTRY_DATA_SET(pData,pConfig) \
do { \
(pData)->ipv4_address = (pConfig)->ipv4_address; \
(pData)->vlan_id = (pConfig)->vlan_id; \
} while (0)

#define ARP_TABLE_DATA_SET(pData,pConfig) \
do { \
(pData)->mac_address = (pConfig)->mac_address; \
} while (0)


struct arp_config{
#define ARP_ENTRY_DATA_SET(pData, pConfig) \
do { \
(pData)->ipv4_address = (pConfig)->ipv4_address; \
(pData)->vlan_id = (pConfig)->vlan_id; \
} while (0)

#define ARP_TABLE_DATA_SET(pData, pConfig) \
do { \
(pData)->mac_address = (pConfig)->mac_address; \
} while (0)

struct arp_config {
string mac_address;
string ipv4_address;
string ipv6_address;
string ipv6_address;
uint16_t vlan_id;
string port_host_name;
};

struct arp_entry_data{
struct arp_entry_data {
string ipv4_address;
string ipv6_address;
string ipv6_address;
uint16_t vlan_id;
bool operator==(const arp_entry_data &p) const{
return ipv4_address==p.ipv4_address && vlan_id==p.vlan_id;
bool operator==(const arp_entry_data &p) const
{
return ipv4_address == p.ipv4_address && vlan_id == p.vlan_id;
}

bool operator!=(const arp_entry_data &p) const{
return ipv4_address!=p.ipv4_address || vlan_id!=p.vlan_id;
bool operator!=(const arp_entry_data &p) const
{
return ipv4_address != p.ipv4_address || vlan_id != p.vlan_id;
}
};


struct arp_hash{
size_t operator() (const arp_entry_data &p) const{
struct arp_hash {
size_t operator()(const arp_entry_data &p) const
{
return hash<string>()(p.ipv4_address) ^ (hash<uint16_t>()(p.vlan_id) << 1);
}
};

struct arp_table_data{
struct arp_table_data {
string mac_address;
};

struct arp_message{
struct arp_message {
uint16_t hrd;
uint16_t pro;
uint8_t hln;
Expand All @@ -79,9 +79,9 @@ struct arp_message{
uint32_t spa;
uint8_t tha[6];
uint32_t tpa;
} __attribute__ ((__packed__));
} __attribute__((__packed__));

struct vlan_message{
struct vlan_message {
uint16_t vlan_proto; //should always be 0x8100
uint16_t vlan_tci;
};
Expand All @@ -96,51 +96,48 @@ struct vlan_message{
#define ARP_MSG_HRD_LEN (0x6)
#define ARP_MSG_PRO_LEN (0x4)

class ACA_ARP_Responder{
public:
static ACA_ARP_Responder &get_instance();
class ACA_ARP_Responder {
public:
static ACA_ARP_Responder &get_instance();

/* Managemet Plane Ops*/
int add_arp_entry(arp_config *arp_config_in);
int create_or_update_arp_entry(arp_config *arp_config_in);
int delete_arp_entry(arp_config *arp_config_in);
bool does_arp_entry_exist(arp_entry_data stData);

/* Data plane Ops */
int arp_recv(uint32_t in_port, void *vlanmsg, void *message);
void arp_xmit(uint32_t in_port, void *vlanmsg, void *message, int is_find);
string _get_requested_ip(arp_message *arpmsg);
string _get_source_ip(arp_message *arpmsg);
int _parse_arp_request(uint32_t in_port, vlan_message *vlanmsg, arp_message *arpmsg);

private:
ACA_ARP_Responder();
~ACA_ARP_Responder();

CTSL::HashMap<arp_entry_data,arp_table_data *,arp_hash> _arp_db;

/* Managemet Plane Ops*/
int add_arp_entry(arp_config *arp_config_in);
int create_or_update_arp_entry(arp_config *arp_config_in);
int delete_arp_entry(arp_config *arp_config_in);

/* Data plane Ops */
int arp_recv(uint32_t in_port, void *vlanmsg, void *message);
void arp_xmit(uint32_t in_port, void *vlanmsg, void *message, int is_find);
string _get_requested_ip(arp_message *arpmsg);
string _get_source_ip(arp_message *arpmsg);
int _parse_arp_request(uint32_t in_port, vlan_message *vlanmsg, arp_message *arpmsg);

private:
ACA_ARP_Responder();
~ACA_ARP_Responder();

/*************** Initialization and De-initialization ***********************/
void _init_arp_db();
void _deinit_arp_db();
void _init_arp_ofp();
void _deinit_arp_ofp();
CTSL::HashMap<arp_entry_data, arp_table_data *, arp_hash> _arp_db;

/*************** Management plane operations ***********************/
void _validate_mac_address(const char *mac_string);
void _validate_ipv4_address(const char *ip_address);
void _validate_ipv6_address(const char *ip_address);
int _validate_arp_entry(arp_config *arp_cfg_in);
/*************** Initialization and De-initialization ***********************/
void _init_arp_db();
void _deinit_arp_db();
void _init_arp_ofp();
void _deinit_arp_ofp();

/**************** Data plane operations *********************/
int _validate_arp_message(arp_message *arpmsg);
/*************** Management plane operations ***********************/
void _validate_mac_address(const char *mac_string);
void _validate_ipv4_address(const char *ip_address);
void _validate_ipv6_address(const char *ip_address);
int _validate_arp_entry(arp_config *arp_cfg_in);

arp_message *_pack_arp_reply(arp_message *arpreq, string mac_address);
/**************** Data plane operations *********************/
int _validate_arp_message(arp_message *arpmsg);

string _serialize_arp_message(vlan_message *vlanmsg, arp_message *arpmsg);
arp_message *_pack_arp_reply(arp_message *arpreq, string mac_address);

string _serialize_arp_message(vlan_message *vlanmsg, arp_message *arpmsg);
};
} // namespace aca_arp_responder
#endif // #ifndef ACA_ARP_RESPONDER_H

9 changes: 8 additions & 1 deletion include/aca_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

#define DEFAULT_MTU 9000

#define USLEEPTIME_IN_MICROSECONDS 15000
#define ON_DEMAND_ENTRY_CLEANUP_FREQUENCY_IN_MICROSECONDS 10000000 // 10 seconds

#define ON_DEMAND_ENTRY_EXPIRATION_IN_MICROSECONDS 10000000 // 10 seconds

#define REQUEST_UUID_ON_DEMAND_PAYLOAD_MAP_MAX_SIZE 1000000 // one million

#define REQUEST_UUID_ON_DEMAND_PAYLOAD_MAP_SIZE_CHECK_FREQUENCY_IN_MICROSECONDS \
1000 // 10 microsecond, which is 1 millisecond

#endif // #ifndef ACA_CONFIG_H
11 changes: 10 additions & 1 deletion include/aca_grpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class GoalStateProvisionerImpl final : public GoalStateProvisioner::Service {
public:
std::unique_ptr<GoalStateProvisioner::Stub> stub_;
std::shared_ptr<grpc_impl::Channel> chan_;
HostRequestReply RequestGoalStates(HostRequest *request);

void RequestGoalStates(HostRequest *request, grpc::CompletionQueue *cq);

// ~GoalStateProvisionerImpl();
explicit GoalStateProvisionerImpl(){};
Status PushNetworkResourceStates(ServerContext *context, const GoalState *goalState,
Expand All @@ -50,3 +52,10 @@ class GoalStateProvisionerImpl final : public GoalStateProvisioner::Service {
private:
std::unique_ptr<Server> server;
};

struct AsyncClientCall {
alcor::schema::HostRequestReply reply;
grpc::ClientContext context;
grpc::Status status;
std::unique_ptr<grpc::ClientAsyncResponseReader<alcor::schema::HostRequestReply> > response_reader;
};
Loading