当前位置: 首页>>代码示例>>Golang>>正文


Golang keymutex.NewKeyMutex函数代码示例

本文整理汇总了Golang中k8s/io/kubernetes/pkg/util/keymutex.NewKeyMutex函数的典型用法代码示例。如果您正苦于以下问题:Golang NewKeyMutex函数的具体用法?Golang NewKeyMutex怎么用?Golang NewKeyMutex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewKeyMutex函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Init

func (plugin *cinderPlugin) Init(host volume.VolumeHost) error {
	plugin.host = host
	plugin.volumeLocks = keymutex.NewKeyMutex()
	return nil
}
开发者ID:ncdc,项目名称:origin,代码行数:5,代码来源:cinder.go

示例2: AttachAndMountDisk

	"k8s.io/kubernetes/pkg/util/sets"
	"k8s.io/kubernetes/pkg/volume"
)

const (
	diskPartitionSuffix = ""
	diskXVDPath         = "/dev/xvd"
	diskXVDPattern      = "/dev/xvd*"
	maxChecks           = 60
	maxRetries          = 10
	checkSleepDuration  = time.Second
	errorSleepDuration  = 5 * time.Second
)

// Singleton key mutex for keeping attach/detach operations for the same PD atomic
var attachDetachMutex = keymutex.NewKeyMutex()

type AWSDiskUtil struct{}

// Attaches a disk to the current kubelet.
// Mounts the disk to it's global path.
func (diskUtil *AWSDiskUtil) AttachAndMountDisk(b *awsElasticBlockStoreBuilder, globalPDPath string) error {
	glog.V(5).Infof("AttachAndMountDisk(...) called for PD %q. Will block for existing operations, if any. (globalPDPath=%q)\r\n", b.volumeID, globalPDPath)

	// Block execution until any pending detach operations for this PD have completed
	attachDetachMutex.LockKey(b.volumeID)
	defer attachDetachMutex.UnlockKey(b.volumeID)

	glog.V(5).Infof("AttachAndMountDisk(...) called for PD %q. Awake and ready to execute. (globalPDPath=%q)\r\n", b.volumeID, globalPDPath)

	xvdBefore, err := filepath.Glob(diskXVDPattern)
开发者ID:ethernetdan,项目名称:kubernetes,代码行数:31,代码来源:aws_util.go

示例3: NewAttacher

type azureDiskAttacher struct {
	host          volume.VolumeHost
	azureProvider azureCloudProvider
}

var _ volume.Attacher = &azureDiskAttacher{}

var _ volume.AttachableVolumePlugin = &azureDataDiskPlugin{}

const (
	checkSleepDuration = time.Second
)

// acquire lock to get an lun number
var getLunMutex = keymutex.NewKeyMutex()

// NewAttacher initializes an Attacher
func (plugin *azureDataDiskPlugin) NewAttacher() (volume.Attacher, error) {
	azure, err := getAzureCloudProvider(plugin.host.GetCloudProvider())
	if err != nil {
		glog.V(4).Infof("failed to get azure provider")
		return nil, err
	}

	return &azureDiskAttacher{
		host:          plugin.host,
		azureProvider: azure,
	}, nil
}
开发者ID:pst,项目名称:kubernetes,代码行数:29,代码来源:attacher.go

示例4: Init

func (plugin *azureDataDiskPlugin) Init(host volume.VolumeHost) error {
	plugin.host = host
	plugin.volumeLocks = keymutex.NewKeyMutex()
	return nil
}
开发者ID:Q-Lee,项目名称:kubernetes,代码行数:5,代码来源:azure_dd.go


注:本文中的k8s/io/kubernetes/pkg/util/keymutex.NewKeyMutex函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。