当前位置: 首页>>代码示例>>Java>>正文


Java ZooKeeperServer类代码示例

本文整理汇总了Java中org.apache.zookeeper.server.ZooKeeperServer的典型用法代码示例。如果您正苦于以下问题:Java ZooKeeperServer类的具体用法?Java ZooKeeperServer怎么用?Java ZooKeeperServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ZooKeeperServer类属于org.apache.zookeeper.server包,在下文中一共展示了ZooKeeperServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shutdownServerInstance

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的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

示例2: MiniZKFCCluster

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
public MiniZKFCCluster(Configuration conf, ZooKeeperServer zks) {
  this.conf = conf;
  // Fast check interval so tests run faster
  conf.setInt(CommonConfigurationKeys.HA_HM_CHECK_INTERVAL_KEY, 50);
  conf.setInt(CommonConfigurationKeys.HA_HM_CONNECT_RETRY_INTERVAL_KEY, 50);
  conf.setInt(CommonConfigurationKeys.HA_HM_SLEEP_AFTER_DISCONNECT_KEY, 50);
  svcs = new ArrayList<DummyHAService>(2);
  // remove any existing instances we are keeping track of
  DummyHAService.instances.clear();

  for (int i = 0; i < 2; i++) {
    addSvcs(svcs, i);
  }

  this.ctx = new TestContext();
  this.zks = zks;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:MiniZKFCCluster.java

示例3: startServerInstance

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的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

示例4: shutdownServerInstance

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的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

示例5: run

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
@Override
public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
    CommandResponse response = initializeResponse();
    long traceMask;
    if (!kwargs.containsKey("traceMask")) {
        response.put("error", "setTraceMask requires long traceMask argument");
        return response;
    }
    try {
        traceMask = Long.parseLong(kwargs.get("traceMask"));
    } catch (NumberFormatException e) {
        response.put("error", "setTraceMask requires long traceMask argument, got "
                              + kwargs.get("traceMask"));
        return response;
    }

    ZooTrace.setTextTraceLevel(traceMask);
    response.put("tracemask", traceMask);
    return response;
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:Commands.java

示例6: setupZooKeeper

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
@BeforeClass
public static void setupZooKeeper() throws Exception {
  LOG.info("Starting ZK server");
  zkTmpDir = File.createTempFile("zookeeper", "test");
  zkTmpDir.delete();
  zkTmpDir.mkdir();
  try {
    zks = new ZooKeeperServer(zkTmpDir, zkTmpDir, ZooKeeperDefaultPort);
    serverFactory = new NIOServerCnxnFactory();
    serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
    serverFactory.startup(zks);
  } catch (Exception e) {
    LOG.error("Exception while instantiating ZooKeeper", e);
  }
  boolean b = LocalBookKeeper.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
  LOG.debug("ZooKeeper server up: " + b);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestCurrentInprogress.java

示例7: setupZooKeeper

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
@BeforeClass
public static void setupZooKeeper() throws Exception {
  // create a ZooKeeper server(dataDir, dataLogDir, port)
  LOG.info("Starting ZK server");
  ZkTmpDir = File.createTempFile("zookeeper", "test");
  ZkTmpDir.delete();
  ZkTmpDir.mkdir();

  try {
    zks = new ZooKeeperServer(ZkTmpDir, ZkTmpDir, ZooKeeperDefaultPort);
    serverFactory = new NIOServerCnxnFactory();
    serverFactory.configure(new InetSocketAddress(ZooKeeperDefaultPort), 10);
    serverFactory.startup(zks);
  } catch (Exception e) {
    LOG.error("Exception while instantiating ZooKeeper", e);
  }

  boolean b = LocalBookKeeper.waitForServerUp(HOSTPORT, CONNECTION_TIMEOUT);
  LOG.debug("ZooKeeper server up: " + b);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestBookKeeperConfiguration.java

示例8: MiniZooKeeperCluster

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
public MiniZooKeeperCluster(Configuration configuration) {
  this.started = false;
  this.configuration = configuration;
  activeZKServerIndex = -1;
  zooKeeperServers = new ArrayList<ZooKeeperServer>();
  clientPortList = new ArrayList<Integer>();
  standaloneServerFactoryList = new ArrayList<NIOServerCnxnFactory>();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:MiniZooKeeperCluster.java

示例9: waitForActiveLockData

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
public static void waitForActiveLockData(TestContext ctx,
    ZooKeeperServer zks, String parentDir, byte[] activeData)
    throws Exception {
  long st = Time.now();
  long lastPrint = st;
  while (true) {
    if (ctx != null) {
      ctx.checkException();
    }
    try {
      Stat stat = new Stat();
      byte[] data = zks.getZKDatabase().getData(
        parentDir + "/" +
        ActiveStandbyElector.LOCK_FILENAME, stat, null);
      if (activeData != null &&
          Arrays.equals(activeData, data)) {
        return;
      }
      if (Time.now() > lastPrint + LOG_INTERVAL_MS) {
        LOG.info("Cur data: " + StringUtils.byteToHexString(data));
        lastPrint = Time.now();
      }
    } catch (NoNodeException nne) {
      if (activeData == null) {
        return;
      }
      if (Time.now() > lastPrint + LOG_INTERVAL_MS) {
        LOG.info("Cur data: no node");
        lastPrint = Time.now();
      }
    }
    Thread.sleep(50);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:35,代码来源:ActiveStandbyElectorTestUtil.java

示例10: EmbeddedZooKeeper

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
EmbeddedZooKeeper() throws IOException, InterruptedException {
  this.tmpDir = Files.createTempDirectory(null).toFile();
  this.factory = new NIOServerCnxnFactory();
  this.zookeeper = new ZooKeeperServer(new File(tmpDir, "data"), new File(tmpDir, "log"), TICK_TIME);
  InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 0);
  factory.configure(addr, 0);
  factory.startup(zookeeper);
  this.port = zookeeper.getClientPort();
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:10,代码来源:EmbeddedZooKeeper.java

示例11: ReadOnlyRequestProcessor

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
public ReadOnlyRequestProcessor(ZooKeeperServer zks,
        RequestProcessor nextProcessor) {
    super("ReadOnlyRequestProcessor:" + zks.getServerId(), zks
            .getZooKeeperServerListener());
    this.zks = zks;
    this.nextProcessor = nextProcessor;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:8,代码来源:ReadOnlyRequestProcessor.java

示例12: getActiveServer

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
synchronized public ZooKeeperServer getActiveServer(){
    if(leader!=null)
        return leader.zk;
    else if(follower!=null)
        return follower.zk;
    else if (observer != null)
        return observer.zk;
    return null;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:10,代码来源:QuorumPeer.java

示例13: unregisterJMX

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
protected void unregisterJMX(ZooKeeperServer zks) {
    // unregister from JMX
    try {
        if (jmxServerBean != null) {
            MBeanRegistry.getInstance().unregister(jmxServerBean);
        }
    } catch (Exception e) {
        LOG.warn("Failed to unregister with JMX", e);
    }
    jmxServerBean = null;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:12,代码来源:ReadOnlyZooKeeperServer.java

示例14: initialize

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
public static void initialize() {
    synchronized (ProviderRegistry.class) {
        if (initialized)
            return;
        IPAuthenticationProvider ipp = new IPAuthenticationProvider();
        DigestAuthenticationProvider digp = new DigestAuthenticationProvider();
        authenticationProviders.put(ipp.getScheme(), ipp);
        authenticationProviders.put(digp.getScheme(), digp);
        Enumeration<Object> en = System.getProperties().keys();
        while (en.hasMoreElements()) {
            String k = (String) en.nextElement();
            if (k.startsWith("zookeeper.authProvider.")) {
                String className = System.getProperty(k);
                try {
                    Class<?> c = ZooKeeperServer.class.getClassLoader()
                            .loadClass(className);
                    AuthenticationProvider ap = (AuthenticationProvider) c
                            .newInstance();
                    authenticationProviders.put(ap.getScheme(), ap);
                } catch (Exception e) {
                    LOG.warn("Problems loading " + className,e);
                }
            }
        }
        initialized = true;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:28,代码来源:ProviderRegistry.java

示例15: createFollower

import org.apache.zookeeper.server.ZooKeeperServer; //导入依赖的package包/类
private ConversableFollower createFollower(File tmpDir, QuorumPeer peer)
throws IOException {
    FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
    peer.setTxnFactory(logFactory);
    ZKDatabase zkDb = new ZKDatabase(logFactory);
    FollowerZooKeeperServer zk = new FollowerZooKeeperServer(logFactory, peer, new ZooKeeperServer.BasicDataTreeBuilder(), zkDb);
    peer.setZKDatabase(zkDb);
    return new ConversableFollower(peer, zk);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:10,代码来源:Zab1_0Test.java


注:本文中的org.apache.zookeeper.server.ZooKeeperServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。