Java Code Examples for org.apache.solr.common.cloud.ClusterState#CollectionRef
The following examples show how to use
org.apache.solr.common.cloud.ClusterState#CollectionRef .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrClientNodeStateProvider.java From lucene-solr with Apache License 2.0 | 6 votes |
protected void readReplicaDetails() throws IOException { ClusterStateProvider clusterStateProvider = getClusterStateProvider(); ClusterState clusterState = clusterStateProvider.getClusterState(); if (clusterState == null) { // zkStateReader still initializing return; } Map<String, ClusterState.CollectionRef> all = clusterStateProvider.getClusterState().getCollectionStates(); all.forEach((collName, ref) -> { DocCollection coll = ref.get(); if (coll == null) return; if (coll.getProperties().get(CollectionAdminParams.WITH_COLLECTION) != null) { withCollectionsMap.put(coll.getName(), (String) coll.getProperties().get(CollectionAdminParams.WITH_COLLECTION)); } coll.forEachReplica((shard, replica) -> { Map<String, Map<String, List<ReplicaInfo>>> nodeData = nodeVsCollectionVsShardVsReplicaInfo.computeIfAbsent(replica.getNodeName(), k -> new HashMap<>()); Map<String, List<ReplicaInfo>> collData = nodeData.computeIfAbsent(collName, k -> new HashMap<>()); List<ReplicaInfo> replicas = collData.computeIfAbsent(shard, k -> new ArrayList<>()); replicas.add(new ReplicaInfo(collName, shard, replica, new HashMap<>(replica.getProperties()))); }); }); }
Example 2
Source File: DelegatingClusterStateProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public ClusterState.CollectionRef getState(String collection) { if (delegate != null) { return delegate.getState(collection); } else { return null; } }
Example 3
Source File: ZkClientClusterStateProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public ClusterState.CollectionRef getState(String collection) { ClusterState clusterState = getZkStateReader().getClusterState(); if (clusterState != null) { return clusterState.getCollectionRef(collection); } else { return null; } }
Example 4
Source File: SimClusterStateProvider.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public ClusterState.CollectionRef getState(String collection) { try { return getClusterState().getCollectionRef(collection); } catch (IOException e) { return null; } }
Example 5
Source File: BaseCloudSolrClient.java From lucene-solr with Apache License 2.0 | 4 votes |
protected DocCollection getDocCollection(String collection, Integer expectedVersion) throws SolrException { if (expectedVersion == null) expectedVersion = -1; if (collection == null) return null; ExpiringCachedDocCollection cacheEntry = collectionStateCache.get(collection); DocCollection col = cacheEntry == null ? null : cacheEntry.cached; if (col != null) { if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col; } ClusterState.CollectionRef ref = getCollectionRef(collection); if (ref == null) { //no such collection exists return null; } if (!ref.isLazilyLoaded()) { //it is readily available just return it return ref.get(); } @SuppressWarnings({"rawtypes"}) List locks = this.locks; final Object lock = locks.get(Math.abs(Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size())); DocCollection fetchedCol = null; synchronized (lock) { /*we have waited for sometime just check once again*/ cacheEntry = collectionStateCache.get(collection); col = cacheEntry == null ? null : cacheEntry.cached; if (col != null) { if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col; } // We are going to fetch a new version // we MUST try to get a new version fetchedCol = ref.get();//this is a call to ZK if (fetchedCol == null) return null;// this collection no more exists if (col != null && fetchedCol.getZNodeVersion() == col.getZNodeVersion()) { cacheEntry.setRetriedAt();//we retried and found that it is the same version cacheEntry.maybeStale = false; } else { collectionStateCache.put(collection, new ExpiringCachedDocCollection(fetchedCol)); } return fetchedCol; } }
Example 6
Source File: BaseCloudSolrClient.java From lucene-solr with Apache License 2.0 | 4 votes |
ClusterState.CollectionRef getCollectionRef(String collection) { return getClusterStateProvider().getState(collection); }
Example 7
Source File: ZkClientClusterStateProvider.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public String getPolicyNameByCollection(String coll) { ClusterState.CollectionRef state = getState(coll); return state == null || state.get() == null ? null : (String) state.get().getProperties().get("policy"); }
Example 8
Source File: SnapshotClusterStateProvider.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override public ClusterState.CollectionRef getState(String collection) { return clusterState.getCollectionRef(collection); }
Example 9
Source File: ClusterStateProvider.java From lucene-solr with Apache License 2.0 | 2 votes |
/** * Obtain the state of the collection (cluster status). * @return the collection state, or null is collection doesn't exist */ ClusterState.CollectionRef getState(String collection);