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


Golang godbc.Ensure函数代码示例

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


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

示例1: NewVolumeDeleteCommand

func NewVolumeDeleteCommand(options *Options) *VolumeDeleteCommand {

	godbc.Require(options != nil)

	cmd := &VolumeDeleteCommand{}
	cmd.name = "delete"
	cmd.options = options
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Deletes the volume

USAGE
  heketi-cli [options] volume delete [id]

  Where "id" is the id of the volume to be deleted

EXAMPLE
  $ heketi-cli volume delete 886a86a868711bef83001

`)
	}

	godbc.Ensure(cmd.flags != nil)
	godbc.Ensure(cmd.name == "delete")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:30,代码来源:volume_delete.go

示例2: adjustAsuSizes

// ASU1 + ASU2 + ASU3 = X
// ASU1 is 45% of X
// ASU2 is 45% of X
// ASU3 is 10% of X
// Call this function after all ASUs are opened
func (s *SpcInfo) adjustAsuSizes() error {
	godbc.Require(s.asus[ASU1].len != 0)
	godbc.Require(s.asus[ASU2].len != 0)
	godbc.Require(s.asus[ASU3].len != 0)

	// lets start making user ASU1 and ASU2 are equal
	if s.asus[ASU1].len > s.asus[ASU2].len {
		s.asus[ASU1].len = s.asus[ASU2].len
	} else {
		s.asus[ASU2].len = s.asus[ASU1].len
	}

	// Now we need to adjust ASU3
	asu3_correct_size := uint32(float64(2*s.asus[ASU1].len) / 9)
	if asu3_correct_size > s.asus[ASU3].len {
		return fmt.Errorf("\nASU3 size is too small: %v KB.\n"+
			"It must be bigger than 1/9 of 2*ASU1,\n"+
			"or %v KB for this configuration\n",
			s.asus[ASU3].len*4, asu3_correct_size*4)
	} else {
		s.asus[ASU3].len = asu3_correct_size
	}

	godbc.Ensure(s.asus[ASU1].len != 0)
	godbc.Ensure(s.asus[ASU2].len != 0)
	godbc.Ensure(s.asus[ASU3].len != 0, asu3_correct_size)

	return nil
}
开发者ID:chenweicai,项目名称:pblcache,代码行数:34,代码来源:spc.go

示例3: NewKubeExecutor

func NewKubeExecutor(config *KubeConfig) (*KubeExecutor, error) {
	// Override configuration
	setWithEnvVariables(config)

	// Initialize
	k := &KubeExecutor{}
	k.config = config
	k.Throttlemap = make(map[string]chan bool)
	k.RemoteExecutor = k

	if k.config.Fstab == "" {
		k.Fstab = "/etc/fstab"
	} else {
		k.Fstab = config.Fstab
	}

	// Check required values
	if k.config.Namespace == "" {
		return nil, fmt.Errorf("Namespace must be provided in configuration")
	}

	godbc.Ensure(k != nil)
	godbc.Ensure(k.Fstab != "")

	return k, nil
}
开发者ID:yepengxj,项目名称:heketi,代码行数:26,代码来源:kubeexec.go

示例4: NewClusterInfoCommand

func NewClusterInfoCommand(options *Options) *ClusterInfoCommand {

	godbc.Require(options != nil)

	cmd := &ClusterInfoCommand{}
	cmd.name = "info"
	cmd.options = options
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Retreives information about the cluster

USAGE
  heketi-cli [options] cluster info [id]

  Where "id" is the id of the cluster

EXAMPLE
  $ heketi-cli cluster info 886a86a868711bef83001

`)
	}

	godbc.Ensure(cmd.flags != nil)
	godbc.Ensure(cmd.name == "info")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:30,代码来源:cluster_info.go

示例5: NewLogger

func NewLogger(prefix string, level LogLevel) *Logger {
	godbc.Require(level >= 0, level)
	godbc.Require(level <= LEVEL_DEBUG, level)

	l := &Logger{}

	if level == LEVEL_NOLOG {
		l.level = LEVEL_DEBUG
	} else {
		l.level = level
	}

	l.critlog = log.New(stderr, prefix+" CRITICAL ", log.LstdFlags)
	l.errorlog = log.New(stderr, prefix+" ERROR ", log.LstdFlags)
	l.warninglog = log.New(stdout, prefix+" WARNING ", log.LstdFlags)
	l.infolog = log.New(stdout, prefix+" INFO ", log.LstdFlags)
	l.debuglog = log.New(stdout, prefix+" DEBUG ", log.LstdFlags)

	godbc.Ensure(l.critlog != nil)
	godbc.Ensure(l.errorlog != nil)
	godbc.Ensure(l.warninglog != nil)
	godbc.Ensure(l.infolog != nil)
	godbc.Ensure(l.debuglog != nil)

	return l
}
开发者ID:Zandrr,项目名称:heketi,代码行数:26,代码来源:log.go

示例6: StorageAdd

func (c *ClusterEntry) StorageAdd(amount uint64) {
	c.Info.Storage.Free += amount
	c.Info.Storage.Total += amount

	godbc.Ensure(c.Info.Storage.Free >= 0)
	godbc.Ensure(c.Info.Storage.Used >= 0)
	godbc.Ensure(c.Info.Storage.Total >= 0)
}
开发者ID:gaurav36,项目名称:heketi,代码行数:8,代码来源:cluster_entry.go

示例7: StorageAllocate

func (c *ClusterEntry) StorageAllocate(amount uint64) {
	c.Info.Storage.Free -= amount
	c.Info.Storage.Used += amount
	c.Info.Storage.Total -= amount

	godbc.Ensure(c.Info.Storage.Free >= 0)
	godbc.Ensure(c.Info.Storage.Used >= 0)
	godbc.Ensure(c.Info.Storage.Total >= 0)
}
开发者ID:gaurav36,项目名称:heketi,代码行数:9,代码来源:cluster_entry.go

示例8: Completed

// Registers that the handler has completed and no data needs to be returned
func (h *AsyncHttpHandler) Completed() {

	h.manager.lock.RLock()
	defer h.manager.lock.RUnlock()

	godbc.Require(h.completed == false)

	h.completed = true

	godbc.Ensure(h.completed == true)
	godbc.Ensure(h.location == "")
	godbc.Ensure(h.err == nil)
}
开发者ID:Zandrr,项目名称:heketi,代码行数:14,代码来源:asynchttp.go

示例9: NewDeviceAddCommand

func NewDeviceAddCommand(options *Options) *DeviceAddCommand {
	godbc.Require(options != nil)

	cmd := &DeviceAddCommand{}
	cmd.name = "add"
	cmd.options = options
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)
	cmd.flags.StringVar(&cmd.device, "name", "", "Name of device to add")
	cmd.flags.StringVar(&cmd.nodeId, "node", "", "Id of the node which has this device")

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Add new device to node to be managed by Heketi

USAGE
  heketi-cli device add [options]

OPTIONS`)

		//print flags
		cmd.flags.PrintDefaults()
		fmt.Println(`
EXAMPLES
  $ heketi-cli device add \
      -name=/dev/sdb
      -node=3e098cb4407d7109806bb196d9e8f095 
`)
	}

	godbc.Ensure(cmd.name == "add")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:34,代码来源:device_add.go

示例10: NewClusterCreateCommand

func NewClusterCreateCommand(options *Options) *ClusterCreateCommand {

	godbc.Require(options != nil)

	cmd := &ClusterCreateCommand{}
	cmd.name = "create"
	cmd.options = options

	// Set flags
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Create a cluster

A cluster is used to group a collection of nodes.  It also provides
the caller with the choice to specify clusters where volumes should
be created.

USAGE
  heketi-cli [options] cluster create

EXAMPLE
  $ heketi-cli cluster create

`)
	}

	godbc.Ensure(cmd.name == "create")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:33,代码来源:cluster_create.go

示例11: NewVolumeExpandCommand

func NewVolumeExpandCommand(options *Options) *VolumeExpandCommand {

	godbc.Require(options != nil)

	cmd := &VolumeExpandCommand{}
	cmd.name = "expand"
	cmd.options = options
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)
	cmd.flags.IntVar(&cmd.expand_size, "expand-size", -1,
		"\n\tAmount in GB to add to the volume")
	cmd.flags.StringVar(&cmd.id, "volume", "",
		"\n\tId of volume to expand")

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Expand a volume

USAGE
  heketi-cli volume expand [options]

OPTIONS`)

		//print flags
		cmd.flags.PrintDefaults()
		fmt.Println(`
EXAMPLES
  * Add 10GB to a volume
      $ heketi-cli volume expand -volume=60d46d518074b13a04ce1022c8c7193c -expand-size=10
`)
	}
	godbc.Ensure(cmd.name == "expand")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:35,代码来源:volume_expand.go

示例12: NewNodeDestroyCommand

func NewNodeDestroyCommand(options *Options) *NodeDestroyCommand {

	godbc.Require(options != nil)

	cmd := &NodeDestroyCommand{}
	cmd.name = "delete"
	cmd.options = options
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Deletes a node from Heketi management

USAGE
  heketi-cli [options] node delete [id]

  Where "id" is the id of the cluster

EXAMPLE
  $ heketi-cli node delete 886a86a868711bef83001
`)
	}

	godbc.Ensure(cmd.name == "delete")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:28,代码来源:node_delete.go

示例13: NewNodeCommand

//function to create new node command
func NewNodeCommand(options *Options) *NodeCommand {
	godbc.Require(options != nil)

	cmd := &NodeCommand{}
	cmd.name = "node"
	cmd.options = options
	cmd.cmds = Commands{
		NewNodeAddCommand(options),
		NewNodeInfoCommand(options),
		NewNodeDestroyCommand(options),
	}

	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Heketi node management

USAGE
  heketi-cli [options] node [commands]

COMMANDS
  add     Adds a node for Heketi to manage.
  info    Returns information about a specific node.
  delete  Delete node with specified id. 

Use "heketi-cli node [command] -help" for more information about a command
`)
	}

	godbc.Ensure(cmd.name == "node")
	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:35,代码来源:node.go

示例14: NewVolumeListCommand

func NewVolumeListCommand(options *Options) *VolumeListCommand {

	godbc.Require(options != nil)

	cmd := &VolumeListCommand{}
	cmd.name = "list"
	cmd.options = options
	cmd.flags = flag.NewFlagSet(cmd.name, flag.ExitOnError)

	//usage on -help
	cmd.flags.Usage = func() {
		fmt.Println(`
Lists the volumes managed by Heketi

USAGE
  heketi-cli [options] volume list

EXAMPLE
  $ heketi-cli volume list
`)
	}

	godbc.Ensure(cmd.name == "list")

	return cmd
}
开发者ID:vbellur,项目名称:heketi,代码行数:26,代码来源:volume_list.go

示例15: Add

func (m *Message) Add(child *Message) {
	godbc.Require(child.parent == nil, child)

	m.wg.Add(1)
	child.parent = m

	godbc.Ensure(child.parent == m)
}
开发者ID:chenweicai,项目名称:pblcache,代码行数:8,代码来源:message.go


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