当前位置: 首页>>代码示例>>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;未经允许,请勿转载。