Commit 184a3b67 authored by Paras Garg's avatar Paras Garg

Added code for follower

parent b954b568
No preview for this file type
......@@ -19,13 +19,13 @@ void RdmaServerRepEndpoint::createResources()
*/
if (_state != CONN_STATE_INITIALIZED)
{
CPPLog::LOG_ERROR("RdmaEndpoint : createResource invalid state");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : createResource invalid state");
}
// Step 1 to create endpoint
_protectionDomain = ibv_alloc_pd(_cm_id->verbs);
if (_protectionDomain == NULL)
{
CPPLog::LOG_ERROR("RdmaEndpoint : ibv_alloc_pd failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : ibv_alloc_pd failed");
return;
}
// step 2 Creating Queue pair with completion queueu setted for send and recieve
......@@ -54,11 +54,11 @@ void RdmaServerRepEndpoint::createResources()
int ret = rdma_create_qp(_cm_id, _protectionDomain, &qp_init_attr);
if (ret)
{
CPPLog::LOG_ERROR("RdmaEndpoint : ibv_create_cq failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : ibv_create_cq failed");
}
if (_cm_id->pd == NULL)
{
CPPLog::LOG_ERROR("RdmaEndpoint : pd not set");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : pd not set");
_cm_id->pd = _protectionDomain;
}
/*
......@@ -66,19 +66,19 @@ void RdmaServerRepEndpoint::createResources()
*/
_sendBuff = new char[(_sendMsgSize * _sendQueueSize)];
if (_sendBuff == NULL)
CPPLog::LOG_ERROR("RdmaEndpoint : sendBuff allocation failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : sendBuff allocation failed");
_sendMr = rdma_reg_write(_cm_id, reinterpret_cast<void *>(_sendBuff), _sendMsgSize * _sendQueueSize);
if (_sendMr == NULL)
CPPLog::LOG_ERROR("RdmaEndpoint : sendMr reg failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : sendMr reg failed");
_recvBuff = new char[(_recvMsgSize * _recvQueueSize)];
if (_recvBuff == NULL)
CPPLog::LOG_ERROR("RdmaEndpoint : recvBuff allocation failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : recvBuff allocation failed");
_recvMr = rdma_reg_read(_cm_id, reinterpret_cast<void *>(_recvBuff), _recvMsgSize * _recvQueueSize);
if (_recvMr == NULL)
CPPLog::LOG_ERROR("RdmaEndpoint : recvMr reg failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : recvMr reg failed");
/*
* adding buffers for recving rdma data
......@@ -104,24 +104,24 @@ void RdmaServerRepEndpoint::createResources()
void RdmaServerRepEndpoint::processCmEvent(struct rdma_cm_event *event)
{
std::ostringstream ss;
ss << "RdmaEndpoint : Event " << rdma_event_str(event->event);
ss << "RdmaServerRepEndpoint : Event " << rdma_event_str(event->event);
CPPLog::LOG_ALWAYS(ss);
if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST)
{
CPPLog::LOG_ALWAYS("RdmaEndpoint : Connect request");
CPPLog::LOG_ALWAYS("RdmaServerRepEndpoint : Connect request");
}
else if (event->event == RDMA_CM_EVENT_ESTABLISHED)
{
if (_state != CONN_STATE_RESOURCES_ALLOCATED)
{
CPPLog::LOG_ERROR("RdmaEndpoint : Established_Event but resource not alloted");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : Established_Event but resource not alloted");
}
CPPLog::LOG_INFO("RdmaEndpoint : step 6 Connected");
CPPLog::LOG_INFO("RdmaServerRepEndpoint : step 6 Connected");
_state = CONN_STATE_CONNECTED;
}
else if (event->event == RDMA_CM_EVENT_DISCONNECTED)
{
CPPLog::LOG_INFO("RdmaEndpoint : step 7 disconnected");
CPPLog::LOG_INFO("RdmaServerRepEndpoint : step 7 disconnected");
close();
}
}
......@@ -132,25 +132,25 @@ void RdmaServerRepEndpoint::close()
{
return;
}
CPPLog::LOG_INFO("RdmaEndpoint : closing connection");
CPPLog::LOG_INFO("RdmaServerRepEndpoint : closing connection");
int ret;
ret = rdma_disconnect(_cm_id);
if (ret)
{
CPPLog::LOG_ERROR("RdmaEndpoint : rdma_disconnect failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : rdma_disconnect failed");
}
ret = rdma_dereg_mr(_sendMr);
if (ret)
{
CPPLog::LOG_ERROR("RdmaEndpoint : rdma_dereg_mr send failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : rdma_dereg_mr send failed");
}
delete[] _sendBuff;
ret = rdma_dereg_mr(_recvMr);
if (ret)
{
CPPLog::LOG_ERROR("RdmaEndpoint : rdma_dereg_mr recv failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : rdma_dereg_mr recv failed");
}
delete[] _recvBuff;
......@@ -163,7 +163,7 @@ void RdmaServerRepEndpoint::close()
CPPLog::LOG_INFO("des mr");
if (ret)
{
CPPLog::LOG_ERROR("RdmaEndpoint : rdma_destroy_id failed");
CPPLog::LOG_ERROR("RdmaServerRepEndpoint : rdma_destroy_id failed");
}
_state = CONN_STATE_CLOSED;
CPPLog::LOG_INFO("closed");
......
......@@ -12,7 +12,7 @@ TaskThread::TaskThread(int id, int cpu, ConcurrentQueue *taskqueue,
CPPLog::LOG_ERROR("pthread create has been failed while creating taskthread");
exit(0);
}
cpu_set_t cpuset;
/*cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(cpu, &cpuset);
std::ostringstream ss;
......@@ -21,7 +21,7 @@ TaskThread::TaskThread(int id, int cpu, ConcurrentQueue *taskqueue,
if (pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset) != 0)
{
CPPLog::LOG_ERROR("Error calling pthread_setaffinity_np ");
}
}*/
pthread_setname_np(thread, "TaskThread");
}
......@@ -134,7 +134,9 @@ void TaskThread::processEvent(RdmaSalEndpoint *ep, struct ibv_wc *data)
ep->processPut(req);
break;
default:
CPPLog::LOG_ERROR("SalRequest invalid req type");
std::ostringstream ss;
ss<<"SalRequest invalid req type"<<data->opcode;
CPPLog::LOG_ERROR(ss);
break;
}
delete[] buffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment