From 4a64d1f90b9a2948eded0a73a490c2e372bd136f Mon Sep 17 00:00:00 2001 From: Nan Monnand Deng Date: Fri, 20 Jun 2014 16:53:10 -0400 Subject: [PATCH 1/5] inference detector. --- advice/inference/detector.go | 23 ++++++++++++++++++++++ info/advice.go | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 advice/inference/detector.go create mode 100644 info/advice.go diff --git a/advice/inference/detector.go b/advice/inference/detector.go new file mode 100644 index 00000000..e4b9a08a --- /dev/null +++ b/advice/inference/detector.go @@ -0,0 +1,23 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// 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. + +package inference + +import "github.com/google/cadvisor/info" + +type AntagonismDetector interface { + AddContainer(ref info.ContainerReference) + Detect() ([]*info.Antagonism, error) + Name() string +} diff --git a/info/advice.go b/info/advice.go new file mode 100644 index 00000000..d984ed2b --- /dev/null +++ b/info/advice.go @@ -0,0 +1,38 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// 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. + +package info + +// This struct describes one type of relationship between containers: One +// container, antagonist, interferes the performance of other +// containers, victims. +type Antagonism struct { + // The absolute path of the atagnoism container name. This field should + // not be empty. + Antagonist string `json:"antagonist"` + + // The absolute path of victims. This field should not be empty. + Victims []string `json:"victims"` + + // The detector name which detects this agtagonism. This field should + // not be empty. + Dectory string `json:"detector"` + + // Human readable string + Description string `json:"description,omitempty"` +} + +type Interference struct { + Antagonisms []*Antagonism `json:"antagonisms,omitempty"` +} From cc39f9996b15b97703bd85b0a6f579243ac58fd2 Mon Sep 17 00:00:00 2001 From: Nan Monnand Deng Date: Fri, 20 Jun 2014 17:22:03 -0400 Subject: [PATCH 2/5] name, docs --- advice/inference/detector.go | 13 +++++++++++-- info/advice.go | 10 +++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/advice/inference/detector.go b/advice/inference/detector.go index e4b9a08a..f6f9b676 100644 --- a/advice/inference/detector.go +++ b/advice/inference/detector.go @@ -16,8 +16,17 @@ package inference import "github.com/google/cadvisor/info" -type AntagonismDetector interface { +// InterferenceDectector detects if there's a container which +// interference with a set of container. The detector monitors +// a set of container and find the victims and antagnist. +type InterferenceDetector interface { + // Monitor the behavior of the container. AddContainer(ref info.ContainerReference) - Detect() ([]*info.Antagonism, error) + + // Returns a list of Interference. The upper layer may take action + // based on the interference. + Detect() ([]*info.Interference, error) + + // The name of the detector. Name() string } diff --git a/info/advice.go b/info/advice.go index d984ed2b..d2f527f6 100644 --- a/info/advice.go +++ b/info/advice.go @@ -17,7 +17,7 @@ package info // This struct describes one type of relationship between containers: One // container, antagonist, interferes the performance of other // containers, victims. -type Antagonism struct { +type Interference struct { // The absolute path of the atagnoism container name. This field should // not be empty. Antagonist string `json:"antagonist"` @@ -27,12 +27,8 @@ type Antagonism struct { // The detector name which detects this agtagonism. This field should // not be empty. - Dectory string `json:"detector"` + Detector string `json:"detector"` - // Human readable string + // Human readable description of the interference Description string `json:"description,omitempty"` } - -type Interference struct { - Antagonisms []*Antagonism `json:"antagonisms,omitempty"` -} From 71a2fa7b030e65452eea6a142748dc7cf4b7f2dd Mon Sep 17 00:00:00 2001 From: Nan Monnand Deng Date: Fri, 20 Jun 2014 17:24:41 -0400 Subject: [PATCH 3/5] typo --- info/advice.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info/advice.go b/info/advice.go index d2f527f6..b5d5a572 100644 --- a/info/advice.go +++ b/info/advice.go @@ -18,8 +18,8 @@ package info // container, antagonist, interferes the performance of other // containers, victims. type Interference struct { - // The absolute path of the atagnoism container name. This field should - // not be empty. + // The absolute path of the antagnoism container name. This field + // should not be empty. Antagonist string `json:"antagonist"` // The absolute path of victims. This field should not be empty. From 619ae2ea1a7021110d6285b4de325ecf0d2f040a Mon Sep 17 00:00:00 2001 From: Nan Monnand Deng Date: Fri, 20 Jun 2014 17:57:40 -0400 Subject: [PATCH 4/5] comment --- info/advice.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info/advice.go b/info/advice.go index b5d5a572..0bd51f18 100644 --- a/info/advice.go +++ b/info/advice.go @@ -25,8 +25,8 @@ type Interference struct { // The absolute path of victims. This field should not be empty. Victims []string `json:"victims"` - // The detector name which detects this agtagonism. This field should - // not be empty. + // The name of the detector used to detect this antagonism. This field + // should not be empty Detector string `json:"detector"` // Human readable description of the interference From a71fdd464503a2f8c92449b59c6b07324bd956a2 Mon Sep 17 00:00:00 2001 From: Nan Monnand Deng Date: Fri, 20 Jun 2014 18:22:43 -0400 Subject: [PATCH 5/5] grammar --- advice/{inference => interference}/detector.go | 8 ++++---- info/advice.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) rename advice/{inference => interference}/detector.go (79%) diff --git a/advice/inference/detector.go b/advice/interference/detector.go similarity index 79% rename from advice/inference/detector.go rename to advice/interference/detector.go index f6f9b676..8c291763 100644 --- a/advice/inference/detector.go +++ b/advice/interference/detector.go @@ -17,13 +17,13 @@ package inference import "github.com/google/cadvisor/info" // InterferenceDectector detects if there's a container which -// interference with a set of container. The detector monitors -// a set of container and find the victims and antagnist. +// interferences with a set of containers. The detector tracks +// a set of containers and find the victims and antagonist. type InterferenceDetector interface { - // Monitor the behavior of the container. + // Tracks the behavior of the container. AddContainer(ref info.ContainerReference) - // Returns a list of Interference. The upper layer may take action + // Returns a list of possible interferences. The upper layer may take action // based on the interference. Detect() ([]*info.Interference, error) diff --git a/info/advice.go b/info/advice.go index 0bd51f18..8084cf47 100644 --- a/info/advice.go +++ b/info/advice.go @@ -18,17 +18,17 @@ package info // container, antagonist, interferes the performance of other // containers, victims. type Interference struct { - // The absolute path of the antagnoism container name. This field + // Absolute name of the antagonist container name. This field // should not be empty. Antagonist string `json:"antagonist"` - // The absolute path of victims. This field should not be empty. + // The absolute path of the victims. This field should not be empty. Victims []string `json:"victims"` // The name of the detector used to detect this antagonism. This field // should not be empty Detector string `json:"detector"` - // Human readable description of the interference + // Human readable description of this interference Description string `json:"description,omitempty"` }