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
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ set(SOURCES src/backend/JasmineGraphBackend.cpp
src/util/dbinterface/DBInterface.cpp
src/query/processor/cypher/semanticanalyzer/SemanticAnalyzer.cpp
src/query/processor/cypher/util/Const.cpp
src/frontend/ui/JasmineGraphFrontEndUIProtocol.h
src/frontend/ui/JasmineGraphFrontEndUIProtocol.cpp
src/frontend/ui/JasmineGraphFrontEndUI.cpp
src/frontend/ui/JasmineGraphFrontEndUI.h
src/frontend/core/common/JasmineGraphFrontendCommon.cpp
src/frontend/core/common/JasmineGraphFrontendCommon.h
)

if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
Expand Down
2 changes: 1 addition & 1 deletion cmake_modules/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ function(setup_target_for_coverage_gcovr_xml)
# Running gcovr
set(GCOVR_XML_CMD
${GCOVR_PATH} --xml ${Coverage_NAME}.xml -r ${BASEDIR} ${GCOVR_ADDITIONAL_ARGS}
${GCOVR_EXCLUDE_ARGS} --object-directory=${PROJECT_BINARY_DIR}
${GCOVR_EXCLUDE_ARGS} --object-directory=${PROJECT_BINARY_DIR} --gcov-ignore-parse-errors=negative_hits.warn
)

if(CODE_COVERAGE_VERBOSE)
Expand Down
295 changes: 36 additions & 259 deletions src/frontend/JasmineGraphFrontEnd.cpp

Large diffs are not rendered by default.

24 changes: 1 addition & 23 deletions src/frontend/JasmineGraphFrontEnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,12 @@ class JasmineGraphFrontEnd {

int run();

static bool graphExists(std::string basic_string, SQLiteDBInterface *sqlite);

static bool modelExists(std::string basic_string, SQLiteDBInterface *sqlite);

static bool graphExistsByID(std::string id, SQLiteDBInterface *sqlite);

static bool modelExistsByID(std::string id, SQLiteDBInterface *sqlite);

static void removeGraph(std::string graphID, SQLiteDBInterface *sqlite, std::string masterIP);

static void getAndUpdateUploadTime(std::string graphID, SQLiteDBInterface *sqlite);

static bool isGraphActiveAndTrained(std::string graphID, SQLiteDBInterface *sqlite);

static map<long, long> getOutDegreeDistributionHashMap(map<long, unordered_set<long>> graphMap);

static bool isGraphActive(string graphID, SQLiteDBInterface *sqlite);

static int getUid();

static long getSLAForGraphId(SQLiteDBInterface *sqlite, PerformanceSQLiteDBInterface *perfSqlite,
std::string graphId, std::string command, std::string category);

static void scheduleStrianJobs(JobRequest &jobDetails, std::priority_queue<JobRequest> &jobQueue,
JobScheduler *jobScheduler, bool *strian_exist);

static int getRunningHighPriorityTaskCount();
static bool areRunningJobsForSameGraph();

static bool strian_exit;
std::map<std::string, std::atomic<bool>> *streamsState;
std::map<std::string, std::thread> streamingThreads;
Expand Down
1 change: 0 additions & 1 deletion src/frontend/JasmineGraphFrontEndProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ const string COMMAND = "command";
const string PRIORITY = "priority(>=1)";
const string INVALID_FORMAT = "Invalid message format";
const string CYPHER_AST = "cypher-ast";

230 changes: 230 additions & 0 deletions src/frontend/core/common/JasmineGraphFrontendCommon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/**
Copyright 2019 JasminGraph Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "JasmineGraphFrontendCommon.h"
#include "../../JasmineGraphFrontEndProtocol.h"
#include "../../../server/JasmineGraphServer.h"
#include "../../../util/logger/Logger.h"

Logger common_logger;

/**
* This method checks if a graph exists in JasmineGraph.
* This method uses the unique path of the graph.
* @param basic_string
* @param dummyPt
* @return
*/
bool JasmineGraphFrontEndCommon::graphExists(string path, SQLiteDBInterface *sqlite) {

Check warning on line 28 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L28

Added line #L28 was not covered by tests
string stmt = "SELECT COUNT( * ) FROM graph WHERE upload_path LIKE '" + path +
"' AND graph_status_idgraph_status = '" + to_string(Conts::GRAPH_STATUS::OPERATIONAL) + "';";
std::vector<vector<pair<string, string>>> v = sqlite->runSelect(stmt);
return (std::stoi(v[0][0].second) != 0);
}

Check warning on line 33 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L33

Added line #L33 was not covered by tests

/**
* This method checks if an accessible graph exists in JasmineGraph with the same unique ID.
* @param id
* @param dummyPt
* @return
*/
bool JasmineGraphFrontEndCommon::graphExistsByID(string id, SQLiteDBInterface *sqlite) {

Check warning on line 41 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L41

Added line #L41 was not covered by tests
string stmt = "SELECT COUNT( * ) FROM graph WHERE idgraph = " + id;
std::vector<vector<pair<string, string>>> v = sqlite->runSelect(stmt);
return (std::stoi(v[0][0].second) != 0);
}

Check warning on line 45 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L45

Added line #L45 was not covered by tests

/**
* This method removes a graph from JasmineGraph
*/
void JasmineGraphFrontEndCommon::removeGraph(std::string graphID, SQLiteDBInterface *sqlite, std::string masterIP) {
vector<pair<string, string>> hostHasPartition;

Check warning on line 51 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L50-L51

Added lines #L50 - L51 were not covered by tests
vector<vector<pair<string, string>>> hostPartitionResults = sqlite->runSelect(
"SELECT name, partition_idpartition FROM worker_has_partition INNER JOIN worker ON "
"worker_has_partition.worker_idworker = worker.idworker WHERE partition_graph_idgraph = " +

Check warning on line 54 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L54

Added line #L54 was not covered by tests
graphID + ";");
for (vector<vector<pair<string, string>>>::iterator i = hostPartitionResults.begin();

Check warning on line 56 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L56

Added line #L56 was not covered by tests
i != hostPartitionResults.end(); ++i) {
int count = 0;
string hostname;
string partitionID;

Check warning on line 60 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L58-L60

Added lines #L58 - L60 were not covered by tests
for (std::vector<pair<string, string>>::iterator j = (i->begin()); j != i->end(); ++j) {
if (count == 0) {
hostname = j->second;
} else {
partitionID = j->second;
hostHasPartition.push_back(pair<string, string>(hostname, partitionID));
}
count++;

Check warning on line 68 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L68

Added line #L68 was not covered by tests
}
}

Check warning on line 70 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L70

Added line #L70 was not covered by tests
for (std::vector<pair<string, string>>::iterator j = (hostHasPartition.begin()); j != hostHasPartition.end(); ++j) {
common_logger.info("HOST ID : " + j->second + " PARTITION ID : " + j->first);
}
sqlite->runUpdate("UPDATE graph SET graph_status_idgraph_status = " + to_string(Conts::GRAPH_STATUS::DELETING) +
" WHERE idgraph = " + graphID);

JasmineGraphServer::removeGraph(hostHasPartition, graphID, masterIP);

sqlite->runUpdate("DELETE FROM worker_has_partition WHERE partition_graph_idgraph = " + graphID);
sqlite->runUpdate("DELETE FROM partition WHERE graph_idgraph = " + graphID);
sqlite->runUpdate("DELETE FROM graph WHERE idgraph = " + graphID);
}

Check warning on line 82 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L82

Added line #L82 was not covered by tests

/**
* This method checks whether the graph is active and trained
* @param graphID
* @param dummyPt
* @return
*/
bool JasmineGraphFrontEndCommon::isGraphActiveAndTrained(std::string graphID, SQLiteDBInterface *sqlite) {

Check warning on line 90 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L90

Added line #L90 was not covered by tests
string stmt = "SELECT COUNT( * ) FROM graph WHERE idgraph LIKE '" + graphID +
"' AND graph_status_idgraph_status = '" + to_string(Conts::GRAPH_STATUS::OPERATIONAL) +
"' AND train_status = '" + (Conts::TRAIN_STATUS::TRAINED) + "';";
std::vector<vector<pair<string, string>>> v = sqlite->runSelect(stmt);
return (std::stoi(v[0][0].second) != 0);
}

Check warning on line 96 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L96

Added line #L96 was not covered by tests

/**
* This method checks whether the graph is active
* @param graphID
* @param dummyPt
* @return
*/
bool JasmineGraphFrontEndCommon::isGraphActive(std::string graphID, SQLiteDBInterface *sqlite) {

Check warning on line 104 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L104

Added line #L104 was not covered by tests
string stmt = "SELECT COUNT( * ) FROM graph WHERE idgraph LIKE '" + graphID +
"' AND graph_status_idgraph_status = '" + to_string(Conts::GRAPH_STATUS::OPERATIONAL) + "';";
std::vector<vector<pair<string, string>>> v = sqlite->runSelect(stmt);
return (std::stoi(v[0][0].second) != 0);
}

Check warning on line 109 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L109

Added line #L109 was not covered by tests

bool JasmineGraphFrontEndCommon::modelExistsByID(string id, SQLiteDBInterface *sqlite) {

Check warning on line 111 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L111

Added line #L111 was not covered by tests
string stmt = "SELECT COUNT( * ) FROM model WHERE idmodel = " + id +
" and model_status_idmodel_status = " + to_string(Conts::GRAPH_STATUS::OPERATIONAL);
std::vector<vector<pair<string, string>>> v = sqlite->runSelect(stmt);
return (std::stoi(v[0][0].second) != 0);
}

Check warning on line 116 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L116

Added line #L116 was not covered by tests

bool JasmineGraphFrontEndCommon::modelExists(string path, SQLiteDBInterface *sqlite) {

Check warning on line 118 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L118

Added line #L118 was not covered by tests
string stmt = "SELECT COUNT( * ) FROM model WHERE upload_path LIKE '" + path +
"' AND model_status_idmodel_status = '" + to_string(Conts::GRAPH_STATUS::OPERATIONAL) + "';";
std::vector<vector<pair<string, string>>> v = sqlite->runSelect(stmt);
return (std::stoi(v[0][0].second) != 0);
}

Check warning on line 123 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L123

Added line #L123 was not covered by tests

void JasmineGraphFrontEndCommon::getAndUpdateUploadTime(std::string graphID, SQLiteDBInterface *sqlite) {

Check warning on line 125 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L125

Added line #L125 was not covered by tests
struct tm tm;
vector<vector<pair<string, string>>> uploadStartFinishTimes =
sqlite->runSelect("SELECT upload_start_time,upload_end_time FROM graph WHERE idgraph = '" + graphID + "'");
string startTime = uploadStartFinishTimes[0][0].second;
string endTime = uploadStartFinishTimes[0][1].second;
string sTime = startTime.substr(startTime.size() - 14, startTime.size() - 5);
string eTime = endTime.substr(startTime.size() - 14, startTime.size() - 5);
strptime(sTime.c_str(), "%H:%M:%S", &tm);
time_t start = mktime(&tm);
strptime(eTime.c_str(), "%H:%M:%S", &tm);
time_t end = mktime(&tm);
double difTime = difftime(end, start);

Check warning on line 137 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L133-L137

Added lines #L133 - L137 were not covered by tests
sqlite->runUpdate("UPDATE graph SET upload_time = " + to_string(difTime) + " WHERE idgraph = " + graphID);
common_logger.info("Upload time updated in the database");
}

Check warning on line 140 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L140

Added line #L140 was not covered by tests

map<long, long> JasmineGraphFrontEndCommon::getOutDegreeDistributionHashMap(map<long, unordered_set<long>> graphMap) {
map<long, long> distributionHashMap;

Check warning on line 143 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L142-L143

Added lines #L142 - L143 were not covered by tests

for (map<long, unordered_set<long>>::iterator it = graphMap.begin(); it != graphMap.end(); ++it) {
long distribution = (it->second).size();

Check warning on line 146 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L146

Added line #L146 was not covered by tests
distributionHashMap[it->first] = distribution;
}
return distributionHashMap;
}

Check warning on line 150 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L149-L150

Added lines #L149 - L150 were not covered by tests

int JasmineGraphFrontEndCommon::getUid() {

Check warning on line 152 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L152

Added line #L152 was not covered by tests
static std::atomic<std::uint32_t> uid{0};
return ++uid;

Check warning on line 154 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L154

Added line #L154 was not covered by tests
}

long JasmineGraphFrontEndCommon::getSLAForGraphId(SQLiteDBInterface *sqlite, PerformanceSQLiteDBInterface *perfSqlite,

Check warning on line 157 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L157

Added line #L157 was not covered by tests
std::string graphId, std::string command, std::string category) {
long graphSLAValue = 0;

Check warning on line 159 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L159

Added line #L159 was not covered by tests

string sqlStatement =
"SELECT worker_idworker, name,ip,user,server_port,server_data_port,partition_idpartition "
"FROM worker_has_partition INNER JOIN worker ON worker_has_partition.worker_idworker=worker.idworker "
"WHERE partition_graph_idgraph=" +
graphId + ";";

std::vector<vector<pair<string, string>>> results = sqlite->runSelect(sqlStatement);
int partitionCount = results.size();

Check warning on line 168 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L168

Added line #L168 was not covered by tests

string graphSlaQuery =
"select graph_sla.sla_value from graph_sla,sla_category where graph_sla.id_sla_category=sla_category.id "
"and sla_category.command='" +
command + "' and sla_category.category='" + category +
"' and "
"graph_sla.graph_id='" +
graphId + "' and graph_sla.partition_count='" + std::to_string(partitionCount) + "';";

std::vector<vector<pair<string, string>>> slaResults = perfSqlite->runSelect(graphSlaQuery);

if (slaResults.size() > 0) {
string currentSlaString = slaResults[0][0].second;
long graphSLAValue = atol(currentSlaString.c_str());
}

Check warning on line 183 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L182-L183

Added lines #L182 - L183 were not covered by tests

return graphSLAValue;
}

Check warning on line 186 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L185-L186

Added lines #L185 - L186 were not covered by tests

std::vector<std::vector<std::pair<std::string, std::string>>>
JasmineGraphFrontEndCommon::getGraphData(SQLiteDBInterface *sqlite) {

Check warning on line 189 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L189

Added line #L189 was not covered by tests
return sqlite->runSelect("SELECT idgraph, name, upload_path, graph_status_idgraph_status, "
"vertexcount, edgecount, centralpartitioncount FROM graph;");
}

bool JasmineGraphFrontEndCommon::checkServerBusy(std::atomic<int> *currentFESession, int connFd) {

Check warning on line 194 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L194

Added line #L194 was not covered by tests
if (*currentFESession >= Conts::MAX_FE_SESSIONS) {
if (!Utils::send_str_wrapper(connFd, "JasmineGraph server is busy. Please try again later.")) {
common_logger.error("Error writing to socket");
}
close(connFd);
return true;

Check warning on line 200 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L199-L200

Added lines #L199 - L200 were not covered by tests
}
(*currentFESession)++; // Increment only if not busy
return false;

Check warning on line 203 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L202-L203

Added lines #L202 - L203 were not covered by tests
}

std::string JasmineGraphFrontEndCommon::readAndProcessInput(int connFd, char* data, int &failCnt) {

Check warning on line 206 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L206

Added line #L206 was not covered by tests
std::string line = Utils::read_str_wrapper(connFd, data, FRONTEND_DATA_LENGTH, true);
if (line.empty()) {
failCnt++;

Check warning on line 209 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L209

Added line #L209 was not covered by tests
if (failCnt > 4) {
return "";
}
sleep(1);
} else {
failCnt = 0;

Check warning on line 215 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L215

Added line #L215 was not covered by tests
}
return Utils::trim_copy(line);
}

Check warning on line 218 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L218

Added line #L218 was not covered by tests

std::string JasmineGraphFrontEndCommon::getPartitionCount(std::string path) {

Check warning on line 220 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L220

Added line #L220 was not covered by tests
if (Utils::getJasmineGraphProperty("org.jasminegraph.autopartition.enabled") != "true") {
return "";
}
ifstream dataFile(path);
size_t edges = std::count(std::istreambuf_iterator<char>(dataFile), std::istreambuf_iterator<char>(), '\n');
dataFile.close();
int partCnt = (int)round(pow(edges, 0.2) / 6);

Check warning on line 227 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L227

Added line #L227 was not covered by tests
if (partCnt < 2) partCnt = 2;
return to_string(partCnt);
}

Check warning on line 230 in src/frontend/core/common/JasmineGraphFrontendCommon.cpp

View check run for this annotation

Codecov / codecov/patch

src/frontend/core/common/JasmineGraphFrontendCommon.cpp#L230

Added line #L230 was not covered by tests
57 changes: 57 additions & 0 deletions src/frontend/core/common/JasmineGraphFrontendCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
Copyright 2019 JasminGraph Team
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef JASMINEGRAPHFRONTENDCOMMON_H
#define JASMINEGRAPHFRONTENDCOMMON_H

#include <map>
#include <thread>

#include "../../../metadb/SQLiteDBInterface.h"
#include "../../../query/algorithms/triangles/Triangles.h"

class JasmineGraphFrontEndCommon {
public:
static bool graphExists(std::string basic_string, SQLiteDBInterface *sqlite);

static bool graphExistsByID(std::string id, SQLiteDBInterface *sqlite);

static void removeGraph(std::string graphID, SQLiteDBInterface *sqlite, std::string masterIP);

static bool isGraphActive(string graphID, SQLiteDBInterface *sqlite);

static bool modelExists(std::string basic_string, SQLiteDBInterface *sqlite);

static bool modelExistsByID(std::string id, SQLiteDBInterface *sqlite);

static void getAndUpdateUploadTime(std::string graphID, SQLiteDBInterface *sqlite);

static bool isGraphActiveAndTrained(std::string graphID, SQLiteDBInterface *sqlite);

static map<long, long> getOutDegreeDistributionHashMap(map<long, unordered_set<long>> graphMap);

static int getUid();

static long getSLAForGraphId(SQLiteDBInterface *sqlite, PerformanceSQLiteDBInterface *perfSqlite,
std::string graphId, std::string command, std::string category);

static std::vector<std::vector<std::pair<std::string, std::string>>> getGraphData(SQLiteDBInterface *sqlite);

static bool checkServerBusy(std::atomic<int> *currentFESession, int connFd);

static std::string readAndProcessInput(int connFd, char* data, int &failCnt);

static std::string getPartitionCount(std::string path);
};

#endif // JASMINEGRAPHFRONTENDCOMMON_H
Loading
Loading