本文整理匯總了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);
}