Java Code Examples for org.apache.solr.common.cloud.ZkStateReader#CORE_NAME_PROP
The following examples show how to use
org.apache.solr.common.cloud.ZkStateReader#CORE_NAME_PROP .
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: ReplaceNodeCmd.java From lucene-solr with Apache License 2.0 | 6 votes |
static List<ZkNodeProps> getReplicasOfNode(String source, ClusterState state) { List<ZkNodeProps> sourceReplicas = new ArrayList<>(); for (Map.Entry<String, DocCollection> e : state.getCollectionsMap().entrySet()) { for (Slice slice : e.getValue().getSlices()) { for (Replica replica : slice.getReplicas()) { if (source.equals(replica.getNodeName())) { ZkNodeProps props = new ZkNodeProps( COLLECTION_PROP, e.getKey(), SHARD_ID_PROP, slice.getName(), ZkStateReader.CORE_NAME_PROP, replica.getCoreName(), ZkStateReader.REPLICA_PROP, replica.getName(), ZkStateReader.REPLICA_TYPE, replica.getType().name(), ZkStateReader.LEADER_PROP, String.valueOf(replica.equals(slice.getLeader())), CoreAdminParams.NODE, source); sourceReplicas.add(props); } } } } return sourceReplicas; }
Example 2
Source File: LeaderElectionTest.java From lucene-solr with Apache License 2.0 | 6 votes |
public ClientThread(ElectorSetup es, String shard, int nodeNumber, long runLeaderDelay) throws Exception { super("Thread-" + shard + nodeNumber); this.shard = shard; this.nodeName = shard + nodeNumber; this.runLeaderDelay = runLeaderDelay; props = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, Integer.toString(nodeNumber), ZkStateReader.CORE_NAME_PROP, ""); this.es = es; if (this.es == null) { this.es = new ElectorSetup(() -> { try { setupOnConnect(); } catch (Throwable t) { } }); } }
Example 3
Source File: OverseerCollectionMessageHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
void deleteCoreNode(String collectionName, String replicaName, Replica replica, String core) throws Exception { ZkNodeProps m = new ZkNodeProps( Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(), ZkStateReader.CORE_NAME_PROP, core, ZkStateReader.NODE_NAME_PROP, replica.getStr(ZkStateReader.NODE_NAME_PROP), ZkStateReader.COLLECTION_PROP, collectionName, ZkStateReader.CORE_NODE_NAME_PROP, replicaName, ZkStateReader.BASE_URL_PROP, replica.getStr(ZkStateReader.BASE_URL_PROP)); overseer.offerStateUpdate(Utils.toJSON(m)); }
Example 4
Source File: DeleteShardCmd.java From lucene-solr with Apache License 2.0 | 5 votes |
private List<ZkNodeProps> getReplicasForSlice(String collectionName, Slice slice) { List<ZkNodeProps> sourceReplicas = new ArrayList<>(); for (Replica replica : slice.getReplicas()) { ZkNodeProps props = new ZkNodeProps( COLLECTION_PROP, collectionName, SHARD_ID_PROP, slice.getName(), ZkStateReader.CORE_NAME_PROP, replica.getCoreName(), ZkStateReader.REPLICA_PROP, replica.getName(), CoreAdminParams.NODE, replica.getNodeName()); sourceReplicas.add(props); } return sourceReplicas; }
Example 5
Source File: LeaderElectionTest.java From lucene-solr with Apache License 2.0 | 5 votes |
@Test public void testBasic() throws Exception { LeaderElector elector = new LeaderElector(zkClient); ZkNodeProps props = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, "http://127.0.0.1/solr/", ZkStateReader.CORE_NAME_PROP, ""); ZkController zkController = MockSolrSource.makeSimpleMock(null, null, zkClient); ElectionContext context = new ShardLeaderElectionContextBase(elector, "shard2", "collection1", "dummynode1", props, zkController); elector.setup(context); elector.joinElection(context, false); assertEquals("http://127.0.0.1/solr/", getLeaderUrl("collection1", "shard2")); }
Example 6
Source File: DeleteReplicaTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Test public void deleteReplicaFromClusterState() throws Exception { final String collectionName = "deleteFromClusterStateCollection"; CollectionAdminRequest.createCollection(collectionName, "conf", 1, 3) .process(cluster.getSolrClient()); cluster.waitForActiveCollection(collectionName, 1, 3); cluster.getSolrClient().add(collectionName, new SolrInputDocument("id", "1")); cluster.getSolrClient().add(collectionName, new SolrInputDocument("id", "2")); cluster.getSolrClient().commit(collectionName); cluster.waitForActiveCollection(collectionName, 1, 3); Slice shard = getCollectionState(collectionName).getSlice("shard1"); // don't choose the leader to shutdown, it just complicates things unnecessarily Replica replica = getRandomReplica(shard, (r) -> ( r.getState() == Replica.State.ACTIVE && ! r.equals(shard.getLeader()))); JettySolrRunner replicaJetty = cluster.getReplicaJetty(replica); ZkStateReaderAccessor accessor = new ZkStateReaderAccessor(replicaJetty.getCoreContainer().getZkController().getZkStateReader()); final long preDeleteWatcherCount = countUnloadCoreOnDeletedWatchers (accessor.getStateWatchers(collectionName)); ZkNodeProps m = new ZkNodeProps( Overseer.QUEUE_OPERATION, OverseerAction.DELETECORE.toLower(), ZkStateReader.CORE_NAME_PROP, replica.getCoreName(), ZkStateReader.NODE_NAME_PROP, replica.getNodeName(), ZkStateReader.COLLECTION_PROP, collectionName, ZkStateReader.CORE_NODE_NAME_PROP, replica.getName(), ZkStateReader.BASE_URL_PROP, replica.getBaseUrl()); cluster.getOpenOverseer().getStateUpdateQueue().offer(Utils.toJSON(m)); waitForState("Timeout waiting for replica get deleted", collectionName, (liveNodes, collectionState) -> collectionState.getSlice("shard1").getReplicas().size() == 2); TimeOut timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME); timeOut.waitFor("Waiting for replica get unloaded", () -> replicaJetty.getCoreContainer().getCoreDescriptor(replica.getCoreName()) == null ); // the core should no longer have a watch collection state since it was removed timeOut = new TimeOut(60, TimeUnit.SECONDS, TimeSource.NANO_TIME); timeOut.waitFor("Waiting for core's watcher to be removed", () -> { final long postDeleteWatcherCount = countUnloadCoreOnDeletedWatchers (accessor.getStateWatchers(collectionName)); log.info("preDeleteWatcherCount={} vs postDeleteWatcherCount={}", preDeleteWatcherCount, postDeleteWatcherCount); return (preDeleteWatcherCount - 1L == postDeleteWatcherCount); }); CollectionAdminRequest.deleteCollection(collectionName).process(cluster.getSolrClient()); }