github.com/kubewharf/katalyst-core@v0.5.3/pkg/config/agent/agent_base.go (about)

     1  /*
     2  Copyright 2022 The Katalyst Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package agent
    18  
    19  import (
    20  	"github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic"
    21  	"github.com/kubewharf/katalyst-core/pkg/config/agent/eviction"
    22  	"github.com/kubewharf/katalyst-core/pkg/config/agent/global"
    23  	"github.com/kubewharf/katalyst-core/pkg/config/agent/metaserver"
    24  	"github.com/kubewharf/katalyst-core/pkg/config/agent/orm"
    25  	"github.com/kubewharf/katalyst-core/pkg/config/agent/qrm"
    26  	"github.com/kubewharf/katalyst-core/pkg/config/agent/reporter"
    27  	"github.com/kubewharf/katalyst-core/pkg/config/agent/sysadvisor"
    28  )
    29  
    30  // AgentConfiguration stores all the configurations needed by core katalyst components,
    31  // and those configurations can be modified dynamically
    32  type AgentConfiguration struct {
    33  	// those configurations are used by agents
    34  	*GenericAgentConfiguration
    35  	*StaticAgentConfiguration
    36  	*dynamic.DynamicAgentConfiguration
    37  }
    38  
    39  func NewAgentConfiguration() *AgentConfiguration {
    40  	return &AgentConfiguration{
    41  		GenericAgentConfiguration: NewGenericAgentConfiguration(),
    42  		StaticAgentConfiguration:  NewStaticAgentConfiguration(),
    43  		DynamicAgentConfiguration: dynamic.NewDynamicAgentConfiguration(),
    44  	}
    45  }
    46  
    47  type GenericAgentConfiguration struct {
    48  	// those configurations should be used as generic configurations, and
    49  	// be shared by all agent components.
    50  	*global.BaseConfiguration
    51  	*global.PluginManagerConfiguration
    52  	*global.QRMAdvisorConfiguration
    53  
    54  	*metaserver.MetaServerConfiguration
    55  	*eviction.GenericEvictionConfiguration
    56  	*reporter.GenericReporterConfiguration
    57  	*sysadvisor.GenericSysAdvisorConfiguration
    58  	*qrm.GenericQRMPluginConfiguration
    59  	*orm.GenericORMConfiguration
    60  }
    61  
    62  type StaticAgentConfiguration struct {
    63  	*eviction.EvictionConfiguration
    64  	*reporter.ReporterPluginsConfiguration
    65  	*sysadvisor.SysAdvisorPluginsConfiguration
    66  	*qrm.QRMPluginsConfiguration
    67  }
    68  
    69  func NewGenericAgentConfiguration() *GenericAgentConfiguration {
    70  	return &GenericAgentConfiguration{
    71  		BaseConfiguration:              global.NewBaseConfiguration(),
    72  		PluginManagerConfiguration:     global.NewPluginManagerConfiguration(),
    73  		MetaServerConfiguration:        metaserver.NewMetaServerConfiguration(),
    74  		QRMAdvisorConfiguration:        global.NewQRMAdvisorConfiguration(),
    75  		GenericEvictionConfiguration:   eviction.NewGenericEvictionConfiguration(),
    76  		GenericReporterConfiguration:   reporter.NewGenericReporterConfiguration(),
    77  		GenericSysAdvisorConfiguration: sysadvisor.NewGenericSysAdvisorConfiguration(),
    78  		GenericQRMPluginConfiguration:  qrm.NewGenericQRMPluginConfiguration(),
    79  		GenericORMConfiguration:        orm.NewGenericORMConfiguration(),
    80  	}
    81  }
    82  
    83  func NewStaticAgentConfiguration() *StaticAgentConfiguration {
    84  	return &StaticAgentConfiguration{
    85  		EvictionConfiguration:          eviction.NewEvictionConfiguration(),
    86  		ReporterPluginsConfiguration:   reporter.NewReporterPluginsConfiguration(),
    87  		SysAdvisorPluginsConfiguration: sysadvisor.NewSysAdvisorPluginsConfiguration(),
    88  		QRMPluginsConfiguration:        qrm.NewQRMPluginsConfiguration(),
    89  	}
    90  }