gpt4 book ai didi

org.apache.solr.common.cloud.ZkStateReader.getUpdateLock()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 11:40:40 26 4
gpt4 key购买 nike

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

ZkStateReader.getUpdateLock介绍

暂无

代码示例

代码示例来源:origin: org.apache.solr/solr-solrj

@Override
public void process(WatchedEvent event) {
 // session events are not change events, and do not remove the watcher
 if (EventType.None.equals(event.getType())) {
  return;
 }
 log.debug("A collections change: [{}], has occurred - updating...", event);
 refreshAndWatch();
 synchronized (getUpdateLock()) {
  constructState(Collections.emptySet());
 }
}

代码示例来源:origin: org.apache.solr/solr-solrj

/**
  * Refresh collection state from ZK and leave a watch for future changes.
  * As a side effect, updates {@link #clusterState} and {@link #watchedCollectionStates}
  * with the results of the refresh.
  */
 public void refreshAndWatch() {
  try {
   DocCollection newState = fetchCollectionState(coll, this);
   updateWatchedCollection(coll, newState);
   synchronized (getUpdateLock()) {
    constructState(Collections.singleton(coll));
   }
  } catch (KeeperException.SessionExpiredException | KeeperException.ConnectionLossException e) {
   log.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK: [{}]", e.getMessage());
  } catch (KeeperException e) {
   log.error("Unwatched collection: [{}]", coll, e);
   throw new ZooKeeperException(ErrorCode.SERVER_ERROR, "A ZK error has occurred", e);
  } catch (InterruptedException e) {
   Thread.currentThread().interrupt();
   log.error("Unwatched collection: [{}]", coll, e);
  }
 }
}

代码示例来源:origin: com.hynnet/solr-solrj

private void updateClusterState(boolean onlyLiveNodes) throws KeeperException, InterruptedException {
 // build immutable CloudInfo
 synchronized (getUpdateLock()) {
  List<String> liveNodes = zkClient.getChildren(LIVE_NODES_ZKNODE, null, true);
  Set<String> liveNodesSet = new HashSet<>(liveNodes);
  if (!onlyLiveNodes) {
   log.debug("Updating cloud state from ZooKeeper... ");
   clusterState = constructState(liveNodesSet, null);
  } else {
   log.debug("Updating live nodes from ZooKeeper... ({})", liveNodesSet.size());
   clusterState = this.clusterState;
   clusterState.setLiveNodes(liveNodesSet);
  }
 }
}

代码示例来源:origin: org.apache.solr/solr-solrj

private void refreshAliases(AliasesManager watcher) throws KeeperException, InterruptedException {
 synchronized (getUpdateLock()) {
  constructState(Collections.emptySet());
  zkClient.exists(ALIASES, watcher, true);
 }
 aliasesManager.update();
}

代码示例来源:origin: org.apache.solr/solr-solrj

synchronized (getUpdateLock()) {
 newLiveNodes = lastFetchedLiveNodes.getAndSet(null);
 if (newLiveNodes == null) {

代码示例来源:origin: org.apache.solr/solr-solrj

/**
 * Remove a watcher from a collection's watch list.
 *
 * This allows Zookeeper watches to be removed if there is no interest in the
 * collection.
 *
 * @param collection the collection
 * @param watcher    the watcher
 */
public void removeCollectionStateWatcher(String collection, CollectionStateWatcher watcher) {
 AtomicBoolean reconstructState = new AtomicBoolean(false);
 collectionWatches.compute(collection, (k, v) -> {
  if (v == null)
   return null;
  v.stateWatchers.remove(watcher);
  if (v.canBeRemoved()) {
   watchedCollectionStates.remove(collection);
   lazyCollectionStates.put(collection, new LazyCollectionRef(collection));
   reconstructState.set(true);
   return null;
  }
  return v;
 });
 if (reconstructState.get()) {
  synchronized (getUpdateLock()) {
   constructState(Collections.emptySet());
  }
 }
}

代码示例来源:origin: org.apache.solr/solr-solrj

});
if (reconstructState.get()) {
 synchronized (getUpdateLock()) {
  constructState(Collections.emptySet());

代码示例来源:origin: org.apache.solr/solr-solrj

@Override
public void process(WatchedEvent event) {
 // session events are not change events, and do not remove the watcher
 if (EventType.None.equals(event.getType())) {
  return;
 }
 try {
  synchronized (ZkStateReader.this.getUpdateLock()) {
   log.debug("Updating [{}] ... ", SOLR_SECURITY_CONF_PATH);
   // remake watch
   final Watcher thisWatch = this;
   final Stat stat = new Stat();
   final byte[] data = getZkClient().getData(SOLR_SECURITY_CONF_PATH, thisWatch, stat, true);
   try {
    callback.call(new Pair<>(data, stat));
   } catch (Exception e) {
    log.error("Error running collections node listener", e);
   }
  }
 } catch (KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e) {
  log.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK: [{}]", e.getMessage());
 } catch (KeeperException e) {
  log.error("A ZK error has occurred", e);
  throw new ZooKeeperException(ErrorCode.SERVER_ERROR, "", e);
 } catch (InterruptedException e) {
  // Restore the interrupted status
  Thread.currentThread().interrupt();
  log.warn("Interrupted", e);
 }
}

代码示例来源:origin: com.hynnet/solr-solrj

synchronized (ZkStateReader.this.getUpdateLock()) {
 List<String> liveNodes = zkClient.getChildren(
   LIVE_NODES_ZKNODE, this, true);

代码示例来源:origin: com.hynnet/solr-solrj

synchronized (ZkStateReader.this.getUpdateLock()) {
 log.info("Updating aliases... ");

代码示例来源:origin: com.hynnet/solr-solrj

synchronized (ZkStateReader.this.getUpdateLock()) {

代码示例来源:origin: org.apache.solr/solr-solrj

final byte[] data = zkClient.getData(CLUSTER_STATE, watcher, stat, true);
final ClusterState loadedData = ClusterState.load(stat.getVersion(), data, emptySet(), CLUSTER_STATE);
synchronized (getUpdateLock()) {
 if (this.legacyClusterStateVersion >= stat.getVersion()) {
synchronized (getUpdateLock()) {
 this.legacyCollectionStates = emptyMap();
 this.legacyClusterStateVersion = 0;

代码示例来源:origin: com.hynnet/solr-solrj

synchronized (ZkStateReader.this.getUpdateLock()) {
 log.info("Updating {} ... ", path);

代码示例来源:origin: com.hynnet/solr-solrj

synchronized (ZkStateReader.this.getUpdateLock()) {
 if (!watchedCollections.contains(coll)) {
  log.info("Unwatched collection {}", coll);

代码示例来源:origin: org.apache.solr/solr-solrj

synchronized (getUpdateLock()) {
 if (clusterState == null) {
  log.warn("ClusterState watchers have not been initialized");

代码示例来源:origin: org.apache.solr/solr-solrj

/**
 * Forcibly refresh cluster state from ZK. Do this only to avoid race conditions because it's expensive.
 *
 * It is cheaper to call {@link #forceUpdateCollection(String)} on a single collection if you must.
 * 
 * @lucene.internal
 */
public void forciblyRefreshAllClusterStateSlow() throws KeeperException, InterruptedException {
 synchronized (getUpdateLock()) {
  if (clusterState == null) {
   // Never initialized, just run normal initialization.
   createClusterStateWatchersAndUpdate();
   return;
  }
  // No need to set watchers because we should already have watchers registered for everything.
  refreshCollectionList(null);
  refreshLiveNodes(null);
  refreshLegacyClusterState(null);
  // Need a copy so we don't delete from what we're iterating over.
  Collection<String> safeCopy = new ArrayList<>(watchedCollectionStates.keySet());
  Set<String> updatedCollections = new HashSet<>();
  for (String coll : safeCopy) {
   DocCollection newState = fetchCollectionState(coll, null);
   if (updateWatchedCollection(coll, newState)) {
    updatedCollections.add(coll);
   }
  }
  constructState(updatedCollections);
 }
}

代码示例来源:origin: com.hynnet/solr-solrj

log.info("addZkWatch {}", coll);
final String fullpath = getCollectionPath(coll);
synchronized (getUpdateLock()) {

代码示例来源:origin: org.apache.solr/solr-solrj

public Integer compareStateVersions(String coll, int version) {
 DocCollection collection = clusterState.getCollectionOrNull(coll);
 if (collection == null) return null;
 if (collection.getZNodeVersion() < version) {
  log.debug("Server older than client {}<{}", collection.getZNodeVersion(), version);
  DocCollection nu = getCollectionLive(this, coll);
  if (nu == null) return -1 ;
  if (nu.getZNodeVersion() > collection.getZNodeVersion()) {
   if (updateWatchedCollection(coll, nu)) {
    synchronized (getUpdateLock()) {
     constructState(Collections.singleton(coll));
    }
   }
   collection = nu;
  }
 }
 
 if (collection.getZNodeVersion() == version) {
  return null;
 }
 
 log.debug("Wrong version from client [{}]!=[{}]", version, collection.getZNodeVersion());
 
 return collection.getZNodeVersion();
}

代码示例来源:origin: com.hynnet/solr-solrj

synchronized (getUpdateLock()) {
synchronized (ZkStateReader.this.getUpdateLock()) {
 List<String> liveNodes = zkClient.getChildren(LIVE_NODES_ZKNODE,
   new Watcher() {

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