Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JasmineGraph Frontend Shell #254

Merged
merged 31 commits into from
Jan 14, 2025
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
30072a0
frontend input length issue fixed
ChandiH Sep 4, 2024
96d2a53
implent ui-frontend list command
ChandiH Sep 4, 2024
8ab59bd
seperated frontend common function
ChandiH Sep 17, 2024
1608554
remove duplicate code
ChandiH Sep 17, 2024
9f6f668
remove duplicate code
ChandiH Sep 17, 2024
36ba3d6
remove duplicate code
ChandiH Sep 17, 2024
1af1815
change volatile variable to atomic
ChandiH Sep 17, 2024
d06d9fb
Merge remote-tracking branch 'upstream/master' into feature/frontend
ChandiH Sep 17, 2024
7ee9c07
fix review comment and add graph upload command in ui frontend
ChandiH Sep 29, 2024
d4f1457
fix review comment and add graph upload command in ui frontend
ChandiH Sep 29, 2024
921104b
fix lint issue
ChandiH Sep 29, 2024
c9f6eaa
add remove graph command in ui-frontend
ChandiH Oct 8, 2024
fac0a9b
triangle count
ChandiH Oct 15, 2024
c8e9bc6
Merge remote-tracking branch 'upstream/master' into feature/frontend
ChandiH Nov 26, 2024
ed03fbd
Merge branch 'master' into feature/frontend
miyurud Dec 24, 2024
b64d1b0
Fixed style issues
ChandiH Dec 26, 2024
1295ad2
Fixed style issues
ChandiH Dec 26, 2024
4391838
Fixed style issues
ChandiH Dec 26, 2024
a150caa
Fixed style issues
ChandiH Dec 26, 2024
3c1ca59
Merge remote-tracking branch 'origin' into feature/frontend
ChandiH Jan 2, 2025
c3f376a
Add break statement to list_command
ChandiH Jan 2, 2025
0f647bf
Add gcovr option to ignore parse errors in CodeCoverage.cmake
ChandiH Jan 2, 2025
47f6067
add test cases for frontend-ui
ChandiH Jan 2, 2025
2cbee17
update test cases for rmgr and lst commands in integration tests
ChandiH Jan 2, 2025
55b8797
update expected response in lst command test case
ChandiH Jan 2, 2025
9bbed41
add shutdown server test case to integration tests
ChandiH Jan 2, 2025
ebea06b
format response in lst command test case for improved readability
ChandiH Jan 2, 2025
3f155d1
refactor integration tests by removing redundant logging and commente…
ChandiH Jan 2, 2025
fdc97f6
Remove cout in JamineGraphFrontEnd.cpp
ChandiH Jan 13, 2025
f392d9c
Add meaningful variable name
ChandiH Jan 13, 2025
e8d85e7
Merge branch 'master' into feature/frontend
miyurud Jan 14, 2025
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
Prev Previous commit
Next Next commit
triangle count
ChandiH committed Oct 15, 2024
commit fac0a9b7f37938520130bfa04c8db62572060b5f
146 changes: 145 additions & 1 deletion src/frontend/ui/JasmineGraphFrontEndUI.cpp
Original file line number Diff line number Diff line change
@@ -60,56 +60,60 @@
static void list_command(int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p);
static void add_graph_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p, std::string command);
static void remove_graph_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p, std::string command);
static void triangles_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite,
PerformanceSQLiteDBInterface *perfSqlite, JobScheduler *jobScheduler, bool *loop_exit_p, std::string command);

void *uifrontendservicesesion(void *dummyPt) {
frontendservicesessionargs *sessionargs = (frontendservicesessionargs *)dummyPt;

Check warning on line 67 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L66-L67

Added lines #L66 - L67 were not covered by tests
std::string masterIP = sessionargs->masterIP;
int connFd = sessionargs->connFd;
SQLiteDBInterface *sqlite = sessionargs->sqlite;
PerformanceSQLiteDBInterface *perfSqlite = sessionargs->perfSqlite;
JobScheduler *jobScheduler = sessionargs->jobScheduler;

Check warning on line 72 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L69-L72

Added lines #L69 - L72 were not covered by tests
delete sessionargs;

if (JasmineGraphFrontEndCommon::checkServerBusy(&currentFESession, connFd)) {
ui_frontend_logger.error("Server is busy");
return NULL;

Check warning on line 77 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L77

Added line #L77 was not covered by tests
}

char data[FRONTEND_DATA_LENGTH + 1];
// Initiate Thread
thread input_stream_handler;

Check warning on line 82 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L82

Added line #L82 was not covered by tests

bool loop_exit = false;
int failCnt = 0;

Check warning on line 85 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L84-L85

Added lines #L84 - L85 were not covered by tests
while (!loop_exit) {
std::string line = JasmineGraphFrontEndCommon::readAndProcessInput(connFd, data, failCnt);
if (line.empty()) {
continue;

Check warning on line 89 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L89

Added line #L89 was not covered by tests
}
ui_frontend_logger.info("Command received: " + line);
if (line.empty()) {
continue;

Check warning on line 93 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L93

Added line #L93 was not covered by tests
}

if (currentFESession > 1) {
canCalibrate = false;

Check warning on line 97 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L97

Added line #L97 was not covered by tests
} else {
canCalibrate = true;
workerResponded = false;

Check warning on line 100 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L99-L100

Added lines #L99 - L100 were not covered by tests
}

// split the string in '|' and take first
char delimiter = '|';

Check warning on line 104 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L104

Added line #L104 was not covered by tests
std::stringstream ss(line);
std::string token;

Check warning on line 106 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L106

Added line #L106 was not covered by tests
std::getline(ss, token, delimiter);

if (token.compare(EXIT) == 0) {
break;

Check warning on line 110 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L110

Added line #L110 was not covered by tests
} else if (token.compare(LIST) == 0) {
list_command(connFd, sqlite, &loop_exit);
} else if (token.compare(ADGR) == 0){
add_graph_command(masterIP, connFd, sqlite, &loop_exit, line);
} else if (token.compare(TRIANGLES) == 0) {
triangles_command(masterIP, connFd, sqlite, perfSqlite, jobScheduler, &loop_exit, line);
}else if (token.compare(RMGR) == 0) {
remove_graph_command(masterIP, connFd, sqlite, &loop_exit, line);
} else {
@@ -117,7 +121,7 @@
int result_wr = write(connFd, INVALID_FORMAT.c_str(), INVALID_FORMAT.size());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
break;

Check warning on line 124 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L124

Added line #L124 was not covered by tests
}
}
}
@@ -126,42 +130,42 @@
}
ui_frontend_logger.info("Closing thread " + to_string(pthread_self()) + " and connection");
close(connFd);
currentFESession--;
return NULL;
}

Check warning on line 135 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L133-L135

Added lines #L133 - L135 were not covered by tests

JasmineGraphFrontEndUI::JasmineGraphFrontEndUI(SQLiteDBInterface *db, PerformanceSQLiteDBInterface *perfDb,
std::string masterIP, JobScheduler *jobScheduler) {
this->sqlite = db;

Check warning on line 139 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L137-L139

Added lines #L137 - L139 were not covered by tests
this->masterIP = masterIP;
this->perfSqlite = perfDb;
this->jobScheduler = jobScheduler;
}

Check warning on line 143 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L141-L143

Added lines #L141 - L143 were not covered by tests

int JasmineGraphFrontEndUI::run() {

Check warning on line 145 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L145

Added line #L145 was not covered by tests
int pId;
int portNo = Conts::JASMINEGRAPH_UI_FRONTEND_PORT;

Check warning on line 147 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L147

Added line #L147 was not covered by tests
int listenFd;
socklen_t len;
bool loop = false;

Check warning on line 150 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L150

Added line #L150 was not covered by tests
struct sockaddr_in svrAdd;
struct sockaddr_in clntAdd;

// create socket
listenFd = socket(AF_INET, SOCK_STREAM, 0);

Check warning on line 155 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L155

Added line #L155 was not covered by tests

if (listenFd < 0) {
ui_frontend_logger.error("Cannot open socket");
return 0;

Check warning on line 159 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L159

Added line #L159 was not covered by tests
}

bzero((char *)&svrAdd, sizeof(svrAdd));

Check warning on line 162 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L162

Added line #L162 was not covered by tests

svrAdd.sin_family = AF_INET;
svrAdd.sin_addr.s_addr = INADDR_ANY;
svrAdd.sin_port = htons(portNo);

Check warning on line 166 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L164-L166

Added lines #L164 - L166 were not covered by tests

int yes = 1;

Check warning on line 168 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L168

Added line #L168 was not covered by tests

if (setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) == -1) {
perror("setsockopt");
@@ -170,15 +174,15 @@
// bind socket
if (bind(listenFd, (struct sockaddr *)&svrAdd, sizeof(svrAdd)) < 0) {
ui_frontend_logger.error("Cannot bind on port " + portNo);
return 0;

Check warning on line 177 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L177

Added line #L177 was not covered by tests
}

listen(listenFd, MAX_PENDING_CONNECTIONS);

Check warning on line 180 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L180

Added line #L180 was not covered by tests

std::vector<std::thread> threadVector;
len = sizeof(clntAdd);

Check warning on line 183 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L182-L183

Added lines #L182 - L183 were not covered by tests

int noThread = 0;

Check warning on line 185 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L185

Added line #L185 was not covered by tests

while (true) {
ui_frontend_logger.info("Frontend Listening");
@@ -188,23 +192,23 @@

if (connFd < 0) {
ui_frontend_logger.error("Cannot accept connection");
continue;

Check warning on line 195 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L195

Added line #L195 was not covered by tests
}
ui_frontend_logger.info("Connection successful from " + std::string(inet_ntoa(clntAdd.sin_addr)));

frontendservicesessionargs *sessionargs = new frontendservicesessionargs;
sessionargs->masterIP = masterIP;
sessionargs->connFd = connFd;
sessionargs->sqlite = this->sqlite;
sessionargs->perfSqlite = this->perfSqlite;
sessionargs->jobScheduler = this->jobScheduler;

Check warning on line 204 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L201-L204

Added lines #L201 - L204 were not covered by tests
pthread_t pt;
pthread_create(&pt, NULL, uifrontendservicesesion, sessionargs);
pthread_detach(pt);
}
}

Check warning on line 209 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L206-L209

Added lines #L206 - L209 were not covered by tests

static void list_command(int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p) {

Check warning on line 211 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L211

Added line #L211 was not covered by tests
json result_json = json::array(); // Create a JSON array to hold the result

// Fetch data from the database
@@ -212,21 +216,21 @@

// Iterate through the result set and construct the JSON array
for (auto &row : data) {
json entry; // JSON object for a single row
int counter = 0;

Check warning on line 220 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L219-L220

Added lines #L219 - L220 were not covered by tests

for (auto &column : row) {
switch (counter) {
case 0:

Check warning on line 224 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L224

Added line #L224 was not covered by tests
entry["idgraph"] = column.second;
break;
case 1:

Check warning on line 227 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L226-L227

Added lines #L226 - L227 were not covered by tests
entry["name"] = column.second;
break;
case 2:

Check warning on line 230 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L229-L230

Added lines #L229 - L230 were not covered by tests
entry["upload_path"] = column.second;
break;
case 3:

Check warning on line 233 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L232-L233

Added lines #L232 - L233 were not covered by tests
if (std::stoi(column.second) == Conts::GRAPH_STATUS::LOADING) {
entry["status"] = "loading";
} else if (std::stoi(column.second) == Conts::GRAPH_STATUS::DELETING) {
@@ -236,25 +240,25 @@
} else if (std::stoi(column.second) == Conts::GRAPH_STATUS::OPERATIONAL) {
entry["status"] = "op";
}
break;
case 4:

Check warning on line 244 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L243-L244

Added lines #L243 - L244 were not covered by tests
entry["vertexcount"] = column.second;
break;
case 5:

Check warning on line 247 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L246-L247

Added lines #L246 - L247 were not covered by tests
entry["edgecount"] = column.second;
break;
case 6:

Check warning on line 250 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L249-L250

Added lines #L249 - L250 were not covered by tests
entry["centralpartitioncount"] = column.second;
break;
default:
break;

Check warning on line 254 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L252-L254

Added lines #L252 - L254 were not covered by tests
}
counter++;

Check warning on line 256 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L256

Added line #L256 was not covered by tests
}

// Add the entry to the JSON array
result_json.push_back(entry);
}

Check warning on line 261 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L261

Added line #L261 was not covered by tests

// Convert JSON object to string
string result = result_json.dump();
@@ -264,46 +268,46 @@
int result_wr = write(connFd, EMPTY.c_str(), EMPTY.length());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 272 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L271-L272

Added lines #L271 - L272 were not covered by tests
}

result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;

Check warning on line 278 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L278

Added line #L278 was not covered by tests
}
} else {
int result_wr = write(connFd, result.c_str(), result.length());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;

Check warning on line 284 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L284

Added line #L284 was not covered by tests
}
}
}

// Function to extract the file name from the URL
std::string extractFileNameFromURL(const std::string& url) {

Check warning on line 290 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L290

Added line #L290 was not covered by tests
std::regex urlRegex("([^/]+)$");
std::smatch matches;

Check warning on line 292 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L292

Added line #L292 was not covered by tests
if (std::regex_search(url, matches, urlRegex) && matches.size() > 1) {
return matches.str(1);
}
return "downloaded_file";
}

Check warning on line 297 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L297

Added line #L297 was not covered by tests

std::string sanitizeFileName(const std::string& fileName) {

Check warning on line 299 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L299

Added line #L299 was not covered by tests
// Remove unsafe characters using regex (allow alphanumeric and some safe symbols)
std::regex unsafePattern("[^a-zA-Z0-9_.-]");
return std::regex_replace(fileName, unsafePattern, "");
}

Check warning on line 303 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L303

Added line #L303 was not covered by tests

static void add_graph_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p, std::string command) {
char delimiter = '|';

Check warning on line 306 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L305-L306

Added lines #L305 - L306 were not covered by tests
std::stringstream ss(command);
std::string token;
std::string graph;
std::string fileURL;

Check warning on line 310 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L308-L310

Added lines #L308 - L310 were not covered by tests

std::getline(ss, token, delimiter);
std::getline(ss, graph, delimiter);
@@ -322,14 +326,14 @@
int result_wr = write(connFd, SEND.c_str(), FRONTEND_COMMAND_LENGTH);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 330 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L329-L330

Added lines #L329 - L330 were not covered by tests
}
result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 336 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L335-L336

Added lines #L335 - L336 were not covered by tests
}

string name = "";
@@ -339,7 +343,7 @@
name = graph;
path = savedFilePath;

std::time_t time = chrono::system_clock::to_time_t(chrono::system_clock::now());

Check warning on line 346 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L346

Added line #L346 was not covered by tests
string uploadStartTime = ctime(&time);

partitionCount = JasmineGraphFrontEndCommon::getPartitionCount(path);
@@ -347,7 +351,7 @@
if (JasmineGraphFrontEndCommon::graphExists(path, sqlite)) {
ui_frontend_logger.error("Graph exists");
// TODO: inform client?
return;

Check warning on line 354 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L354

Added line #L354 was not covered by tests
}

if (Utils::fileExists(path)) {
@@ -360,7 +364,7 @@
to_string(Conts::GRAPH_STATUS::LOADING) + "\", \"\", \"\", \"\")";
int newGraphID = sqlite->runInsert(sqlStatement);
MetisPartitioner partitioner(sqlite);
vector<std::map<int, string>> fullFileList;

Check warning on line 367 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L367

Added line #L367 was not covered by tests

partitioner.loadDataSet(path, newGraphID);
int result = partitioner.constructMetisFormat(Conts::GRAPH_TYPE_NORMAL);
@@ -369,7 +373,7 @@
partitioner.loadDataSet(reformattedFilePath, newGraphID);
partitioner.constructMetisFormat(Conts::GRAPH_TYPE_NORMAL_REFORMATTED);
fullFileList = partitioner.partitioneWithGPMetis(partitionCount);
} else {

Check warning on line 376 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L376

Added line #L376 was not covered by tests
fullFileList = partitioner.partitioneWithGPMetis(partitionCount);
}
ui_frontend_logger.info("Upload done");
@@ -380,29 +384,29 @@
int result_wr = write(connFd, DONE.c_str(), DONE.size());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 388 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L387-L388

Added lines #L387 - L388 were not covered by tests
}
result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;

Check warning on line 393 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L393

Added line #L393 was not covered by tests
}
} else {
ui_frontend_logger.error("Graph data file does not exist on the specified path");
}
}

static void remove_graph_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p, std::string command){
char delimiter = '|';

Check warning on line 401 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L400-L401

Added lines #L400 - L401 were not covered by tests
std::stringstream ss(command);
std::string token;
std::string graphID;

Check warning on line 404 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L403-L404

Added lines #L403 - L404 were not covered by tests

std::getline(ss, token, delimiter);
std::getline(ss, graphID, delimiter);

std::cout << "recieved graph id: " <<graphID << std::endl;
ui_frontend_logger.info("recieved graph id: " + graphID);

if (JasmineGraphFrontEndCommon::graphExistsByID(graphID, sqlite)) {
ui_frontend_logger.info("Graph with ID " + graphID + " is being deleted now");
@@ -410,27 +414,167 @@
int result_wr = write(connFd, DONE.c_str(), DONE.size());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 418 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L417-L418

Added lines #L417 - L418 were not covered by tests
}
result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 424 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L423-L424

Added lines #L423 - L424 were not covered by tests
}
} else {
ui_frontend_logger.error("Graph does not exist or cannot be deleted with the current hosts setting");
int result_wr = write(connFd, ERROR.c_str(), ERROR.size());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 432 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L431-L432

Added lines #L431 - L432 were not covered by tests
}
result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;

Check warning on line 437 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L437

Added line #L437 was not covered by tests
}
}
}

static void triangles_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite,

Check warning on line 442 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L442

Added line #L442 was not covered by tests
PerformanceSQLiteDBInterface *perfSqlite, JobScheduler *jobScheduler, bool *loop_exit_p, std::string command) {
char delimiter = '|';

Check warning on line 444 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L444

Added line #L444 was not covered by tests
std::stringstream ss(command);
std::string token;
std::string graph_id;
std::string priority;

Check warning on line 448 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L446-L448

Added lines #L446 - L448 were not covered by tests

std::getline(ss, token, delimiter);
std::getline(ss, graph_id, delimiter);
std::getline(ss, priority, delimiter);

ui_frontend_logger.info("recieved graph id: " + graph_id);
ui_frontend_logger.info("Priority: " + priority);

// add RDF graph
int uniqueId = JasmineGraphFrontEndCommon::getUid();

string name = "";

if (!JasmineGraphFrontEndCommon::graphExistsByID(graph_id, sqlite)) {
string error_message = "The specified graph id does not exist";
int result_wr = write(connFd, error_message.c_str(), FRONTEND_COMMAND_LENGTH);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 468 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L467-L468

Added lines #L467 - L468 were not covered by tests
}

result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;

Check warning on line 474 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L474

Added line #L474 was not covered by tests
}
} else {
if (!(std::find_if(priority.begin(), priority.end(), [](unsigned char c) { return !std::isdigit(c); }) ==
priority.end())) {
*loop_exit_p = true;

Check warning on line 479 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L479

Added line #L479 was not covered by tests
string error_message = "Priority should be numeric and > 1 or empty";
int result_wr = write(connFd, error_message.c_str(), error_message.length());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
return;

Check warning on line 484 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L484

Added line #L484 was not covered by tests
}

result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
}
return;
}

Check warning on line 492 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L491-L492

Added lines #L491 - L492 were not covered by tests

int threadPriority = std::atoi(priority.c_str());

Check warning on line 494 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L494

Added line #L494 was not covered by tests

static volatile int reqCounter = 0;
string reqId = to_string(reqCounter++);
ui_frontend_logger.info("Started processing request " + reqId);
auto begin = chrono::high_resolution_clock::now();
JobRequest jobDetails;

Check warning on line 500 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L499-L500

Added lines #L499 - L500 were not covered by tests
jobDetails.setJobId(std::to_string(uniqueId));
jobDetails.setJobType(TRIANGLES);

long graphSLA = -1; // This prevents auto calibration for priority=1 (=default priority)

Check warning on line 504 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L504

Added line #L504 was not covered by tests
if (threadPriority > Conts::DEFAULT_THREAD_PRIORITY) {
// All high priority threads will be set the same high priority level
threadPriority = Conts::HIGH_PRIORITY_DEFAULT_VALUE;

Check warning on line 507 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L507

Added line #L507 was not covered by tests
graphSLA = JasmineGraphFrontEndCommon::getSLAForGraphId(sqlite, perfSqlite, graph_id, TRIANGLES,
Conts::SLA_CATEGORY::LATENCY);
jobDetails.addParameter(Conts::PARAM_KEYS::GRAPH_SLA, std::to_string(graphSLA));
}

if (graphSLA == 0) {
if (JasmineGraphFrontEnd::areRunningJobsForSameGraph()) {
if (canCalibrate) {
// initial calibration
jobDetails.addParameter(Conts::PARAM_KEYS::AUTO_CALIBRATION, "false");
} else {
// auto calibration
jobDetails.addParameter(Conts::PARAM_KEYS::AUTO_CALIBRATION, "true");
}
} else {
// TODO(ASHOK12011234): Need to investigate for multiple graphs
ui_frontend_logger.error("Can't calibrate the graph now");
}
}

jobDetails.setPriority(threadPriority);
jobDetails.setMasterIP(masterIP);
jobDetails.addParameter(Conts::PARAM_KEYS::GRAPH_ID, graph_id);
jobDetails.addParameter(Conts::PARAM_KEYS::CATEGORY, Conts::SLA_CATEGORY::LATENCY);
if (canCalibrate) {
jobDetails.addParameter(Conts::PARAM_KEYS::CAN_CALIBRATE, "true");
} else {
jobDetails.addParameter(Conts::PARAM_KEYS::CAN_CALIBRATE, "false");
}

jobScheduler->pushJob(jobDetails);
JobResponse jobResponse = jobScheduler->getResult(jobDetails);
std::string errorMessage = jobResponse.getParameter(Conts::PARAM_KEYS::ERROR_MESSAGE);

if (!errorMessage.empty()) {
*loop_exit_p = true;

Check warning on line 543 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L543

Added line #L543 was not covered by tests
int result_wr = write(connFd, errorMessage.c_str(), errorMessage.length());

if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
return;

Check warning on line 548 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L548

Added line #L548 was not covered by tests
}
result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
}
return;

Check warning on line 554 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L554

Added line #L554 was not covered by tests
}

std::string triangleCount = jobResponse.getParameter(Conts::PARAM_KEYS::TRIANGLE_COUNT);

if (threadPriority == Conts::HIGH_PRIORITY_DEFAULT_VALUE) {
highPriorityTaskCount--;

Check warning on line 560 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L560

Added line #L560 was not covered by tests
}

auto end = chrono::high_resolution_clock::now();

Check warning on line 563 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L563

Added line #L563 was not covered by tests
auto dur = end - begin;
auto msDuration = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
ui_frontend_logger.info("Req: " + reqId + " Triangle Count: " + triangleCount +
" Time Taken: " + to_string(msDuration) + " milliseconds");
int result_wr = write(connFd, triangleCount.c_str(), triangleCount.length());
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;
return;

Check warning on line 572 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L571-L572

Added lines #L571 - L572 were not covered by tests
}
result_wr = write(connFd, "\r\n", 2);
if (result_wr < 0) {
ui_frontend_logger.error("Error writing to socket");
*loop_exit_p = true;

Check warning on line 577 in src/frontend/ui/JasmineGraphFrontEndUI.cpp

Codecov / codecov/patch

src/frontend/ui/JasmineGraphFrontEndUI.cpp#L577

Added line #L577 was not covered by tests
}
}
}
Loading