本文整理汇总了Java中org.apache.solr.client.solrj.impl.HttpSolrServer.getBaseURL方法的典型用法代码示例。如果您正苦于以下问题:Java HttpSolrServer.getBaseURL方法的具体用法?Java HttpSolrServer.getBaseURL怎么用?Java HttpSolrServer.getBaseURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.HttpSolrServer
的用法示例。
在下文中一共展示了HttpSolrServer.getBaseURL方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testArbitraryJsonIndexing
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Test
public void testArbitraryJsonIndexing() throws Exception {
HttpSolrServer server = (HttpSolrServer) getSolrServer();
server.deleteByQuery("*:*");
server.commit();
assertNumFound("*:*", 0); // make sure it got in
// two docs, one with uniqueKey, another without it
String json = "{\"id\":\"abc1\", \"name\": \"name1\"} {\"name\" : \"name2\"}";
HttpClient httpClient = server.getHttpClient();
HttpPost post = new HttpPost(server.getBaseURL() + "/update/json/docs");
post.setHeader("Content-Type", "application/json");
post.setEntity(new InputStreamEntity(new ByteArrayInputStream(json.getBytes("UTF-8")), -1));
HttpResponse response = httpClient.execute(post);
assertEquals(200, response.getStatusLine().getStatusCode());
server.commit();
assertNumFound("*:*", 2);
}
示例2: getNumCommits
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private Long getNumCommits(HttpSolrServer solrServer) throws
SolrServerException, IOException {
HttpSolrServer server = new HttpSolrServer(solrServer.getBaseURL());
server.setConnectionTimeout(15000);
server.setSoTimeout(60000);
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/admin/mbeans?key=updateHandler&stats=true");
// use generic request to avoid extra processing of queries
QueryRequest req = new QueryRequest(params);
NamedList<Object> resp = server.request(req);
NamedList mbeans = (NamedList) resp.get("solr-mbeans");
NamedList uhandlerCat = (NamedList) mbeans.get("UPDATEHANDLER");
NamedList uhandler = (NamedList) uhandlerCat.get("updateHandler");
NamedList stats = (NamedList) uhandler.get("stats");
Long commits = (Long) stats.get("commits");
server.shutdown();
return commits;
}
示例3: testStreamUrl
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Test
public void testStreamUrl() throws Exception {
HttpSolrServer solrServer = (HttpSolrServer) getSolrServer();
String streamUrl = solrServer.getBaseURL()+"/select?q=*:*&fl=id&wt=csv";
String getUrl = solrServer.getBaseURL()+"/debug/dump?wt=xml&stream.url="+URLEncoder.encode(streamUrl,"UTF-8");
String content = getUrlForString(getUrl);
assertTrue(content.contains("1234"));
//System.out.println(content);
}
示例4: testMaxRetries
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void testMaxRetries() throws IOException {
final MockStreamingSolrServers ss = new MockStreamingSolrServers(updateShardHandler);
SolrCmdDistributor cmdDistrib = new SolrCmdDistributor(ss, 5, 0);
ss.setExp(Exp.CONNECT_EXCEPTION);
ArrayList<Node> nodes = new ArrayList<>();
final HttpSolrServer solrclient1 = (HttpSolrServer) clients.get(0);
final AtomicInteger retries = new AtomicInteger();
ZkNodeProps nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, solrclient1.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1") {
@Override
public boolean checkRetry() {
retries.incrementAndGet();
return true;
}
};
nodes.add(retryNode);
AddUpdateCommand cmd = new AddUpdateCommand(null);
cmd.solrDoc = sdoc("id", id.incrementAndGet());
ModifiableSolrParams params = new ModifiableSolrParams();
cmdDistrib.distribAdd(cmd, nodes, params);
cmdDistrib.finish();
assertEquals(6, retries.get());
assertEquals(1, cmdDistrib.getErrors().size());
}
示例5: doTest
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public void doTest() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/cores");
int which = r.nextInt(clients.size());
HttpSolrServer client = (HttpSolrServer)clients.get(which);
String previousBaseURL = client.getBaseURL();
// Strip /collection1 step from baseURL - requests fail otherwise
client.setBaseURL(previousBaseURL.substring(0, previousBaseURL.lastIndexOf("/")));
NamedList namedListResponse = client.request(request);
client.setBaseURL(previousBaseURL); // Restore baseURL
NamedList status = (NamedList)namedListResponse.get("status");
NamedList collectionStatus = (NamedList)status.get("collection1");
String collectionSchema = (String)collectionStatus.get(CoreAdminParams.SCHEMA);
// Make sure the upgrade to managed schema happened
assertEquals("Schema resource name differs from expected name", "managed-schema", collectionSchema);
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), 30000);
try {
// Make sure "DO NOT EDIT" is in the content of the managed schema
String fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/managed-schema");
assertTrue("Managed schema is missing", fileContent.contains("DO NOT EDIT"));
// Make sure the original non-managed schema is no longer in ZooKeeper
assertFileNotInZooKeeper(zkClient, "/solr/configs/conf1", "schema.xml");
// Make sure the renamed non-managed schema is present in ZooKeeper
fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/schema.xml.bak");
assertTrue("schema file doesn't contain '<schema'", fileContent.contains("<schema"));
} finally {
if (zkClient != null) {
zkClient.close();
}
}
}
示例6: afterPropertiesSet
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
if (querySolrServer instanceof HttpSolrServer) {
HttpSolrServer httpSolrServer = (HttpSolrServer) querySolrServer;
this.updateSolrServer = new ConcurrentUpdateSolrServer(httpSolrServer.getBaseURL(), httpSolrServer.getHttpClient(), 20, 4);
} else {
this.updateSolrServer = querySolrServer;
}
}
示例7: makeDeleteAllUrl
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
/** Compose a url that if you get it, it will delete all the data. */
private String makeDeleteAllUrl() throws UnsupportedEncodingException {
HttpSolrServer solrServer = (HttpSolrServer) getSolrServer();
String deleteQuery = "<delete><query>*:*</query></delete>";
return solrServer.getBaseURL()+"/update?commit=true&stream.body="+ URLEncoder.encode(deleteQuery, "UTF-8");
}
示例8: checkForBackupSuccess
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void checkForBackupSuccess(final HttpSolrServer client, File location)
throws InterruptedException, IOException {
class CheckStatus extends Thread {
volatile String fail = null;
volatile String response = null;
volatile boolean success = false;
final Pattern p = Pattern
.compile("<str name=\"snapshotCompletedAt\">(.*?)</str>");
CheckStatus() {}
@Override
public void run() {
String masterUrl = client.getBaseURL() + "/replication?command="
+ ReplicationHandler.CMD_DETAILS;
try {
response = client.getHttpClient().execute(new HttpGet(masterUrl), new BasicResponseHandler());
if (response.contains("<str name=\"status\">success</str>")) {
Matcher m = p.matcher(response);
if (!m.find()) {
fail("could not find the completed timestamp in response.");
}
success = true;
}
} catch (Exception e) {
e.printStackTrace();
fail = e.getMessage();
}
};
}
int waitCnt = 0;
CheckStatus checkStatus = new CheckStatus();
while (true) {
checkStatus.run();
if (checkStatus.fail != null) {
fail(checkStatus.fail);
}
if (checkStatus.success) {
break;
}
Thread.sleep(500);
if (waitCnt == 90) {
fail("Backup success not detected:" + checkStatus.response);
}
waitCnt++;
}
File[] files = location.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (name.startsWith("snapshot")) {
return true;
}
return false;
}
});
assertEquals(Arrays.asList(files).toString(), 1, files.length);
File snapDir = files[0];
TestUtil.rm(snapDir);
}