org.apache.zookeeper.server.ZooKeeperServer#setTxnLogFactory ( )源码实例Demo

下面列出了org.apache.zookeeper.server.ZooKeeperServer#setTxnLogFactory ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RDFS   文件: MiniAvatarCluster.java
public static void createAndStartZooKeeper() 
  throws IOException, ConfigException, InterruptedException {
  ServerConfig zkConf = createZooKeeperConf();

  zooKeeper = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new 
    FileTxnSnapLog(new File(zkConf.getDataLogDir()),
                   new File(zkConf.getDataDir()));
  zooKeeper.setTxnLogFactory(ftxn);
  zooKeeper.setTickTime(zkConf.getTickTime());
  zooKeeper.setMinSessionTimeout(zkConf.getMinSessionTimeout());
  zooKeeper.setMaxSessionTimeout(zkConf.getMaxSessionTimeout());

  cnxnFactory =
    new NIOServerCnxn.Factory(zkConf.getClientPortAddress(),
                              zkConf.getMaxClientCnxns());
  cnxnFactory.startup(zooKeeper);

}
 
源代码2 项目: wildfly-camel   文件: EmbeddedZookeeper.java
public EmbeddedZookeeper(int port, Path baseDir) throws Exception {
    this.port = port;

    zookeeperBaseDir = baseDir;

    zkServer = new ZooKeeperServer();
    File dataDir = zookeeperBaseDir.resolve("log").toFile();
    File snapDir = zookeeperBaseDir.resolve("data").toFile();
    FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);
    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(1000);
    connectionFactory = new NIOServerCnxnFactory() {
        @Override
        protected void configureSaslLogin() throws IOException {
            // do nothing
        }
    };
    connectionFactory.configure(new InetSocketAddress("localhost", port), 0);
}
 
源代码3 项目: camel-spring-boot   文件: ZookeeperServer.java
public ZookeeperServer(File root) throws IOException, InterruptedException {
    zkServer = new ZooKeeperServer();

    File dataDir = new File(root, "log");
    File snapDir = new File(root, "data");
    FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, snapDir);

    zkServer.setTxnLogFactory(ftxn);
    zkServer.setTickTime(1000);

    connectionFactory = new NIOServerCnxnFactory();
    connectionFactory.configure(new InetSocketAddress("localhost", SocketUtils.findAvailableTcpPort()), 0);
    connectionFactory.startup(zkServer);
}
 
源代码4 项目: hadoop   文件: MicroZookeeperService.java
/**
 * Startup: start ZK. It is only after this that
 * the binding information is valid.
 * @throws Exception
 */
@Override
protected void serviceStart() throws Exception {

  setupSecurity();

  ZooKeeperServer zkServer = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
  zkServer.setTxnLogFactory(ftxn);
  zkServer.setTickTime(tickTime);

  LOG.info("Starting Local Zookeeper service");
  factory = ServerCnxnFactory.createFactory();
  factory.configure(getAddress(port), -1);
  factory.startup(zkServer);

  String connectString = getConnectionString();
  LOG.info("In memory ZK started at {}\n", connectString);

  if (LOG.isDebugEnabled()) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    zkServer.dumpConf(pw);
    pw.flush();
    LOG.debug(sw.toString());
  }
  binding = new BindingInformation();
  binding.ensembleProvider = new FixedEnsembleProvider(connectString);
  binding.description =
      getName() + " reachable at \"" + connectString + "\"";

  addDiagnostics(binding.description);
  // finally: set the binding information in the config
  getConfig().set(KEY_REGISTRY_ZK_QUORUM, connectString);
}
 
源代码5 项目: twill   文件: InMemoryZKServer.java
@Override
protected void startUp() throws Exception {
  ZooKeeperServer zkServer = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
  zkServer.setTxnLogFactory(ftxn);
  zkServer.setTickTime(tickTime);

  factory = ServerCnxnFactory.createFactory();
  factory.configure(getAddress(port), -1);
  factory.startup(zkServer);

  LOG.info("In memory ZK started: " + getConnectionStr());
}
 
源代码6 项目: big-c   文件: MicroZookeeperService.java
/**
 * Startup: start ZK. It is only after this that
 * the binding information is valid.
 * @throws Exception
 */
@Override
protected void serviceStart() throws Exception {

  setupSecurity();

  ZooKeeperServer zkServer = new ZooKeeperServer();
  FileTxnSnapLog ftxn = new FileTxnSnapLog(dataDir, dataDir);
  zkServer.setTxnLogFactory(ftxn);
  zkServer.setTickTime(tickTime);

  LOG.info("Starting Local Zookeeper service");
  factory = ServerCnxnFactory.createFactory();
  factory.configure(getAddress(port), -1);
  factory.startup(zkServer);

  String connectString = getConnectionString();
  LOG.info("In memory ZK started at {}\n", connectString);

  if (LOG.isDebugEnabled()) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    zkServer.dumpConf(pw);
    pw.flush();
    LOG.debug(sw.toString());
  }
  binding = new BindingInformation();
  binding.ensembleProvider = new FixedEnsembleProvider(connectString);
  binding.description =
      getName() + " reachable at \"" + connectString + "\"";

  addDiagnostics(binding.description);
  // finally: set the binding information in the config
  getConfig().set(KEY_REGISTRY_ZK_QUORUM, connectString);
}
 
源代码7 项目: tajo   文件: EmbeddedZookeeper.java
public EmbeddedZookeeper(int port) throws IOException {
  zkDataDir = Files.createTempDir();
  zkServer = new ZooKeeperServer();

  FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir);
  zkServer.setTxnLogFactory(ftxn);

  cnxnFactory = new NIOServerCnxnFactory();
  cnxnFactory.configure(new InetSocketAddress(port), 0);
}
 
源代码8 项目: jesos   文件: EmbeddedZookeeper.java
public EmbeddedZookeeper(final int port)
                throws IOException
{
    this.port = port;
    zkDataDir = Files.createTempDir();
    zkServer = new ZooKeeperServer();

    final FileTxnSnapLog ftxn = new FileTxnSnapLog(zkDataDir, zkDataDir);
    zkServer.setTxnLogFactory(ftxn);

    cnxnFactory = new NIOServerCnxn.Factory(new InetSocketAddress(this.port), 0);
}
 
源代码9 项目: oryx   文件: LocalZKServer.java
/**
 * Starts Zookeeper.
 *
 * @throws IOException if an error occurs during initialization
 * @throws InterruptedException if an error occurs during initialization
 */
public synchronized void start() throws IOException, InterruptedException {
  log.info("Starting Zookeeper on port {}", port);

  dataDir = Files.createTempDirectory(LocalZKServer.class.getSimpleName());
  dataDir.toFile().deleteOnExit();

  QuorumPeerConfig quorumConfig = new QuorumPeerConfig();
  try {
    quorumConfig.parseProperties(ConfigUtils.keyValueToProperties(
        "dataDir", dataDir.toAbsolutePath(),
        "clientPort", port
    ));
  } catch (QuorumPeerConfig.ConfigException e) {
    throw new IllegalArgumentException(e);
  }

  purgeManager =
      new DatadirCleanupManager(quorumConfig.getDataDir(),
                                quorumConfig.getDataLogDir(),
                                quorumConfig.getSnapRetainCount(),
                                quorumConfig.getPurgeInterval());
  purgeManager.start();

  ServerConfig serverConfig = new ServerConfig();
  serverConfig.readFrom(quorumConfig);

  zkServer = new ZooKeeperServer();
  zkServer.setTickTime(serverConfig.getTickTime());
  zkServer.setMinSessionTimeout(serverConfig.getMinSessionTimeout());
  zkServer.setMaxSessionTimeout(serverConfig.getMaxSessionTimeout());

  // These two ServerConfig methods returned String in 3.4.x and File in 3.5.x
  transactionLog = new FileTxnSnapLog(new File(serverConfig.getDataLogDir().toString()),
                                      new File(serverConfig.getDataDir().toString()));
  zkServer.setTxnLogFactory(transactionLog);

  connectionFactory = ServerCnxnFactory.createFactory();
  connectionFactory.configure(serverConfig.getClientPortAddress(), serverConfig.getMaxClientCnxns());
  connectionFactory.startup(zkServer);
}