Skip to content

Commit 9e92248

Browse files
author
Tim Middleton
committed
Fix issue with describe http-server and proxy
1 parent 328ab7d commit 9e92248

File tree

6 files changed

+54
-26
lines changed

6 files changed

+54
-26
lines changed

docs/reference/15_members.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ Output:
107107
----
108108
NODE ID ADDRESS PORT PROCESS MEMBER ROLE PKT SENT PKT REC RESENT EFFICIENCY SEND Q DATA SENT DATA REC WEAKEST
109109
1 /127.0.0.1 50724 81363 storage-1 CoherenceServer 531 586 2 100.00% 0 8 MB 9 MB 4
110-
2 /127.0.0.1 50725 81364 storage-2 CoherenceServer 181 152 0 100.00% 0 8 MB 8 MB -1
111-
3 /127.0.0.1 50726 81362 storage-0 CoherenceServer 182 148 0 100.00% 0 7 MB 10 MB -1
112-
4 /127.0.0.1 50968 81733 com.tangosol.net.CacheFactory CoherenceConsole 64 58 0 100.00% 0 3 MB 0 MB -1
110+
2 /127.0.0.1 50725 81364 storage-2 CoherenceServer 181 152 0 100.00% 0 8 MB 8 MB -
111+
3 /127.0.0.1 50726 81362 storage-0 CoherenceServer 182 148 0 100.00% 0 7 MB 10 MB -
112+
4 /127.0.0.1 50968 81733 com.tangosol.net.CacheFactory CoherenceConsole 64 58 0 100.00% 0 3 MB 0 MB -
113113
----
114114
115115
[#get-p2p-stats]

docs/reference/20_services.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///////////////////////////////////////////////////////////////////////////////
22

3-
Copyright (c) 2021, 2023 Oracle and/or its affiliates.
3+
Copyright (c) 2021, 2024 Oracle and/or its affiliates.
44
Licensed under the Universal Permissive License v 1.0 as shown at
55
https://oss.oracle.com/licenses/upl.
66

@@ -238,11 +238,11 @@ Output:
238238
[source,bash]
239239
----
240240
SERVICE NAME TYPE MEMBERS STATUS HA STORAGE SENIOR PARTITIONS
241-
Proxy Proxy 2 n/a -1 1 -1
241+
Proxy Proxy 2 n/a 0 1 -
242242
PartitionedTopic DistributedCache 2 NODE-SAFE 2 2 257
243243
PartitionedCache2 DistributedCache 2 NODE-SAFE 2 2 257
244244
PartitionedCache DistributedCache 2 NODE-SAFE 2 1 257
245-
ManagementHttpProxy Proxy 1 n/a -1 1 -1
245+
ManagementHttpProxy Proxy 1 n/a 0 1 -
246246
----
247247
248248
[source,bash]

pkg/cmd/formatting.go

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func FormatFederationDetails(federationDetails []config.FederationDescription, t
236236
var nodeID, _ = strconv.Atoi(value.NodeID)
237237
table.AddRow(formatSmallInteger(int32(nodeID)))
238238

239-
if target == "destinations" {
239+
if target == destinations {
240240
bytes = value.TotalBytesSent
241241
messages = value.TotalMsgSent
242242
records = value.TotalRecordsSent
@@ -359,7 +359,7 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar
359359
)
360360

361361
for _, value := range federationSummaries {
362-
if target == "destinations" {
362+
if target == destinations {
363363
bytes = value.TotalBytesSent.Sum
364364
messages = value.TotalMsgSent.Sum
365365
records = value.TotalRecordsSent.Sum
@@ -956,8 +956,8 @@ func FormatCacheDetailsSizeAndAccess(cacheDetails []config.CacheDetail) string {
956956
if OutputFormat == constants.WIDE {
957957
table.AddColumnsToRow(formatLargeInteger(totalHits),
958958
formatLargeInteger(value.CacheMisses), formatPercent(hitProb),
959-
formatLargeInteger(value.StoreReads), formatLargeInteger(value.StoreWrites),
960-
formatLargeInteger(value.StoreFailures))
959+
formatLargeIntegerOrDash(value.StoreReads), formatLargeIntegerOrDash(value.StoreWrites),
960+
formatLargeIntegerOrDash(value.StoreFailures))
961961
}
962962
}
963963

@@ -1521,7 +1521,7 @@ func FormatNetworkStatistics(members []config.Member) string {
15211521
table.AddColumnsToRow(formatLargeInteger(value.PacketsSent), formatLargeInteger(value.PacketsReceived),
15221522
formatLargeInteger(value.PacketsResent), formatPercent(value.PacketDeliveryEfficiency),
15231523
formatLargeInteger(value.SendQueueSize), formattingFunction(value.TransportSentBytes),
1524-
formattingFunction(value.TransportReceivedBytes), formatSmallInteger(value.WeakestChannel))
1524+
formattingFunction(value.TransportReceivedBytes), formatSmallIntegerOrDash(value.WeakestChannel))
15251525
}
15261526

15271527
return table.String()
@@ -1685,18 +1685,18 @@ func FormatServices(services []config.ServiceSummary) string {
16851685
table := newFormattedTable().WithHeader(ServiceNameColumn, "TYPE", MembersColumn, "STATUS HA", "STORAGE",
16861686
"SENIOR", partitions, "STATUS").WithSortingColumn(ServiceNameColumn)
16871687
if OutputFormat == constants.WIDE {
1688-
table.WithAlignment(L, L, R, L, R, R, R, L, R, R, R, L)
1689-
table.AddHeaderColumns(endangered, "VULNERABLE", "UNBALANCED", "SUSPENDED")
1688+
table.WithAlignment(L, L, R, L, R, R, R, L, R, R, R, R, L)
1689+
table.AddHeaderColumns(endangered, "VULNERABLE", "UNBALANCED", "PENDING REQ", "SUSPENDED")
16901690
table.AddFormattingFunction(8, endangeredPartitionsFormatter)
16911691
table.AddFormattingFunction(9, vulnerablePartitionsFormatter)
16921692
table.AddFormattingFunction(10, vulnerablePartitionsFormatter)
16931693
table.AddFormattingFunction(11, yesBoolFormatter)
16941694
} else {
1695-
table.WithAlignment(L, L, R, L, R, R, R, L)
1695+
table.WithAlignment(L, L, R, L, R, R, R, R, L)
16961696
}
16971697

16981698
table.AddFormattingFunction(3, statusHAFormatter)
1699-
table.AddFormattingFunction(7, statusHAFormatter)
1699+
table.AddFormattingFunction(8, statusHAFormatter)
17001700

17011701
for _, value := range services {
17021702
var (
@@ -1729,12 +1729,13 @@ func FormatServices(services []config.ServiceSummary) string {
17291729

17301730
table.AddRow(value.ServiceName, value.ServiceType, formatSmallInteger(value.MemberCount),
17311731
value.StatusHA, formatSmallInteger(value.StorageEnabledCount), formatSmallInteger(value.SeniorMemberID),
1732-
formatSmallInteger(value.PartitionsAll), status)
1732+
formatSmallIntegerOrDash(value.PartitionsAll), status)
17331733

17341734
if OutputFormat == constants.WIDE {
1735-
table.AddColumnsToRow(formatSmallInteger(value.PartitionsEndangered),
1736-
formatSmallInteger(value.PartitionsVulnerable),
1737-
formatSmallInteger(value.PartitionsUnbalanced), suspended)
1735+
table.AddColumnsToRow(formatSmallIntegerOrDash(value.PartitionsEndangered),
1736+
formatSmallIntegerOrDash(value.PartitionsVulnerable),
1737+
formatSmallIntegerOrDash(value.PartitionsUnbalanced),
1738+
formatSmallInteger(value.RequestPendingCount), suspended)
17381739
}
17391740
}
17401741

@@ -2102,6 +2103,22 @@ func formatSmallInteger(value int32) string {
21022103
return printer.Sprintf("%d", value)
21032104
}
21042105

2106+
// formatSmallIntegerOrDash formats a small integer but if the value is -1 returns "n/a"
2107+
func formatSmallIntegerOrDash(value int32) string {
2108+
if value == -1 {
2109+
return "-"
2110+
}
2111+
return formatSmallInteger(value)
2112+
}
2113+
2114+
// formatLargeIntegerOrDash formats a large integer but if the value is -1 returns "n/a"
2115+
func formatLargeIntegerOrDash(value int64) string {
2116+
if value == -1 {
2117+
return "-"
2118+
}
2119+
return formatLargeInteger(value)
2120+
}
2121+
21052122
// formatPort formats a small integer with a max length.
21062123
func formatPort(value int32) string {
21072124
return fmt.Sprintf("%d", value)

pkg/cmd/http_server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var getHTTPProxiesCmd = &cobra.Command{
3535
return err
3636
}
3737

38-
details, err := returnGetProxiesDetails(cmd, httpString, dataFetcher, connection)
38+
details, err := returnGetProxiesDetails(cmd, httpString, dataFetcher, connection, "")
3939
if err != nil {
4040
return err
4141
}
@@ -99,7 +99,7 @@ var describeHTTPProxyCmd = &cobra.Command{
9999
return err
100100
}
101101

102-
err = displayProxyDetails(cmd, dataFetcher, connection, httpString, serviceResult, proxyResults)
102+
err = displayProxyDetails(cmd, dataFetcher, connection, httpString, serviceResult, proxyResults, serviceName)
103103
if err != nil {
104104
return err
105105
}

pkg/cmd/proxy.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ servers for a cluster. You can specify '-o wide' to display addition information
4444
return err
4545
}
4646

47-
details, err := returnGetProxiesDetails(cmd, tcpString, dataFetcher, connection)
47+
details, err := returnGetProxiesDetails(cmd, tcpString, dataFetcher, connection, "")
4848
if err != nil {
4949
return err
5050
}
@@ -127,7 +127,7 @@ all nodes running the proxy service as well as detailed connection information.`
127127
}
128128
}
129129

130-
err = displayProxyDetails(cmd, dataFetcher, connection, "tcp", serviceResult, proxyResults)
130+
err = displayProxyDetails(cmd, dataFetcher, connection, "tcp", serviceResult, proxyResults, serviceName)
131131
if err != nil {
132132
return err
133133
}
@@ -298,7 +298,7 @@ func getProxyNodeIDs(selectedService string, proxiesSummary config.ProxiesSummar
298298
return nodeIDs
299299
}
300300

301-
func displayProxyDetails(cmd *cobra.Command, dataFetcher fetcher.Fetcher, connection, protocol string, serviceResult, proxyResults []byte) error {
301+
func displayProxyDetails(cmd *cobra.Command, dataFetcher fetcher.Fetcher, connection, protocol string, serviceResult, proxyResults []byte, service string) error {
302302
var (
303303
err error
304304
finalResult []byte
@@ -342,7 +342,7 @@ func displayProxyDetails(cmd *cobra.Command, dataFetcher fetcher.Fetcher, connec
342342

343343
cmd.Print(member + "\n")
344344
cmd.Print("--------------------" + header + "\n")
345-
value, err = returnGetProxiesDetails(cmd, protocol, dataFetcher, connection)
345+
value, err = returnGetProxiesDetails(cmd, protocol, dataFetcher, connection, service)
346346
if err != nil {
347347
return err
348348
}
@@ -352,7 +352,7 @@ func displayProxyDetails(cmd *cobra.Command, dataFetcher fetcher.Fetcher, connec
352352
return nil
353353
}
354354

355-
func returnGetProxiesDetails(cmd *cobra.Command, protocol string, dataFetcher fetcher.Fetcher, connection string) (string, error) {
355+
func returnGetProxiesDetails(cmd *cobra.Command, protocol string, dataFetcher fetcher.Fetcher, connection string, service string) (string, error) {
356356
var sb strings.Builder
357357
for {
358358
var proxiesSummary = config.ProxiesSummary{}
@@ -384,6 +384,16 @@ func returnGetProxiesDetails(cmd *cobra.Command, protocol string, dataFetcher fe
384384
if err != nil {
385385
return "", utils.GetError("unable to unmarshall proxy result", err)
386386
}
387+
if service != "" {
388+
// exclude any proxies that don't equal the service name
389+
finalProxySummary := make([]config.ProxySummary, 0)
390+
for _, v := range proxiesSummary.Proxies {
391+
if v.ServiceName == service {
392+
finalProxySummary = append(finalProxySummary, v)
393+
}
394+
}
395+
proxiesSummary.Proxies = finalProxySummary
396+
}
387397
sb.WriteString(FormatProxyServers(proxiesSummary.Proxies, protocol))
388398
}
389399

pkg/config/config_helper.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ type ServiceSummary struct {
209209
PartitionsEndangered int32 `json:"partitionsEndangered"`
210210
PartitionsVulnerable int32 `json:"partitionsVulnerable"`
211211
PartitionsUnbalanced int32 `json:"partitionsUnbalanced"`
212+
RequestPendingCount int32 `json:"requestPendingCount"`
212213
StorageEnabled bool `json:"storageEnabled"`
213214
QuorumStatus string `json:"quorumStatus"`
214215
SeniorMemberID int32 `json:"seniorMemberId"`

0 commit comments

Comments
 (0)