func (m *resmgr) SetAdjustment(adjustment *config.Adjustment) map[string]error {
	m.Info("applying new adjustments from agent...")
	m.Lock()
	defer m.Unlock()
	return m.setAdjustment(adjustment)
}
SetAdjustment pushes new external adjustments to the resource manager.
package resmgr
import (
	"golang.org/x/sys/unix"
	"os"
	"os/signal"
	"path/filepath"
	"strings"
	"sync"
	"time"
	pkgcfg "github.com/intel/cri-resource-manager/pkg/config"
	"github.com/intel/cri-resource-manager/pkg/cri/relay"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/agent"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/cache"
	config "github.com/intel/cri-resource-manager/pkg/cri/resource-manager/config"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/control"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/introspect"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/metrics"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/policy"
	"github.com/intel/cri-resource-manager/pkg/cri/resource-manager/visualizer"
	"github.com/intel/cri-resource-manager/pkg/instrumentation"
	logger "github.com/intel/cri-resource-manager/pkg/log"
	"github.com/intel/cri-resource-manager/pkg/utils"
)
type ResourceManager interface {
	Start() error
	Stop()
	SetConfig(*config.RawConfig) error
	SetAdjustment(*config.Adjustment) map[string]error
	SendEvent(event interface{}) error
	ResourceManagerTestAPI
}
type resmgr struct {
	logger.Logger
	sync.RWMutex
	relay        relay.Relay         
	cache        cache.Cache         
	policy       policy.Policy       
	policySwitch bool                
	configServer config.Server       
	control      control.Control     
	agent        agent.Interface     
	conf         *config.RawConfig   
	metrics      *metrics.Metrics    
	events       chan interface{}    
	stop         chan interface{}    
	signals      chan os.Signal      
	introspect   *introspect.Server  
}
func NewResourceManager() (ResourceManager, error) {
	m := &resmgr{Logger: logger.NewLogger("resource-manager")}
	if err := m.setupCache(); err != nil {
		return nil, err
	}
	switch {
	case opt.ResetPolicy && opt.ResetConfig:
		os.Exit(m.resetCachedPolicy() + m.resetCachedConfig())
	case opt.ResetPolicy:
		os.Exit(m.resetCachedPolicy())
	case opt.ResetConfig:
		os.Exit(m.resetCachedConfig())
	}
	if err := m.checkOpts(); err != nil {
		return nil, err
	}
	if err := m.setupAgentInterface(); err != nil {
		return nil, err
	}
	if err := m.loadConfig(); err != nil {
		return nil, err
	}
	if err := m.setupConfigServer(); err != nil {
		return nil, err
	}
	if err := m.setupPolicy(); err != nil {
		return nil, err
	}
	if err := m.setupRelay(); err != nil {
		return nil, err
	}
	if err := m.setupRequestProcessing(); err != nil {
		return nil, err
	}
	if err := m.setupEventProcessing(); err != nil {
		return nil, err
	}
	if err := m.setupControllers(); err != nil {
		return nil, err
	}
	if err := m.setupIntrospection(); err != nil {
		return nil, err
	}
	return m, nil
}
func (m *resmgr) Start() error {
	m.Info("starting...")
	m.Lock()
	defer m.Unlock()
	if err := m.startControllers(); err != nil {
		return err
	}
	if err := m.startRequestProcessing(); err != nil {
		return err
	}
	if err := m.startEventProcessing(); err != nil {
		return err
	}
	m.startIntrospection()
	if err := m.relay.Start(); err != nil {
		return resmgrError("failed to start CRI relay: %v", err)
	}
	if opt.ForceConfig == "" {
		if err := m.configServer.Start(opt.ConfigSocket); err != nil {
			return resmgrError("failed to start configuration server: %v", err)
		}
		if m.conf != nil {
			m.cache.SetConfig(m.conf)
			m.conf = nil
		}
	}
	m.Info("up and running")
	return nil
}
func (m *resmgr) Stop() {
	m.Info("shutting down...")
	m.Lock()
	defer m.Unlock()
	if m.signals != nil {
		close(m.signals)
		m.signals = nil
	}
	m.configServer.Stop()
	m.relay.Stop()
	m.stopIntrospection()
	m.stopEventProcessing()
}
func (m *resmgr) SetConfig(conf *config.RawConfig) error {
	m.Info("applying new configuration from agent...")
	return m.setConfig(conf)
}