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


Java QuorumPeerConfig類代碼示例

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


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

示例1: startFakeCluster

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
/**
 * 啟動偽集群模式
 * @param config
 * @throws IOException
 * @throws InterruptedException
 * @throws ConfigException
 */
public void startFakeCluster(QuorumPeerConfig config) throws IOException{

	ServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
	cnxnFactory.configure(config.getClientPortAddress(), config.getMaxClientCnxns());

	QuorumPeer quorumPeer = new QuorumPeer(config.getServers(), config.getDataDir(), config.getDataLogDir(), config.getElectionAlg(), config.getServerId(), config.getTickTime(), config.getInitLimit(), config.getSyncLimit(), config.getQuorumListenOnAllIPs(), cnxnFactory, config.getQuorumVerifier());
	quorumPeer.setClientAddress(config.getClientPortAddress());
	quorumPeer.setTxnFactory(new FileTxnSnapLog(config.getDataLogDir(), config.getDataDir()));
	quorumPeer.setElectionType(config.getElectionAlg());
	quorumPeer.setMyid(config.getServerId());
	quorumPeer.setTickTime(config.getTickTime());
	quorumPeer.setMinSessionTimeout(config.getMinSessionTimeout());
	quorumPeer.setMaxSessionTimeout(config.getMaxSessionTimeout());
	quorumPeer.setInitLimit(config.getInitLimit());
	quorumPeer.setSyncLimit(config.getSyncLimit());
	quorumPeer.setQuorumVerifier(config.getQuorumVerifier(), true);
	quorumPeer.setCnxnFactory(cnxnFactory);
	quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory()));
	quorumPeer.setLearnerType(config.getPeerType());
	quorumPeer.setSyncEnabled(config.getSyncEnabled());
	quorumPeer.setQuorumListenOnAllIPs(config.getQuorumListenOnAllIPs());

	quorumPeer.start();
	LOGGER.info("ZkServerCluster Started! ClientPortAddress={}", config.getClientPortAddress());
}
 
開發者ID:all4you,項目名稱:redant,代碼行數:33,代碼來源:ZkServer.java

示例2: setup

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
@Before
public void setup() throws InterruptedException {
    System.setProperty(authProvider, superDigest);
    QuorumPeerConfig.setReconfigEnabled(true);

    // Get a three server quorum.
    qu = new QuorumUtil(1);
    qu.disableJMXTest = true;

    try {
        qu.startAll();
    } catch (IOException e) {
        Assert.fail("Fail to start quorum servers.");
    }

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

示例3: startZkLocal

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
private static void startZkLocal() throws Exception {
    final File zkTmpDir = File.createTempFile("zookeeper", "test");
    if (zkTmpDir.delete() && zkTmpDir.mkdir()) {
        Properties zkProperties = new Properties();
        zkProperties.setProperty("dataDir", zkTmpDir.getAbsolutePath());
        zkProperties.setProperty("clientPort", String.valueOf(ZK_PORT));

        ServerConfig configuration = new ServerConfig();
        QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig();
        quorumConfiguration.parseProperties(zkProperties);
        configuration.readFrom(quorumConfiguration);

        new Thread() {
            public void run() {
                try {
                    new ZooKeeperServerMain().runFromConfig(configuration);
                } catch (IOException e) {
                    System.out.println("Start of Local ZooKeeper Failed");
                    e.printStackTrace(System.err);
                }
            }
        }.start();
    } else {
        System.out.println("Failed to delete or create data dir for Zookeeper");
    }
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:27,代碼來源:KafkaDemoClient.java

示例4: main

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
/**
 * Parse ZooKeeper configuration from HBase XML config and run a QuorumPeer.
 * @param args String[] of command line arguments. Not used.
 */
public static void main(String[] args) {
  Configuration conf = HBaseConfiguration.create();
  try {
    Properties zkProperties = ZKConfig.makeZKProps(conf);
    writeMyID(zkProperties);
    QuorumPeerConfig zkConfig = new QuorumPeerConfig();
    zkConfig.parseProperties(zkProperties);

    // login the zookeeper server principal (if using security)
    ZKUtil.loginServer(conf, HConstants.ZK_SERVER_KEYTAB_FILE,
      HConstants.ZK_SERVER_KERBEROS_PRINCIPAL,
      zkConfig.getClientPortAddress().getHostName());

    runZKServer(zkConfig);
  } catch (Exception e) {
    e.printStackTrace();
    System.exit(-1);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:HQuorumPeer.java

示例5: testUpdateConfig

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public void testUpdateConfig() throws Exception {
    final File tempDir = new File("target");
    IMocksControl control = EasyMock.createControl();
    BundleContext bc = control.createMock(BundleContext.class);
    expect(bc.getDataFile("")).andReturn(tempDir);
    final MyZooKeeperServerMain mockServer = control.createMock(MyZooKeeperServerMain.class);
    control.replay();

    ZookeeperStarter starter = new ZookeeperStarter(bc) {
        @Override
        protected void startFromConfig(QuorumPeerConfig config) {
            assertEquals(1234, config.getClientPortAddress().getPort());
            assertTrue(config.getDataDir().contains(tempDir + File.separator + "zkdata"));
            assertEquals(2000, config.getTickTime());
            assertEquals(10, config.getInitLimit());
            assertEquals(5, config.getSyncLimit());
            this.main = mockServer;
        }
    };
    Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put("clientPort", "1234");
    starter.updated(props);
    assertNotNull(starter.main);

    control.verify();
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:27,代碼來源:ZookeeperStarterTest.java

示例6: main

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
/**
 * Parse ZooKeeper configuration from HBase XML config and run a QuorumPeer.
 * @param args String[] of command line arguments. Not used.
 */
public static void main(String[] args) {
  Configuration conf = HBaseConfiguration.create();
  try {
    Properties zkProperties = ZKConfig.makeZKProps(conf);
    writeMyID(zkProperties);
    QuorumPeerConfig zkConfig = new QuorumPeerConfig();
    zkConfig.parseProperties(zkProperties);

    // login the zookeeper server principal (if using security)
    ZKUtil.loginServer(conf, "hbase.zookeeper.server.keytab.file",
      "hbase.zookeeper.server.kerberos.principal",
      zkConfig.getClientPortAddress().getHostName());

    runZKServer(zkConfig);
  } catch (Exception e) {
    e.printStackTrace();
    System.exit(-1);
  }
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:24,代碼來源:HQuorumPeer.java

示例7: TestingZookeeperServerEmbedded

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public TestingZookeeperServerEmbedded(int clientPort, File baseDir) throws Exception {
    Properties p = new Properties();
    String host = "localhost";
    String dataDir = "data";
    File dir = new File(baseDir, dataDir);
    p.setProperty("syncEnabled", "false");
    p.setProperty("dataDir", dir.getAbsolutePath());
    p.setProperty("clientPort", clientPort + "");
    p.setProperty("authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
    p.setProperty("kerberos.removeHostFromPrincipal", "true");
    p.setProperty("kerberos.removeRealmFromPrincipal", "true");

    config = new QuorumPeerConfig();

    config.parseProperties(p);

}
 
開發者ID:diennea,項目名稱:majordodo,代碼行數:18,代碼來源:TestingZookeeperServerEmbedded.java

示例8: TestingZookeeperServerEmbedded

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public TestingZookeeperServerEmbedded(int clientPort, File baseDir) throws Exception {
    this.clientPort = clientPort;
    Properties p = new Properties();
    String host = "localhost";
    String dataDir = "data";
    File dir = new File(baseDir, dataDir);
    p.setProperty("syncEnabled", "false");
    p.setProperty("dataDir", dir.getAbsolutePath());
    p.setProperty("clientPort", clientPort + "");
    p.setProperty("authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
    p.setProperty("kerberos.removeHostFromPrincipal", "true");
    p.setProperty("kerberos.removeRealmFromPrincipal", "true");

    config = new QuorumPeerConfig();

    config.parseProperties(p);

}
 
開發者ID:diennea,項目名稱:blazingcache,代碼行數:19,代碼來源:TestingZookeeperServerEmbedded.java

示例9: start

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public void start() throws Exception
{
    if ( !state.compareAndSet(State.LATENT, State.STARTED) )
    {
        return;
    }

    new Thread(new Runnable()
    {
        public void run()
        {
            try
            {
                QuorumPeerConfig config = configBuilder.buildConfig(thisInstanceIndex);
                main.runFromConfig(config);
            }
            catch ( Exception e )
            {
                logger.error(String.format("From testing server (random state: %s) for instance: %s", String.valueOf(configBuilder.isFromRandom()), getInstanceSpec()), e);
            }
        }
    }).start();

    main.blockUntilStarted();
}
 
開發者ID:apache,項目名稱:curator,代碼行數:26,代碼來源:TestingZooKeeperServer.java

示例10: create

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr = new DatadirCleanupManager(
      zkConfig.getDataDir(), 
      zkConfig.getDataLogDir(), 
      zkConfig.getSnapRetainCount(), 
      zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    logger.warn(
      "Either no config or no quorum defined in config, running in standalone mode"
    );
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig) ;
  }
}
 
開發者ID:DemandCube,項目名稱:NeverwinterDP-Commons,代碼行數:21,代碼來源:ZookeeperClusterService.java

示例11: create

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
ZookeeperLaucher create(Properties zkProperties) throws ConfigException, IOException {
  QuorumPeerConfig zkConfig = new QuorumPeerConfig();
  zkConfig.parseProperties(zkProperties);
  DatadirCleanupManager purgeMgr =
      new DatadirCleanupManager(zkConfig.getDataDir(), zkConfig.getDataLogDir(),
          zkConfig.getSnapRetainCount(), zkConfig.getPurgeInterval());
  purgeMgr.start();

  if (zkConfig.getServers().size() > 0) {
    return new QuorumPeerMainExt(zkConfig);
  } else {
    System.out
        .println("Either no config or no quorum defined in config, running in standalone mode");
    // there is only server in the quorum -- run as standalone
    return new ZooKeeperServerMainExt(zkConfig);
  }
}
 
開發者ID:DemandCube,項目名稱:Scribengin,代碼行數:18,代碼來源:EmbededZKServer.java

示例12: SpliceZoo

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public SpliceZoo(QuorumPeerConfig config, int number) throws IOException {
	this.config = config;
	ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
	cnxnFactory.configure(config.getClientPortAddress(),config.getMaxClientCnxns());

	peer = new QuorumPeer(config.getServers(), null, null, config.getElectionAlg(),
			number, config.getTickTime(), config.getInitLimit(), config.getSyncLimit(), cnxnFactory);

	peer.setClientPortAddress(config.getClientPortAddress());
	peer.setTxnFactory(new FileTxnSnapLog(new File(config.getDataLogDir()),
                    new File(config.getDataDir())));
	peer.setQuorumPeers(config.getServers());
	peer.setElectionType(config.getElectionAlg());
	peer.setMyid(config.getServerId());
	peer.setTickTime(config.getTickTime());
	peer.setMinSessionTimeout(config.getMinSessionTimeout());
	peer.setMaxSessionTimeout(config.getMaxSessionTimeout());
	peer.setInitLimit(config.getInitLimit());
	peer.setSyncLimit(config.getSyncLimit());
	peer.setQuorumVerifier(config.getQuorumVerifier());
	peer.setCnxnFactory(cnxnFactory);
	peer.setZKDatabase(new ZKDatabase(peer.getTxnFactory()));
	peer.setLearnerType(config.getPeerType());
	peer.setMyid(number);

}
 
開發者ID:splicemachine,項目名稱:spliceengine,代碼行數:27,代碼來源:SpliceZoo.java

示例13: SpliceZoo

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public SpliceZoo(QuorumPeerConfig config, int number) throws IOException {
	this.config = config;
	this.peer = new QuorumPeer();
	ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
	cnxnFactory.configure(config.getClientPortAddress(),config.getMaxClientCnxns());
	peer.setClientPortAddress(config.getClientPortAddress());
	peer.setTxnFactory(new FileTxnSnapLog(new File(config.getDataLogDir()),
                    new File(config.getDataDir())));
	peer.setQuorumPeers(config.getServers());
	peer.setElectionType(config.getElectionAlg());
	peer.setMyid(config.getServerId());
	peer.setTickTime(config.getTickTime());
	peer.setMinSessionTimeout(config.getMinSessionTimeout());
	peer.setMaxSessionTimeout(config.getMaxSessionTimeout());
	peer.setInitLimit(config.getInitLimit());
	peer.setSyncLimit(config.getSyncLimit());
	peer.setQuorumVerifier(config.getQuorumVerifier());
	peer.setCnxnFactory(cnxnFactory);
	peer.setZKDatabase(new ZKDatabase(peer.getTxnFactory()));
	peer.setLearnerType(config.getPeerType());
	peer.setMyid(number);
}
 
開發者ID:splicemachine,項目名稱:spliceengine,代碼行數:23,代碼來源:SpliceZoo.java

示例14: SpliceZoo

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
public SpliceZoo(QuorumPeerConfig config, int number) throws IOException {
	this.config = config;
	ServerCnxnFactory cnxnFactory = ServerCnxnFactory.createFactory();
	cnxnFactory.configure(config.getClientPortAddress(),config.getMaxClientCnxns());
	peer.setClientPortAddress(config.getClientPortAddress());
	peer.setTxnFactory(new FileTxnSnapLog(new File(config.getDataLogDir()),
                    new File(config.getDataDir())));
	peer.setQuorumPeers(config.getServers());
	peer.setElectionType(config.getElectionAlg());
	peer.setMyid(config.getServerId());
	peer.setTickTime(config.getTickTime());
	peer.setMinSessionTimeout(config.getMinSessionTimeout());
	peer.setMaxSessionTimeout(config.getMaxSessionTimeout());
	peer.setInitLimit(config.getInitLimit());
	peer.setSyncLimit(config.getSyncLimit());
	peer.setQuorumVerifier(config.getQuorumVerifier());
	peer.setCnxnFactory(cnxnFactory);
	peer.setZKDatabase(new ZKDatabase(peer.getTxnFactory()));
	peer.setLearnerType(config.getPeerType());
	peer.setMyid(number);
}
 
開發者ID:splicemachine,項目名稱:spliceengine,代碼行數:22,代碼來源:SpliceZoo.java

示例15: parse

import org.apache.zookeeper.server.quorum.QuorumPeerConfig; //導入依賴的package包/類
/**
 * Parse a ZooKeeper configuration file
 * @param path the patch of the configuration file
 * @return ServerConfig configured wrt arguments
 * @throws ConfigException error processing configuration
 */
public void parse(String path) throws ConfigException {
    QuorumPeerConfig config = new QuorumPeerConfig();
    config.parse(path);

    // let qpconfig parse the file and then pull the stuff we are
    // interested in
    readFrom(config);
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:15,代碼來源:ServerConfig.java


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