-
Notifications
You must be signed in to change notification settings - Fork 1
/
Application.h
77 lines (71 loc) · 1.57 KB
/
Application.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**********************************
* FILE NAME: Application.h
*
* DESCRIPTION: Header file of all classes pertaining to the Application Layer
**********************************/
#ifndef _APPLICATION_H_
#define _APPLICATION_H_
#include "stdincludes.h"
#include "MP1Node.h"
#include "Log.h"
#include "Params.h"
#include "Member.h"
#include "EmulNet.h"
#include "Queue.h"
#include "MP2Node.h"
#include "Node.h"
#include "common.h"
/**
* global variables
*/
int nodeCount = 0;
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
/*
* Macros
*/
#define ARGS_COUNT 2
#define TOTAL_RUNNING_TIME 700
#define INSERT_TIME (TOTAL_RUNNING_TIME-600)
#define TEST_TIME (INSERT_TIME+50)
#define STABILIZE_TIME 50
#define FIRST_FAIL_TIME 25
#define LAST_FAIL_TIME 10
#define RF 3
#define NUMBER_OF_INSERTS 100
#define KEY_LENGTH 5
/**
* CLASS NAME: Application
*
* DESCRIPTION: Application layer of the distributed system
*/
class Application{
private:
// Address for introduction to the group
// Coordinator Node
char JOINADDR[30];
EmulNet *en;
EmulNet *en1;
Log *log;
MP1Node **mp1;
MP2Node **mp2;
Params *par;
map<string, string> testKVPairs;
public:
Application(char *);
virtual ~Application();
Address getjoinaddr();
void initTestKVPairs();
int run();
void mp1Run();
void mp2Run();
void fail();
void insertTestKVPairs();
int findARandomNodeThatIsAlive();
void deleteTest();
void readTest();
void updateTest();
};
#endif /* _APPLICATION_H__ */