Skip to content

Commit

Permalink
fix interface
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Feb 3, 2023
1 parent 65e7a4d commit f2dda62
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
3 changes: 1 addition & 2 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/projecteru2/core/resource3"
"github.com/projecteru2/core/resource3/cobalt"
plugintypes "github.com/projecteru2/core/resource3/plugins/types"
"github.com/projecteru2/core/resources"
"github.com/projecteru2/core/types"
"github.com/projecteru2/core/utils"

Expand Down Expand Up @@ -131,7 +130,7 @@ var Client = Metrics{}
var once sync.Once

// InitMetrics new a metrics obj
func InitMetrics(config types.Config, metricsDescriptions []*resources.MetricsDescription) error {
func InitMetrics(config types.Config, metricsDescriptions []*plugintypes.MetricsDescription) error {
hostname, err := os.Hostname()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion resource3/plugins/binary/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (p Plugin) RemoveNode(ctx context.Context, nodename string) (*plugintypes.R
}

// GetNodesDeployCapacity .
func (p Plugin) GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResource) (*plugintypes.GetNodesDeployCapacityResponse, error) {
func (p Plugin) GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResourceRequest) (*plugintypes.GetNodesDeployCapacityResponse, error) {
req := &binarytypes.GetNodesDeployCapacityRequest{
Nodenames: nodenames,
WorkloadResource: resource,
Expand Down
2 changes: 1 addition & 1 deletion resource3/plugins/cpumem/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (p Plugin) RemoveNode(ctx context.Context, nodename string) (*plugintypes.R
}

// GetNodesDeployCapacity returns available nodes and total capacity
func (p Plugin) GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResource) (*plugintypes.GetNodesDeployCapacityResponse, error) {
func (p Plugin) GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResourceRequest) (*plugintypes.GetNodesDeployCapacityResponse, error) {
logger := log.WithFunc("resource.cpumem.GetNodesDeployCapacity")
req := &cpumemtypes.WorkloadResourceRequest{}
if err := req.Parse(resource); err != nil {
Expand Down
14 changes: 7 additions & 7 deletions resource3/plugins/cpumem/types/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

// WorkloadResource indicate cpumem workload resource
type WorkloadResource struct {
CPURequest float64 `json:"cpu_request"`
CPULimit float64 `json:"cpu_limit"`
MemoryRequest int64 `json:"memory_request"`
MemoryLimit int64 `json:"memory_limit"`
CPUMap CPUMap `json:"cpu_map"`
NUMAMemory NUMAMemory `json:"numa_memory"`
NUMANode string `json:"numa_node"`
CPURequest float64 `json:"cpu_request" mapstructure:"cpu_request"`
CPULimit float64 `json:"cpu_limit" mapstructure:"cpu_limit"`
MemoryRequest int64 `json:"memory_request" mapstructure:"memory_request"`
MemoryLimit int64 `json:"memory_limit" mapstructure:"memory_limit"`
CPUMap CPUMap `json:"cpu_map" mapstructure:"cpu_map"`
NUMAMemory NUMAMemory `json:"numa_memory" mapstructure:"numa_memory"`
NUMANode string `json:"numa_node" mapstructure:"numa_node"`
}

// ParseFromRawParams .
Expand Down
16 changes: 15 additions & 1 deletion resource3/plugins/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import (
"context"

enginetypes "github.com/projecteru2/core/engine/types"
"github.com/projecteru2/core/resource3/plugins/binary"
"github.com/projecteru2/core/resource3/plugins/cpumem"
"github.com/projecteru2/core/resource3/plugins/storage"
plugintypes "github.com/projecteru2/core/resource3/plugins/types"
"github.com/projecteru2/core/types"
)

const (
Expand Down Expand Up @@ -39,7 +43,7 @@ type Plugin interface {
RemoveNode(ctx context.Context, nodename string) (*plugintypes.RemoveNodeResponse, error)

// GetNodesDeployCapacity returns available nodes and total capacity
GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResource) (*plugintypes.GetNodesDeployCapacityResponse, error)
GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResourceRequest) (*plugintypes.GetNodesDeployCapacityResponse, error)

// SetNodeResourceCapacity sets the amount of total resource info
SetNodeResourceCapacity(ctx context.Context, nodename string, resource *plugintypes.NodeResource, resourceRequest *plugintypes.NodeResourceRequest, delta bool, incr bool) (*plugintypes.SetNodeResourceCapacityResponse, error)
Expand Down Expand Up @@ -71,3 +75,13 @@ type Plugin interface {
// Name returns the name of plugin
Name() string
}

func _() {
ctx := context.TODO()
b, _ := binary.NewPlugin(ctx, "", types.Config{})
c, _ := cpumem.NewPlugin(ctx, types.Config{})
s, _ := storage.NewPlugin(ctx, types.Config{})
_ = Plugin(b)
_ = Plugin(c)
_ = Plugin(s)
}
2 changes: 1 addition & 1 deletion resource3/plugins/storage/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (p Plugin) RemoveNode(ctx context.Context, nodename string) (*plugintypes.R
return &plugintypes.RemoveNodeResponse{}, nil
}

func (p Plugin) GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResource) (*plugintypes.GetNodesDeployCapacityResponse, error) {
func (p Plugin) GetNodesDeployCapacity(ctx context.Context, nodenames []string, resource *plugintypes.WorkloadResourceRequest) (*plugintypes.GetNodesDeployCapacityResponse, error) {
logger := log.WithFunc("resource.storage.GetNodesDeployCapacity")
req := &storagetypes.WorkloadResourceRequest{}
if err := req.Parse(resource); err != nil {
Expand Down

0 comments on commit f2dda62

Please sign in to comment.