cmd

package
v0.0.0-...-b7e2043 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: UPL-1.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	R                     = "R"
	L                     = "L"
	NodeIDColumn          = "NODE ID"
	SubscriberIDColumn    = "SUBSCRIBER ID"
	ServiceColumn         = "SERVICE"
	CacheColumn           = "CACHE"
	CountColumn           = "COUNT"
	PolledColumn          = "POLLED"
	HeadColumn            = "HEAD"
	HitProbColumn         = "HIT PROB"
	ChannelsColumn        = "CHANNELS"
	ChannelColumn         = "CHANNEL"
	SubscriberGroupColumn = "SUBSCRIBER GROUP"
	PublishedColumn       = "PUBLISHED"
	MeanColumn            = "MEAN"
	OneMinuteColumn       = "1 MIN"
	FiveMinuteColumn      = "5 MIN"
	FifteenMinuteColumn   = "15 MIN"
	ServiceNameColumn     = "SERVICE NAME"
	AddressColumn         = "ADDRESS"
	PortColumn            = "PORT"
	MemberColumn          = "MEMBER"
	MembersColumn         = "MEMBERS"
	RoleColumn            = "ROLE"
	ProcessColumn         = "PROCESS"
	MaxHeapColumn         = "MAX HEAP"
	UsedHeapColumn        = "USED HEAP"
	AvailHeapColumn       = "AVAIL HEAP"
	NameColumn            = "NAME"
)
View Source
const (
	SupplyTopicMessage = "you must provide a topic"
	NoTopicForService  = "there are no topics for service %s"
	TopicDoesNotExist  = "a topic named %s does not exist for service %s"
)
View Source
const (
	OperationCompleted = "operation completed"
)

various command constants

View Source
const (
	UnableToFindClusterMsg = "unable to find cluster with connection name "
)

Variables

View Source
var (
	ElasticDataMessage = fmt.Sprintf("name must be %s or %s", ram, flash)
	ErrInvalidType     = errors.New(ElasticDataMessage)
)
View Source
var (
	KB int64 = 1024
	MB       = KB * KB
	GB       = MB * MB
)
View Source
var (

	// Config is the CLI config
	Config CoherenceCLIConfig

	// Username contains the current username
	Username string

	// UsingContext indicates if we are using a context via the set context command
	UsingContext bool

	Logger *zap.Logger

	// Version is the cohctl version injected by the Go linker at build time.
	Version string
	// Commit is the git commit hash injected by the Go linker at build time.
	Commit string
	// Date is the build timestamp injected by the Go linker at build time.
	Date string
)
View Source
var (

	// ArchivedSnapshots indicates if we are working with archived snapshots
	ArchivedSnapshots bool
)
View Source
var (
	InvalidTierMsg = "tier must be back or front"
)
View Source
var (
	NodeID string
)
View Source
var (
	OutputFormat string
)

Functions

func CreateCamelCaseLabel

func CreateCamelCaseLabel(field string) string

CreateCamelCaseLabel creates a camel case label from a field, e.g. unicastListener becomes "Unicast Listener".

func DeduplicatePersistenceServices

func DeduplicatePersistenceServices(servicesSummary config.ServicesSummaries) []config.ServiceSummary

DeduplicatePersistenceServices removes duplicated persistence details.

func DeduplicateServices

func DeduplicateServices(servicesSummary config.ServicesSummaries, serviceType string) []config.ServiceSummary

DeduplicateServices removes duplicated service details.

func DeduplicateSessions

func DeduplicateSessions(httpSummary config.HTTPSessionSummaries) []config.HTTPSessionSummary

DeduplicateSessions removes duplicated http session details.

func Execute

func Execute(version string, date string, commit string)

Execute run the root command

func FormatCacheDetailsSizeAndAccess

func FormatCacheDetailsSizeAndAccess(cacheDetails []config.CacheDetail) string

FormatCacheDetailsSizeAndAccess returns the cache details size and access details in column formatted output.

func FormatCacheDetailsStorage

func FormatCacheDetailsStorage(cacheDetails []config.CacheDetail) string

FormatCacheDetailsStorage returns the cache storage details in column formatted output.

func FormatCacheIndexDetails

func FormatCacheIndexDetails(cacheDetails []config.CacheDetail) string

FormatCacheIndexDetails returns the cache index details.

func FormatCachePartitions

func FormatCachePartitions(cacheDetails []config.CachePartitionDetail, summary bool) string

FormatCachePartitions returns the cache partition details in column formatted output.

func FormatCacheStoreDetails

func FormatCacheStoreDetails(cacheDetails []config.CacheStoreDetail, cache, service string, includeHeader bool) string

FormatCacheStoreDetails returns the cache store details in column formatted output.

func FormatCacheSummary

func FormatCacheSummary(cacheSummaries []config.CacheSummaryDetail) string

FormatCacheSummary returns the cache summary in column formatted output.

func FormatChannelStats

func FormatChannelStats(channelStats []config.ChannelStats) string

FormatChannelStats returns the channel stats in column formatted output.

func FormatCluster

func FormatCluster(cluster config.Cluster) string

FormatCluster returns a string representing a cluster.

func FormatClusterConnections

func FormatClusterConnections(clusters []ClusterConnection) string

FormatClusterConnections returns the cluster information in a column formatted output.

func FormatCurrentCluster

func FormatCurrentCluster(clusterName string) string

FormatCurrentCluster will display a message indicating a cluster context is being used.

func FormatDepartedMembers

func FormatDepartedMembers(members []config.DepartedMembers) string

FormatDepartedMembers returns the departed member's information in a column formatted output.

func FormatDiscoveredClusters

func FormatDiscoveredClusters(clusters []discovery.DiscoveredCluster) string

FormatDiscoveredClusters returns the discovered clusters in the column formatted output.

func FormatElasticData

func FormatElasticData(edData []config.ElasticData, summary bool) string

FormatElasticData formats the elastic data summary.

func FormatExecutors

func FormatExecutors(executors []config.Executor, summary bool) string

FormatExecutors returns the executor's information in a column formatted output.

func FormatFederationDetails

func FormatFederationDetails(federationDetails []config.FederationDescription, target string) string

func FormatFederationSummary

func FormatFederationSummary(federationSummaries []config.FederationSummary, target string) string

FormatFederationSummary returns the federation summary in column formatted output the target may be destinations or origins and columns will change slightly.

func FormatHTTPSessions

func FormatHTTPSessions(sessions []config.HTTPSessionSummary, isSummary bool) string

FormatHTTPSessions returns the Coherence*Web information in a column formatted output.

func FormatHeadsStats

func FormatHeadsStats(channelStats []config.HeadStats) string

FormatHeadsStats returns the subscriber heads stats in column formatted output.

func FormatHealthMonitoring

func FormatHealthMonitoring(health []config.HealthMonitoring) string

FormatHealthMonitoring returns the healt HTTP endpoints..

func FormatHealthSummary

func FormatHealthSummary(health []config.HealthSummaryShort) string

FormatHealthSummary returns member health in a short or summary view.

func FormatJSONForDescribe

func FormatJSONForDescribe(jsonValue []byte, showAllColumns bool, orderedColumns ...string) (string, error)

FormatJSONForDescribe formats a two column display for a describe command showAllColumns indicates if all the columns including ordered are shown orderedColumns are the column names, expanded, that should be displayed first for context.

func FormatMachines

func FormatMachines(machines []config.Machine) string

FormatMachines returns the machine's information in a column formatted output.

func FormatMemberHealth

func FormatMemberHealth(health []config.HealthSummary) string

FormatMemberHealth returns member health in a column formatted output.

func FormatMembers

func FormatMembers(members []config.Member, verbose bool, storageMap map[int]bool, summary bool, departureCount int) string

FormatMembers returns the member's information in a column formatted output.

func FormatNetworkStatistics

func FormatNetworkStatistics(members []config.Member) string

FormatNetworkStatistics returns all the member's network statistics in a column formatted output.

func FormatNetworkStats

func FormatNetworkStats(details []config.NetworkStatsDetails) string

FormatNetworkStats formats the network stats.

func FormatPersistenceServices

func FormatPersistenceServices(services []config.ServiceSummary, isSummary bool) string

FormatPersistenceServices returns the services' persistence information in a column formatted output if isSummary then leave out storage count.

func FormatProfiles

func FormatProfiles(profiles []ProfileValue) string

FormatProfiles returns the profiles in a column formatted output.

func FormatProxyConnections

func FormatProxyConnections(connections []config.ProxyConnection) string

FormatProxyConnections returns the proxy connections in a column formatted output.

func FormatProxyServers

func FormatProxyServers(services []config.ProxySummary, protocol string) string

FormatProxyServers returns the proxy servers' information in a column formatted output protocol is either tcp or http and will display a different format based upon this.

func FormatReporters

func FormatReporters(reporters []config.Reporter) string

FormatReporters returns the reporters' info in a column formatted output.

func FormatServiceMembers

func FormatServiceMembers(serviceMembers []config.ServiceMemberDetail) string

FormatServiceMembers returns the service member details in column formatted output.

func FormatServices

func FormatServices(services []config.ServiceSummary) string

FormatServices returns the services' information in a column formatted output.

func FormatServicesStorage

func FormatServicesStorage(services []config.ServiceStorageSummary) string

FormatServicesStorage returns the services' storage information in a column formatted output.

func FormatSnapshots

func FormatSnapshots(serviceSnapshots []config.Snapshots, archived bool) string

FormatSnapshots returns the snapshots in a formatted output.

func FormatSubscriberChannelStats

func FormatSubscriberChannelStats(channelStats []config.SubscriberChannelStats) string

FormatSubscriberChannelStats returns the subscriber channel stats in column formatted output.

func FormatSubscriberGroupChannelStats

func FormatSubscriberGroupChannelStats(channelStats []config.SubscriberGroupChannelStats) string

FormatSubscriberGroupChannelStats returns the subscriber channel stats in column formatted output.

func FormatTopicsMembers

func FormatTopicsMembers(topicsMembers []config.TopicsMemberDetail) string

FormatTopicsMembers returns the topics member details in column formatted output.

func FormatTopicsSubscriberGroups

func FormatTopicsSubscriberGroups(subscriberGroups []config.TopicsSubscriberGroupDetail) string

FormatTopicsSubscriberGroups returns the topics subscriber groups details in column formatted output.

func FormatTopicsSubscribers

func FormatTopicsSubscribers(topicsSubscribers []config.TopicsSubscriberDetail) string

FormatTopicsSubscribers returns the topics subscriber details in column formatted output

func FormatTopicsSummary

func FormatTopicsSummary(topicDetails []config.TopicDetail) string

FormatTopicsSummary returns the topics summary in column formatted output.

func FormatTracing

func FormatTracing(members []config.Member) string

FormatTracing returns the member's tracing details in a column formatted output.

func FormatViewCacheDetail

func FormatViewCacheDetail(cacheDetails []config.ViewCacheDetail) string

FormatViewCacheDetail returns the view cache details in column formatted output.

func FormatViewCacheSummary

func FormatViewCacheSummary(cacheSummaries []config.ViewCacheSummaryDetail) string

FormatViewCacheSummary returns the view cache summary in column formatted output.

func GetArchivedSnapshots

func GetArchivedSnapshots(dataFetcher fetcher.Fetcher, serviceName string) ([]string, error)

GetArchivedSnapshots retrieves the archived snapshots for a service.

func GetConfigDir

func GetConfigDir() string

GetConfigDir returns the configuration directory.

func GetConnectionAndDataFetcher

func GetConnectionAndDataFetcher() (string, fetcher.Fetcher, error)

GetConnectionAndDataFetcher returns the connection and dataFetcher.

func GetConnectionNameFromContextOrArg

func GetConnectionNameFromContextOrArg() (string, error)

GetConnectionNameFromContextOrArg returns the connection name from the '-c' option or the current context if set.

func GetDataFetcher

func GetDataFetcher(clusterName string) (fetcher.Fetcher, error)

GetDataFetcher returns a Fetcher given a cluster name.

func GetDistributedServices

func GetDistributedServices(dataFetcher fetcher.Fetcher) ([]string, error)

GetDistributedServices returns a list of distributed services.

func GetFederatedServices

func GetFederatedServices(dataFetcher fetcher.Fetcher) ([]string, error)

GetFederatedServices returns a list of federated services.

func GetFileName

func GetFileName(nodeID string, iteration int32) string

GetFileName returns a file name for the thread dump.

func GetListOfCacheServices

func GetListOfCacheServices(servicesSummary config.ServicesSummaries) []string

GetListOfCacheServices returns a list of cache services.

func GetLogDirectory

func GetLogDirectory() string

func GetMachineList

func GetMachineList(dataFetcher fetcher.Fetcher) (map[string]string, error)

GetMachineList returns a list of machines.

func GetNodeIds

func GetNodeIds(dataFetcher fetcher.Fetcher) ([]string, error)

GetNodeIds returns the node ids for the current cluster.

func GetPersistenceServices

func GetPersistenceServices(dataFetcher fetcher.Fetcher) ([]string, error)

GetPersistenceServices returns a list of persistence services.

func GetServices

func GetServices(dataFetcher fetcher.Fetcher) (config.ServicesSummaries, error)

GetServices returns a list of services.

func GetSnapshots

func GetSnapshots(dataFetcher fetcher.Fetcher, serviceName string) ([]string, error)

GetSnapshots returns the snapshots for a service.

func GetURLContents

func GetURLContents(resourceURL string) ([]byte, error)

GetURLContents returns the contents at the given url as a []byte.

func Initialize

func Initialize(command *cobra.Command) *cobra.Command

Initialize initializes the command hierarchy - required for tests if command is nil then a new command is created otherwise the existing one is used.

func IssueFederationCommand

func IssueFederationCommand(cmd *cobra.Command, serviceName, command, participant, mode string) error

IssueFederationCommand issues a federation command.

func IssueReporterCommand

func IssueReporterCommand(nodeID, command string, cmd *cobra.Command) error

IssueReporterCommand issues a reporter command.

func ServiceExists

func ServiceExists(dataFetcher fetcher.Fetcher, serviceName string) (bool, error)

ServiceExists returns true if a service exists.

func SetRootCommandFlags

func SetRootCommandFlags(command *cobra.Command)

SetRootCommandFlags sets all the persistent root command flags.

func UnmarshalThreadDump

func UnmarshalThreadDump(jsonData []byte) (string, error)

UnmarshalThreadDump unmarshal a thread dump.

func WriteConfig

func WriteConfig() error

WriteConfig writes the viper config and exit if there is an error.

Types

type ByteArraySink

type ByteArraySink struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ByteArraySink is a thread safe byte array.

func (*ByteArraySink) AppendByteArray

func (b *ByteArraySink) AppendByteArray(bytes []byte)

AppendByteArray appends a byte array.

func (*ByteArraySink) GetByteArrays

func (b *ByteArraySink) GetByteArrays() [][]byte

GetByteArrays returns the values for an GetByteArrays.

type ClusterConnection

type ClusterConnection struct {
	Name                 string `json:"name"` // the name the user gives to the cluster connection
	DiscoveryType        string `json:"discoveryType"`
	ConnectionType       string `json:"connectionType"` // currently only valid value is "http"
	ConnectionURL        string `json:"url"`
	NameServiceDiscovery string `json:"nameServiceDiscovery"`
	ClusterVersion       string `json:"clusterVersionParam"`
	ClusterName          string `json:"clusterName"` // the actual cluster name
	ClusterType          string `json:"clusterType"`

	// the following attributes are specific to manually created clusters
	ManuallyCreated     bool   `json:"manuallyCreated"`     // indicates if this was created by the create cluster command
	BaseClasspath       string `json:"baseClasspath"`       // the minimum required classes coherence.jar and coherence-json
	AdditionalClasspath string `json:"additionalClasspath"` // additional classpath provided by the user
	Arguments           string `json:"arguments"`           // arguments to start cluster with including cluster name, etc
	ManagementPort      int32  `json:"managementPort"`      // arguments to start cluster with including cluster name, etc
	PersistenceMode     string `json:"persistenceMode"`
	LoggingDestination  string `json:"loggingDestination"` // logging destination, if empty then place under ~/.cohctl/logs
	ManagementAvailable bool   // only used when using -o wide option
	StartupClass        string `json:"startupClass"`
}

ClusterConnection describes an individual connection to a cluster.

func GetClusterConnection

func GetClusterConnection(connectionName string) (bool, ClusterConnection)

GetClusterConnection returns the URL for a given a cluster connection name.

type CoherenceCLIConfig

type CoherenceCLIConfig struct {
	Version            string              `json:"version"`
	CurrentContext     string              `json:"currentContext"`
	Clusters           []ClusterConnection `mapstructure:"clusters"`
	Debug              bool                `json:"debug"`
	Color              string              `json:"color"`
	RequestTimeout     int32               `json:"requestTimeout"`
	IgnoreInvalidCerts bool                `json:"ignoreInvalidCerts"`
	DefaultBytesFormat string              `json:"defaultBytesFormat"`
	DefaultHeap        string              `json:"defaultHeap"`
	UseGradle          bool                `json:"useGradle"`
	Profiles           []ProfileValue      `mapstructure:"profiles"`
}

CoherenceCLIConfig describes the details stored in the .cohctl.yaml.

type ErrorSink

type ErrorSink struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ErrorSink holds errors from multiple go routines.

func (*ErrorSink) AppendError

func (e *ErrorSink) AppendError(err error)

AppendError appends an error.

func (*ErrorSink) GetErrors

func (e *ErrorSink) GetErrors() []error

GetErrors returns the errors for an ErrorSync.

type FormattedTable

type FormattedTable interface {
	WithAlignment(...string) FormattedTable
	WithHeader(...string) FormattedTable
	MaxLength(int) FormattedTable
	AddColumnsToRow(...string)
	AddHeaderColumns(...string)
	AddRow(...string)
	AddFormattingFunction(int, formatter)
	String() string
}

FormattedTable defines a formatted table of information.

type KeyValues

type KeyValues struct {
	Key   string
	Value interface{}
}

type ProfileValue

type ProfileValue struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

ProfileValue describes a profile to be used for creating and starting clusters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL