Skip to content

Commit

Permalink
Show app name with parentheses for deleted and brackets for not yet s…
Browse files Browse the repository at this point in the history
…taged apps
  • Loading branch information
Kurt Kellner committed Jan 23, 2018
1 parent d13ca1b commit f536ba0
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 38 deletions.
14 changes: 13 additions & 1 deletion ui/dataCommon/commonData.go
Expand Up @@ -118,7 +118,17 @@ func (cd *CommonData) PostProcessData() map[string]*DisplayAppStats {
displayStatsMap[appId] = displayAppStats
appMetadata := cd.appMdMgr.FindItem(appStats.AppId)

displayAppStats.AppNameForSort = appMetadata.Name
displayAppStats.AppName = appMetadata.Name

if appMetadata.PackageState == "PENDING" {
displayAppStats.IsPackageStatePending = true
displayAppStats.AppName = "[" + displayAppStats.AppName + "]"
}
if mdMgr.GetAppMdManager().IsPendingDeleteFromCache(appId) {
displayAppStats.IsDeleted = true
displayAppStats.AppName = "(" + displayAppStats.AppName + ")"
}
if mdMgr.IsMonitorAppDetails(appId) {
displayAppStats.AppName += "*"
}
Expand Down Expand Up @@ -195,7 +205,9 @@ func (cd *CommonData) PostProcessData() map[string]*DisplayAppStats {
}
}
}
if displayAppStats.Monitored && totalReportingContainers < displayAppStats.DesiredContainers {
if displayAppStats.Monitored &&
!displayAppStats.IsPackageStatePending &&
totalReportingContainers < displayAppStats.DesiredContainers {
appsNotInDesiredState = appsNotInDesiredState + 1
}
if totalReportingContainers > 0 {
Expand Down
6 changes: 6 additions & 0 deletions ui/dataCommon/displayAppStats.go
Expand Up @@ -25,6 +25,7 @@ type DisplayAppStats struct {
*eventApp.AppStats

AppName string
AppNameForSort string
SpaceId string
SpaceName string
OrgId string
Expand All @@ -35,6 +36,11 @@ type DisplayAppStats struct {
IsolationSegmentGuid string
IsolationSegmentName string

// If the app is in the pending delete from cache, then its been deleted
// but we keep it around for a n seconds to show newly deleted app on the UI
IsDeleted bool
IsPackageStatePending bool

// Indicate if this app is monitored. For privileged users
// this should always be true.
Monitored bool
Expand Down
3 changes: 3 additions & 0 deletions ui/uiCommon/listWidget.go
Expand Up @@ -81,6 +81,7 @@ const (
ATTENTION_ALERT
ATTENTION_WARN
ATTENTION_NOT_MONITORED
ATTENTION_DELETED
ATTENTION_STATE_STARTING
ATTENTION_STATE_UNKNOWN
ATTENTION_STATE_DOWN
Expand Down Expand Up @@ -576,6 +577,8 @@ func (asUI *ListWidget) writeRowData(g *gocui.Gui, v *gocui.View, rowIndex int)
colorString = util.CYAN
case ATTENTION_NOT_MONITORED:
colorString = util.BRIGHT_BLACK
case ATTENTION_DELETED:
colorString = util.BRIGHT_BLACK
case ATTENTION_STATE_STARTING:
colorString = util.YELLOW
case ATTENTION_STATE_UNKNOWN:
Expand Down
70 changes: 41 additions & 29 deletions ui/views/appViews/appView/columns.go
Expand Up @@ -29,7 +29,12 @@ import (
func columnAppName() *uiCommon.ListColumn {
defaultColSize := 50
sortFunc := func(c1, c2 util.Sortable) bool {
return util.CaseInsensitiveLess(c1.(*dataCommon.DisplayAppStats).AppName, c2.(*dataCommon.DisplayAppStats).AppName)
// We sort on app name - if the app name is identical, then sort on App GUID
compare := util.CaseInsensitiveCompare(c1.(*dataCommon.DisplayAppStats).AppNameForSort, c2.(*dataCommon.DisplayAppStats).AppNameForSort)
if compare == 0 {
return c1.(*dataCommon.DisplayAppStats).AppId < c2.(*dataCommon.DisplayAppStats).AppId
}
return compare < 0
}
displayFunc := func(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) string {
appStats := data.(*dataCommon.DisplayAppStats)
Expand All @@ -40,11 +45,7 @@ func columnAppName() *uiCommon.ListColumn {
return appStats.AppName
}
attentionFunc := func(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) uiCommon.AttentionType {
appStats := data.(*dataCommon.DisplayAppStats)
if !appStats.Monitored {
return uiCommon.ATTENTION_NOT_MONITORED
}
attentionType := notInDesiredStateAttentionFunc(data, columnOwner)
attentionType := appNameColumnAttentionFunc(data, columnOwner)
if attentionType == uiCommon.ATTENTION_NORMAL {
attentionType = activityAttentionFunc(data, columnOwner)
}
Expand All @@ -55,17 +56,17 @@ func columnAppName() *uiCommon.ListColumn {
return c
}

func notInDesiredStateAttentionFunc(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) uiCommon.AttentionType {
func appNameColumnAttentionFunc(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) uiCommon.AttentionType {
appStats := data.(*dataCommon.DisplayAppStats)
appListView := columnOwner.(*AppListView)
if appStats.IsDeleted {
return uiCommon.ATTENTION_DELETED
}
if !appStats.Monitored {
return uiCommon.ATTENTION_NOT_MONITORED
}
attentionType := uiCommon.ATTENTION_NORMAL
if !appStats.Monitored {
return attentionType
}
if appListView.isWarmupComplete && appStats.DesiredContainers > appStats.TotalReportingContainers {
if appListView.isWarmupComplete && !appStats.IsPackageStatePending && appStats.DesiredContainers > appStats.TotalReportingContainers {
attentionType = uiCommon.ATTENTION_NOT_DESIRED_STATE
}
return attentionType
Expand All @@ -83,14 +84,25 @@ func activityAttentionFunc(data uiCommon.IData, columnOwner uiCommon.IColumnOwne
return attentionType
}

func notMonitoredAttentionFunc(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) uiCommon.AttentionType {
func columnAttentionFunc(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) uiCommon.AttentionType {
appStats := data.(*dataCommon.DisplayAppStats)
if appStats.IsDeleted {
return uiCommon.ATTENTION_DELETED
}
if !appStats.Monitored {
return uiCommon.ATTENTION_NOT_MONITORED
}
return uiCommon.ATTENTION_NORMAL
}

func isAppDeletedAttentionFunc(data uiCommon.IData, columnOwner uiCommon.IColumnOwner) uiCommon.AttentionType {
appStats := data.(*dataCommon.DisplayAppStats)
if !appStats.IsDeleted {
return uiCommon.ATTENTION_DELETED
}
return uiCommon.ATTENTION_NORMAL
}

func columnSpaceName() *uiCommon.ListColumn {
defaultColSize := 10
sortFunc := func(c1, c2 util.Sortable) bool {
Expand All @@ -109,7 +121,7 @@ func columnSpaceName() *uiCommon.ListColumn {
return appStats.SpaceName
}
c := uiCommon.NewListColumn("SPACE", "SPACE", defaultColSize,
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -131,7 +143,7 @@ func columnOrgName() *uiCommon.ListColumn {
return appStats.OrgName
}
c := uiCommon.NewListColumn("ORG", "ORG", defaultColSize,
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -151,7 +163,7 @@ func columnReportingContainers() *uiCommon.ListColumn {
appStats := data.(*dataCommon.DisplayAppStats)
return strconv.Itoa(appStats.TotalReportingContainers)
}
attentionFunc := notInDesiredStateAttentionFunc
attentionFunc := columnAttentionFunc
c := uiCommon.NewListColumn("RCR", "RCR", 3,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, attentionFunc)
return c
Expand All @@ -169,7 +181,7 @@ func columnDesiredInstances() *uiCommon.ListColumn {
appStats := data.(*dataCommon.DisplayAppStats)
return strconv.Itoa(appStats.DesiredContainers)
}
attentionFunc := notInDesiredStateAttentionFunc
attentionFunc := columnAttentionFunc
c := uiCommon.NewListColumn("DCR", "DCR", 3,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, attentionFunc)
return c
Expand Down Expand Up @@ -200,7 +212,7 @@ func columnTotalCpu() *uiCommon.ListColumn {
return fmt.Sprintf("%.2f", appStats.TotalCpuPercentage)
}
c := uiCommon.NewListColumn("CPU_PER", "CPU%", 6,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -223,7 +235,7 @@ func columnTotalMemoryUsed() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.TotalMemoryUsed)
}
c := uiCommon.NewListColumn("MEM_USED", "MEM_USED", 9,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -246,7 +258,7 @@ func columnTotalDiskUsed() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.TotalDiskUsed)
}
c := uiCommon.NewListColumn("DSK_USED", "DSK_USED", 9,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand Down Expand Up @@ -274,7 +286,7 @@ func columnAvgResponseTimeL60Info() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.TotalTraffic.AvgResponseL60Time)
}
c := uiCommon.NewListColumn("RESP", "RESP", 6,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -291,7 +303,7 @@ func columnLogStdout() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.TotalLogStdout)
}
c := uiCommon.NewListColumn("LOG_OUT", "LOG_OUT", 11,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -308,7 +320,7 @@ func columnLogStderr() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.TotalLogStderr)
}
c := uiCommon.NewListColumn("LOG_ERR", "LOG_ERR", 11,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand Down Expand Up @@ -399,7 +411,7 @@ func columnTotalReq() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.HttpAllCount)
}
c := uiCommon.NewListColumn("TOT_REQ", "TOT_REQ", 10,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}
func column2XX() *uiCommon.ListColumn {
Expand All @@ -415,7 +427,7 @@ func column2XX() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.Http2xxCount)
}
c := uiCommon.NewListColumn("2XX", "2XX", 10,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}
func column3XX() *uiCommon.ListColumn {
Expand All @@ -431,7 +443,7 @@ func column3XX() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.Http3xxCount)
}
c := uiCommon.NewListColumn("3XX", "3XX", 10,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -448,7 +460,7 @@ func column4XX() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.Http4xxCount)
}
c := uiCommon.NewListColumn("4XX", "4XX", 10,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -465,7 +477,7 @@ func column5XX() *uiCommon.ListColumn {
return fmt.Sprintf("%v", appStats.Http5xxCount)
}
c := uiCommon.NewListColumn("5XX", "5XX", 10,
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.NUMERIC, false, sortFunc, true, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -483,7 +495,7 @@ func columnStackName() *uiCommon.ListColumn {
return appStats.StackName
}
c := uiCommon.NewListColumn("STACK", "STACK", defaultColSize,
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand All @@ -505,7 +517,7 @@ func columnIsolationSegmentName() *uiCommon.ListColumn {
return appStats.IsolationSegmentName
}
c := uiCommon.NewListColumn("ISO_SEG", "ISO_SEG", defaultColSize,
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, notMonitoredAttentionFunc)
uiCommon.ALPHANUMERIC, true, sortFunc, false, displayFunc, rawValueFunc, columnAttentionFunc)
return c
}

Expand Down
20 changes: 12 additions & 8 deletions ui/views/appViews/appView/helpText.go
Expand Up @@ -33,10 +33,12 @@ be colored red.
const HelpColumnsText = `
**Application Columns:**
APPLICATION - Application name. If the name has an asterisk (*) on
the end, the application is being activily monitored. See
Active Monitoring below for more infomation. See Application
Name Color Key below for color information.
APPLICATION - Application name. If application name has:
() - App has been deleted. It will be removed from display shortly
[] - App is not yet fully staged (i.e., it is still deploying)
Asterisk (*) on the end of name means the application is being
activily monitored. See Active Monitoring below for more info.
See Application Name Color Key below for color information.
SPACE - Space name.
ORG - Organization name.
DCR - Desired containers (instances).
Expand Down Expand Up @@ -69,10 +71,12 @@ CYAN - Active. HTTP(S) traffic has been recieved in the last
10 seconds.
RED - Not in desired state. The application has been configured
for DCR instances, but only RCR are running.
GRAY - Not monitored (non-privileged only). In non-privileged only
the first 50 applications in the currently targeted org and
space are monitored.
GRAY - One of two possibilities:
1. App has been deleted.
2. Not monitored (non-privileged only). In non-privileged
only the first 50 applications in the currently targeted
org and space are monitored.
**Active Monitoring:**
For the most part cf top passively monitors a platform by analyzing
firehose events as they occur. Because of limitations of this data
Expand Down
13 changes: 13 additions & 0 deletions util/stringUtil.go
Expand Up @@ -31,6 +31,19 @@ func CaseInsensitiveLess(s1, s2 string) bool {
return strings.ToUpper(s1) < strings.ToUpper(s2)
}

func CaseInsensitiveCompare(s1, s2 string) int {
// TODO: Find a more efficent way to do this that does not involve obj creation
s1 = strings.ToUpper(s1)
s2 = strings.ToUpper(s2)
if s1 < s2 {
return -1
} else if s1 == s2 {
return 0
} else {
return 1
}
}

func Format(n int64) string {
return FormatUint64(uint64(n))
}
Expand Down

0 comments on commit f536ba0

Please sign in to comment.