2018-04-26 07:37:59 +00:00
|
|
|
package probe
|
2018-04-18 08:37:18 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-04-18 11:20:43 +00:00
|
|
|
const (
|
|
|
|
FlagPidFilePathName = "pid-path"
|
|
|
|
FlagLoggingConfigFilePathName = "logging-config-path"
|
|
|
|
)
|
|
|
|
|
2018-04-18 11:10:29 +00:00
|
|
|
var (
|
|
|
|
ContainerBinFileName = map[ContainerType]string{
|
|
|
|
ContainerDiscovery: "container_discovery",
|
|
|
|
ContainerNetwork: "container_network",
|
|
|
|
ContainerGenernal: "container_general.jar",
|
|
|
|
}
|
|
|
|
ContainerLoggingConfigFileName = map[ContainerType]string{
|
|
|
|
ContainerDiscovery: "discovery.logging.json",
|
|
|
|
ContainerNetwork: "network.logging.json",
|
|
|
|
ContainerGenernal: "general.logging.json",
|
|
|
|
}
|
2018-04-18 11:04:34 +00:00
|
|
|
)
|
|
|
|
|
2018-04-18 08:37:18 +00:00
|
|
|
type ContainerType int
|
|
|
|
|
|
|
|
const (
|
2018-04-18 11:04:34 +00:00
|
|
|
ContainerDiscovery ContainerType = iota
|
|
|
|
ContainerNetwork
|
|
|
|
ContainerGenernal
|
2018-04-18 08:37:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
containerTypeID = map[ContainerType]string{
|
2018-04-18 11:04:34 +00:00
|
|
|
ContainerDiscovery: "DISCOVERY",
|
|
|
|
ContainerNetwork: "NETWORK",
|
|
|
|
ContainerGenernal: "GENERNAL",
|
2018-04-18 08:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
containerTypeName = map[string]ContainerType{
|
2018-04-18 11:04:34 +00:00
|
|
|
"DISCOVERY": ContainerDiscovery,
|
|
|
|
"NETWORK": ContainerNetwork,
|
|
|
|
"GENERNAL": ContainerGenernal,
|
2018-04-18 08:37:18 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2018-04-28 13:12:16 +00:00
|
|
|
func ToContainerType(v string) ContainerType {
|
|
|
|
return containerTypeName[v]
|
|
|
|
}
|
|
|
|
|
2018-04-18 08:37:18 +00:00
|
|
|
func (ct ContainerType) String() string {
|
|
|
|
return containerTypeID[ct]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ct ContainerType) MarshalJSON() ([]byte, error) {
|
|
|
|
value, ok := containerTypeID[ct]
|
|
|
|
if !ok {
|
|
|
|
return nil, fmt.Errorf("Invalid EnumType[%s] value", ct)
|
|
|
|
}
|
|
|
|
return json.Marshal(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ct ContainerType) UnmarshalJSON(b []byte) error {
|
|
|
|
var s string
|
|
|
|
err := json.Unmarshal(b, &s)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
value, ok := containerTypeName[s]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
|
|
|
}
|
|
|
|
ct = value
|
|
|
|
return nil
|
|
|
|
}
|