Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor cosmetic and message updates #242

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/reference/15_members.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ Output:
----
NODE ID ADDRESS PORT PROCESS MEMBER ROLE PKT SENT PKT REC RESENT EFFICIENCY SEND Q DATA SENT DATA REC WEAKEST
1 /127.0.0.1 50724 81363 storage-1 CoherenceServer 531 586 2 100.00% 0 8 MB 9 MB 4
2 /127.0.0.1 50725 81364 storage-2 CoherenceServer 181 152 0 100.00% 0 8 MB 8 MB -1
3 /127.0.0.1 50726 81362 storage-0 CoherenceServer 182 148 0 100.00% 0 7 MB 10 MB -1
4 /127.0.0.1 50968 81733 com.tangosol.net.CacheFactory CoherenceConsole 64 58 0 100.00% 0 3 MB 0 MB -1
2 /127.0.0.1 50725 81364 storage-2 CoherenceServer 181 152 0 100.00% 0 8 MB 8 MB -
3 /127.0.0.1 50726 81362 storage-0 CoherenceServer 182 148 0 100.00% 0 7 MB 10 MB -
4 /127.0.0.1 50968 81733 com.tangosol.net.CacheFactory CoherenceConsole 64 58 0 100.00% 0 3 MB 0 MB -
----

[#get-p2p-stats]
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/20_services.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

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

Expand Down Expand Up @@ -238,11 +238,11 @@ Output:
[source,bash]
----
SERVICE NAME TYPE MEMBERS STATUS HA STORAGE SENIOR PARTITIONS
Proxy Proxy 2 n/a -1 1 -1
Proxy Proxy 2 n/a 0 1 -
PartitionedTopic DistributedCache 2 NODE-SAFE 2 2 257
PartitionedCache2 DistributedCache 2 NODE-SAFE 2 2 257
PartitionedCache DistributedCache 2 NODE-SAFE 2 1 257
ManagementHttpProxy Proxy 1 n/a -1 1 -1
ManagementHttpProxy Proxy 1 n/a 0 1 -
----

[source,bash]
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ var (
)

const (
provideCacheMessage = "you must provide a cache name"
provideViewCacheMessage = "you must provide a view cache name"
provideCacheMessage = "you must provide a single cache name"
provideViewCacheMessage = "you must provide a single view cache name"
back = "back"
all = "all"
partitionDisplayType = "partition"
Expand Down Expand Up @@ -800,7 +800,7 @@ batchFactor, refreshFactor or requeueThreshold.`,
ValidArgsFunction: completionCaches,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a cache name")
displayErrorAndExit(cmd, provideCacheMessage)
}
return nil
},
Expand Down
24 changes: 12 additions & 12 deletions pkg/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ var (
)

const (
clusterMessage = "A cluster connection already exists with the name %s for %s\n"
ignoreErrorsMessage = "ignore errors from NS lookup"
youMustProviderClusterMessage = "you must provide a cluster name"
clusterMessage = "A cluster connection already exists with the name %s for %s\n"
ignoreErrorsMessage = "ignore errors from NS lookup"
youMustProviderConnectionMessage = "you must provide a single connection name"
)

// addClusterCmd represents the add cluster command
Expand All @@ -49,7 +49,7 @@ You can also specify host:port (for http connections) and the url will be automa
populated constructed.`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a connection name")
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand All @@ -62,7 +62,7 @@ populated constructed.`,
}

if connectionURL == "" {
return errors.New("you must supply a connection url")
return errors.New("you must provide a connection url")
}

if err = addCluster(cmd, connection, connectionURL, "manual", ""); err != nil {
Expand All @@ -81,7 +81,7 @@ var removeClusterCmd = &cobra.Command{
ValidArgsFunction: completionAllClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a connection name")
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand Down Expand Up @@ -203,7 +203,7 @@ addition information as well as '-v' to displayed additional information.`,
ValidArgsFunction: completionAllClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a cluster connection")
displayErrorAndExit(cmd, "you must provide a single cluster connection")
}
return nil
},
Expand Down Expand Up @@ -774,7 +774,7 @@ commercial 14.1.1.2206.1 and above. Default version is currently CE ` + defaultC
NOTE: This is an experimental feature and my be altered or removed in the future.`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, youMustProviderClusterMessage)
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand Down Expand Up @@ -1141,7 +1141,7 @@ var startClusterCmd = &cobra.Command{
ValidArgsFunction: completionAllManualClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, youMustProviderClusterMessage)
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand All @@ -1161,7 +1161,7 @@ var scaleClusterCmd = &cobra.Command{
ValidArgsFunction: completionAllManualClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, youMustProviderClusterMessage)
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand All @@ -1178,7 +1178,7 @@ var stopClusterCmd = &cobra.Command{
ValidArgsFunction: completionAllManualClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, youMustProviderClusterMessage)
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand All @@ -1195,7 +1195,7 @@ var restartClusterCmd = &cobra.Command{
ValidArgsFunction: completionAllManualClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, youMustProviderClusterMessage)
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var setContextCmd = &cobra.Command{
ValidArgsFunction: completionAllClusters,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a connection name")
displayErrorAndExit(cmd, youMustProviderConnectionMessage)
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This includes details of the JVM as well as system properties.`,
ValidArgsFunction: completionNodeID,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a node id")
displayErrorAndExit(cmd, "you must provide a single node id")
}
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
)

const (
provideExecutorName = "you must provide an executor name"
provideExecutorName = "you must provide a single executor name"
cannotFindExecutors = "unable to find any executors in this cluster"
stringTrue = "true"
stringFalse = "false"
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (
)

const (
destinations = "destinations"
origins = "origins"
destinations = "outgoing"
origins = "incoming"
outgoing = "outgoing"
incoming = "incoming"
participantMessage = "participant to apply to"
supplyService = "you must provide a service name"
supplyService = "you must provide a single federated service name"
federationUse = "federation service-name"
replicateAll = "replicateAll"
)
Expand All @@ -42,10 +42,10 @@ var (

// getFederationCmd represents the get federation command.
var getFederationCmd = &cobra.Command{
Use: "federation {destinations|origins|all}",
Use: "federation {outgoing|incoming|all}",
Short: "display federation details for a cluster",
Long: `The 'get federation' command displays the federation details for a cluster.
You must specify either destinations, origins or all to show both. You
You must specify either outgoing, incoming or all to show both. You
can also specify '-o wide' to display addition information.`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
Expand Down Expand Up @@ -109,7 +109,7 @@ can also specify '-o wide' to display addition information.`,
jsonDataDest, _ := json.Marshal(finalSummariesDestinations)
jsonDataOrigins, _ := json.Marshal(finalSummariesOrigins)
finalData, err := utils.CombineByteArraysForJSON([][]byte{jsonDataDest, jsonDataOrigins},
[]string{"destinations", "origins"})
[]string{outgoing, incoming})
if err != nil {
return err
}
Expand Down
53 changes: 37 additions & 16 deletions pkg/cmd/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func FormatFederationDetails(federationDetails []config.FederationDescription, t
var nodeID, _ = strconv.Atoi(value.NodeID)
table.AddRow(formatSmallInteger(int32(nodeID)))

if target == "destinations" {
if target == destinations {
bytes = value.TotalBytesSent
messages = value.TotalMsgSent
records = value.TotalRecordsSent
Expand Down Expand Up @@ -288,7 +288,7 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar
fedCount = len(federationSummaries)
finalAlignment []string
suffix = "SENT"
participantCol = "DESTINATION"
participantCol = "OUTGOING"
memberCol = MembersColumn
formattingFunction = getFormattingFunction()
table FormattedTable
Expand All @@ -301,7 +301,7 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar
// setup columns and alignments
if target == origins {
suffix = "REC"
participantCol = "ORIGIN"
participantCol = "INCOMING"
memberCol = "MEMBERS RECEIVING"
}

Expand Down Expand Up @@ -359,7 +359,7 @@ func FormatFederationSummary(federationSummaries []config.FederationSummary, tar
)

for _, value := range federationSummaries {
if target == "destinations" {
if target == destinations {
bytes = value.TotalBytesSent.Sum
messages = value.TotalMsgSent.Sum
records = value.TotalRecordsSent.Sum
Expand Down Expand Up @@ -956,8 +956,8 @@ func FormatCacheDetailsSizeAndAccess(cacheDetails []config.CacheDetail) string {
if OutputFormat == constants.WIDE {
table.AddColumnsToRow(formatLargeInteger(totalHits),
formatLargeInteger(value.CacheMisses), formatPercent(hitProb),
formatLargeInteger(value.StoreReads), formatLargeInteger(value.StoreWrites),
formatLargeInteger(value.StoreFailures))
formatLargeIntegerOrDash(value.StoreReads), formatLargeIntegerOrDash(value.StoreWrites),
formatLargeIntegerOrDash(value.StoreFailures))
}
}

Expand Down Expand Up @@ -1193,7 +1193,7 @@ func FormatClusterConnections(clusters []ClusterConnection) string {
return ""
}

table := newFormattedTable().WithHeader("CONNECTION", "TYPE", "URL", "VERSION", "CLUSTER NAME", "TYPE", "CTX", "LOCAL").
table := newFormattedTable().WithHeader("CONNECTION", "TYPE", "URL", "VERSION", "CLUSTER NAME", "TYPE", "CTX", "CREATED").
WithSortingColumn("CONNECTION")

for _, value := range clusters {
Expand Down Expand Up @@ -1521,7 +1521,7 @@ func FormatNetworkStatistics(members []config.Member) string {
table.AddColumnsToRow(formatLargeInteger(value.PacketsSent), formatLargeInteger(value.PacketsReceived),
formatLargeInteger(value.PacketsResent), formatPercent(value.PacketDeliveryEfficiency),
formatLargeInteger(value.SendQueueSize), formattingFunction(value.TransportSentBytes),
formattingFunction(value.TransportReceivedBytes), formatSmallInteger(value.WeakestChannel))
formattingFunction(value.TransportReceivedBytes), formatSmallIntegerOrDash(value.WeakestChannel))
}

return table.String()
Expand Down Expand Up @@ -1685,18 +1685,18 @@ func FormatServices(services []config.ServiceSummary) string {
table := newFormattedTable().WithHeader(ServiceNameColumn, "TYPE", MembersColumn, "STATUS HA", "STORAGE",
"SENIOR", partitions, "STATUS").WithSortingColumn(ServiceNameColumn)
if OutputFormat == constants.WIDE {
table.WithAlignment(L, L, R, L, R, R, R, L, R, R, R, L)
table.AddHeaderColumns(endangered, "VULNERABLE", "UNBALANCED", "SUSPENDED")
table.WithAlignment(L, L, R, L, R, R, R, L, R, R, R, R, L)
table.AddHeaderColumns(endangered, "VULNERABLE", "UNBALANCED", "PENDING REQ", "SUSPENDED")
table.AddFormattingFunction(8, endangeredPartitionsFormatter)
table.AddFormattingFunction(9, vulnerablePartitionsFormatter)
table.AddFormattingFunction(10, vulnerablePartitionsFormatter)
table.AddFormattingFunction(11, yesBoolFormatter)
} else {
table.WithAlignment(L, L, R, L, R, R, R, L)
table.WithAlignment(L, L, R, L, R, R, R, R, L)
}

table.AddFormattingFunction(3, statusHAFormatter)
table.AddFormattingFunction(7, statusHAFormatter)
table.AddFormattingFunction(8, statusHAFormatter)

for _, value := range services {
var (
Expand All @@ -1715,6 +1715,10 @@ func FormatServices(services []config.ServiceSummary) string {
status = fmt.Sprintf("%d partitions are unbalanced", value.PartitionsUnbalanced)
}

if value.StorageEnabledCount == -1 {
value.StorageEnabledCount = 0
}

if value.QuorumStatus == "Suspended" {
suspended = "yes"
} else {
Expand All @@ -1725,12 +1729,13 @@ func FormatServices(services []config.ServiceSummary) string {

table.AddRow(value.ServiceName, value.ServiceType, formatSmallInteger(value.MemberCount),
value.StatusHA, formatSmallInteger(value.StorageEnabledCount), formatSmallInteger(value.SeniorMemberID),
formatSmallInteger(value.PartitionsAll), status)
formatSmallIntegerOrDash(value.PartitionsAll), status)

if OutputFormat == constants.WIDE {
table.AddColumnsToRow(formatSmallInteger(value.PartitionsEndangered),
formatSmallInteger(value.PartitionsVulnerable),
formatSmallInteger(value.PartitionsUnbalanced), suspended)
table.AddColumnsToRow(formatSmallIntegerOrDash(value.PartitionsEndangered),
formatSmallIntegerOrDash(value.PartitionsVulnerable),
formatSmallIntegerOrDash(value.PartitionsUnbalanced),
formatSmallInteger(value.RequestPendingCount), suspended)
}
}

Expand Down Expand Up @@ -2098,6 +2103,22 @@ func formatSmallInteger(value int32) string {
return printer.Sprintf("%d", value)
}

// formatSmallIntegerOrDash formats a small integer but if the value is -1 returns "n/a"
func formatSmallIntegerOrDash(value int32) string {
if value == -1 {
return "-"
}
return formatSmallInteger(value)
}

// formatLargeIntegerOrDash formats a large integer but if the value is -1 returns "n/a"
func formatLargeIntegerOrDash(value int64) string {
if value == -1 {
return "-"
}
return formatLargeInteger(value)
}

// formatPort formats a small integer with a max length.
func formatPort(value int32) string {
return fmt.Sprintf("%d", value)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var getHTTPProxiesCmd = &cobra.Command{
return err
}

details, err := returnGetProxiesDetails(cmd, httpString, dataFetcher, connection)
details, err := returnGetProxiesDetails(cmd, httpString, dataFetcher, connection, "")
if err != nil {
return err
}
Expand All @@ -55,7 +55,7 @@ var describeHTTPProxyCmd = &cobra.Command{
ValidArgsFunction: completionHTTPServers,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide a service name")
displayErrorAndExit(cmd, provideService)
}
return nil
},
Expand Down Expand Up @@ -99,7 +99,7 @@ var describeHTTPProxyCmd = &cobra.Command{
return err
}

err = displayProxyDetails(cmd, dataFetcher, connection, httpString, serviceResult, proxyResults)
err = displayProxyDetails(cmd, dataFetcher, connection, httpString, serviceResult, proxyResults, serviceName)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/http_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ var describeHTTPSessionCmd = &cobra.Command{
ValidArgsFunction: completionHTTPSessions,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
displayErrorAndExit(cmd, "you must provide an application id")
displayErrorAndExit(cmd, "you must provide a single application id")
}
return nil
},
Expand Down
Loading
Loading