Commit c739d0ee authored by Lily Tsai's avatar Lily Tsai
Browse files

Merge branch 'master' of gitlab.mpi-sws.org:encounters/ebc

parents 76a79ec1 c6d3a8e7
......@@ -65,8 +65,6 @@ int call_client_with_message(const char* send_buf)
int sock;
SSL_CTX *ctx;
const long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION;
//const char *serv_ip = "127.0.0.1";
//const char *serv_ip = "192.168.100.54";
const char *serv_ip = "139.19.168.145";
uint32_t serv_port = 4433;
......
#include <SSLClient.h>
#include <iostream>
#include <ctime>
#include <chrono>
#include <thread>
#include <vector>
#include <queue>
#include <map>
......@@ -9,9 +12,10 @@
#define CONSTRAINT_LOCATION_RANGE 100 // boxes centered around 0
#define NUM_CONSTRAINT_BOXES 1
#define CHAIN_LEN 2
#define FANOUT 5
#define PROPORTION_SATISFY 0.5
#define CHAIN_LEN 10
#define FANOUT 2
#define PROPORTION_SATISFY 1
#define USEST 1
int user_index = 0;
......@@ -97,10 +101,21 @@ std::vector<EncounterInfo> generate_encounters() {
int total_encs = (int)((double)num_satisfying_encounters / (double)PROPORTION_SATISFY);
int user1, user2;
for (int num_encs = num_satisfying_encounters; num_encs < total_encs; num_encs++) {
user1 = rand() % user_index;
user2 = rand() % user_index;
while (user2 == user1) {
user2 = rand() % user_index;
// half the time let's add a random user
if (rand() % 2) {
user1 = rand() % user_index;
user2 = ++user_index;
} else {
if (user_index == 1) {
user1 = 0;
user2 = 1;
} else {
user1 = rand() % user_index;
user2 = rand() % user_index;
while (user2 == user1) {
user2 = rand() % user_index;
}
}
}
// for right now, ensure that the time doesn't overlap (or else we get weird
// jumpy behavior)
......@@ -122,11 +137,16 @@ return encs;
void insert_auths(std::vector<EncounterInfo>& encs)
{
std::ofstream myfile;
myfile.open ("auths.txt");
char buffer[1000];
for (int i = 0; i <= user_index; i++) {
snprintf(buffer, sizeof(buffer), "%dAUTHDELIMITERSocialPlus TK=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzalNIRVUzNTA4ZVxuR29vZ2xlXG4xMTY4Njc1MTE0MDIxMzc1NzcxNTkiLCJpc3MiOiIzcWdtZzlWUmNaeFxuMmU1YTFjYzgtNWVhYi00ZGJkLThkNmQtNmE4NGVhYjIzMzc0IiwiZXhwIjoxNTQ1MDU1MzgzfQ.qOfRCnuO0wn6ntBMkCRgcKYzd0Ymzn5a6Tm56Wc5nlI\r\n", i);
printf("Return: %d\n", call_client_with_message(buffer));
myfile << buffer;
//printf("Return: %d\n", call_client_with_message(buffer));
//std::this_thread::sleep_for (std::chrono::milliseconds(250));
}
myfile.close();
}
struct LocationEntry {
......@@ -138,6 +158,8 @@ struct LocationEntry {
};
void insert_encs(std::vector<EncounterInfo>& encs)
{
std::ofstream myfile;
myfile.open ("encs.txt");
for (int i = 0; i <= user_index; i++) {
std::string encountersStr;
std::string locationsStr;
......@@ -163,13 +185,28 @@ void insert_encs(std::vector<EncounterInfo>& encs)
char buffer[encountersStr.length() + locationsStr.length() + 100];
snprintf(buffer, sizeof(buffer), "%dENCDELIMITER%sENCDELIMITER%s\r\n",
i, encountersStr.c_str(), locationsStr.c_str());
printf("Return: %d\n", call_client_with_message(buffer));
myfile << buffer;
//printf("Return: %d\n", call_client_with_message(buffer));
//std::this_thread::sleep_for (std::chrono::milliseconds(250));
}
myfile.close();
}
void query_constraint() {
char buffer[1000];
// always call from user 0 (the sender)
// all query
/*snprintf(buffer, sizeof(buffer),
"%dMESSAGEDELIMITER%dMESSAGEDELIMITER%dMESSAGEDELIMITER%dMESSAGEDELIMITER%s"\
"MESSAGEDELIMITER%dMESSAGEDELIMITER"\
"ALLMESSAGEDELIMITER%s\r\n",
0, CHAIN_LEN, FANOUT, INT_MAX, "False", 0, "hello world");
printf("Query: %s\n", buffer);
call_client_with_message(buffer);*/
// non-proj traj query
#if USEST
snprintf(buffer, sizeof(buffer),
"%dMESSAGEDELIMITER%dMESSAGEDELIMITER%dMESSAGEDELIMITER%dMESSAGEDELIMITER%s"\
"MESSAGEDELIMITER%dMESSAGEDELIMITER"\
......@@ -178,6 +215,16 @@ void query_constraint() {
CONSTRAINT_TIME_START, CONSTRAINT_TIME_END, 0, 0, CONSTRAINT_LOCATION_RANGE, "hello world");
printf("Query: %s\n", buffer);
call_client_with_message(buffer);
#else
snprintf(buffer, sizeof(buffer),
"%dMESSAGEDELIMITER%dMESSAGEDELIMITER%dMESSAGEDELIMITER%dMESSAGEDELIMITER%s"\
"MESSAGEDELIMITER%dMESSAGEDELIMITER"\
"%sTRAJ%dTRAJ%dMESSAGEDELIMITER%s\r\n",
0, CHAIN_LEN, FANOUT, INT_MAX, "False", 0,
"False", CONSTRAINT_TIME_START, CONSTRAINT_TIME_END, "hello world");
printf("Query: %s\n", buffer);
call_client_with_message(buffer);
#endif
}
int main(int argc, char* argv[]){
......
......@@ -44,8 +44,7 @@ public class TrajectoryConstraint extends EncounterQueryConstraint implements Se
@Override
public String toQueryString() {
return useCausalityConstraint()
+ TRAJDELIMITER + projectIntoFuture
return projectIntoFuture
+ TRAJDELIMITER + startTime
+ TRAJDELIMITER + endTime;
......
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