本文整理汇总了Java中org.apache.solr.client.solrj.impl.HttpSolrServer.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java HttpSolrServer.shutdown方法的具体用法?Java HttpSolrServer.shutdown怎么用?Java HttpSolrServer.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.impl.HttpSolrServer
的用法示例。
在下文中一共展示了HttpSolrServer.shutdown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeCollectionApi
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
protected NamedList<Object> invokeCollectionApi(String... args) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
SolrRequest request = new QueryRequest(params);
for (int i = 0; i < args.length - 1; i+=2) {
params.add(args[i], args[i+1]);
}
request.setPath("/admin/collections");
String baseUrl = ((HttpSolrServer) shardToJetty.get(SHARD1).get(0).client.solrClient)
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
baseServer.setConnectionTimeout(15000);
baseServer.setSoTimeout(60000 * 5);
NamedList r = baseServer.request(request);
baseServer.shutdown();
return r;
}
示例2: addDocumentsToSolr
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void addDocumentsToSolr(List<Map<String,Object>> docs) throws SolrServerException, IOException {
List<SolrInputDocument> sidl = new ArrayList<>();
for (Map<String,Object> doc : docs) {
SolrInputDocument sd = new SolrInputDocument();
for (Entry<String,Object> entry : doc.entrySet()) {
sd.addField(entry.getKey(), entry.getValue());
}
sidl.add(sd);
}
HttpSolrServer solrServer = new HttpSolrServer(getSourceUrl());
try {
solrServer.setConnectionTimeout(15000);
solrServer.setSoTimeout(30000);
solrServer.add(sidl);
solrServer.commit(true, true);
} finally {
solrServer.shutdown();
}
}
示例3: checkConsistency
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void checkConsistency(String replicatedCollection)
throws SolrServerException {
Collection<Slice> slices = cloudClient.getZkStateReader().getClusterState()
.getSlices(replicatedCollection);
for (Slice slice : slices) {
Collection<Replica> replicas = slice.getReplicas();
long found = -1;
for (Replica replica : replicas) {
HttpSolrServer client = new HttpSolrServer(
new ZkCoreNodeProps(replica).getCoreUrl());
SolrQuery query = new SolrQuery("*:*");
query.set("distrib", false);
QueryResponse replicaResults = client.query(query);
long count = replicaResults.getResults().getNumFound();
if (found != -1) {
assertEquals(slice.getName() + " is inconsistent "
+ new ZkCoreNodeProps(replica).getCoreUrl(), found, count);
}
found = count;
client.shutdown();
}
}
}
示例4: getLatestVersion
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
/**
* Gets the latest commit version and generation from the master
*/
@SuppressWarnings("unchecked")
NamedList getLatestVersion() throws IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(COMMAND, CMD_INDEX_VERSION);
params.set(CommonParams.WT, "javabin");
params.set(CommonParams.QT, "/replication");
QueryRequest req = new QueryRequest(params);
HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX modify to use shardhandler
NamedList rsp;
try {
server.setSoTimeout(60000);
server.setConnectionTimeout(15000);
rsp = server.request(req);
} catch (SolrServerException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, e.getMessage(), e);
} finally {
server.shutdown();
}
return rsp;
}
示例5: deleteShard
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
protected void deleteShard(String shard) throws SolrServerException, IOException,
KeeperException, InterruptedException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.DELETESHARD.toString());
params.set("collection", AbstractFullDistribZkTestBase.DEFAULT_COLLECTION);
params.set("shard", shard);
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
String baseUrl = ((HttpSolrServer) shardToJetty.get(SHARD1).get(0).client.solrClient)
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
baseServer.setConnectionTimeout(15000);
baseServer.setSoTimeout(60000);
baseServer.request(request);
baseServer.shutdown();
}
示例6: getDetails
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
NamedList getDetails() throws IOException, SolrServerException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(COMMAND, CMD_DETAILS);
params.set("slave", false);
params.set(CommonParams.QT, "/replication");
HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX use shardhandler
NamedList rsp;
try {
server.setSoTimeout(60000);
server.setConnectionTimeout(15000);
QueryRequest request = new QueryRequest(params);
rsp = server.request(request);
} finally {
server.shutdown();
}
return rsp;
}
示例7: checkSubShardConsistency
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
protected void checkSubShardConsistency(String shard) throws SolrServerException {
SolrQuery query = new SolrQuery("*:*").setRows(1000).setFields("id", "_version_");
query.set("distrib", false);
ClusterState clusterState = cloudClient.getZkStateReader().getClusterState();
Slice slice = clusterState.getSlice(AbstractDistribZkTestBase.DEFAULT_COLLECTION, shard);
long[] numFound = new long[slice.getReplicasMap().size()];
int c = 0;
for (Replica replica : slice.getReplicas()) {
String coreUrl = new ZkCoreNodeProps(replica).getCoreUrl();
HttpSolrServer server = new HttpSolrServer(coreUrl);
QueryResponse response;
try {
response = server.query(query);
} finally {
server.shutdown();
}
numFound[c++] = response.getResults().getNumFound();
log.info("Shard: " + shard + " Replica: {} has {} docs", coreUrl, String.valueOf(response.getResults().getNumFound()));
assertTrue("Shard: " + shard + " Replica: " + coreUrl + " has 0 docs", response.getResults().getNumFound() > 0);
}
for (int i = 0; i < slice.getReplicasMap().size(); i++) {
assertEquals(shard + " is not consistent", numFound[0], numFound[i]);
}
}
示例8: doCommitPerf
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public void doCommitPerf() throws Exception {
HttpSolrServer client = new HttpSolrServer("http://127.0.0.1:8983/solr");
long start = System.currentTimeMillis();
for (int i=0; i<10000; i++) {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", Integer.toString(i % 13));
client.add(doc);
client.commit(true, true, true);
}
long end = System.currentTimeMillis();
client.shutdown();
System.out.println("TIME: " + (end-start));
}
示例9: checkReloadNeeded
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
/**
* Checks whether the server's configured URL matches that in the config file. If not, a new server instance is created.
*/
public void checkReloadNeeded() {
if (!testMode && server != null && server instanceof HttpSolrServer) {
HttpSolrServer httpSolrServer = (HttpSolrServer) server;
if (!DataManager.getInstance().getConfiguration().getIndexUrl().equals(httpSolrServer.getBaseURL())) {
logger.info("Solr URL has changed, re-initializing SolrHelper...");
httpSolrServer.shutdown();
server = getNewHttpSolrServer(DataManager.getInstance().getConfiguration().getIndexUrl());
}
}
}
示例10: splitShard
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
protected void splitShard(String collection, String shardId, List<DocRouter.Range> subRanges, String splitKey) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.SPLITSHARD.toString());
params.set("collection", collection);
if (shardId != null) {
params.set("shard", shardId);
}
if (subRanges != null) {
StringBuilder ranges = new StringBuilder();
for (int i = 0; i < subRanges.size(); i++) {
DocRouter.Range subRange = subRanges.get(i);
ranges.append(subRange.toString());
if (i < subRanges.size() - 1)
ranges.append(",");
}
params.set("ranges", ranges.toString());
}
if (splitKey != null) {
params.set("split.key", splitKey);
}
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
String baseUrl = ((HttpSolrServer) shardToJetty.get(SHARD1).get(0).client.solrClient)
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
baseServer.setConnectionTimeout(15000);
baseServer.setSoTimeout(60000 * 5);
baseServer.request(request);
baseServer.shutdown();
}
示例11: invoke
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
protected void invoke(ModifiableSolrParams params) throws SolrServerException, IOException {
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
String baseUrl = ((HttpSolrServer) shardToJetty.get(SHARD1).get(0).client.solrClient)
.getBaseURL();
baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());
HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
baseServer.setConnectionTimeout(15000);
baseServer.setSoTimeout(60000 * 5);
baseServer.request(request);
baseServer.shutdown();
}
示例12: deleteLiveReplicaTest
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void deleteLiveReplicaTest() throws Exception {
String collectionName = "delLiveColl";
CloudSolrServer client = createCloudClient(null);
try {
createCollection(collectionName, client);
waitForRecoveriesToFinish(collectionName, false);
DocCollection testcoll = getCommonCloudSolrServer().getZkStateReader()
.getClusterState().getCollection(collectionName);
Slice shard1 = null;
Replica replica1 = null;
for (Slice slice : testcoll.getSlices()) {
if ("active".equals(slice.getStr("state"))) {
shard1 = slice;
for (Replica replica : shard1.getReplicas())
if ("active".equals(replica.getStr("state"))) replica1 = replica;
}
}
if (replica1 == null) fail("no active replicas found");
HttpSolrServer replica1Server = new HttpSolrServer(replica1.getStr("base_url"));
String dataDir = null;
try {
CoreAdminResponse status = CoreAdminRequest.getStatus(replica1.getStr("core"), replica1Server);
NamedList<Object> coreStatus = status.getCoreStatus(replica1.getStr("core"));
dataDir = (String) coreStatus.get("dataDir");
} finally {
replica1Server.shutdown();
}
removeAndWaitForReplicaGone(collectionName, client, replica1,
shard1.getName());
assertFalse("dataDir for " + replica1.getName() + " should have been deleted by deleteReplica API", new File(dataDir).exists());
} finally {
client.shutdown();
}
}
示例13: submit
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void submit(final Req req, boolean isCommit) {
if (req.synchronous) {
blockAndDoRetries();
HttpSolrServer server = new HttpSolrServer(req.node.getUrl(),
servers.getHttpClient());
try {
server.request(req.uReq);
} catch (Exception e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "Failed synchronous update on shard " + req.node + " update: " + req.uReq , e);
} finally {
server.shutdown();
}
return;
}
if (log.isDebugEnabled()) {
log.debug("sending update to "
+ req.node.getUrl() + " retry:"
+ req.retries + " " + req.cmdString + " params:" + req.uReq.getParams());
}
if (isCommit) {
// a commit using ConncurrentUpdateSolrServer is not async,
// so we make it async to prevent commits from happening
// serially across multiple nodes
pending.add(completionService.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
doRequest(req);
return null;
}
}));
} else {
doRequest(req);
}
}
示例14: collectStartTimes
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void collectStartTimes(String collectionName,
Map<String,Long> urlToTime) throws SolrServerException, IOException {
ClusterState clusterState = getCommonCloudSolrServer().getZkStateReader()
.getClusterState();
// Map<String,DocCollection> collections = clusterState.getCollectionStates();
if (clusterState.hasCollection(collectionName)) {
Map<String,Slice> slices = clusterState.getSlicesMap(collectionName);
Iterator<Entry<String,Slice>> it = slices.entrySet().iterator();
while (it.hasNext()) {
Entry<String,Slice> sliceEntry = it.next();
Map<String,Replica> sliceShards = sliceEntry.getValue().getReplicasMap();
Iterator<Entry<String,Replica>> shardIt = sliceShards.entrySet()
.iterator();
while (shardIt.hasNext()) {
Entry<String,Replica> shardEntry = shardIt.next();
ZkCoreNodeProps coreProps = new ZkCoreNodeProps(shardEntry.getValue());
HttpSolrServer server = new HttpSolrServer(coreProps.getBaseUrl());
CoreAdminResponse mcr;
try {
mcr = CoreAdminRequest.getStatus(coreProps.getCoreName(), server);
} finally {
server.shutdown();
}
long before = mcr.getStartTime(coreProps.getCoreName()).getTime();
urlToTime.put(coreProps.getCoreUrl(), before);
}
}
} else {
throw new IllegalArgumentException("Could not find collection in :"
+ clusterState.getCollections());
}
}
示例15: fetchFileList
import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
/**
* Fetches the list of files in a given index commit point and updates internal list of files to download.
*/
private void fetchFileList(long gen) throws IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(COMMAND, CMD_GET_FILE_LIST);
params.set(GENERATION, String.valueOf(gen));
params.set(CommonParams.WT, "javabin");
params.set(CommonParams.QT, "/replication");
QueryRequest req = new QueryRequest(params);
HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX modify to use shardhandler
try {
server.setSoTimeout(60000);
server.setConnectionTimeout(15000);
NamedList response = server.request(req);
List<Map<String, Object>> files = (List<Map<String,Object>>) response.get(CMD_GET_FILE_LIST);
if (files != null)
filesToDownload = Collections.synchronizedList(files);
else {
filesToDownload = Collections.emptyList();
LOG.error("No files to download for index generation: "+ gen);
}
files = (List<Map<String,Object>>) response.get(CONF_FILES);
if (files != null)
confFilesToDownload = Collections.synchronizedList(files);
} catch (SolrServerException e) {
throw new IOException(e);
} finally {
server.shutdown();
}
}