Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf31cb8a

Browse files
committed
print connectivity matrix only if changed#11
1 parent1b8929d commitf31cb8a

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

‎contrib/mmts/multimaster.c‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ static ExecutorFinish_hook_type PreviousExecutorFinishHook;
230230
staticProcessUtility_hook_typePreviousProcessUtilityHook;
231231
staticshmem_startup_hook_typePreviousShmemStartupHook;
232232

233+
staticnodemask_tlastKnownMatrix[MAX_NODES];
233234

234235
staticvoidMtmExecutorFinish(QueryDesc*queryDesc);
235236
staticvoidMtmProcessUtility(Node*parsetree,constchar*queryString,
@@ -1552,7 +1553,8 @@ static bool
15521553
MtmBuildConnectivityMatrix(nodemask_t*matrix,boolnowait)
15531554
{
15541555
inti,j,n=Mtm->nAllNodes;
1555-
fprintf(stderr,"Connectivity matrix:\n");
1556+
boolchanged= false;
1557+
15561558
for (i=0;i<n;i++) {
15571559
if (i+1!=MtmNodeId) {
15581560
void*data=RaftableGet(psprintf("node-mask-%d",i+1),NULL,NULL,nowait);
@@ -1563,12 +1565,27 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
15631565
}else {
15641566
matrix[i]=Mtm->connectivityMask;
15651567
}
1566-
for (j=0;j<n;j++) {
1567-
putc(BIT_CHECK(matrix[i],j) ?'X' :'+',stderr);
1568+
1569+
if (lastKnownMatrix[i]!=matrix[i])
1570+
{
1571+
changed= true;
1572+
lastKnownMatrix[i]=matrix[i];
15681573
}
1569-
putc('\n',stderr);
15701574
}
1571-
fputs("-----------------------\n",stderr);
1575+
1576+
/* Print matrix if changed */
1577+
if (changed)
1578+
{
1579+
fprintf(stderr,"Connectivity matrix:\n");
1580+
for (i=0;i<n;i++)
1581+
{
1582+
for (j=0;j<n;j++)
1583+
putc(BIT_CHECK(matrix[i],j) ?'X' :'+',stderr);
1584+
putc('\n',stderr);
1585+
}
1586+
fputs("-----------------------\n",stderr);
1587+
}
1588+
15721589
/* make matrix symetric: required for Bron–Kerbosch algorithm */
15731590
for (i=0;i<n;i++) {
15741591
for (j=0;j<i;j++) {
@@ -1577,8 +1594,9 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
15771594
}
15781595
matrix[i] &= ~((nodemask_t)1 <<i);
15791596
}
1597+
15801598
return true;
1581-
}
1599+
}
15821600

15831601

15841602
/**
@@ -1599,6 +1617,11 @@ bool MtmRefreshClusterStatus(bool nowait, int testNodeId)
15991617
}
16001618

16011619
clique=MtmFindMaxClique(matrix,Mtm->nAllNodes,&clique_size);
1620+
1621+
if (clique== (~Mtm->disabledNodeMask& (((nodemask_t)1 <<Mtm->nAllNodes)-1)) )
1622+
/* Nothing is changed */
1623+
return false;
1624+
16021625
if (clique_size >=Mtm->nAllNodes/2+1) {/* have quorum */
16031626
fprintf(stderr,"Old mask: ");
16041627
for (i=0;i<Mtm->nAllNodes;i++) {
@@ -1729,7 +1752,7 @@ void MtmOnNodeDisconnect(int nodeId)
17291752
}
17301753
}
17311754
MtmUnlock();
1732-
}else {
1755+
}else {
17331756
MtmRefreshClusterStatus(false,0);
17341757
}
17351758
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp