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


Golang NCC.IPVSFlush方法代码示例

本文整理汇总了Golang中github.com/google/seesaw/ncc/client.NCC.IPVSFlush方法的典型用法代码示例。如果您正苦于以下问题:Golang NCC.IPVSFlush方法的具体用法?Golang NCC.IPVSFlush怎么用?Golang NCC.IPVSFlush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/google/seesaw/ncc/client.NCC的用法示例。


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

示例1: ipvsTests

func ipvsTests(ncc client.NCC) {

	// Manipulate the IPVS table.
	if err := ncc.IPVSFlush(); err != nil {
		log.Fatalf("Failed to flush the IPVS table: %v", err)
	}

	log.Printf("Adding IPVS service %v with %d destinations", testSvc, len(testSvc.Destinations))
	if err := ncc.IPVSAddService(testSvc); err != nil {
		log.Fatalf("Failed to add IPVS service: %v", err)
	}

	svcs, err := ncc.IPVSGetServices()
	if err != nil {
		log.Fatalf("Failed to get IPVS services: %v", err)
	}
	for _, svc := range svcs {
		log.Printf("Got IPVS service %v with %d destinations",
			svc, len(svc.Destinations))
	}
	if len(svcs) != 1 {
		log.Fatalf("IPVSGetServices returned %d services, expected 1", len(svcs))
	}
	if len(svcs[0].Destinations) != len(testSvc.Destinations) {
		log.Fatalf("IPVSGetServices returned %d destinations, expected %d",
			len(svcs[0].Destinations), len(testSvc.Destinations))
	}

	dst := testSvc.Destinations[0]
	if err := ncc.IPVSDeleteDestination(testSvc, dst); err != nil {
		log.Fatalf("Failed to delete destination: %v", err)
	}

	svc, err := ncc.IPVSGetService(testSvc)
	if err != nil {
		log.Fatalf("Failed to get IPVS service: %v", err)
	}
	if len(svc.Destinations) != len(testSvc.Destinations)-1 {
		log.Fatalf("IPVSGetService returned %d destinations, expected %d",
			len(svc.Destinations), len(testSvc.Destinations)-1)
	}

	ipvsGetLoadTest(4, 10*time.Second)

	if err := ncc.IPVSDeleteService(testSvc); err != nil {
		log.Fatalf("Failed to delete IPVS service: %v", err)
	}

	ipvsAddLoadTest(ncc, 20, 50)

	// Clean up after ourselves...
	if err := ncc.IPVSFlush(); err != nil {
		log.Fatalf("Failed to flush the IPVS table: %v", err)
	}
}
开发者ID:Cepave,项目名称:lvs-metrics,代码行数:55,代码来源:main.go

示例2: ipvsAddLoadTest

func ipvsAddLoadTest(ncc client.NCC, services, dests int) {
	log.Printf("Starting IPVS add load test - %d services, each with %d destinations", services, dests)

	if err := ncc.IPVSFlush(); err != nil {
		log.Fatalf("Failed to flush the IPVS table: %v", err)
	}

	done := make(chan bool)
	for i := 0; i < services; i++ {
		go ipvsAddService(done, i, dests)
	}
	for i := 0; i < services; i++ {
		<-done
	}

	if err := ncc.IPVSFlush(); err != nil {
		log.Fatalf("Failed to flush the IPVS table: %v", err)
	}

	log.Printf("Completed IPVS add load test")
}
开发者ID:Cepave,项目名称:lvs-metrics,代码行数:21,代码来源:main.go


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