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

Commite91a49a

Browse files
committed
print connectivity matrix only if changed#11
1 parent83ea67b commite91a49a

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

‎multimaster.c

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

232+
staticnodemask_tlastKnownMatrix[MAX_NODES];
232233

233234
staticvoidMtmExecutorFinish(QueryDesc*queryDesc);
234235
staticvoidMtmProcessUtility(Node*parsetree,constchar*queryString,
@@ -1551,7 +1552,8 @@ static bool
15511552
MtmBuildConnectivityMatrix(nodemask_t*matrix,boolnowait)
15521553
{
15531554
inti,j,n=Mtm->nAllNodes;
1554-
fprintf(stderr,"Connectivity matrix:\n");
1555+
boolchanged= false;
1556+
15551557
for (i=0;i<n;i++) {
15561558
if (i+1!=MtmNodeId) {
15571559
void*data=RaftableGet(psprintf("node-mask-%d",i+1),NULL,NULL,nowait);
@@ -1562,12 +1564,27 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
15621564
}else {
15631565
matrix[i]=Mtm->connectivityMask;
15641566
}
1565-
for (j=0;j<n;j++) {
1566-
putc(BIT_CHECK(matrix[i],j) ?'X' :'+',stderr);
1567+
1568+
if (lastKnownMatrix[i]!=matrix[i])
1569+
{
1570+
changed= true;
1571+
lastKnownMatrix[i]=matrix[i];
15671572
}
1568-
putc('\n',stderr);
15691573
}
1570-
fputs("-----------------------\n",stderr);
1574+
1575+
/* Print matrix if changed */
1576+
if (changed)
1577+
{
1578+
fprintf(stderr,"Connectivity matrix:\n");
1579+
for (i=0;i<n;i++)
1580+
{
1581+
for (j=0;j<n;j++)
1582+
putc(BIT_CHECK(matrix[i],j) ?'X' :'+',stderr);
1583+
putc('\n',stderr);
1584+
}
1585+
fputs("-----------------------\n",stderr);
1586+
}
1587+
15711588
/* make matrix symetric: required for Bron–Kerbosch algorithm */
15721589
for (i=0;i<n;i++) {
15731590
for (j=0;j<i;j++) {
@@ -1576,8 +1593,9 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
15761593
}
15771594
matrix[i] &= ~((nodemask_t)1 <<i);
15781595
}
1596+
15791597
return true;
1580-
}
1598+
}
15811599

15821600

15831601
/**
@@ -1598,6 +1616,11 @@ bool MtmRefreshClusterStatus(bool nowait, int testNodeId)
15981616
}
15991617

16001618
clique=MtmFindMaxClique(matrix,Mtm->nAllNodes,&clique_size);
1619+
1620+
if (clique== (~Mtm->disabledNodeMask& (((nodemask_t)1 <<Mtm->nAllNodes)-1)) )
1621+
/* Nothing is changed */
1622+
return false;
1623+
16011624
if (clique_size >=Mtm->nAllNodes/2+1) {/* have quorum */
16021625
fprintf(stderr,"Old mask: ");
16031626
for (i=0;i<Mtm->nAllNodes;i++) {
@@ -1728,7 +1751,7 @@ void MtmOnNodeDisconnect(int nodeId)
17281751
}
17291752
}
17301753
MtmUnlock();
1731-
}else {
1754+
}else {
17321755
MtmRefreshClusterStatus(false,0);
17331756
}
17341757
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp