@@ -29,7 +29,7 @@ nodestatePrepareHeaders(CurrentNodeStateArray *nodesArray,
2929 nodesArray -> headers .maxNameSize = 4 ; /* "Name" */
3030 nodesArray -> headers .maxHostSize = 10 ; /* "Host:Port" */
3131 nodesArray -> headers .maxNodeSize = 5 ; /* "Node" */
32- nodesArray -> headers .maxLSNSize = 3 ; /* "LSN" */
32+ nodesArray -> headers .maxLSNSize = 9 ; /* "TLI: LSN" */
3333 nodesArray -> headers .maxStateSize = MAX_NODE_STATE_LEN ;
3434 nodesArray -> headers .maxHealthSize = strlen ("read-write *" );
3535
@@ -117,38 +117,21 @@ void
117117nodestateAdjustHeaders (NodeAddressHeaders * headers ,
118118 NodeAddress * node , int groupId )
119119{
120- int nameLen = strlen (node -> name );
121-
122- /* compute strlen of host:port */
123- IntString portString = intToString (node -> port );
124- int hostLen =
125- strlen (node -> host ) + strlen (portString .strValue ) + 1 ;
126-
127- /* compute strlen of groupId/nodeId, as in "0/1" */
128- IntString nodeIdString = intToString (node -> nodeId );
129- int nodeLen = 0 ;
130-
131- int lsnLen = strlen (node -> lsn );
132-
133- switch (headers -> nodeKind )
134- {
135- case NODE_KIND_STANDALONE :
136- {
137- nodeLen = strlen (nodeIdString .strValue );
138- break ;
139- }
140-
141- default :
142- {
143- IntString groupIdString = intToString (groupId );
120+ char hostport [BUFSIZE ] = { 0 };
121+ char composedId [BUFSIZE ] = { 0 };
122+ char tliLSN [BUFSIZE ] = { 0 };
144123
145- nodeLen =
146- strlen (groupIdString .strValue ) +
147- strlen (nodeIdString .strValue ) + 1 ;
124+ (void ) nodestatePrepareNode (headers ,
125+ node ,
126+ groupId ,
127+ hostport ,
128+ composedId ,
129+ tliLSN );
148130
149- break ;
150- }
151- }
131+ int nameLen = strlen (node -> name );
132+ int hostLen = strlen (hostport );
133+ int nodeLen = strlen (composedId );
134+ int lsnLen = strlen (tliLSN );
152135
153136 /*
154137 * In order to have a static nice table output even when using
@@ -178,8 +161,8 @@ nodestateAdjustHeaders(NodeAddressHeaders *headers,
178161
179162 if (headers -> maxLSNSize == 0 )
180163 {
181- /* Unknown LSN is going to be "0/0" */
182- headers -> maxLSNSize = 3 ;
164+ /* Unknown LSN is going to be " 1: 0/0" */
165+ headers -> maxLSNSize = 9 ;
183166 }
184167
185168 if (headers -> maxHealthSize == 0 )
@@ -224,7 +207,7 @@ nodestatePrintHeader(NodeAddressHeaders *headers)
224207 headers -> maxNameSize , "Name" ,
225208 headers -> maxNodeSize , "Node" ,
226209 headers -> maxHostSize , "Host:Port" ,
227- headers -> maxLSNSize , "LSN" ,
210+ headers -> maxLSNSize , "TLI: LSN" ,
228211 headers -> maxHealthSize , "Connection" ,
229212 headers -> maxStateSize , "Current State" ,
230213 headers -> maxStateSize , "Assigned State" );
@@ -250,14 +233,16 @@ nodestatePrintNodeState(NodeAddressHeaders *headers,
250233{
251234 char hostport [BUFSIZE ] = { 0 };
252235 char composedId [BUFSIZE ] = { 0 };
236+ char tliLSN [BUFSIZE ] = { 0 };
253237 char connection [BUFSIZE ] = { 0 };
254238 char healthChar = nodestateHealthToChar (nodeState -> health );
255239
256240 (void ) nodestatePrepareNode (headers ,
257241 & (nodeState -> node ),
258242 nodeState -> groupId ,
259243 hostport ,
260- composedId );
244+ composedId ,
245+ tliLSN );
261246
262247 if (healthChar == ' ' )
263248 {
@@ -273,7 +258,7 @@ nodestatePrintNodeState(NodeAddressHeaders *headers,
273258 headers -> maxNameSize , nodeState -> node .name ,
274259 headers -> maxNodeSize , composedId ,
275260 headers -> maxHostSize , hostport ,
276- headers -> maxLSNSize , nodeState -> node . lsn ,
261+ headers -> maxLSNSize , tliLSN ,
277262 headers -> maxHealthSize , connection ,
278263 headers -> maxStateSize , NodeStateToString (nodeState -> reportedState ),
279264 headers -> maxStateSize , NodeStateToString (nodeState -> goalState ));
@@ -287,9 +272,11 @@ nodestatePrintNodeState(NodeAddressHeaders *headers,
287272 */
288273void
289274nodestatePrepareNode (NodeAddressHeaders * headers , NodeAddress * node ,
290- int groupId , char * hostport , char * composedId )
275+ int groupId , char * hostport ,
276+ char * composedId , char * tliLSN )
291277{
292278 sformat (hostport , BUFSIZE , "%s:%d" , node -> host , node -> port );
279+ sformat (tliLSN , BUFSIZE , "%3d: %s" , node -> tli , node -> lsn );
293280
294281 switch (headers -> nodeKind )
295282 {
@@ -353,6 +340,8 @@ nodestateAsJSON(CurrentNodeState *nodeState, JSON_Value *js)
353340 json_object_set_string (jsobj , "assigned_group_state" ,
354341 NodeStateToString (nodeState -> goalState ));
355342
343+ json_object_set_number (jsobj , "timeline" , (double ) nodeState -> node .tli );
344+
356345 json_object_set_string (jsobj , "Minimum Recovery Ending LSN" ,
357346 nodeState -> node .lsn );
358347
@@ -551,14 +540,14 @@ printNodeArray(NodeAddressArray *nodesArray)
551540void
552541printNodeHeader (NodeAddressHeaders * headers )
553542{
554- fformat (stdout , "%*s | %*s | %*s | %18s | %8s\n" ,
543+ fformat (stdout , "%*s | %*s | %*s | %21s | %8s\n" ,
555544 headers -> maxNameSize , "Name" ,
556545 headers -> maxNodeSize , "Node" ,
557546 headers -> maxHostSize , "Host:Port" ,
558- "LSN" ,
547+ "TLI: LSN" ,
559548 "Primary?" );
560549
561- fformat (stdout , "%*s-+-%*s-+-%*s-+-%18s -+-%8s\n" ,
550+ fformat (stdout , "%*s-+-%*s-+-%*s-+-%21s -+-%8s\n" ,
562551 headers -> maxNameSize , headers -> nameSeparatorHeader ,
563552 headers -> maxNodeSize , headers -> nodeSeparatorHeader ,
564553 headers -> maxHostSize , headers -> hostSeparatorHeader ,
@@ -574,13 +563,14 @@ printNodeEntry(NodeAddressHeaders *headers, NodeAddress *node)
574563{
575564 char hostport [BUFSIZE ] = { 0 };
576565 char composedId [BUFSIZE ] = { 0 };
566+ char tliLSN [BUFSIZE ] = { 0 };
577567
578- (void ) nodestatePrepareNode (headers , node , 0 , hostport , composedId );
568+ (void ) nodestatePrepareNode (headers , node , 0 , hostport , composedId , tliLSN );
579569
580- fformat (stdout , "%*s | %*s | %*s | %18s | %8s\n" ,
570+ fformat (stdout , "%*s | %*s | %*s | %21s | %8s\n" ,
581571 headers -> maxNameSize , node -> name ,
582572 headers -> maxNodeSize , composedId ,
583573 headers -> maxHostSize , hostport ,
584- node -> lsn ,
574+ tliLSN ,
585575 node -> isPrimary ? "yes" : "no" );
586576}
0 commit comments