Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
docmerlin committed Oct 12, 2022
1 parent be15c8f commit c705d4c
Show file tree
Hide file tree
Showing 37 changed files with 1,161 additions and 2,145 deletions.
1,159 changes: 0 additions & 1,159 deletions Gopkg.lock

This file was deleted.

79 changes: 0 additions & 79 deletions Gopkg.toml

This file was deleted.

1 change: 1 addition & 0 deletions alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ func (n *AlertNode) newAlertState(tags models.Tags) *alertState {
}

func (n *AlertNode) restoreEvent(id string) (alert.Level, time.Time) {
//panic("NOT IMPLEMENTED")
var topicState, anonTopicState alert.EventState
var anonFound, topicFound bool
// Check for previous state on anonTopic
Expand Down
38 changes: 35 additions & 3 deletions alert/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,26 @@ func (s *Topics) Close() error {
return nil
}

// Topic returns the topic with the given id, and if it exists or not
func (s *Topics) Topic(id string) (*Topic, bool) {
s.mu.RLock()
t, ok := s.topics[id]
s.mu.RUnlock()
return t, ok
}

func (s *Topics) RestoreTopic(id string, eventStates map[string]EventState) {
func (s *Topics) RestoreTopicNoCopy(topic string, eventStates map[string]*EventState) {
s.mu.Lock()
defer s.mu.Unlock()
t, ok := s.topics[topic]
if !ok {
t = s.newTopic(topic)
s.topics[topic] = t
}
t.restoreEventStatesNoCopy(eventStates)
}

func (s *Topics) RestoreTopic(id string, eventStates map[string]*EventState) {
s.mu.Lock()
defer s.mu.Unlock()
t, ok := s.topics[id]
Expand All @@ -66,6 +78,14 @@ func (s *Topics) RestoreTopic(id string, eventStates map[string]EventState) {
t.restoreEventStates(eventStates)
}

func (s *Topics) RestoreTopics() {
s.mu.Lock()
defer s.mu.Unlock()
for _, t := range s.topics {
t.restoreEventStates(t.events)
}
}

func (s *Topics) UpdateEvent(id string, event EventState) {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down Expand Up @@ -266,14 +286,26 @@ func (t *Topic) removeHandler(h Handler) {
}
}

func (t *Topic) restoreEventStates(eventStates map[string]EventState) {
func (t *Topic) restoreEventStatesNoCopy(eventStates map[string]*EventState) {
t.mu.Lock()
defer t.mu.Unlock()
t.events = make(map[string]*EventState, len(eventStates))
t.sorted = make([]*EventState, 0, len(eventStates))
for id, state := range eventStates {
t.events[id] = state
t.sorted = append(t.sorted, state)
}
sort.Sort(sortedStates(t.sorted))
}

func (t *Topic) restoreEventStates(eventStates map[string]*EventState) {
t.mu.Lock()
defer t.mu.Unlock()
t.events = make(map[string]*EventState, len(eventStates))
t.sorted = make([]*EventState, 0, len(eventStates))
for id, state := range eventStates {
e := new(EventState)
*e = state
*e = *state
t.events[id] = e
t.sorted = append(t.sorted, e)
}
Expand Down
15 changes: 15 additions & 0 deletions alert/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ type Event struct {
previousState EventState
}

func (e Event) MarshalBinary() (data []byte, err error) {
//TODO implement me
panic("implement me")
}

func (e Event) UnmarshalBinary(data []byte) error {
//TODO implement me
panic("implement me")
}

func (e Event) ObjectID() string {
//TODO implement me
panic("implement me")
}

func (e Event) AlertData() Data {
return Data{
ID: e.State.ID,
Expand Down
7 changes: 6 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ def run_tests(race, parallel, timeout, verbose):
test_command += " -timeout {}".format(timeout)
test_command += " ./..."
logging.info("Running tests...")

packages = run("go list ./...").split("\n")
print(packages)
logging.info("Test command: " + test_command)
output = run(test_command, printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG)
for package in packages:
run(test_command + " " + package, printOutput=logging.getLogger().getEffectiveLevel() == logging.DEBUG)

return True

def package_udfs(version, dist_dir):
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ BUILD_NUM=${BUILD_NUM-$RANDOM}
HOME_DIR=/root

GO_VERSION=1.17.1
PROTO_VERSION=3.18.3

imagename=kapacitor-builder-img-$BUILD_NUM

# Build new docker image
docker build -f Dockerfile_build_ubuntu64 -t $imagename --build-arg GO_VERSION=${GO_VERSION} $DIR
docker build -f Dockerfile_build_ubuntu64 -t $imagename --build-arg GO_VERSION=${GO_VERSION} --build-arg PROTO_VERSION=${PROTO_VERSION} $DIR

echo "Running build.py"
# Run docker
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
github.com/urfave/cli/v2 v2.3.0
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
github.com/zeebo/mwc v0.0.4
go.etcd.io/bbolt v1.3.5
go.etcd.io/bbolt v1.3.6
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20220214200702-86341886e292
golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f
Expand Down Expand Up @@ -262,3 +262,5 @@ replace k8s.io/client-go => k8s.io/client-go v0.20.5
replace k8s.io/api => k8s.io/api v0.20.5

replace github.com/dgrijalva/jwt-go => github.com/Waterdrips/jwt-go v3.2.1-0.20200915121943-f6506928b72e+incompatible

replace go.etcd.io/bbolt => github.com/0x0177b11f/bbolt v1.3.7-0.20220308103559-afc583528bb7
7 changes: 3 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
github.com/0x0177b11f/bbolt v1.3.7-0.20220308103559-afc583528bb7 h1:VbZYwrPh0R9OxStYGcn7WeB6vfcXCMpwEvPAAXGYJtw=
github.com/0x0177b11f/bbolt v1.3.7-0.20220308103559-afc583528bb7/go.mod h1:sh/Yp01MYDakY7RVfzKZn+T1WOMTTFJrWjl7+M73RXA=
github.com/AlecAivazis/survey/v2 v2.2.9 h1:LWvJtUswz/W9/zVVXELrmlvdwWcKE60ZAw0FWV9vssk=
github.com/AlecAivazis/survey/v2 v2.2.9/go.mod h1:9DYvHgXtiXm6nCn+jXnOXLKbH+Yo9u8fAS/SduGdoPk=
github.com/Azure/azure-pipeline-go v0.2.3 h1:7U9HBg1JFK3jHl5qmo4CTZKFTVgMwdFHMVtCdfBE21U=
Expand Down Expand Up @@ -1338,10 +1340,6 @@ github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/mwc v0.0.4 h1:9dNXNLtUB4lUXoXgyhy3YrKoV0OD7oRiu907YMS0nl0=
github.com/zeebo/mwc v0.0.4/go.mod h1:qNHfgp/ZCpQNcJHwKcO5EP3VgaBrW6DPohsK4QfyxxE=
github.com/zeebo/xxh3 v0.13.0/go.mod h1:AQY73TOrhF3jNsdiM9zZOb8MThrYbZONHj7ryDBaLpg=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
Expand Down Expand Up @@ -1641,6 +1639,7 @@ golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2858,7 +2858,7 @@ test value=1 0000000011
func TestServer_UpdateTaskID(t *testing.T) {
s, cli := OpenDefaultServer(t)
defer s.Close()

println("here")
id := "testTaskID"
ttype := client.StreamTask
dbrps := []client.DBRP{
Expand Down
Loading

0 comments on commit c705d4c

Please sign in to comment.