@mindline/sync 1.0.40 → 1.0.41
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/.vs/slnx.sqlite
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -203,6 +203,7 @@ declare module "@mindline/sync" {
|
|
|
203
203
|
read: number;
|
|
204
204
|
written: number;
|
|
205
205
|
deferred: number;
|
|
206
|
+
nothingtosync: boolean;
|
|
206
207
|
targets: TenantNode[];
|
|
207
208
|
constructor(tid: string, name: string);
|
|
208
209
|
update(total: number, read: number, written: number, deferred: number): void;
|
package/index.ts
CHANGED
|
@@ -732,22 +732,32 @@ export class BatchArray {
|
|
|
732
732
|
this.pb_idleMax = 0;
|
|
733
733
|
setIdleText(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`);
|
|
734
734
|
this.pb_timer = setInterval(() => {
|
|
735
|
-
// if
|
|
736
|
-
this.
|
|
737
|
-
this.pb_idleMax = Math.max(this.pb_idle, this.pb_idleMax);
|
|
738
|
-
setIdleText(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`);
|
|
739
|
-
if (this.pb_idle >= 20) {
|
|
735
|
+
// if signalR has finished the sync, stop the timer
|
|
736
|
+
if (this.milestoneArray.milestones[0].Write != null) {
|
|
740
737
|
clearInterval(this.pb_timer);
|
|
741
738
|
this.pb_timer = null;
|
|
742
|
-
|
|
743
|
-
this.milestoneArray.write(setMilestones);
|
|
744
|
-
}
|
|
745
|
-
setConfigSyncResult(`finished sync, no updates for ${this.pb_idle} seconds`);
|
|
746
|
-
}
|
|
747
|
-
// if we get to 100, stop the timer, let SignalR or countdown timer finish sync
|
|
748
|
-
if (this.pb_progress < 100) {
|
|
749
|
-
this.pb_progress = Math.min(100, this.pb_progress + this.pb_increment);
|
|
739
|
+
this.pb_progress = 100;
|
|
750
740
|
setSyncProgress(this.pb_progress);
|
|
741
|
+
setIdleText(`Complete. [max idle: ${this.pb_idleMax}]`);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
// if we've gone 30 seconds without a signalR message, finish the sync
|
|
745
|
+
this.pb_idle = this.pb_idle + 1;
|
|
746
|
+
this.pb_idleMax = Math.max(this.pb_idle, this.pb_idleMax);
|
|
747
|
+
setIdleText(`No updates seen for ${this.pb_idle} seconds. [max idle: ${this.pb_idleMax}]`);
|
|
748
|
+
if (this.pb_idle >= 60) {
|
|
749
|
+
clearInterval(this.pb_timer);
|
|
750
|
+
this.pb_timer = null;
|
|
751
|
+
if (this.milestoneArray.milestones[0].Write == null) {
|
|
752
|
+
this.milestoneArray.write(setMilestones);
|
|
753
|
+
setConfigSyncResult(`finished sync, no updates for ${this.pb_idle} seconds`);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
// if we get to 100, the progress bar stops but SignalR or countdown timer completes the sync
|
|
757
|
+
if (this.pb_progress < 100) {
|
|
758
|
+
this.pb_progress = Math.min(100, this.pb_progress + this.pb_increment);
|
|
759
|
+
setSyncProgress(this.pb_progress);
|
|
760
|
+
}
|
|
751
761
|
}
|
|
752
762
|
}, 1000);
|
|
753
763
|
this.milestoneArray.start(setMilestones);
|
|
@@ -803,10 +813,13 @@ export class BatchArray {
|
|
|
803
813
|
return;
|
|
804
814
|
}
|
|
805
815
|
tenantNode.batchId = matchingPair.BatchId;
|
|
806
|
-
// process stats for this SignalR message batch
|
|
816
|
+
// process stats for this SignalR message (one batch per tenant node)
|
|
807
817
|
let statsarray = item.Stats; // get the array of statistics
|
|
808
818
|
let statskeys = Object.keys(statsarray); // get the keys of the array
|
|
809
819
|
let statsvalues = Object.values(statsarray); // get the values of the array
|
|
820
|
+
// does this tenantnode/batch have nothing to sync?
|
|
821
|
+
let bTotalCountZero: boolean = false;
|
|
822
|
+
let bCurrentCountZero: boolean = false;
|
|
810
823
|
for (let j = 0; j < statskeys.length; j++) {
|
|
811
824
|
let bTotalCount = statskeys[j].endsWith("TotalCount");
|
|
812
825
|
let bCurrentCount = statskeys[j].endsWith("CurrentCount");
|
|
@@ -823,15 +836,18 @@ export class BatchArray {
|
|
|
823
836
|
return;
|
|
824
837
|
}
|
|
825
838
|
if (bTotalCount) {
|
|
839
|
+
bTotalCountZero = Number(statsvalues[j]) == 0;
|
|
826
840
|
tenantNode.total = Math.max(Number(statsvalues[j]), tenantNode.total);
|
|
827
841
|
console.log(`----- ${tenantNode.name} TID: ${tenantNode.tid} batchId: ${tenantNode.batchId}`);
|
|
828
842
|
console.log(`----- ${tenantNode.name} Total To Read: ${tenantNode.total}`);
|
|
829
843
|
}
|
|
830
844
|
else {
|
|
845
|
+
bCurrentCountZero = Number(statsvalues[j]) == 0;
|
|
831
846
|
tenantNode.read = Math.max(Number(statsvalues[j]), tenantNode.read);
|
|
832
847
|
console.log(`----- ${tenantNode.name} Currently Read: ${tenantNode.read}`);
|
|
833
848
|
}
|
|
834
849
|
}
|
|
850
|
+
tenantNode.nothingtosync = bTotalCountZero && bCurrentCountZero;
|
|
835
851
|
if (statskeys[j].startsWith("Writer")) {
|
|
836
852
|
// parse tid from Writer key
|
|
837
853
|
let tidRegexp = /Writer\/TID:(.+)\/TotalCount/;
|
|
@@ -878,6 +894,7 @@ export class BatchArray {
|
|
|
878
894
|
let bReadingComplete: boolean = true;
|
|
879
895
|
let bWritingComplete: boolean = true;
|
|
880
896
|
let bWritingStarted: boolean = false;
|
|
897
|
+
let bNothingToSync: boolean = true;
|
|
881
898
|
let readerTotal: number = 0;
|
|
882
899
|
let readerCurrent: number = 0;
|
|
883
900
|
let writerTotal: number = 0;
|
|
@@ -889,6 +906,7 @@ export class BatchArray {
|
|
|
889
906
|
writerTotal += Math.max(writerNode.total, sourceTenantNode.total);
|
|
890
907
|
writerCurrent += writerNode.written;
|
|
891
908
|
});
|
|
909
|
+
bNothingToSync &&= sourceTenantNode.nothingtosync;
|
|
892
910
|
bReadingComplete &&= (sourceTenantNode.status == "complete" || sourceTenantNode.status == "failed");
|
|
893
911
|
readerTotal += sourceTenantNode.total;
|
|
894
912
|
readerCurrent += sourceTenantNode.read;
|
|
@@ -898,37 +916,44 @@ export class BatchArray {
|
|
|
898
916
|
setReadersCurrent(readerCurrent);
|
|
899
917
|
setWritersTotal(Math.max(writerTotal, readerTotal));
|
|
900
918
|
setWritersCurrent(writerCurrent);
|
|
901
|
-
//
|
|
902
|
-
if (
|
|
903
|
-
this.milestoneArray.read(setMilestones);
|
|
904
|
-
setConfigSyncResult("reading complete");
|
|
905
|
-
console.log(`Setting config sync result: "reading complete"`);
|
|
906
|
-
// trigger refresh delta tokens
|
|
907
|
-
setRefreshDeltaTrigger(true);
|
|
908
|
-
// change to % per second to complete in 7x as long as it took to get here
|
|
909
|
-
let readTS = Date.now();
|
|
910
|
-
let secsElapsed = (readTS - this.pb_startTS) / 1000;
|
|
911
|
-
let expectedPercentDone = 7;
|
|
912
|
-
let expectedPercentPerSecond = secsElapsed / expectedPercentDone;
|
|
913
|
-
this.pb_increment = expectedPercentPerSecond;
|
|
914
|
-
console.log(`Setting increment: ${this.pb_increment}% per second`);
|
|
915
|
-
}
|
|
916
|
-
// with that out of the way, is writing complete?
|
|
917
|
-
if (bWritingComplete) {
|
|
919
|
+
// check to see if there was nothing to sync
|
|
920
|
+
if (bNothingToSync) {
|
|
918
921
|
this.milestoneArray.write(setMilestones);
|
|
919
|
-
setConfigSyncResult("sync
|
|
920
|
-
console.log(`Setting config sync result: "
|
|
921
|
-
this.pb_progress = 99;
|
|
922
|
-
}
|
|
923
|
-
// if not, has writing even started?
|
|
924
|
-
else if (bWritingStarted) {
|
|
925
|
-
setConfigSyncResult("writing in progress");
|
|
926
|
-
console.log(`Setting config sync result: "writing in progress"`);
|
|
922
|
+
setConfigSyncResult("nothing to sync");
|
|
923
|
+
console.log(`Setting config sync result: "nothing to sync"`);
|
|
927
924
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
925
|
+
else {
|
|
926
|
+
// because it is an important milestone, we always check if we have *just* completed reading
|
|
927
|
+
if (bReadingComplete && this.milestoneArray.milestones[0].Read == null) {
|
|
928
|
+
this.milestoneArray.read(setMilestones);
|
|
929
|
+
setConfigSyncResult("reading complete");
|
|
930
|
+
console.log(`Setting config sync result: "reading complete"`);
|
|
931
|
+
// trigger refresh delta tokens
|
|
932
|
+
setRefreshDeltaTrigger(true);
|
|
933
|
+
// change to % per second to complete in 7x as long as it took to get here
|
|
934
|
+
let readTS = Date.now();
|
|
935
|
+
let secsElapsed = (readTS - this.pb_startTS) / 1000;
|
|
936
|
+
let expectedPercentDone = 7;
|
|
937
|
+
let expectedPercentPerSecond = secsElapsed / expectedPercentDone;
|
|
938
|
+
this.pb_increment = expectedPercentPerSecond;
|
|
939
|
+
console.log(`Setting increment: ${this.pb_increment}% per second`);
|
|
940
|
+
}
|
|
941
|
+
// with that out of the way, is writing complete?
|
|
942
|
+
if (bWritingComplete) {
|
|
943
|
+
this.milestoneArray.write(setMilestones);
|
|
944
|
+
setConfigSyncResult("sync complete");
|
|
945
|
+
console.log(`Setting config sync result: "complete"`);
|
|
946
|
+
}
|
|
947
|
+
// if not, has writing even started?
|
|
948
|
+
else if (bWritingStarted) {
|
|
949
|
+
setConfigSyncResult("writing in progress");
|
|
950
|
+
console.log(`Setting config sync result: "writing in progress"`);
|
|
951
|
+
}
|
|
952
|
+
// else, we must be reading (unless we already completed reading)
|
|
953
|
+
else if (this.milestoneArray.milestones[0].Read == null) {
|
|
954
|
+
setConfigSyncResult("reading in progress");
|
|
955
|
+
console.log(`Setting config sync result: "reading in progress"`);
|
|
956
|
+
}
|
|
932
957
|
}
|
|
933
958
|
}
|
|
934
959
|
// start SignalR connection based on each batchId
|
|
@@ -986,12 +1011,14 @@ export class TenantNode {
|
|
|
986
1011
|
read: number;
|
|
987
1012
|
written: number;
|
|
988
1013
|
deferred: number;
|
|
1014
|
+
nothingtosync: boolean;
|
|
989
1015
|
targets: TenantNode[];
|
|
990
1016
|
constructor(tid: string, name: string, batchId: string) {
|
|
991
1017
|
this.expanded = false;
|
|
992
1018
|
this.name = name;
|
|
993
1019
|
this.tid = tid;
|
|
994
1020
|
this.batchId = batchId;
|
|
1021
|
+
this.nothingtosync = false;
|
|
995
1022
|
this.targets = new Array<TenantNode>();
|
|
996
1023
|
this.update(0, 0, 0, 0);
|
|
997
1024
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindline/sync",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.41",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"exports": "./index.ts",
|
|
7
7
|
"description": "sync is a node.js package encapsulating javscript classes required for configuring Mindline sync service.",
|
|
Binary file
|