util

package
v0.0.0-...-d1c0bb1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2016 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Overview

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var PanicHandlers = []func(interface{}){logPanic}

PanicHandlers is a list of functions which will be invoked when a panic happens.

View Source
var ReallyCrash bool

For testing, bypass HandleCrash.

Functions

func AnalyseThresholdBreach

func AnalyseThresholdBreach(ctxt string, utilizationType string, resourceName string, resourceUtilization float64, cluster models.Cluster) (models.Event, bool, error)

func AppendServiceToNode

func AppendServiceToNode(selectCriteria bson.M, serviceName string, status string, ctxt string)

func ComputeClustersStatusWiseCounts

func ComputeClustersStatusWiseCounts() (map[string]int, error)

func ComputeSluStatusWiseCount

func ComputeSluStatusWiseCount(sluSelectCriteria bson.M, sluThresholdSelectCriteria bson.M) (map[string]int, error)

func ComputeStorageProfileUtilization

func ComputeStorageProfileUtilization(selectCriteria bson.M, spThresholdconfigs []monitoring.PluginConfig) (map[string]map[string]interface{}, error)

func ComputeUsage

func ComputeUsage(selectCriteria bson.M) (models.Utilization, error)

func FailTask

func FailTask(msg string, err error, t *task.Task)

func FetchNodeStatusWiseCounts

func FetchNodeStatusWiseCounts(selectCriteria bson.M) (map[string]int, error)

func Forever

func Forever(f func(), period time.Duration)

Deprecated. Please use Until and pass NeverStop as the stopCh.

func GenerifyStringArr

func GenerifyStringArr(keys []string) []interface{}

func GetClusterSummaries

func GetClusterSummaries(selectCriteria bson.M) ([]models.ClusterSummary, error)

func GetClusters

func GetClusters(selectCriteria bson.M) ([]models.Cluster, error)

func GetMapKeys

func GetMapKeys(inMap interface{}) ([]reflect.Value, error)

func GetNodes

func GetNodes(clusterNodes []models.ClusterNode) (map[uuid.UUID]models.Node, error)

func GetNodesByIdStr

func GetNodesByIdStr(clusterNodes []models.ClusterNode) (map[string]models.Node, error)

func GetReadableFloat

func GetReadableFloat(str string, ctxt string) (string, error)

func GetStorageCount

func GetStorageCount(selectCriteria bson.M) (map[string]int, error)

func GetString

func GetString(param interface{}) (string, error)

func GetSystem

func GetSystem() (system models.System, err error)

func GetTopStorageUsage

func GetTopStorageUsage(selectCriteria bson.M) ([]models.StorageUsage, error)

func HTTPGet

func HTTPGet(url string) ([]byte, error)

func HandleCrash

func HandleCrash()

HandleCrash simply catches a crash and logs an error. Meant to be called via defer.

func InitializeClusterSummary

func InitializeClusterSummary(cluster models.Cluster)

func InitializeSystemSummary

func InitializeSystemSummary()

func Md5FromString

func Md5FromString(name string) string

func StringInSlice

func StringInSlice(value string, slice []string) bool

func StringIndexInSlice

func StringIndexInSlice(arr []string, str string) int

func StringSetDiff

func StringSetDiff(keys1 []string, keys2 []string) (diff []string)

func Stringify

func Stringify(keys []reflect.Value) (strings []string)

func StringifyInterface

func StringifyInterface(keys []interface{}) ([]string, error)

func Until

func Until(f func(), period time.Duration, stopCh <-chan struct{})

Until loops until stop channel is closed, running f every period. Catches any panics, and keeps going. f may not be invoked if stop channel is already closed.

func UpdateClusterStateWiseCount

func UpdateClusterStateWiseCount(ctxt string)

func UpdateDb

func UpdateDb(selectCriteria bson.M, update bson.M, collectionName string, ctxt string)

func UpdateSluCountToSummaries

func UpdateSluCountToSummaries(ctxt string, cluster models.Cluster)

func UpdateStorageCountToSummaries

func UpdateStorageCountToSummaries(ctxt string, cluster models.Cluster)

func UpdateStorageProfileUtilizationToSummaries

func UpdateStorageProfileUtilizationToSummaries(ctxt string, cluster models.Cluster)

func UpdateThresholdInfoToTable

func UpdateThresholdInfoToTable(tEvent models.ThresholdEvent) (err error, isRaiseEvent bool)

Types

type Set

type Set map[interface{}]bool

Golang doesn't provide Set type. The easiest O(1) way of implementing one is using maps.

func NewSet

func NewSet() Set

Use this for a type independent Set

func NewSetWithType

func NewSetWithType(t reflect.Type) Set

Use this for conventional Set of a required type

func (*Set) Add

func (s *Set) Add(element interface{}) error

func (*Set) AddAll

func (s *Set) AddAll(elements []interface{}) error

func (Set) GetElements

func (s Set) GetElements() (values []interface{})

func (*Set) Remove

func (s *Set) Remove(element interface{}) error

type Unit

type Unit struct {
	Name             string
	NoOfPrevUnitEqui int
	Order            int
}

func (Unit) AutoConvert

func (fromUnit Unit) AutoConvert(fromValue float64, unitSet Units) (size float64, unit Unit)

func (Unit) Convert

func (fromUnit Unit) Convert(fromValue float64, toUnit Unit, unitSet Units) (size float64)

type Units

type Units []Unit
var SizeUnits Units = MakeUnits([]string{"Bytes", "KibiBytes", "MibiBytes", "GibiBytes", "TibiBytes"}, 1024)

func GetSizeUnits

func GetSizeUnits() Units

func MakeUnits

func MakeUnits(orderedUnitNames []string, commonScale int) (units Units)

func (Units) Len

func (slice Units) Len() int

func (Units) Less

func (slice Units) Less(i, j int) bool

func (Units) Swap

func (slice Units) Swap(i, j int)

Jump to

Keyboard shortcuts

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