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()) { updateWatchedCollection(nu); collection = nu; } } if (collection.getZNodeVersion() == version) { return null; } log.debug("wrong version from client {}!={} ", version, collection.getZNodeVersion()); return collection.getZNodeVersion(); }
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(); }
if (oldState == null) { if (watchedCollectionStates.putIfAbsent(coll, newState) == null) { log.debug("Add data for [{}] ver [{}]", coll, newState.getZNodeVersion()); updated = true; break; if (oldState.getZNodeVersion() >= newState.getZNodeVersion()) { log.debug("Updating data for [{}] from [{}] to [{}]", coll, oldState.getZNodeVersion(), newState.getZNodeVersion()); updated = true; break;
private void updateWatchedCollection(DocCollection newState) { watchedCollectionStates.put(newState.getName(), newState); log.info("Updating data for {} to ver {} ", newState.getName(), newState.getZNodeVersion()); this.clusterState = clusterState.copyWith(newState.getName(), newState); }
@Override public synchronized DocCollection get(boolean allowCached) { gets.incrementAndGet(); if (!allowCached || lastUpdateTime < 0 || System.nanoTime() - lastUpdateTime > LAZY_CACHE_TIME) { boolean shouldFetch = true; if (cachedDocCollection != null) { Stat exists = null; try { exists = zkClient.exists(getCollectionPath(collName), null, true); } catch (Exception e) {} if (exists != null && exists.getVersion() == cachedDocCollection.getZNodeVersion()) { shouldFetch = false; } } if (shouldFetch) { cachedDocCollection = getCollectionLive(ZkStateReader.this, collName); lastUpdateTime = System.nanoTime(); } } return cachedDocCollection; }
if (col != null) { if (expectedVersion == null) return col; if (expectedVersion.intValue() == col.getZNodeVersion()) return col; if (col != null) { if (expectedVersion == null) return col; if (expectedVersion.intValue() == col.getZNodeVersion()) { return col; } else {
DocCollection col = cacheEntry == null ? null : cacheEntry.cached; if (col != null) { if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col; col = cacheEntry == null ? null : cacheEntry.cached; if (col != null) { if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col; if (col != null && fetchedCol.getZNodeVersion() == col.getZNodeVersion()) {
int collVer = coll.getZNodeVersion(); if (coll.getStateFormat()>1) { if(requestedCollections == null) requestedCollections = new ArrayList<>(requestedCollectionNames.size()); for (DocCollection ext : requestedCollections) { DocCollection latestStateFromZk = getDocCollection(zkStateReader.getClusterState(), ext.getName(),null); if (latestStateFromZk.getZNodeVersion() != ext.getZNodeVersion()) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Collection not found: " + requestedCollection); int collVer = coll.getZNodeVersion(); if (coll.getStateFormat()>1) { if(requestedCollections == null) requestedCollections = new ArrayList<>(requestedCollectionNames.size()); for (DocCollection ext : requestedCollections) { DocCollection latestStateFromZk = getDocCollection(ext.getName(), null); if (latestStateFromZk.getZNodeVersion() != ext.getZNodeVersion()) {