@nsshunt/stsappframework 2.19.210 → 2.19.212
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tcpserver/app.js +15 -0
- package/dist/tcpserver/app.js.map +1 -0
- package/dist/tcpserver/appConfig.js +61 -0
- package/dist/tcpserver/appConfig.js.map +1 -0
- package/dist/tcpserver/appmaster.js +487 -0
- package/dist/tcpserver/appmaster.js.map +1 -0
- package/package.json +1 -1
- package/run1.sh +25 -0
- package/run2.sh +25 -0
- package/run3.sh +25 -0
- package/src/tcpserver/app.ts +11 -0
- package/src/tcpserver/appConfig.ts +66 -0
- package/src/tcpserver/appmaster.ts +545 -0
- package/types/tcpserver/app.d.ts +2 -0
- package/types/tcpserver/app.d.ts.map +1 -0
- package/types/tcpserver/appConfig.d.ts +3 -0
- package/types/tcpserver/appConfig.d.ts.map +1 -0
- package/types/tcpserver/appmaster.d.ts +24 -0
- package/types/tcpserver/appmaster.d.ts.map +1 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const appConfig_js_1 = require("./appConfig.js");
|
|
7
|
+
const appmaster_1 = require("./appmaster");
|
|
8
|
+
const cluster_1 = __importDefault(require("cluster"));
|
|
9
|
+
if (cluster_1.default.isPrimary) {
|
|
10
|
+
new appmaster_1.AppMaster((0, appConfig_js_1.ServiceConfigOptions)(cluster_1.default.isPrimary)).SetupServer();
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
//new WorkerProcessBase(ServiceConfigOptions(cluster.isPrimary)).SetupServer();
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/tcpserver/app.ts"],"names":[],"mappings":";;;;;AAAA,iDAAqD;AAErD,2CAAuC;AAEvC,sDAA8B;AAE9B,IAAI,iBAAO,CAAC,SAAS,EAAE;IACnB,IAAI,qBAAS,CAAC,IAAA,mCAAoB,EAAC,iBAAO,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;CACxE;KAAM;IACH,+EAA+E;CAClF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceConfigOptions = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const stsconfig_1 = require("@nsshunt/stsconfig");
|
|
6
|
+
const goptions = (0, stsconfig_1.$Options)();
|
|
7
|
+
const index_1 = require("../index");
|
|
8
|
+
/*
|
|
9
|
+
// nid: `${goptions.rest01servicename} @ ${goptions.rest01serviceversion} | ${this.options.globalServiceData.serviceInstanceId} @ ${os.hostname()} ^ ${process.pid} @ ${(cluster.isMaster ? process.pid : process.ppid)}`,
|
|
10
|
+
// <serviceId> <serviceInstanceId> <serviceInstanceProcessId>
|
|
11
|
+
// <serviceName> <serviceVersion> <sid> <hostName> <pid> <ppid>
|
|
12
|
+
// << ............... Static Nid ............... >> << ............... Dynamic Nid ............... >>
|
|
13
|
+
// Note: The final nid will NOT contain the NID_SEPERATOR character. This will be replaced with the SEPERATOR character.
|
|
14
|
+
const Context = (isMaster, serviceInstanceId) => {
|
|
15
|
+
return {
|
|
16
|
+
nid: `\
|
|
17
|
+
${goptions.rest01servicename}${ModelDelimeter.COMPONENT_SEPERATOR}${goptions.rest01serviceversion}\
|
|
18
|
+
${ModelDelimeter.SEPERATOR}\
|
|
19
|
+
${serviceInstanceId}${ModelDelimeter.COMPONENT_SEPERATOR}${os.hostname()}\
|
|
20
|
+
${ModelDelimeter.NID_SEPERATOR}\
|
|
21
|
+
${process.pid}${ModelDelimeter.COMPONENT_SEPERATOR}${(isMaster ? process.pid : process.ppid)}`
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
*/
|
|
25
|
+
function ServiceConfigOptions(isMaster) {
|
|
26
|
+
if (isMaster === true) {
|
|
27
|
+
const serviceInstanceId = (0, uuid_1.v4)();
|
|
28
|
+
const data = {
|
|
29
|
+
serverType: index_1.STSServerType.TCPRAW_TLS,
|
|
30
|
+
wssServer: false,
|
|
31
|
+
useLatency: false,
|
|
32
|
+
httpsServerKeyPath: goptions.httpsserverkeypath,
|
|
33
|
+
httpsServerCertificatePath: goptions.httpsservercertpath,
|
|
34
|
+
processExitOnTerminate: true,
|
|
35
|
+
serviceInstanceId: serviceInstanceId,
|
|
36
|
+
useDatabase: true,
|
|
37
|
+
useInstrumentationWorkers: true,
|
|
38
|
+
isMaster: isMaster,
|
|
39
|
+
endpoint: goptions.rest01endpoint,
|
|
40
|
+
apiRoot: goptions.rest01apiroot,
|
|
41
|
+
listenPort: goptions.rest01hostport,
|
|
42
|
+
port: goptions.rest01port,
|
|
43
|
+
prometheusSupport: false,
|
|
44
|
+
prometheusClusterPort: goptions.rest01prometheusclusterport,
|
|
45
|
+
serviceName: goptions.rest01servicename,
|
|
46
|
+
serviceVersion: goptions.rest01serviceversion,
|
|
47
|
+
consoleLogging: true,
|
|
48
|
+
instrumentLogging: true,
|
|
49
|
+
instrumentationObservationInterval: goptions.instrumentationObservationInterval,
|
|
50
|
+
instrumentationTimeWindow: goptions.instrumentationTimeWindow,
|
|
51
|
+
useRedisAdaptor: false
|
|
52
|
+
};
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const data = JSON.parse(process.env['STS_GSD_SII']);
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.ServiceConfigOptions = ServiceConfigOptions;
|
|
61
|
+
//# sourceMappingURL=appConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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aAAa,CAAW,CAAmB,CAAC;QAChG,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AAvCD,oDAuCC"}
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AppMaster = exports.AppMasterRAFTState = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const jayson_1 = __importDefault(require("jayson"));
|
|
10
|
+
const masterprocessbase_1 = require("./../masterprocessbase");
|
|
11
|
+
// Colour codes
|
|
12
|
+
// ---------------------------------
|
|
13
|
+
// Red - Error
|
|
14
|
+
// Green - Vote YES
|
|
15
|
+
// Yellow - Vote No
|
|
16
|
+
// White - standard logging message
|
|
17
|
+
// Magenta - node state change
|
|
18
|
+
// Cyan - node term change
|
|
19
|
+
var AppMasterRAFTState;
|
|
20
|
+
(function (AppMasterRAFTState) {
|
|
21
|
+
AppMasterRAFTState["IDLE"] = "IDLE";
|
|
22
|
+
AppMasterRAFTState["FOLLOWER"] = "FOLLOWER";
|
|
23
|
+
AppMasterRAFTState["CANDIDATE"] = "CANDIDATE";
|
|
24
|
+
AppMasterRAFTState["LEADER"] = "LEADER";
|
|
25
|
+
})(AppMasterRAFTState = exports.AppMasterRAFTState || (exports.AppMasterRAFTState = {}));
|
|
26
|
+
class AppMaster extends masterprocessbase_1.MasterProcessBase {
|
|
27
|
+
#lastRequiredVotes = -1; // used for logging only
|
|
28
|
+
#lastVotes = -1; // used for logging only
|
|
29
|
+
#RAFTState;
|
|
30
|
+
#minElectionTimeout;
|
|
31
|
+
#maxElectionTimeout;
|
|
32
|
+
#electionTimeout;
|
|
33
|
+
#heartBeatTimeout;
|
|
34
|
+
#startRAFTProtocolTimeout;
|
|
35
|
+
#votes; // keyed by service key (host:port)
|
|
36
|
+
#services;
|
|
37
|
+
#thisService;
|
|
38
|
+
#canidateTimeout = null;
|
|
39
|
+
#appendEntriesTimeout = null;
|
|
40
|
+
#voteRegister = 0;
|
|
41
|
+
#server;
|
|
42
|
+
#serverPort;
|
|
43
|
+
#votedLog = {}; // keyed by term number
|
|
44
|
+
#appendedEntries = {};
|
|
45
|
+
#leaderNode = null;
|
|
46
|
+
#currentTerm;
|
|
47
|
+
#log;
|
|
48
|
+
#currentIndex = 0;
|
|
49
|
+
constructor(serviceConfig) {
|
|
50
|
+
super(serviceConfig);
|
|
51
|
+
this.#RAFTState = AppMasterRAFTState.IDLE;
|
|
52
|
+
this.#currentTerm = 0;
|
|
53
|
+
this.#votes = {};
|
|
54
|
+
this.#services = [{
|
|
55
|
+
host: "stscore.stsmda.org",
|
|
56
|
+
port: 3006
|
|
57
|
+
}, {
|
|
58
|
+
host: "stscore.stsmda.org",
|
|
59
|
+
port: 3007
|
|
60
|
+
}, {
|
|
61
|
+
host: "stscore.stsmda.org",
|
|
62
|
+
port: 3008
|
|
63
|
+
}];
|
|
64
|
+
this.#thisService = this.#services[parseInt(process.env.SERVICE_INDEX)]; // set self service
|
|
65
|
+
this.#serverPort = this.#thisService.port;
|
|
66
|
+
//this.#thisService = this.#services[0]; // set self service
|
|
67
|
+
this.#log = []; // Need to get from storage - volume, redis, etc.
|
|
68
|
+
// Set default config items
|
|
69
|
+
this.#minElectionTimeout = 1000; //@@ config
|
|
70
|
+
this.#maxElectionTimeout = 1200; //@@ config
|
|
71
|
+
this.#startRAFTProtocolTimeout = 2000; //@@ config
|
|
72
|
+
this.#electionTimeout = crypto_1.default.randomInt(this.#minElectionTimeout, this.#maxElectionTimeout);
|
|
73
|
+
this.#heartBeatTimeout = 750; //@@ config - also must be smaller than electionTimeout
|
|
74
|
+
}
|
|
75
|
+
#GetTLSOptions = () => {
|
|
76
|
+
return {
|
|
77
|
+
key: fs_1.default.readFileSync(this.options.httpsServerKeyPath),
|
|
78
|
+
cert: fs_1.default.readFileSync(this.options.httpsServerCertificatePath)
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
#SetupRPCServer = async (socket) => {
|
|
82
|
+
/*
|
|
83
|
+
console.log('CONNECTED: ' + socket.remoteAddress + ':' + socket.remotePort + ' ' + process.pid);
|
|
84
|
+
|
|
85
|
+
socket.on('close', function(data: any) {
|
|
86
|
+
console.log('CLOSED: ' + socket.remoteAddress + ' ' + socket.remotePort + ' ' + process.pid);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
socket.on('data', function(data: any) {
|
|
90
|
+
console.log('DATA ' + socket.remoteAddress + ': ' + data);
|
|
91
|
+
});
|
|
92
|
+
*/
|
|
93
|
+
};
|
|
94
|
+
#GetLogPrefix = () => {
|
|
95
|
+
return `${this.#thisService.host}:${this.#thisService.port}: currentTerm: [${this.#currentTerm}] index: [${this.#currentIndex}]: `;
|
|
96
|
+
};
|
|
97
|
+
#VoteYes = (callback, term, message) => {
|
|
98
|
+
// Log the fact that I have now voted for this currentTerm
|
|
99
|
+
this.#votedLog[term] = true;
|
|
100
|
+
// Update my currentTerm
|
|
101
|
+
this.#currentTerm = term;
|
|
102
|
+
// Return my yes vote
|
|
103
|
+
console.log(`${message} - Vote Yes`.green);
|
|
104
|
+
callback(null, true); // YES vote
|
|
105
|
+
};
|
|
106
|
+
#VoteNo = (callback, term, message) => {
|
|
107
|
+
// Log the fact that I have now voted for this currentTerm
|
|
108
|
+
this.#votedLog[term] = true;
|
|
109
|
+
// Return my yes vote
|
|
110
|
+
console.log(`${message} - Vote No`.yellow);
|
|
111
|
+
callback(null, false); // NO vote
|
|
112
|
+
};
|
|
113
|
+
#FindService = (host, port) => {
|
|
114
|
+
let retService = null;
|
|
115
|
+
this.#services.forEach((service, index) => {
|
|
116
|
+
if (service.host.localeCompare(host) === 0 && service.port === port) {
|
|
117
|
+
retService = service;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return retService;
|
|
122
|
+
};
|
|
123
|
+
#CheckMoreRecentTerm = (term, lastLogItemTerm, lastLogItemIndex) => {
|
|
124
|
+
// Check if the request to vote is newer than my current term
|
|
125
|
+
let msg = '';
|
|
126
|
+
let retVal;
|
|
127
|
+
if (term > this.#currentTerm) {
|
|
128
|
+
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] greater than my currentTerm: [${this.#currentTerm}]`;
|
|
129
|
+
retVal = true;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// Check if the request to vote is older than my current term
|
|
133
|
+
if (term === this.#currentTerm) {
|
|
134
|
+
if (lastLogItemIndex > this.#currentIndex) {
|
|
135
|
+
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] the same as my currentTerm: [${this.#currentTerm}]. Canidate index: [${lastLogItemIndex}] greater than my index: [${this.#currentIndex}]`;
|
|
136
|
+
retVal = true;
|
|
137
|
+
}
|
|
138
|
+
else if (lastLogItemIndex === this.#currentIndex) {
|
|
139
|
+
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] the same as my currentTerm: [${this.#currentTerm}]. Canidate index: [${lastLogItemIndex}] the same as my index: [${this.#currentIndex}]`;
|
|
140
|
+
retVal = true;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] the same as my currentTerm: [${this.#currentTerm}]. Canidate index: [${lastLogItemIndex}] NOT greater than my index: [${this.#currentIndex}]`;
|
|
144
|
+
retVal = false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
msg = `${this.#GetLogPrefix()}: canidate term: [${term}] less than my currentTerm: [${this.#currentTerm}]`;
|
|
149
|
+
retVal = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
msg,
|
|
154
|
+
retVal
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
#SetupJSONRPCServer = async () => {
|
|
158
|
+
const jaysonServer = new jayson_1.default.server();
|
|
159
|
+
jaysonServer.method("appendEntries", async (args, callback) => {
|
|
160
|
+
// Just received a message - reset my electionTimeout
|
|
161
|
+
this.#ResetElectionTimeout();
|
|
162
|
+
// Do something with this new log entry
|
|
163
|
+
// Needs to check if current, otherwise get old entries and duplicate
|
|
164
|
+
});
|
|
165
|
+
jaysonServer.method("vote", async (args, callback) => {
|
|
166
|
+
// Just received a message - reset my electionTimeout
|
|
167
|
+
this.#ResetElectionTimeout();
|
|
168
|
+
const term = args[0];
|
|
169
|
+
const lastLogItemTerm = args[1];
|
|
170
|
+
const lastLogItemIndex = args[2];
|
|
171
|
+
// Now determine whether this requestror gets my vote
|
|
172
|
+
// Check already voted
|
|
173
|
+
if (this.#votedLog[term]) {
|
|
174
|
+
this.#VoteNo(callback, term, `${this.#GetLogPrefix()}: Already voted - vote NO`);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// Check if the request to vote is newer than my current term
|
|
178
|
+
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
179
|
+
if (retVal.retVal === true) {
|
|
180
|
+
this.#VoteYes(callback, term, retVal.msg);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.#VoteNo(callback, term, retVal.msg);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
jaysonServer.method("appendEntry", async (args, callback) => {
|
|
187
|
+
// Just received a message - reset my electionTimeout
|
|
188
|
+
this.#ResetElectionTimeout();
|
|
189
|
+
const host = args[0];
|
|
190
|
+
const port = args[1];
|
|
191
|
+
const term = args[2];
|
|
192
|
+
const lastLogItemTerm = args[3];
|
|
193
|
+
const lastLogItemIndex = args[4];
|
|
194
|
+
if (this.#RAFTState.localeCompare(AppMasterRAFTState.CANDIDATE) === 0) {
|
|
195
|
+
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
196
|
+
if (retVal.retVal === true) {
|
|
197
|
+
console.log(`${retVal.msg}`);
|
|
198
|
+
console.log(`${this.#GetLogPrefix()}: New leader detected, Host: [${host}], Port: [${port}], while in CANDIDATE mode, reverting to FOLLOWER.`.magenta);
|
|
199
|
+
// This sending node is the leader so revert to follower
|
|
200
|
+
this.#currentTerm = term;
|
|
201
|
+
this.#ChangeState(AppMasterRAFTState.FOLLOWER);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
console.log(`${retVal.msg}`);
|
|
205
|
+
console.log(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}].`.magenta);
|
|
206
|
+
// Reject this RPC and continue in the CANDIDATE state
|
|
207
|
+
callback(null, false);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else if (this.#RAFTState.localeCompare(AppMasterRAFTState.LEADER) === 0) {
|
|
212
|
+
console.log(`${this.#GetLogPrefix()}: appendEntry called while I am the current leader, rejecting RPC call.`.red);
|
|
213
|
+
// Reject this RPC and continue in the LEADER state
|
|
214
|
+
callback(null, false);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
// FOLLOWER or IDLE
|
|
219
|
+
if (this.#RAFTState.localeCompare(AppMasterRAFTState.IDLE) === 0) {
|
|
220
|
+
this.#ChangeState(AppMasterRAFTState.FOLLOWER);
|
|
221
|
+
}
|
|
222
|
+
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
223
|
+
if (retVal.retVal === true) {
|
|
224
|
+
if (term > this.#currentTerm) {
|
|
225
|
+
console.log(`${retVal.msg}`.cyan);
|
|
226
|
+
this.#currentTerm = term;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
console.log(`${retVal.msg}`);
|
|
231
|
+
console.log(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}].`.magenta);
|
|
232
|
+
// Reject this RPC and continue in the CANDIDATE state
|
|
233
|
+
callback(null, false);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (this.#leaderNode) {
|
|
238
|
+
const sentLeaderService = this.#FindService(host, port);
|
|
239
|
+
if (sentLeaderService) {
|
|
240
|
+
if (sentLeaderService.host.localeCompare(this.#leaderNode.host) !== 0 || sentLeaderService.port !== this.#leaderNode.port) {
|
|
241
|
+
this.#leaderNode = sentLeaderService;
|
|
242
|
+
console.log(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]`.white);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.#leaderNode = this.#FindService(host, port);
|
|
248
|
+
if (this.#leaderNode) {
|
|
249
|
+
console.log(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]`.white);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Now update the log if only more recent
|
|
253
|
+
callback(null, true);
|
|
254
|
+
});
|
|
255
|
+
jaysonServer.method("ping", async function (args, callback) {
|
|
256
|
+
// do something, do nothing
|
|
257
|
+
console.log('server got ping');
|
|
258
|
+
callback();
|
|
259
|
+
});
|
|
260
|
+
const server = jaysonServer.tls(this.#GetTLSOptions());
|
|
261
|
+
server.on('secureConnection', this.#SetupRPCServer);
|
|
262
|
+
//server.listen(this.options.listenPort, () => { // 'stscore.stsmda.org'
|
|
263
|
+
server.listen(this.#serverPort, () => {
|
|
264
|
+
console.log('JSON RPC 2.0 Server is running on port ' + this.options.listenPort + '.');
|
|
265
|
+
}).on('listening', () => {
|
|
266
|
+
this.LogEx(`JSON RPC 2.0 live on ${this.options.endpoint}:${this.options.listenPort}${this.options.apiRoot}`);
|
|
267
|
+
});
|
|
268
|
+
return server;
|
|
269
|
+
};
|
|
270
|
+
#RequestVote = (service) => {
|
|
271
|
+
const options = {
|
|
272
|
+
port: service.port,
|
|
273
|
+
host: service.host
|
|
274
|
+
};
|
|
275
|
+
const client = jayson_1.default.client.tls(options);
|
|
276
|
+
/*
|
|
277
|
+
client.on('tcp socket', (socket: tls.TLSSocket) => {
|
|
278
|
+
socket.setTimeout(200); //@@ config
|
|
279
|
+
socket.on('timeout', () => {
|
|
280
|
+
console.log('socket timeout');
|
|
281
|
+
socket.end();
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
client.on('tcp error', (error: any) => {
|
|
285
|
+
console.log(`ERROR: [${error}]`.red);
|
|
286
|
+
});
|
|
287
|
+
*/
|
|
288
|
+
let lastLogItem;
|
|
289
|
+
if (this.#log.length > 0) {
|
|
290
|
+
lastLogItem = this.#log[this.#log.length - 1];
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
lastLogItem = {
|
|
294
|
+
term: 0,
|
|
295
|
+
index: 0,
|
|
296
|
+
data: null
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
client.request('vote', [this.#currentTerm, lastLogItem.term, lastLogItem.index], (error, response) => {
|
|
300
|
+
if (error) {
|
|
301
|
+
//console.log(`vote attempt fail: [${JSON.stringify(options)}: ${error}]`.red);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
// Log the result
|
|
305
|
+
if (response.result === true) {
|
|
306
|
+
this.#votes[this.#GetServiceKey(service)] = 1;
|
|
307
|
+
}
|
|
308
|
+
this.#CheckMajority();
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
#AppendEntry = (service) => {
|
|
313
|
+
const options = {
|
|
314
|
+
port: service.port,
|
|
315
|
+
host: service.host
|
|
316
|
+
};
|
|
317
|
+
const client = jayson_1.default.client.tls(options);
|
|
318
|
+
/*
|
|
319
|
+
client.on('tcp socket', (socket: tls.TLSSocket) => {
|
|
320
|
+
socket.setTimeout(200); //@@ config
|
|
321
|
+
socket.on('timeout', () => {
|
|
322
|
+
console.log('socket timeout');
|
|
323
|
+
socket.end();
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
client.on('tcp error', (error: any) => {
|
|
327
|
+
console.log(`ERROR: [${error}]`.red);
|
|
328
|
+
});
|
|
329
|
+
*/
|
|
330
|
+
let lastLogItem;
|
|
331
|
+
if (this.#log.length > 0) {
|
|
332
|
+
lastLogItem = this.#log[this.#log.length - 1];
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
lastLogItem = {
|
|
336
|
+
term: 0,
|
|
337
|
+
index: 0,
|
|
338
|
+
data: null
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
client.request('appendEntry', [this.#thisService.host, this.#thisService.port, this.#currentTerm, lastLogItem.term, lastLogItem.index], (error, response) => {
|
|
342
|
+
if (error) {
|
|
343
|
+
//console.log(`appendEntry attempt fail: [${JSON.stringify(options)}: ${error}]`.red);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
this.#appendedEntries[this.#GetServiceKey(service)] = 1;
|
|
347
|
+
// Log the result
|
|
348
|
+
/*
|
|
349
|
+
if (response.result === true) {
|
|
350
|
+
this.#votes[this.#GetServiceKey(service)] = 1;
|
|
351
|
+
}
|
|
352
|
+
*/
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
#AppendEntries = () => {
|
|
357
|
+
// Reset all appendEntries for this iteration
|
|
358
|
+
this.#appendedEntries = {};
|
|
359
|
+
// Reset all votes
|
|
360
|
+
this.#services.forEach((service, index) => {
|
|
361
|
+
this.#appendedEntries[this.#GetServiceKey(service)] = 0;
|
|
362
|
+
});
|
|
363
|
+
// Request vote for all other services - include my logs current item
|
|
364
|
+
this.#services.forEach((service, index) => {
|
|
365
|
+
if (service.host.localeCompare(this.#thisService.host) === 0 && service.port === this.#thisService.port) {
|
|
366
|
+
// Myself
|
|
367
|
+
this.#ResetElectionTimeout();
|
|
368
|
+
this.#appendedEntries[this.#GetSelfServiceKey()] = 1;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
// Send vote request
|
|
372
|
+
this.#AppendEntry(service);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
#GetServiceKey = (service) => {
|
|
377
|
+
return `${service.host}:${service.port}`;
|
|
378
|
+
};
|
|
379
|
+
#GetSelfServiceKey = () => {
|
|
380
|
+
return this.#GetServiceKey(this.#thisService);
|
|
381
|
+
};
|
|
382
|
+
// set interval ???
|
|
383
|
+
#StartAppendEntries = () => {
|
|
384
|
+
this.#AppendEntries();
|
|
385
|
+
this.#appendEntriesTimeout = setTimeout(() => {
|
|
386
|
+
// Now check if we still have majority
|
|
387
|
+
const majority = this.#CheckMajorityWithCollection(this.#appendedEntries);
|
|
388
|
+
if (majority) {
|
|
389
|
+
this.#StartAppendEntries();
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
console.log(`${this.#GetLogPrefix()}: Not enough response for valid cluster state.`.red);
|
|
393
|
+
}
|
|
394
|
+
}, this.#heartBeatTimeout);
|
|
395
|
+
};
|
|
396
|
+
#Promote = () => {
|
|
397
|
+
this.#ChangeState(AppMasterRAFTState.LEADER);
|
|
398
|
+
console.log(`${this.#GetLogPrefix()}: New LEADER is elected: [${this.#GetSelfServiceKey()}]`.green);
|
|
399
|
+
// As leader, now start the regular pings
|
|
400
|
+
this.#StartAppendEntries();
|
|
401
|
+
};
|
|
402
|
+
#CheckMajority = () => {
|
|
403
|
+
if (this.#CheckMajorityWithCollection(this.#votes)) {
|
|
404
|
+
this.#Promote();
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
#CheckMajorityWithCollection = (col) => {
|
|
408
|
+
let votes = 0;
|
|
409
|
+
for (const [key, val] of Object.entries(col)) {
|
|
410
|
+
votes += val;
|
|
411
|
+
}
|
|
412
|
+
const requiredVotes = Math.floor(this.#services.length / 2) + 1;
|
|
413
|
+
if (requiredVotes !== this.#lastRequiredVotes || votes !== this.#lastVotes) {
|
|
414
|
+
console.log(`${this.#GetLogPrefix()}votes: [${votes} need: [${requiredVotes}]`.cyan);
|
|
415
|
+
this.#lastRequiredVotes = requiredVotes;
|
|
416
|
+
this.#lastVotes = votes;
|
|
417
|
+
}
|
|
418
|
+
return votes >= requiredVotes;
|
|
419
|
+
};
|
|
420
|
+
#StartCanidateVote = () => {
|
|
421
|
+
// Get the election timeout going again
|
|
422
|
+
this.#StartElectionTimeout();
|
|
423
|
+
console.log(`${this.#GetLogPrefix()}: Start CANDIDATE vote`.yellow);
|
|
424
|
+
// Start in the CANDIDATE state
|
|
425
|
+
this.#ChangeState(AppMasterRAFTState.CANDIDATE);
|
|
426
|
+
// Reset votes
|
|
427
|
+
this.#votes = {};
|
|
428
|
+
// Reset all votes from all service instances
|
|
429
|
+
this.#services.forEach((service, index) => {
|
|
430
|
+
this.#votes[this.#GetServiceKey(service)] = 0;
|
|
431
|
+
});
|
|
432
|
+
// Start a new term
|
|
433
|
+
this.#currentTerm++;
|
|
434
|
+
// Request vote for all other services - include my logs current item
|
|
435
|
+
this.#services.forEach((service, index) => {
|
|
436
|
+
if (service.host.localeCompare(this.#thisService.host) === 0 && service.port === this.#thisService.port) {
|
|
437
|
+
// Log the fact that I have now voted for this term
|
|
438
|
+
this.#votedLog[this.#currentTerm] = true;
|
|
439
|
+
// Log the result - Vote for myself
|
|
440
|
+
this.#votes[this.#GetSelfServiceKey()] = 1;
|
|
441
|
+
// Return my yes vote
|
|
442
|
+
console.log(`${this.#GetLogPrefix()}: SELF VOTE: canidate currentTerm: [${this.#currentTerm}], vote YES`.green);
|
|
443
|
+
this.#CheckMajority();
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
// Send vote request
|
|
447
|
+
this.#RequestVote(service);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
#ReceiveVoteRequest = () => {
|
|
452
|
+
// Check if the request term and meta-data is more recent than me
|
|
453
|
+
// If request more recent ...
|
|
454
|
+
this.#voteRegister = 1;
|
|
455
|
+
// Send vote back to requestor
|
|
456
|
+
};
|
|
457
|
+
#ResetElectionTimeout = () => {
|
|
458
|
+
if (this.#canidateTimeout) {
|
|
459
|
+
clearTimeout(this.#canidateTimeout);
|
|
460
|
+
}
|
|
461
|
+
this.#StartElectionTimeout();
|
|
462
|
+
};
|
|
463
|
+
#StartElectionTimeout = () => {
|
|
464
|
+
if (this.#canidateTimeout) {
|
|
465
|
+
clearTimeout(this.#canidateTimeout);
|
|
466
|
+
}
|
|
467
|
+
this.#canidateTimeout = setTimeout(() => {
|
|
468
|
+
this.#StartCanidateVote();
|
|
469
|
+
}, this.#electionTimeout).unref();
|
|
470
|
+
};
|
|
471
|
+
#StartRAFTService = async () => {
|
|
472
|
+
this.LogEx(`---[ RAFT Protocol Starting ]---`.green);
|
|
473
|
+
this.#server = await this.#SetupJSONRPCServer();
|
|
474
|
+
this.#StartElectionTimeout();
|
|
475
|
+
};
|
|
476
|
+
#ChangeState(newState) {
|
|
477
|
+
this.LogEx(`${this.#GetLogPrefix()}: State Change, From: [${this.#RAFTState.toString()}] --> To: [${newState.toString()}]`.magenta);
|
|
478
|
+
this.#RAFTState = newState;
|
|
479
|
+
}
|
|
480
|
+
MasterStarted() {
|
|
481
|
+
setTimeout(() => {
|
|
482
|
+
this.#StartRAFTService();
|
|
483
|
+
}, this.#startRAFTProtocolTimeout).unref();
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
exports.AppMaster = AppMaster;
|
|
487
|
+
//# sourceMappingURL=appmaster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appmaster.js","sourceRoot":"","sources":["../../src/tcpserver/appmaster.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,oDAA4B;AAC5B,oDAA2B;AAK3B,8DAA0D;AAG1D,eAAe;AACf,oCAAoC;AACpC,cAAc;AACd,mBAAmB;AACnB,mBAAmB;AACnB,mCAAmC;AACnC,8BAA8B;AAC9B,0BAA0B;AAE1B,IAAY,kBAKX;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AE,CAAC;QAC7B,CAAC,EAAE,IAAI,CAAC,yBAAyB,CAAC,CAAC,KAAK,EAAE,CAAC;IAC/C,CAAC;CACJ;AA3fD,8BA2fC"}
|
package/package.json
CHANGED
package/run1.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# openssl req -nodes -new -x509 -keyout server.key -out server.cert
|
|
3
|
+
clear; \
|
|
4
|
+
export STS_PROJ_ROOT=./..; \
|
|
5
|
+
STSENVFILE=$STS_PROJ_ROOT/stsglobalresources/.env \
|
|
6
|
+
DB_SCRIPT_FOLDER=$STS_PROJ_ROOT/stsglobalresources/db-scripts \
|
|
7
|
+
REST01_PORT=3003 \
|
|
8
|
+
REST01_HOST_PORT=3003 \
|
|
9
|
+
REST01_SERVICE_NAME="STSRest01-3003" \
|
|
10
|
+
REST01_API_IDENTIFIER="https://stsmda.com.au/stsrest01api/v1.0/" \
|
|
11
|
+
REST01_ENDPOINT="https://stsrest.stsmda.org" \
|
|
12
|
+
MAX_CPU=4 \
|
|
13
|
+
AS_ENDPOINT=https://stscore.stsmda.org \
|
|
14
|
+
AS_HOST_PORT=3002 \
|
|
15
|
+
AS_PORT=3002 \
|
|
16
|
+
DB_HOST=localhost \
|
|
17
|
+
DB_PORT=5432 \
|
|
18
|
+
DB_PASSWORD=postgres \
|
|
19
|
+
HTTPS_SERVER_KEY_PATH=/etc/letsencrypt/live/stsmda.org/privkey.pem \
|
|
20
|
+
HTTPS_SERVER_CERT_PATH=/etc/letsencrypt/live/stsmda.org/fullchain.pem \
|
|
21
|
+
DEBUG=zzproc* \
|
|
22
|
+
PUBLISH_DEBUG=false \
|
|
23
|
+
UV_THREADPOOL_SIZE=64 \
|
|
24
|
+
SERVICE_INDEX=0 \
|
|
25
|
+
node dist/tcpserver/app;
|
package/run2.sh
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# openssl req -nodes -new -x509 -keyout server.key -out server.cert
|
|
3
|
+
clear; \
|
|
4
|
+
export STS_PROJ_ROOT=./..; \
|
|
5
|
+
STSENVFILE=$STS_PROJ_ROOT/stsglobalresources/.env \
|
|
6
|
+
DB_SCRIPT_FOLDER=$STS_PROJ_ROOT/stsglobalresources/db-scripts \
|
|
7
|
+
REST01_PORT=3003 \
|
|
8
|
+
REST01_HOST_PORT=3003 \
|
|
9
|
+
REST01_SERVICE_NAME="STSRest01-3003" \
|
|
10
|
+
REST01_API_IDENTIFIER="https://stsmda.com.au/stsrest01api/v1.0/" \
|
|
11
|
+
REST01_ENDPOINT="https://stsrest.stsmda.org" \
|
|
12
|
+
MAX_CPU=4 \
|
|
13
|
+
AS_ENDPOINT=https://stscore.stsmda.org \
|
|
14
|
+
AS_HOST_PORT=3002 \
|
|
15
|
+
AS_PORT=3002 \
|
|
16
|
+
DB_HOST=localhost \
|
|
17
|
+
DB_PORT=5432 \
|
|
18
|
+
DB_PASSWORD=postgres \
|
|
19
|
+
HTTPS_SERVER_KEY_PATH=/etc/letsencrypt/live/stsmda.org/privkey.pem \
|
|
20
|
+
HTTPS_SERVER_CERT_PATH=/etc/letsencrypt/live/stsmda.org/fullchain.pem \
|
|
21
|
+
DEBUG=zzproc* \
|
|
22
|
+
PUBLISH_DEBUG=false \
|
|
23
|
+
UV_THREADPOOL_SIZE=64 \
|
|
24
|
+
SERVICE_INDEX=1 \
|
|
25
|
+
node dist/tcpserver/app;
|