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


Golang osl.GC函数代码示例

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


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

示例1: Stop

func (c *controller) Stop() {
	if c.localStore != nil {
		c.localStore.KVStore().Close()
	}
	c.stopExternalKeyListener()
	osl.GC()
}
开发者ID:c0b,项目名称:libnetwork,代码行数:7,代码来源:controller.go

示例2: TestSandboxAddSamePrio

func TestSandboxAddSamePrio(t *testing.T) {
	if !testutils.IsRunningInContainer() {
		defer testutils.SetupTestOSContext(t)()
	}

	c, nw1, nw2 := getTestEnv(t)

	ctrlr := c.(*controller)

	sbx, err := ctrlr.NewSandbox("sandbox1")
	if err != nil {
		t.Fatal(err)
	}
	sid := sbx.ID()

	ep1, err := nw1.CreateEndpoint("ep1")
	if err != nil {
		t.Fatal(err)
	}
	ep2, err := nw2.CreateEndpoint("ep2")
	if err != nil {
		t.Fatal(err)
	}

	if err := ep1.Join(sbx); err != nil {
		t.Fatal(err)
	}

	if err := ep2.Join(sbx); err != nil {
		t.Fatal(err)
	}

	if ctrlr.sandboxes[sid].endpoints[0] != ep1 {
		t.Fatal("Expected ep1 to be at the top of the heap. But did not find ep1 at the top of the heap")
	}

	if err := ep1.Leave(sbx); err != nil {
		t.Fatal(err)
	}

	if ctrlr.sandboxes[sid].endpoints[0] != ep2 {
		t.Fatal("Expected ep2 to be at the top of the heap after removing ep3. But did not find ep2 at the top of the heap")
	}

	if err := ep2.Leave(sbx); err != nil {
		t.Fatal(err)
	}

	if err := sbx.Delete(); err != nil {
		t.Fatal(err)
	}

	if len(ctrlr.sandboxes) != 0 {
		t.Fatalf("controller containers is not empty. len = %d", len(ctrlr.sandboxes))
	}

	osl.GC()
}
开发者ID:hw-qiaolei,项目名称:libnetwork,代码行数:58,代码来源:sandbox_test.go

示例3: TestSandboxAddEmpty

func TestSandboxAddEmpty(t *testing.T) {
	ctrlr := createEmptyCtrlr()

	sbx, err := ctrlr.NewSandbox("sandbox0")
	if err != nil {
		t.Fatal(err)
	}

	if err := sbx.Delete(); err != nil {
		t.Fatal(err)
	}

	if len(ctrlr.sandboxes) != 0 {
		t.Fatalf("controller sandboxes is not empty. len = %d", len(ctrlr.sandboxes))
	}

	osl.GC()
}
开发者ID:hw-qiaolei,项目名称:libnetwork,代码行数:18,代码来源:sandbox_test.go

示例4: TestSandboxAddEmpty

func TestSandboxAddEmpty(t *testing.T) {
	c, _, _ := getTestEnv(t, true)
	ctrlr := c.(*controller)

	sbx, err := ctrlr.NewSandbox("sandbox0")
	if err != nil {
		t.Fatal(err)
	}

	if err := sbx.Delete(); err != nil {
		t.Fatal(err)
	}

	if len(ctrlr.sandboxes) != 0 {
		t.Fatalf("controller sandboxes is not empty. len = %d", len(ctrlr.sandboxes))
	}

	osl.GC()
}
开发者ID:YujiOshima,项目名称:libnetwork,代码行数:19,代码来源:sandbox_test.go

示例5: Stop

func (c *controller) Stop() {
	c.closeStores()
	c.stopExternalKeyListener()
	osl.GC()
}
开发者ID:maxim28,项目名称:docker,代码行数:5,代码来源:controller.go

示例6: externalKeyTest

func externalKeyTest(t *testing.T, reexec bool) {
	if !testutils.IsRunningInContainer() {
		defer testutils.SetupTestOSContext(t)()
	}

	n, err := createTestNetwork(bridgeNetType, "testnetwork", options.Generic{
		netlabel.GenericData: options.Generic{
			"BridgeName": "testnetwork",
		},
	}, nil, nil)
	if err != nil {
		t.Fatal(err)
	}
	defer func() {
		if err := n.Delete(); err != nil {
			t.Fatal(err)
		}
	}()

	ep, err := n.CreateEndpoint("ep1")
	if err != nil {
		t.Fatal(err)
	}
	defer func() {
		err = ep.Delete()
		if err != nil {
			t.Fatal(err)
		}
	}()

	ep2, err := n.CreateEndpoint("ep2")
	if err != nil {
		t.Fatal(err)
	}
	defer func() {
		err = ep2.Delete()
		if err != nil {
			t.Fatal(err)
		}
	}()

	cnt, err := controller.NewSandbox(containerID,
		libnetwork.OptionHostname("test"),
		libnetwork.OptionDomainname("docker.io"),
		libnetwork.OptionUseExternalKey(),
		libnetwork.OptionExtraHost("web", "192.168.0.1"))
	defer func() {
		if err := cnt.Delete(); err != nil {
			t.Fatal(err)
		}
		osl.GC()
	}()

	// Join endpoint to sandbox before SetKey
	err = ep.Join(cnt)
	runtime.LockOSThread()
	if err != nil {
		t.Fatal(err)
	}
	defer func() {
		err = ep.Leave(cnt)
		runtime.LockOSThread()
		if err != nil {
			t.Fatal(err)
		}
	}()

	sbox := ep.Info().Sandbox()
	if sbox == nil {
		t.Fatalf("Expected to have a valid Sandbox")
	}

	if reexec {
		err := reexecSetKey("this-must-fail", containerID, controller.ID())
		if err == nil {
			t.Fatalf("SetExternalKey must fail if the corresponding namespace is not created")
		}
	} else {
		// Setting an non-existing key (namespace) must fail
		if err := sbox.SetKey("this-must-fail"); err == nil {
			t.Fatalf("Setkey must fail if the corresponding namespace is not created")
		}
	}

	// Create a new OS sandbox using the osl API before using it in SetKey
	if extOsBox, err := osl.NewSandbox("ValidKey", true); err != nil {
		t.Fatalf("Failed to create new osl sandbox")
	} else {
		defer func() {
			if err := extOsBox.Destroy(); err != nil {
				log.Warnf("Failed to remove os sandbox: %v", err)
			}
		}()
	}

	if reexec {
		err := reexecSetKey("ValidKey", containerID, controller.ID())
		if err != nil {
			t.Fatalf("SetExternalKey failed with %v", err)
		}
//.........这里部分代码省略.........
开发者ID:pirater,项目名称:os,代码行数:101,代码来源:libnetwork_test.go

示例7: GC

func (c *controller) GC() {
	osl.GC()
}
开发者ID:hurrygeek,项目名称:libnetwork,代码行数:3,代码来源:controller.go

示例8: TestSandboxAddMultiPrio

func TestSandboxAddMultiPrio(t *testing.T) {
	if !netutils.IsRunningInContainer() {
		defer osl.SetupTestOSContext(t)()
	}

	c, nw, _ := getTestEnv(t)
	ctrlr := c.(*controller)

	sbx, err := ctrlr.NewSandbox("sandbox1")
	if err != nil {
		t.Fatal(err)
	}
	sid := sbx.ID()

	ep1, err := nw.CreateEndpoint("ep1")
	if err != nil {
		t.Fatal(err)
	}
	ep2, err := nw.CreateEndpoint("ep2")
	if err != nil {
		t.Fatal(err)
	}
	ep3, err := nw.CreateEndpoint("ep3")
	if err != nil {
		t.Fatal(err)
	}

	if err := ep1.Join(sbx, JoinOptionPriority(ep1, 1)); err != nil {
		t.Fatal(err)
	}

	if err := ep2.Join(sbx, JoinOptionPriority(ep2, 2)); err != nil {
		t.Fatal(err)
	}

	if err := ep3.Join(sbx, JoinOptionPriority(ep3, 3)); err != nil {
		t.Fatal(err)
	}

	if ctrlr.sandboxes[sid].endpoints[0] != ep3 {
		t.Fatal("Expected ep3 to be at the top of the heap. But did not find ep3 at the top of the heap")
	}

	if err := ep3.Leave(sbx); err != nil {
		t.Fatal(err)
	}
	if ctrlr.sandboxes[sid].endpoints[0] != ep2 {
		t.Fatal("Expected ep2 to be at the top of the heap after removing ep3. But did not find ep2 at the top of the heap")
	}

	if err := ep2.Leave(sbx); err != nil {
		t.Fatal(err)
	}
	if ctrlr.sandboxes[sid].endpoints[0] != ep1 {
		t.Fatal("Expected ep1 to be at the top of the heap after removing ep2. But did not find ep1 at the top of the heap")
	}

	// Re-add ep3 back
	if err := ep3.Join(sbx, JoinOptionPriority(ep3, 3)); err != nil {
		t.Fatal(err)
	}

	if ctrlr.sandboxes[sid].endpoints[0] != ep3 {
		t.Fatal("Expected ep3 to be at the top of the heap after adding ep3 back. But did not find ep3 at the top of the heap")
	}

	if err := sbx.Delete(); err != nil {
		t.Fatal(err)
	}

	if len(ctrlr.sandboxes) != 0 {
		t.Fatalf("controller sandboxes is not empty. len = %d", len(ctrlr.sandboxes))
	}

	osl.GC()
}
开发者ID:rajatchopra,项目名称:libnetwork,代码行数:76,代码来源:sandbox_test.go


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