Skip to content

Commit 05d31b5

Browse files
committed
Replace localhost with master IP
1 parent 1695b01 commit 05d31b5

File tree

1 file changed

+32
-37
lines changed

1 file changed

+32
-37
lines changed

src/server/JasmineGraphInstanceService.cpp

+32-37
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ limitations under the License.
2121
#include <cmath>
2222
#include <string>
2323

24+
#include "../query/algorithms/triangles/StreamingTriangles.h"
2425
#include "../server/JasmineGraphServer.h"
2526
#include "../util/logger/Logger.h"
2627
#include "JasmineGraphInstance.h"
27-
#include "../query/algorithms/triangles/StreamingTriangles.h"
2828

2929
using namespace std;
3030

@@ -46,6 +46,8 @@ std::vector<std::string> loadAverageVector;
4646
bool collectValid = false;
4747
std::thread JasmineGraphInstanceService::workerThread;
4848

49+
std::string masterIP;
50+
4951
static void handshake_command(int connFd, bool *loop_exit_p);
5052
static inline void close_command(int connFd, bool *loop_exit_p);
5153
__attribute__((noreturn)) static inline void shutdown_command(int connFd);
@@ -87,15 +89,15 @@ static void triangles_command(
8789
std::map<std::string, JasmineGraphHashMapCentralStore> graphDBMapCentralStores,
8890
std::map<std::string, JasmineGraphHashMapDuplicateCentralStore> graphDBMapDuplicateCentralStores,
8991
bool *loop_exit_p);
90-
static void streaming_triangles_command(int connFd, int serverPort, std::map<std::string,
91-
JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
92-
bool *loop_exit_p);
92+
static void streaming_triangles_command(
93+
int connFd, int serverPort, std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
94+
bool *loop_exit_p);
9395
static void send_centralstore_to_aggregator_command(int connFd, bool *loop_exit_p);
9496
static void send_composite_centralstore_to_aggregator_command(int connFd, bool *loop_exit_p);
9597
static void aggregate_centralstore_triangles_command(int connFd, bool *loop_exit_p);
9698
static void aggregate_streaming_centralstore_triangles_command(
97-
int connFd, std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
98-
bool *loop_exit_p);
99+
int connFd, std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
100+
bool *loop_exit_p);
99101
static void aggregate_composite_centralstore_triangles_command(int connFd, bool *loop_exit_p);
100102
static void performance_statistics_command(int connFd, bool *loop_exit_p);
101103
static void initiate_files_command(int connFd, bool *loop_exit_p);
@@ -576,7 +578,7 @@ string JasmineGraphInstanceService::aggregateCentralStoreTriangles(std::string g
576578
map<long, long> distributionHashMap =
577579
JasmineGraphInstanceService::getOutDegreeDistributionHashMap(aggregatedCentralStore);
578580

579-
TriangleResult triangleResult = Triangles::countTriangles(aggregatedCentralStore, distributionHashMap, true);
581+
TriangleResult triangleResult = Triangles::countTriangles(aggregatedCentralStore, distributionHashMap, true);
580582
std::string triangles = triangleResult.triangles;
581583

582584
return triangles;
@@ -652,8 +654,8 @@ string JasmineGraphInstanceService::aggregateCompositeCentralStoreTriangles(std:
652654
map<long, long> distributionHashMap =
653655
JasmineGraphInstanceService::getOutDegreeDistributionHashMap(aggregatedCompositeCentralStore);
654656

655-
TriangleResult triangleResult = Triangles::countTriangles(aggregatedCompositeCentralStore,
656-
distributionHashMap, true);
657+
TriangleResult triangleResult =
658+
Triangles::countTriangles(aggregatedCompositeCentralStore, distributionHashMap, true);
657659
std::string triangles = triangleResult.triangles;
658660

659661
return triangles;
@@ -2045,15 +2047,15 @@ static void handshake_command(int connFd, bool *loop_exit_p) {
20452047
instance_logger.info("Sent : " + JasmineGraphInstanceProtocol::HANDSHAKE_OK);
20462048

20472049
char data[DATA_BUFFER_SIZE];
2048-
string server_hostname = Utils::read_str_trim_wrapper(connFd, data, INSTANCE_DATA_LENGTH);
2049-
instance_logger.info("Received hostname : " + server_hostname);
2050+
masterIP = Utils::read_str_trim_wrapper(connFd, data, INSTANCE_DATA_LENGTH);
2051+
instance_logger.info("Received hostname : " + masterIP);
20502052

20512053
instance_logger.info("Sending : " + JasmineGraphInstanceProtocol::HOST_OK);
20522054
if (!Utils::send_str_wrapper(connFd, JasmineGraphInstanceProtocol::HOST_OK)) {
20532055
*loop_exit_p = true;
20542056
return;
20552057
}
2056-
instance_logger.info("ServerName : " + server_hostname);
2058+
instance_logger.info("ServerName : " + masterIP);
20572059
}
20582060

20592061
static inline void close_command(int connFd, bool *loop_exit_p) {
@@ -2302,7 +2304,7 @@ static void duplicate_centralstore_command(int connFd, int serverPort, bool *loo
23022304
}
23032305

23042306
JasmineGraphInstanceService::duplicateCentralStore(serverPort, stoi(graphID), stoi(partitionID), workerSockets,
2305-
"localhost");
2307+
masterIP);
23062308
}
23072309

23082310
static void worker_in_degree_distribution_command(
@@ -2967,9 +2969,9 @@ static void triangles_command(
29672969
}
29682970
}
29692971

2970-
static void streaming_triangles_command(int connFd, int serverPort,
2971-
std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
2972-
bool *loop_exit_p) {
2972+
static void streaming_triangles_command(
2973+
int connFd, int serverPort, std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
2974+
bool *loop_exit_p) {
29732975
if (!Utils::send_str_wrapper(connFd, JasmineGraphInstanceProtocol::OK)) {
29742976
*loop_exit_p = true;
29752977
return;
@@ -3017,8 +3019,7 @@ static void streaming_triangles_command(int connFd, int serverPort,
30173019

30183020
if (incrementalLocalStoreMap.find(graphIdentifier) == incrementalLocalStoreMap.end()) {
30193021
incrementalLocalStoreInstance =
3020-
JasmineGraphInstanceService::loadStreamingStore(graphID, partitionId,
3021-
incrementalLocalStoreMap, "app");
3022+
JasmineGraphInstanceService::loadStreamingStore(graphID, partitionId, incrementalLocalStoreMap, "app");
30223023
} else {
30233024
incrementalLocalStoreInstance = incrementalLocalStoreMap[graphIdentifier];
30243025
}
@@ -3028,8 +3029,7 @@ static void streaming_triangles_command(int connFd, int serverPort,
30283029
localCount = StreamingTriangles::countLocalStreamingTriangles(incrementalLocalStoreInstance);
30293030
} else {
30303031
localCount = StreamingTriangles::countDynamicLocalTriangles(
3031-
incrementalLocalStoreInstance, std::stol(oldLocalRelationCount),
3032-
std::stol(oldCentralRelationCount));
3032+
incrementalLocalStoreInstance, std::stol(oldLocalRelationCount), std::stol(oldCentralRelationCount));
30333033
}
30343034

30353035
long newLocalRelationCount, newCentralRelationCount, result;
@@ -3045,8 +3045,7 @@ static void streaming_triangles_command(int connFd, int serverPort,
30453045

30463046
string response = Utils::read_str_trim_wrapper(connFd, data, INSTANCE_DATA_LENGTH);
30473047
if (response.compare(JasmineGraphInstanceProtocol::OK) != 0) {
3048-
instance_logger.error("Received : " + response + " instead of : " +
3049-
JasmineGraphInstanceProtocol::HOST_OK);
3048+
instance_logger.error("Received : " + response + " instead of : " + JasmineGraphInstanceProtocol::HOST_OK);
30503049
*loop_exit_p = true;
30513050
return;
30523051
}
@@ -3060,8 +3059,7 @@ static void streaming_triangles_command(int connFd, int serverPort,
30603059

30613060
response = Utils::read_str_trim_wrapper(connFd, data, INSTANCE_DATA_LENGTH);
30623061
if (response.compare(JasmineGraphInstanceProtocol::OK) != 0) {
3063-
instance_logger.error("Received : " + response + " instead of : " +
3064-
JasmineGraphInstanceProtocol::HOST_OK);
3062+
instance_logger.error("Received : " + response + " instead of : " + JasmineGraphInstanceProtocol::HOST_OK);
30653063
*loop_exit_p = true;
30663064
return;
30673065
}
@@ -3365,8 +3363,8 @@ static void aggregate_centralstore_triangles_command(int connFd, bool *loop_exit
33653363
}
33663364

33673365
static void aggregate_streaming_centralstore_triangles_command(
3368-
int connFd, std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
3369-
bool *loop_exit_p) {
3366+
int connFd, std::map<std::string, JasmineGraphIncrementalLocalStore *> &incrementalLocalStoreMap,
3367+
bool *loop_exit_p) {
33703368
if (!Utils::send_str_wrapper(connFd, JasmineGraphInstanceProtocol::OK)) {
33713369
*loop_exit_p = true;
33723370
return;
@@ -3427,8 +3425,7 @@ static void aggregate_streaming_centralstore_triangles_command(
34273425
}
34283426

34293427
std::string aggregatedTriangles = JasmineGraphInstanceService::aggregateStreamingCentralStoreTriangles(
3430-
graphId, partitionId, partitionIdList, centralCountList,
3431-
threadPriority, incrementalLocalStoreMap, mode);
3428+
graphId, partitionId, partitionIdList, centralCountList, threadPriority, incrementalLocalStoreMap, mode);
34323429

34333430
if (threadPriority > Conts::DEFAULT_THREAD_PRIORITY) {
34343431
threadPriorityMutex.lock();
@@ -4252,11 +4249,11 @@ static void send_priority_command(int connFd, bool *loop_exit_p) {
42524249
}
42534250

42544251
string JasmineGraphInstanceService::aggregateStreamingCentralStoreTriangles(
4255-
std::string graphId, std::string partitionId, std::string partitionIdString,
4256-
std::string centralCountString, int threadPriority,
4257-
std::map<std::string, JasmineGraphIncrementalLocalStore *> incrementalLocalStores, std::string mode) {
4252+
std::string graphId, std::string partitionId, std::string partitionIdString, std::string centralCountString,
4253+
int threadPriority, std::map<std::string, JasmineGraphIncrementalLocalStore *> incrementalLocalStores,
4254+
std::string mode) {
42584255
instance_logger.info("###INSTANCE### Started Aggregating Central Store Triangles");
4259-
std::vector<JasmineGraphIncrementalLocalStore*> incrementalLocalStoreInstances;
4256+
std::vector<JasmineGraphIncrementalLocalStore *> incrementalLocalStoreInstances;
42604257
std::vector<std::string> centralCountList = Utils::split(centralCountString, ',');
42614258
std::vector<std::string> partitionIdList = Utils::split(partitionIdString, ',');
42624259
partitionIdList.push_back(partitionId);
@@ -4270,9 +4267,8 @@ string JasmineGraphInstanceService::aggregateStreamingCentralStoreTriangles(
42704267
JasmineGraphIncrementalLocalStore *incrementalLocalStoreInstance;
42714268

42724269
if (incrementalLocalStores.find(graphIdentifier) == incrementalLocalStores.end()) {
4273-
incrementalLocalStoreInstance =
4274-
JasmineGraphInstanceService::loadStreamingStore(graphId, aggregatePartitionId,
4275-
incrementalLocalStores, "app");
4270+
incrementalLocalStoreInstance = JasmineGraphInstanceService::loadStreamingStore(
4271+
graphId, aggregatePartitionId, incrementalLocalStores, "app");
42764272
} else {
42774273
incrementalLocalStoreInstance = incrementalLocalStores[graphIdentifier];
42784274
}
@@ -4283,8 +4279,7 @@ string JasmineGraphInstanceService::aggregateStreamingCentralStoreTriangles(
42834279
if (mode == "0") {
42844280
triangles = StreamingTriangles::countCentralStoreStreamingTriangles(incrementalLocalStoreInstances);
42854281
} else {
4286-
triangles = StreamingTriangles::countDynamicCentralTriangles(
4287-
incrementalLocalStoreInstances, centralCountList);
4282+
triangles = StreamingTriangles::countDynamicCentralTriangles(incrementalLocalStoreInstances, centralCountList);
42884283
}
42894284

42904285
instance_logger.info("###INSTANCE### Central Store Aggregation : Completed");

0 commit comments

Comments
 (0)