...

Source file src/k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state/state.go

Documentation: k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state

     1  /*
     2  Copyright 2017 The Kubernetes 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 state
    18  
    19  import (
    20  	"k8s.io/utils/cpuset"
    21  )
    22  
    23  // ContainerCPUAssignments type used in cpu manager state
    24  type ContainerCPUAssignments map[string]map[string]cpuset.CPUSet
    25  
    26  // Clone returns a copy of ContainerCPUAssignments
    27  func (as ContainerCPUAssignments) Clone() ContainerCPUAssignments {
    28  	ret := make(ContainerCPUAssignments, len(as))
    29  	for pod := range as {
    30  		ret[pod] = make(map[string]cpuset.CPUSet, len(as[pod]))
    31  		for container, cset := range as[pod] {
    32  			ret[pod][container] = cset
    33  		}
    34  	}
    35  	return ret
    36  }
    37  
    38  // Reader interface used to read current cpu/pod assignment state
    39  type Reader interface {
    40  	GetCPUSet(podUID string, containerName string) (cpuset.CPUSet, bool)
    41  	GetDefaultCPUSet() cpuset.CPUSet
    42  	GetCPUSetOrDefault(podUID string, containerName string) cpuset.CPUSet
    43  	GetCPUAssignments() ContainerCPUAssignments
    44  }
    45  
    46  type writer interface {
    47  	SetCPUSet(podUID string, containerName string, cpuset cpuset.CPUSet)
    48  	SetDefaultCPUSet(cpuset cpuset.CPUSet)
    49  	SetCPUAssignments(ContainerCPUAssignments)
    50  	Delete(podUID string, containerName string)
    51  	ClearState()
    52  }
    53  
    54  // State interface provides methods for tracking and setting cpu/pod assignment
    55  type State interface {
    56  	Reader
    57  	writer
    58  }
    59  

View as plain text