gpt4 book ai didi

org.apache.zookeeper.server.ZKDatabase.getDataTree()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 10:42:40 29 4
gpt4 key购买 nike

本文整理了Java中org.apache.zookeeper.server.ZKDatabase.getDataTree()方法的一些代码示例,展示了ZKDatabase.getDataTree()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKDatabase.getDataTree()方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZKDatabase
类名称:ZKDatabase
方法名:getDataTree

ZKDatabase.getDataTree介绍

[英]the datatree for this zkdatabase
[中]此数据库的数据树

代码示例

代码示例来源:origin: apache/zookeeper

/**
 * serialize the snapshot
 * @param oa the output archive to which the snapshot needs to be serialized
 * @throws IOException
 * @throws InterruptedException
 */
public void serializeSnapshot(OutputArchive oa) throws IOException,
InterruptedException {
  SerializeUtils.serializeSnapshot(getDataTree(), oa, getSessionWithTimeOuts());
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

public void takeSnapshot(){
  try {
    txnLogFactory.save(zkDb.getDataTree(), zkDb.getSessionWithTimeOuts());
  } catch (IOException e) {
    LOG.error("Severe unrecoverable error, exiting", e);
    // This is a severe error that we cannot recover from,
    // so we need to exit
    System.exit(10);
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

/**
 * serialize the snapshot
 * @param oa the output archive to which the snapshot needs to be serialized
 * @throws IOException
 * @throws InterruptedException
 */
public void serializeSnapshot(OutputArchive oa) throws IOException,
InterruptedException {
  SerializeUtils.serializeSnapshot(getDataTree(), oa, getSessionWithTimeOuts());
}

代码示例来源:origin: apache/zookeeper

/**
 * deserialize a snapshot from an input archive
 * @param ia the input archive you want to deserialize from
 * @throws IOException
 */
public void deserializeSnapshot(InputArchive ia) throws IOException {
  clear();
  SerializeUtils.deserializeSnapshot(getDataTree(),ia,getSessionWithTimeOuts());
  initialized = true;
}

代码示例来源:origin: apache/zookeeper

@Override
protected void registerJMX() {
  // register with JMX
  try {
    jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
    MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxDataTreeBean = null;
  }
}

代码示例来源:origin: apache/zookeeper

@Override
protected void registerJMX() {
  // register with JMX
  try {
    jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
    MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxDataTreeBean = null;
  }
}

代码示例来源:origin: apache/zookeeper

@Override
protected void registerJMX() {
  // register with JMX
  try {
    jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
    MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxDataTreeBean = null;
  }
}

代码示例来源:origin: apache/zookeeper

public void takeSnapshot(boolean syncSnap){
  long start = Time.currentElapsedTime();
  try {
    txnLogFactory.save(zkDb.getDataTree(), zkDb.getSessionWithTimeOuts(), syncSnap);
  } catch (IOException e) {
    LOG.error("Severe unrecoverable error, exiting", e);
    // This is a severe error that we cannot recover from,
    // so we need to exit
    System.exit(ExitCode.TXNLOG_ERROR_TAKING_SNAPSHOT.getValue());
  }
  long elapsed = Time.currentElapsedTime() - start;
  LOG.info("Snapshot taken in " + elapsed + " ms");
  ServerMetrics.SNAPSHOT_TIME.add(elapsed);
}

代码示例来源:origin: apache/zookeeper

@Override
  public void commandRun() {
    if (!isZKServerRunning()) {
      pw.println(ZK_NOT_SERVING);
    } else {
      DataTree dt = zkServer.getZKDatabase().getDataTree();
      if (len == FourLetterCommands.wchsCmd) {
        dt.dumpWatchesSummary(pw);
      } else if (len == FourLetterCommands.wchpCmd) {
        dt.dumpWatches(pw, true);
      } else {
        dt.dumpWatches(pw, false);
      }
      pw.println();
    }
  }
}

代码示例来源:origin: apache/zookeeper

protected void registerJMX() {
  // register with JMX
  try {
    jmxServerBean = new ZooKeeperServerBean(this);
    MBeanRegistry.getInstance().register(jmxServerBean, null);
    try {
      jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
      MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
    } catch (Exception e) {
      LOG.warn("Failed to register with JMX", e);
      jmxDataTreeBean = null;
    }
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxServerBean = null;
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

@Override
protected void registerJMX() {
  // register with JMX
  try {
    jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
    MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxDataTreeBean = null;
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

@Override
protected void registerJMX() {
  // register with JMX
  try {
    jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
    MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxDataTreeBean = null;
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

@Override
protected void registerJMX() {
  // register with JMX
  try {
    jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
    MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
  } catch (Exception e) {
    LOG.warn("Failed to register with JMX", e);
    jmxDataTreeBean = null;
  }
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

/**
 * deserialize a snapshot from an input archive 
 * @param ia the input archive you want to deserialize from
 * @throws IOException
 */
public void deserializeSnapshot(InputArchive ia) throws IOException {
  clear();
  SerializeUtils.deserializeSnapshot(getDataTree(),ia,getSessionWithTimeOuts());
  initialized = true;
}

代码示例来源:origin: apache/zookeeper

@Override
  public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
    DataTree dt = zkServer.getZKDatabase().getDataTree();
    CommandResponse response = initializeResponse();
    response.put("path_to_session_ids", dt.getWatchesByPath().toMap());
    return response;
  }
}

代码示例来源:origin: apache/zookeeper

@Override
  public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
    DataTree dt = zkServer.getZKDatabase().getDataTree();
    CommandResponse response = initializeResponse();
    response.putAll(dt.getWatchesSummary().toMap());
    return response;
  }
}

代码示例来源:origin: apache/zookeeper

@Override
  public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs) {
    DataTree dt = zkServer.getZKDatabase().getDataTree();
    CommandResponse response = initializeResponse();
    response.put("session_id_to_watched_paths", dt.getWatches().toMap());
    return response;
  }
}

代码示例来源:origin: apache/zookeeper

private void addSerializeListener(int sid, String parent, String child) {
  final ZooKeeper zkClient = zk[followerA];
  CustomDataTree dt =
      (CustomDataTree) mt[sid].main.quorumPeer.getZkDb().getDataTree();
  dt.addListener(parent, new NodeSerializeListener() {
    @Override
    public void nodeSerialized(String path) {
      try {
        zkClient.delete(child, -1);
        LOG.info("Deleted the child node after the parent is serialized");
      } catch (Exception e) {
        LOG.error("Error when deleting node {}", e);
      }
    }
  });
}

代码示例来源:origin: apache/zookeeper

@Test(timeout = 30000)
public void testMultiWithContainerSimple()
    throws KeeperException, InterruptedException {
  Op createContainer = Op.create("/foo", new byte[0],
      ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.CONTAINER);
  zk.multi(Collections.singletonList(createContainer));
  DataTree dataTree = serverFactory.getZooKeeperServer().getZKDatabase().getDataTree();
  Assert.assertEquals(dataTree.getContainers().size(), 1);
}

代码示例来源:origin: apache/zookeeper

/**
   * Checks if a session is registered with the server as a watcher.
   *
   * @param long sessionId the session ID to check
   * @param path the path to check for watchers
   * @param type the type of watcher
   * @return true if the client session is a watcher on path for the type
   */
  private boolean isServerSessionWatcher(long sessionId, String path,
      WatcherType type) {
    Set<ServerCnxn> cnxns = new HashSet<>();
    CollectionUtils.addAll(cnxns, serverFactory.getConnections().iterator());
    for (ServerCnxn cnxn : cnxns) {
      if (cnxn.getSessionId() == sessionId) {
        return getServer(serverFactory).getZKDatabase().getDataTree()
            .containsWatcher(path, type, cnxn);
      }
    }
    return false;
  }
}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com