當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerCnxnFactory.shutdown方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.server.ServerCnxnFactory.shutdown方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerCnxnFactory.shutdown方法的具體用法?Java ServerCnxnFactory.shutdown怎麽用?Java ServerCnxnFactory.shutdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.server.ServerCnxnFactory的用法示例。


在下文中一共展示了ServerCnxnFactory.shutdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shutdownServerInstance

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
static void shutdownServerInstance(ServerCnxnFactory factory,
        String hostPort)
{
    if (factory != null) {
        ZKDatabase zkDb = null;
        {
            ZooKeeperServer zs = getServer(factory);
            if (zs != null) {
                zkDb = zs.getZKDatabase();
            }
        }
        factory.shutdown();
        try {
            if (zkDb != null) {
                zkDb.close();
            }
        } catch (IOException ie) {
            LOG.warn("Error closing logs ", ie);
        }
        final int PORT = getPort(hostPort);

        Assert.assertTrue("waiting for server down",
                   ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                CONNECTION_TIMEOUT));
    }
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:27,代碼來源:ClientBase.java

示例2: shutdownServerInstance

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
static void shutdownServerInstance(ServerCnxnFactory factory,
        String hostPort)
{
    if (factory != null) {
        ZKDatabase zkDb;
        {
            ZooKeeperServer zs = getServer(factory);
    
            zkDb = zs.getZKDatabase();
        }
        factory.shutdown();
        try {
            zkDb.close();
        } catch (IOException ie) {
            LOG.warn("Error closing logs ", ie);
        }
        final int PORT = getPort(hostPort);

        Assert.assertTrue("waiting for server down",
                   ClientBaseWithFixes.waitForServerDown("127.0.0.1:" + PORT,
                                                CONNECTION_TIMEOUT));
    }
}
 
開發者ID:yncxcw,項目名稱:big-c,代碼行數:24,代碼來源:ClientBaseWithFixes.java

示例3: testFail

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/** bring up 5 quorum peers and then shut them down
 * and then bring one of the nodes as server
 *
 * @throws Exception might be thrown here
 */
@Test
public void testFail() throws Exception {
    QuorumBase qb = new QuorumBase();
    qb.setUp();

    System.out.println("Comment: the servers are at " + qb.hostPort);
    ZooKeeper zk = qb.createClient();
    zk.create("/test", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    zk.close();
    qb.shutdown(qb.s1);
    qb.shutdown(qb.s2);
    qb.shutdown(qb.s3);
    qb.shutdown(qb.s4);
    qb.shutdown(qb.s5);
    String hp = qb.hostPort.split(",")[0];
    ZooKeeperServer zks = new ZooKeeperServer(qb.s1.getTxnFactory().getSnapDir(),
            qb.s1.getTxnFactory().getDataDir(), 3000);
    final int PORT = Integer.parseInt(hp.split(":")[1]);
    ServerCnxnFactory factory = ServerCnxnFactory.createFactory(PORT, -1);

    factory.startup(zks);
    System.out.println("Comment: starting factory");
    Assert.assertTrue("waiting for server up",
               ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                       QuorumTest.CONNECTION_TIMEOUT));
    factory.shutdown();
    zks.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                            QuorumTest.CONNECTION_TIMEOUT));
    System.out.println("Comment: shutting down standalone");
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:38,代碼來源:RepeatStartupTest.java

示例4: testPurge

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/**
 * test the purge
 * @throws Exception an exception might be thrown here
 */
@Test
public void testPurge() throws Exception {
    tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(100);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    Assert.assertTrue("waiting for server being up ",
            ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
    ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
    try {
        for (int i = 0; i< 2000; i++) {
            zk.create("/invalidsnap-" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                    CreateMode.PERSISTENT);
        }
    } finally {
        zk.close();
    }
    f.shutdown();
    zks.getTxnLogFactory().close();
    Assert.assertTrue("waiting for server to shutdown",
            ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
    // now corrupt the snapshot
    PurgeTxnLog.purge(tmpDir, tmpDir, 3);
    FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpDir, tmpDir);
    List<File> listLogs = snaplog.findNRecentSnapshots(4);
    int numSnaps = 0;
    for (File ff: listLogs) {
        if (ff.getName().startsWith("snapshot")) {
            numSnaps++;
        }
    }
    Assert.assertTrue("exactly 3 snapshots ", (numSnaps == 3));
    snaplog.close();
    zks.shutdown();
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:43,代碼來源:PurgeTxnTest.java

示例5: testSnapshot

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/**
 * test the snapshot
 * @throws Exception an exception could be expected
 */
@Test
public void testSnapshot() throws Exception {
    File snapDir = new File(testData, "invalidsnap");
    ZooKeeperServer zks = new ZooKeeperServer(snapDir, snapDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    LOG.info("starting up the zookeeper server .. waiting");
    Assert.assertTrue("waiting for server being up",
            ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
    ZooKeeper zk = new ZooKeeper(HOSTPORT, 20000, this);
    try {
        // we know this from the data files
        // this node is the last node in the snapshot

        Assert.assertTrue(zk.exists("/9/9/8", false) != null);
    } finally {
        zk.close();
    }
    f.shutdown();
    zks.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown(HOSTPORT,
                       ClientBase.CONNECTION_TIMEOUT));

}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:32,代碼來源:InvalidSnapshotTest.java

示例6: testDisconnectedAddAuth

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
@Test
public void testDisconnectedAddAuth() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    try {
        LOG.info("starting up the zookeeper server .. waiting");
        Assert.assertTrue("waiting for server being up",
                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
        try {
            zk.addAuthInfo("digest", "pat:test".getBytes());
            zk.setACL("/", Ids.CREATOR_ALL_ACL, -1);
        } finally {
            zk.close();
        }
    } finally {
        f.shutdown();
        zks.shutdown();
        Assert.assertTrue("waiting for server down",
                ClientBase.waitForServerDown(HOSTPORT,
                        ClientBase.CONNECTION_TIMEOUT));
    }
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:29,代碼來源:ACLTest.java

示例7: testPurge

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/**
 * test the purge
 * @throws Exception an exception might be thrown here
 */
@Test
public void testPurge() throws Exception {
    tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(100);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    Assert.assertTrue("waiting for server being up ",
            ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
    ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
    try {
        for (int i = 0; i< 2000; i++) {
            zk.create("/invalidsnap-" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                    CreateMode.PERSISTENT);
        }
    } finally {
        zk.close();
    }
    f.shutdown();
    zks.getTxnLogFactory().close();
    Assert.assertTrue("waiting for server to shutdown",
            ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));
    // now corrupt the snapshot
    PurgeTxnLog.purge(tmpDir, tmpDir, 3);
    FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpDir, tmpDir);
    List<File> listLogs = snaplog.findNRecentSnapshots(4);
    int numSnaps = 0;
    for (File ff: listLogs) {
        if (ff.getName().startsWith("snapshot")) {
            numSnaps++;
        }
    }
    Assert.assertTrue("exactly 3 snapshots ", (numSnaps == 3));
    snaplog.close();
    zks.shutdown();
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:43,代碼來源:PurgeTxnTest.java

示例8: testSnapshot

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/**
 * test the snapshot
 * @throws Exception an exception could be expected
 */
@Test
public void testSnapshot() throws Exception {
    File snapDir = new File(testData, "invalidsnap");
    ZooKeeperServer zks = new ZooKeeperServer(snapDir, snapDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    LOG.info("starting up the zookeeper server .. waiting");
    Assert.assertTrue("waiting for server being up",
            ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
    ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
    try {
        // we know this from the data files
        // this node is the last node in the snapshot

        Assert.assertTrue(zk.exists("/9/9/8", false) != null);
    } finally {
        zk.close();
    }
    f.shutdown();
    zks.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown(HOSTPORT,
                       ClientBase.CONNECTION_TIMEOUT));

}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:32,代碼來源:InvalidSnapshotTest.java

示例9: testDisconnectedAddAuth

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
@Test
public void testDisconnectedAddAuth() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    try {
        LOG.info("starting up the zookeeper server .. waiting");
        Assert.assertTrue("waiting for server being up",
                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
        ZooKeeper zk = ClientBase.createZKClient(HOSTPORT);
        try {
            zk.addAuthInfo("digest", "pat:test".getBytes());
            zk.setACL("/", Ids.CREATOR_ALL_ACL, -1);
        } finally {
            zk.close();
        }
    } finally {
        f.shutdown();
        zks.shutdown();
        Assert.assertTrue("waiting for server down",
                ClientBase.waitForServerDown(HOSTPORT,
                        ClientBase.CONNECTION_TIMEOUT));
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:29,代碼來源:ACLTest.java

示例10: testFail

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/** bring up 5 quorum peers and then shut them down
 * and then bring one of the nodes as server
 *
 * @throws Exception might be thrown here
 */
@Test
public void testFail() throws Exception {
    QuorumBase qb = new QuorumBase();
    qb.setUp();

    System.out.println("Comment: the servers are at " + qb.hostPort);
    ZooKeeper zk = qb.createClient();
    zk.create("/test", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    zk.close();
    QuorumBase.shutdown(qb.s1);
    QuorumBase.shutdown(qb.s2);
    QuorumBase.shutdown(qb.s3);
    QuorumBase.shutdown(qb.s4);
    QuorumBase.shutdown(qb.s5);
    String hp = qb.hostPort.split(",")[0];
    ZooKeeperServer zks = new ZooKeeperServer(qb.s1.getTxnFactory().getSnapDir(),
            qb.s1.getTxnFactory().getDataDir(), 3000);
    final int PORT = Integer.parseInt(hp.split(":")[1]);
    ServerCnxnFactory factory = ServerCnxnFactory.createFactory(PORT, -1);

    factory.startup(zks);
    System.out.println("Comment: starting factory");
    Assert.assertTrue("waiting for server up",
               ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                       QuorumTest.CONNECTION_TIMEOUT));
    factory.shutdown();
    zks.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                            QuorumTest.CONNECTION_TIMEOUT));
    System.out.println("Comment: shutting down standalone");
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:38,代碼來源:RepeatStartupTest.java

示例11: testUpgrade

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/**
 * test the upgrade
 * @throws Exception
 */
@Test
public void testUpgrade() throws Exception {
    File upgradeDir = new File(testData, "upgrade");
    UpgradeMain upgrade = new UpgradeMain(upgradeDir, upgradeDir);
    upgrade.runUpgrade();
    ZooKeeperServer zks = new ZooKeeperServer(upgradeDir, upgradeDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    LOG.info("starting up the zookeeper server .. waiting");
    Assert.assertTrue("waiting for server being up",
            ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
    ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
    Stat stat = zk.exists("/", false);
    List<String> children = zk.getChildren("/", false);
    Collections.sort(children);
    for (int i = 0; i < 10; i++) {
        Assert.assertTrue("data tree sanity check",
                ("test-" + i).equals(children.get(i)));
    }
    //try creating one node
    zk.create("/upgrade", "upgrade".getBytes(), Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    // check if its there
    if (zk.exists("/upgrade", false) == null) {
        Assert.assertTrue(false);
    }

    zk.close();

    // bring down the server
    f.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown(HOSTPORT,
                       ClientBase.CONNECTION_TIMEOUT));

}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:43,代碼來源:UpgradeTest.java

示例12: shutdownServerInstance

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
static void shutdownServerInstance(ServerCnxnFactory factory,
        String hostPort)
{
    if (factory != null) {
        ZKDatabase zkDb = null;
        {
            ZooKeeperServer zs = getServer(factory);
            if (zs != null) {
                zkDb = zs.getZKDatabase();
            }
        }
        factory.shutdown();
        try {
            if (zkDb != null) {
                zkDb.close();
            }
        } catch (IOException ie) {
            LOG.warn("Error closing logs ", ie);
        }
        final int PORT = getPort(hostPort);

        Assert.assertTrue("waiting for server down",
                   ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                                CONNECTION_TIMEOUT,
                                                factory.isSecure()));
    }
}
 
開發者ID:sereca,項目名稱:SecureKeeper,代碼行數:28,代碼來源:ClientBase.java

示例13: testRestoreCommittedLog

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/**
 * test the purge
 * @throws Exception an exception might be thrown here
 */
@Test
public void testRestoreCommittedLog() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(100);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    Assert.assertTrue("waiting for server being up ",
            ClientBase.waitForServerUp(HOSTPORT,CONNECTION_TIMEOUT));
    ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
    try {
        for (int i = 0; i< 2000; i++) {
            zk.create("/invalidsnap-" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                    CreateMode.PERSISTENT);
        }
    } finally {
        zk.close();
    }
    f.shutdown();
    zks.shutdown();
    Assert.assertTrue("waiting for server to shutdown",
            ClientBase.waitForServerDown(HOSTPORT, CONNECTION_TIMEOUT));

    // start server again
    zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    zks.startdata();
    LinkedList<Proposal> committedLog = zks.getZKDatabase().getCommittedLog();
    int logsize = committedLog.size();
    LOG.info("committedLog size = " + logsize);
    Assert.assertTrue("log size != 0", (logsize != 0));
    zks.shutdown();
}
 
開發者ID:jdc91,項目名稱:StreamProcessingInfrastructure,代碼行數:39,代碼來源:RestoreCommittedLogTest.java

示例14: testFail

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
/** bring up 5 quorum peers and then shut them down
 * and then bring one of the nodes as server
 *
 * @throws Exception might be thrown here
 */
@Test
public void testFail() throws Exception {
    QuorumBase qb = new QuorumBase();
    qb.setUp();

    System.out.println("Comment: the servers are at " + qb.hostPort);
    ZooKeeper zk = qb.createClient();
    zk.create("/test", null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    zk.close();
    qb.shutdown(qb.s1);
    qb.shutdown(qb.s2);
    qb.shutdown(qb.s3);
    qb.shutdown(qb.s4);
    qb.shutdown(qb.s5);
    String hp = qb.hostPort.split(",")[0];
    ZooKeeperServer zks = new ZooKeeperServer(qb.s1.getTxnFactory().getSnapDir(),
            qb.s1.getTxnFactory().getDataDir(), 3000);
    final int PORT = Integer.parseInt(hp.split(":")[1]);
    ServerCnxnFactory factory = ServerCnxnFactory.createFactory(PORT, -1);

    factory.startup(zks);
    System.out.println("Comment: starting factory");
    Assert.assertTrue("waiting for server up",
               ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                       QuorumTest.CONNECTION_TIMEOUT));
    factory.shutdown();
    Assert.assertTrue("waiting for server down",
               ClientBase.waitForServerDown("127.0.0.1:" + PORT,
                                            QuorumTest.CONNECTION_TIMEOUT));
    System.out.println("Comment: shutting down standalone");
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:37,代碼來源:RepeatStartupTest.java

示例15: testDisconnectedAddAuth

import org.apache.zookeeper.server.ServerCnxnFactory; //導入方法依賴的package包/類
@Test
public void testDisconnectedAddAuth() throws Exception {
    File tmpDir = ClientBase.createTmpDir();
    ClientBase.setupTestEnv();
    ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    SyncRequestProcessor.setSnapCount(1000);
    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    f.startup(zks);
    try {
        LOG.info("starting up the zookeeper server .. waiting");
        Assert.assertTrue("waiting for server being up",
                ClientBase.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT));
        ZooKeeper zk = new ZooKeeper(HOSTPORT, CONNECTION_TIMEOUT, this);
        try {
            zk.addAuthInfo("digest", "pat:test".getBytes());
            zk.setACL("/", Ids.CREATOR_ALL_ACL, -1);
        } finally {
            zk.close();
        }
    } finally {
        f.shutdown();

        Assert.assertTrue("waiting for server down",
                ClientBase.waitForServerDown(HOSTPORT,
                        ClientBase.CONNECTION_TIMEOUT));
    }
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:29,代碼來源:ACLTest.java


注:本文中的org.apache.zookeeper.server.ServerCnxnFactory.shutdown方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。