Skip to content

Commit

Permalink
Small Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Dec 18, 2024
1 parent 8da3bde commit 6d1be96
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
18 changes: 8 additions & 10 deletions asconfig/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ const (
NONE sysproptype = "NONE"
)

var BenchmarkConfigs = []string{
"enable-benchmarks-batch-sub", "enable-benchmarks-read",
"enable-benchmarks-udf", "enable-benchmarks-write",
"enable-benchmarks-udf-sub", "enable-benchmarks-storage",
"enable-benchmarks-fabric", "enable-benchmarks-ops-sub",
}

var portRegex = regexp.MustCompile("port")

type humanize func(string) (uint64, error)
Expand Down Expand Up @@ -683,16 +690,7 @@ func isSpecialOrNormalBoolField(key string) bool {
// config file is true/false.
// e.g. namespace and storage level benchmark fields
func isSpecialBoolField(key string) bool {
switch key {
case "enable-benchmarks-batch-sub", "enable-benchmarks-read",
"enable-benchmarks-udf", "enable-benchmarks-write",
"enable-benchmarks-udf-sub", "enable-benchmarks-storage",
"enable-benchmarks-fabric", "enable-benchmarks-ops-sub":
return true

default:
return false
}
return lib.ContainsString(BenchmarkConfigs, key)
}

// isSpecialStringField returns true if the passed key
Expand Down
14 changes: 2 additions & 12 deletions deployment/strong_consistency.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/go-logr/logr"

as "github.com/aerospike/aerospike-client-go/v7"
lib "github.com/aerospike/aerospike-management-lib"
)

const (
Expand Down Expand Up @@ -92,7 +93,7 @@ func setFilteredRosterNodes(clHost *host, scNs string, rosterNodes map[string]st
for _, obn := range observedNodesList {
// nodeRoster: nodeID + "@" + rackID
obnNodeID := strings.Split(obn, "@")[0]
if !containsString(rosterNodeBlockList, obnNodeID) {
if !lib.ContainsString(rosterNodeBlockList, obnNodeID) {
newObservedNodesList = append(newObservedNodesList, obn)
}
}
Expand Down Expand Up @@ -324,17 +325,6 @@ func getNamespaces(clHost *host) ([]string, error) {
return nil, nil
}

// ContainsString check whether list contains given string
func containsString(list []string, ele string) bool {
for _, listEle := range list {
if strings.EqualFold(ele, listEle) {
return true
}
}

return false
}

func isNodeInRoster(clHost *host, ns string) (bool, error) {
nodeID, err := getNodeID(clHost)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,14 @@ func CompareVersionsIgnoreRevision(version1, version2 string) (int, error) {

return 0, nil
}

// ContainsString check whether list contains given string
func ContainsString(list []string, ele string) bool {
for _, listEle := range list {
if strings.EqualFold(ele, listEle) {
return true
}
}

return false
}

0 comments on commit 6d1be96

Please sign in to comment.