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


Java ServerCnxnFactory類代碼示例

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


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

示例1: createNewServerInstance

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
static ServerCnxnFactory createNewServerInstance(File dataDir,
        ServerCnxnFactory factory, String hostPort, int maxCnxns)
    throws IOException, InterruptedException
{
    ZooKeeperServer zks = new ZooKeeperServer(dataDir, dataDir, 3000);
    final int PORT = getPort(hostPort);
    if (factory == null) {
        factory = ServerCnxnFactory.createFactory(PORT, maxCnxns);
    }
    factory.startup(zks);
    Assert.assertTrue("waiting for server up",
               ClientBaseWithFixes.waitForServerUp("127.0.0.1:" + PORT,
                                          CONNECTION_TIMEOUT));

    return factory;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:17,代碼來源:ClientBaseWithFixes.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:nucypher,項目名稱:hadoop-oss,代碼行數:24,代碼來源:ClientBaseWithFixes.java

示例3: QuorumPeer

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
        File dataLogDir, int electionType,
        long myid, int tickTime, int initLimit, int syncLimit,
        boolean quorumListenOnAllIPs,
        ServerCnxnFactory cnxnFactory, 
        QuorumVerifier quorumConfig) throws IOException {
    this();
    this.cnxnFactory = cnxnFactory;
    this.quorumPeers = quorumPeers;
    this.electionType = electionType;
    this.myid = myid;
    this.tickTime = tickTime;
    this.initLimit = initLimit;
    this.syncLimit = syncLimit;        
    this.quorumListenOnAllIPs = quorumListenOnAllIPs;
    this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
    this.zkDb = new ZKDatabase(this.logFactory);
    if(quorumConfig == null)
        this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers));
    else this.quorumConfig = quorumConfig;
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:22,代碼來源:QuorumPeer.java

示例4: setUp

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    if (tmpDir == null) {
        tmpDir = ClientBase.createTmpDir();
    }

    ClientBase.setupTestEnv();
    zs = new ZooKeeperServer(tmpDir, tmpDir, TICK_TIME);

    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    serverFactory = ServerCnxnFactory.createFactory(PORT, -1);
    serverFactory.startup(zs);

    Assert.assertTrue("waiting for server up",
               ClientBase.waitForServerUp(HOSTPORT,
                                          CONNECTION_TIMEOUT));
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:18,代碼來源:SessionTest.java

示例5: startServerInstance

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
/**
 * Starting the given server instance
 */
public static void startServerInstance(File dataDir,
        ServerCnxnFactory factory, String hostPort) throws IOException,
        InterruptedException {
    final int port = getPort(hostPort);
    LOG.info("STARTING server instance 127.0.0.1:{}", port);
    ZooKeeperServer zks = new ZooKeeperServer(dataDir, dataDir, 3000);
    factory.startup(zks);
    Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
            "127.0.0.1:" + port, CONNECTION_TIMEOUT));
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:14,代碼來源:ClientBase.java

示例6: 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:maoling,項目名稱:fuck_zookeeper,代碼行數:27,代碼來源:ClientBase.java

示例7: setUp

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    String testDataPath = System.getProperty("test.data.dir", "build/test/data");
    System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, "org.apache.zookeeper.server.NettyServerCnxnFactory");
    System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
    System.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
    System.setProperty(ZKConfig.SSL_AUTHPROVIDER, "x509");
    System.setProperty(ZKConfig.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testKeyStore.jks");
    System.setProperty(ZKConfig.SSL_KEYSTORE_PASSWD, "testpass");
    System.setProperty(ZKConfig.SSL_TRUSTSTORE_LOCATION, testDataPath + "/ssl/testTrustStore.jks");
    System.setProperty(ZKConfig.SSL_TRUSTSTORE_PASSWD, "testpass");
    System.setProperty("javax.net.debug", "ssl");
    System.setProperty("zookeeper.authProvider.x509", "org.apache.zookeeper.server.auth.X509AuthenticationProvider");

    String host = "localhost";
    int port = PortAssignment.unique();
    hostPort = host + ":" + port;

    serverFactory = ServerCnxnFactory.createFactory();
    serverFactory.configure(new InetSocketAddress(host, port), maxCnxns, true);

    super.setUp();
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:24,代碼來源:SSLAuthTest.java

示例8: start

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
@Override
public Future<Unit> start() {
	return Future(() -> {
		ZooKeeperServer zkServer = new ZooKeeperServer();
		FileTxnSnapLog log = new FileTxnSnapLog(new File(rootZooDir, "dataDir"), new File(rootZooDir, "snapDir"));
		zkServer.setTxnLogFactory(log);
		zkServer.setTickTime(2000);
		zkServer.setMinSessionTimeout(10000);
		zkServer.setMaxSessionTimeout(10000);
		ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
		cnxnFactory.configure(new InetSocketAddress(cfgPort), maxClientConnections);
		cnxnFactory.startup(zkServer);
           zkInstanceHolder = Some(new ZKInstanceHolder(log, cnxnFactory));
		//remember the port. if 0 was provided then ZK will pick a free port
		//it must be remembered for the scenario of restarting this instance
		//in such case we want to get the same port again
		cfgPort = cnxnFactory.getLocalPort();
	});
}
 
開發者ID:pnerg,項目名稱:zookeeper-junit,代碼行數:20,代碼來源:ZKInstanceImpl.java

示例9: setUp

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    if (tmpDir == null) {
        tmpDir = ClientBase.createTmpDir();
    }

    ClientBase.setupTestEnv();
    ZooKeeperServer zs = new ZooKeeperServer(tmpDir, tmpDir, TICK_TIME);

    final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
    serverFactory = ServerCnxnFactory.createFactory(PORT, -1);
    serverFactory.startup(zs);

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

示例10: createNewServerInstance

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
static ServerCnxnFactory createNewServerInstance(File dataDir,
        ServerCnxnFactory factory, String hostPort, int maxCnxns)
    throws IOException, InterruptedException
{
    ZooKeeperServer zks = new ZooKeeperServer(dataDir, dataDir, 3000);
    final int PORT = getPort(hostPort);
    if (factory == null) {
        factory = ServerCnxnFactory.createFactory(PORT, maxCnxns);
    }
    factory.startup(zks);
    Assert.assertTrue("waiting for server up",
               ClientBase.waitForServerUp("127.0.0.1:" + PORT,
                                          CONNECTION_TIMEOUT));

    return factory;
}
 
開發者ID:gerritjvv,項目名稱:bigstreams,代碼行數:17,代碼來源:ClientBase.java

示例11: setUp

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    String testDataPath = System.getProperty("test.data.dir", "build/test/data");
    System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, "org.apache.zookeeper.server.NettyServerCnxnFactory");
    System.setProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
    System.setProperty(ZooKeeper.SECURE_CLIENT, "true");
    System.setProperty(X509Util.SSL_AUTHPROVIDER, "x509");
    System.setProperty(X509Util.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testKeyStore.jks");
    System.setProperty(X509Util.SSL_KEYSTORE_PASSWD, "testpass");
    System.setProperty(X509Util.SSL_TRUSTSTORE_LOCATION, testDataPath + "/ssl/testTrustStore.jks");
    System.setProperty(X509Util.SSL_TRUSTSTORE_PASSWD, "testpass");
    System.setProperty("javax.net.debug", "ssl");

    String host = "localhost";
    int port = PortAssignment.unique();
    hostPort = host + ":" + port;

    serverFactory = ServerCnxnFactory.createFactory();
    serverFactory.configure(new InetSocketAddress(host, port), maxCnxns, true);

    super.setUp();
}
 
開發者ID:sereca,項目名稱:SecureKeeper,代碼行數:23,代碼來源:SSLAuthTest.java

示例12: getMaxClientCnxnsPerHost

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
/** Maximum number of connections allowed from particular host (ip) */
public int getMaxClientCnxnsPerHost() {
    ServerCnxnFactory fac = getCnxnFactory();
    if (fac == null) {
        return -1;
    }
    return fac.getMaxClientCnxnsPerHost();
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:9,代碼來源:QuorumPeer.java

示例13: 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

示例14: MockQuorumPeer

import org.apache.zookeeper.server.ServerCnxnFactory; //導入依賴的package包/類
public MockQuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
        File logDir, int clientPort, int electionAlg,
        long myid, int tickTime, int initLimit, int syncLimit)
throws IOException
{
    super(quorumPeers, snapDir, logDir, electionAlg,
            myid,tickTime, initLimit,syncLimit, false,
            ServerCnxnFactory.createFactory(clientPort, -1),
            new QuorumMaj(countParticipants(quorumPeers)));
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:11,代碼來源:LENonTerminateTest.java

示例15: 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


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