本文整理汇总了Java中org.apache.solr.client.solrj.request.CoreAdminRequest.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java CoreAdminRequest.getStatus方法的具体用法?Java CoreAdminRequest.getStatus怎么用?Java CoreAdminRequest.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.request.CoreAdminRequest
的用法示例。
在下文中一共展示了CoreAdminRequest.getStatus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
CoreAdminResponse coreAdminResponse = CoreAdminRequest.getStatus(core, solrServer);
NamedList<Object> index = (NamedList<Object>)coreAdminResponse.getCoreStatus(core).get("index");
Integer segmentCount = (Integer)index.get("segmentCount");
if(segmentCount < maxSegments) {
logger.debug("Core " + core + " only has " + segmentCount + " segments, skipping optimization");
} else {
logger.debug("Core " + core + " has " + segmentCount + " segments, starting optimization");
solrServer.optimize(true, true);
logger.debug("Core " + core + " optimized");
}
return RepeatStatus.FINISHED;
}
示例2: execute
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
CoreAdminResponse coreAdminResponse = CoreAdminRequest.getStatus(core, solrClient);
NamedList<Object> index = (NamedList<Object>)coreAdminResponse.getCoreStatus(core).get("index");
Integer segmentCount = (Integer)index.get("segmentCount");
if(segmentCount < maxSegments) {
logger.debug("Core " + core + " only has " + segmentCount + " segments, skipping optimization");
} else {
logger.debug("Core " + core + " has " + segmentCount + " segments, starting optimization");
solrClient.optimize(true, true);
logger.debug("Core " + core + " optimized");
}
return RepeatStatus.FINISHED;
}
示例3: schemaExists
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Override
public boolean schemaExists() {
boolean exists = false;
try {
CoreAdminResponse rsp = CoreAdminRequest.getStatus(mapping.getCoreName(),
adminServer);
exists = rsp.getUptime(mapping.getCoreName()) != null;
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
return exists;
}
示例4: deleteLiveReplicaTest
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的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();
}
}
示例5: collectStartTimes
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的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());
}
}
示例6: collectStartTimes
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
private void collectStartTimes(String collectionName,
Map<String,Long> urlToTime) throws SolrServerException, IOException {
Map<String,DocCollection> collections = getCommonCloudSolrServer().getZkStateReader()
.getClusterState().getCollectionStates();
if (collections.containsKey(collectionName)) {
Map<String,Slice> slices = collections.get(collectionName).getSlicesMap();
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());
CoreAdminResponse mcr = CoreAdminRequest.getStatus(
coreProps.getCoreName(),
new HttpSolrServer(coreProps.getBaseUrl()));
long before = mcr.getStartTime(coreProps.getCoreName()).getTime();
urlToTime.put(coreProps.getCoreUrl(), before);
}
}
} else {
throw new IllegalArgumentException("Could not find collection in :"
+ collections.keySet());
}
}
示例7: createCoreIfNotExists
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
public void createCoreIfNotExists() throws SolrServerException, IOException, NdexException {
CoreAdminResponse foo = CoreAdminRequest.getStatus(coreName,client);
if (foo.getStatus() != 0 ) {
throw new NdexException ("Failed to get status of solrIndex for " + coreName + ". Error: " + foo.getResponseHeader().toString());
}
NamedList<Object> bar = foo.getResponse();
NamedList<Object> st = (NamedList<Object>)bar.get("status");
NamedList<Object> core = (NamedList<Object>)st.get(coreName);
if ( core.size() == 0 ) {
System.out.println("Solr core " + coreName + " doesn't exist. Creating it now ....");
CoreAdminRequest.Create creator = new CoreAdminRequest.Create();
creator.setCoreName(coreName);
creator.setConfigSet( coreName);
foo = creator.process(client);
if ( foo.getStatus() != 0 ) {
throw new NdexException ("Failed to create solrIndex for " + coreName + ". Error: " + foo.getResponseHeader().toString());
}
System.out.println("Done.");
}
else {
System.out.println("Found core "+ coreName + " in Solr.");
}
}
示例8: createCoreIfNotExists
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
public void createCoreIfNotExists() throws SolrServerException, IOException, NdexException {
CoreAdminResponse foo = CoreAdminRequest.getStatus(coreName,client);
if (foo.getStatus() != 0 ) {
throw new NdexException ("Failed to get status of solrIndex for " + coreName + ". Error: " + foo.getResponseHeader().toString());
}
NamedList<Object> bar = foo.getResponse();
NamedList<Object> st = (NamedList<Object>)bar.get("status");
NamedList<Object> core = (NamedList<Object>)st.get(coreName);
if ( core.size() == 0 ) {
System.out.println("Solr core " + coreName + " doesn't exist. Creating it now ....");
CoreAdminRequest.Create creator = new CoreAdminRequest.Create();
creator.setCoreName(coreName);
creator.setConfigSet( coreName);
foo = creator.process(client);
if ( foo.getStatus() != 0 ) {
throw new NdexException ("Failed to create solrIndex for network " + coreName + ". Error: " + foo.getResponseHeader().toString());
}
System.out.println("Done.");
}
else {
System.out.println("Found core "+ coreName + " in Solr.");
}
}
示例9: schemaExists
import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Override
public boolean schemaExists() {
boolean exists = false;
try {
CoreAdminResponse rsp = CoreAdminRequest.getStatus( mapping.getCoreName(), adminServer );
exists = rsp.getUptime( mapping.getCoreName() ) != null;
} catch ( Exception e ) {
LOG.error( e.getMessage(), e.getStackTrace().toString() );
}
return exists;
}