use of org.apache.solr.client.solrj.request.CoreAdminRequest.Create in project lucene-solr by apache.
the class BasicDistributedZkTest method createCores.
protected void createCores(final HttpSolrClient client, ThreadPoolExecutor executor, final String collection, final int numShards, int cnt) {
for (int i = 0; i < cnt; i++) {
final int freezeI = i;
executor.execute(() -> {
Create createCmd = new Create();
createCmd.setCoreName(collection + freezeI);
createCmd.setCollection(collection);
createCmd.setNumShards(numShards);
try {
String core3dataDir = createTempDir(collection).toFile().getAbsolutePath();
createCmd.setDataDir(getDataDir(core3dataDir));
client.request(createCmd);
} catch (SolrServerException | IOException e) {
throw new RuntimeException(e);
}
});
}
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.Create in project lucene-solr by apache.
the class CollectionsAPIDistributedZkTest method testNoCollectionSpecified.
@Test
public void testNoCollectionSpecified() throws Exception {
// TODO - should we remove this behaviour?
assertFalse(cluster.getSolrClient().getZkStateReader().getClusterState().hasCollection("corewithnocollection"));
assertFalse(cluster.getSolrClient().getZkStateReader().getClusterState().hasCollection("corewithnocollection2"));
// try and create a SolrCore with no collection name
Create createCmd = new Create();
createCmd.setCoreName("corewithnocollection");
createCmd.setCollection("");
String dataDir = createTempDir().toFile().getAbsolutePath();
createCmd.setDataDir(dataDir);
createCmd.setNumShards(1);
createCmd.setCollectionConfigName("conf");
cluster.getSolrClient().request(createCmd);
// try and create a SolrCore with no collection name
createCmd.setCollection(null);
createCmd.setCoreName("corewithnocollection2");
cluster.getSolrClient().request(createCmd);
// in both cases, the collection should have default to the core name
cluster.getSolrClient().getZkStateReader().forceUpdateCollection("corewithnocollection");
cluster.getSolrClient().getZkStateReader().forceUpdateCollection("corewithnocollection2");
assertTrue(cluster.getSolrClient().getZkStateReader().getClusterState().hasCollection("corewithnocollection"));
assertTrue(cluster.getSolrClient().getZkStateReader().getClusterState().hasCollection("corewithnocollection2"));
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.Create in project lucene-solr by apache.
the class BasicDistributedZk2Test method testNodeWithoutCollectionForwarding.
private void testNodeWithoutCollectionForwarding() throws Exception {
final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
try (HttpSolrClient client = getHttpSolrClient(baseUrl)) {
client.setConnectionTimeout(30000);
Create createCmd = new Create();
createCmd.setRoles("none");
createCmd.setCoreName(ONE_NODE_COLLECTION + "core");
createCmd.setCollection(ONE_NODE_COLLECTION);
createCmd.setNumShards(1);
createCmd.setDataDir(getDataDir(createTempDir(ONE_NODE_COLLECTION).toFile().getAbsolutePath()));
client.request(createCmd);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
waitForCollection(cloudClient.getZkStateReader(), ONE_NODE_COLLECTION, 1);
waitForRecoveriesToFinish(ONE_NODE_COLLECTION, cloudClient.getZkStateReader(), false);
cloudClient.getZkStateReader().getLeaderRetry(ONE_NODE_COLLECTION, SHARD1, 30000);
int docs = 2;
for (SolrClient client : clients) {
final String clientUrl = getBaseUrl((HttpSolrClient) client);
addAndQueryDocs(clientUrl, docs);
docs += 2;
}
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.Create in project lucene-solr by apache.
the class BasicDistributedZkTest method createNewCollection.
private void createNewCollection(final String collection) throws InterruptedException {
final List<SolrClient> collectionClients = new ArrayList<>();
otherCollectionClients.put(collection, collectionClients);
int unique = 0;
for (final SolrClient client : clients) {
unique++;
final String baseUrl = ((HttpSolrClient) client).getBaseURL().substring(0, ((HttpSolrClient) client).getBaseURL().length() - DEFAULT_COLLECTION.length() - 1);
final int frozeUnique = unique;
Callable call = () -> {
try (HttpSolrClient client1 = getHttpSolrClient(baseUrl)) {
client1.setConnectionTimeout(15000);
client1.setSoTimeout(60000);
Create createCmd = new Create();
createCmd.setCoreName(collection);
createCmd.setDataDir(getDataDir(createTempDir(collection).toFile().getAbsolutePath()));
client1.request(createCmd);
} catch (Exception e) {
e.printStackTrace();
//fails
}
return null;
};
collectionClients.add(createNewSolrClient(collection, baseUrl));
pending.add(completionService.submit(call));
while (pending != null && pending.size() > 0) {
Future<Object> future = completionService.take();
if (future == null)
return;
pending.remove(future);
}
}
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.Create in project lucene-solr by apache.
the class BasicDistributedZkTest method createSolrCore.
private void createSolrCore(final String collection, List<SolrClient> collectionClients, final String baseUrl, final int num, final String shardId) {
Callable call = () -> {
try (HttpSolrClient client = getHttpSolrClient(baseUrl)) {
// client.setConnectionTimeout(15000);
Create createCmd = new Create();
createCmd.setRoles("none");
createCmd.setCoreName(collection + num);
createCmd.setCollection(collection);
if (random().nextBoolean()) {
// sometimes we use an explicit core node name
createCmd.setCoreNodeName("anode" + nodeCounter.incrementAndGet());
}
if (shardId == null) {
createCmd.setNumShards(2);
}
createCmd.setDataDir(getDataDir(createTempDir(collection).toFile().getAbsolutePath()));
if (shardId != null) {
createCmd.setShardId(shardId);
}
client.request(createCmd);
} catch (Exception e) {
e.printStackTrace();
//fail
}
return null;
};
pending.add(completionService.submit(call));
collectionClients.add(createNewSolrClient(collection + num, baseUrl));
}
Aggregations