use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class HttpPartitionTest method waitToSeeReplicasActive.
protected void waitToSeeReplicasActive(String testCollectionName, String shardId, Set<String> replicasToCheck, int maxWaitSecs) throws Exception {
final RTimer timer = new RTimer();
ZkStateReader zkr = cloudClient.getZkStateReader();
zkr.forceUpdateCollection(testCollectionName);
ClusterState cs = zkr.getClusterState();
Collection<Slice> slices = cs.getActiveSlices(testCollectionName);
boolean allReplicasUp = false;
long waitMs = 0L;
long maxWaitMs = maxWaitSecs * 1000L;
while (waitMs < maxWaitMs && !allReplicasUp) {
cs = cloudClient.getZkStateReader().getClusterState();
assertNotNull(cs);
Slice shard = cs.getSlice(testCollectionName, shardId);
assertNotNull("No Slice for " + shardId, shard);
// assume true
allReplicasUp = true;
// wait to see all replicas are "active"
for (Replica replica : shard.getReplicas()) {
if (!replicasToCheck.contains(replica.getName()))
continue;
final Replica.State state = replica.getState();
if (state != Replica.State.ACTIVE) {
log.info("Replica " + replica.getName() + " is currently " + state);
allReplicasUp = false;
}
}
if (!allReplicasUp) {
try {
Thread.sleep(200L);
} catch (Exception ignoreMe) {
}
waitMs += 200L;
}
}
if (!allReplicasUp)
fail("Didn't see replicas " + replicasToCheck + " come up within " + maxWaitMs + " ms! ClusterState: " + printClusterStateInfo(testCollectionName));
log.info("Took {} ms to see replicas [{}] become active.", timer.getTime(), replicasToCheck);
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class FacetQueryMerger method process.
@Override
public void process(ResponseBuilder rb) throws IOException {
// if this is null, faceting is not enabled
FacetComponentState facetState = getFacetComponentState(rb);
if (facetState == null)
return;
boolean isShard = rb.req.getParams().getBool(ShardParams.IS_SHARD, false);
FacetContext fcontext = new FacetContext();
fcontext.base = rb.getResults().docSet;
fcontext.req = rb.req;
fcontext.searcher = rb.req.getSearcher();
fcontext.qcontext = QueryContext.newContext(fcontext.searcher);
if (isShard) {
fcontext.flags |= FacetContext.IS_SHARD;
fcontext.facetInfo = facetState.facetInfo.isEmpty() ? null : (Map<String, Object>) facetState.facetInfo.get(FACET_REFINE);
if (fcontext.facetInfo != null) {
fcontext.flags |= FacetContext.IS_REFINEMENT;
// the root bucket should have been received from all shards previously
fcontext.flags |= FacetContext.SKIP_FACET;
}
}
FacetProcessor fproc = facetState.facetRequest.createFacetProcessor(fcontext);
if (rb.isDebug()) {
FacetDebugInfo fdebug = new FacetDebugInfo();
fcontext.setDebugInfo(fdebug);
fdebug.setReqDescription(facetState.facetRequest.getFacetDescription());
fdebug.setProcessor(fproc.getClass().getSimpleName());
final RTimer timer = new RTimer();
fproc.process();
long timeElapsed = (long) timer.getTime();
fdebug.setElapse(timeElapsed);
fdebug.putInfoItem("domainSize", (long) fcontext.base.size());
rb.req.getContext().put("FacetDebugInfo", fdebug);
} else {
fproc.process();
}
rb.rsp.add("facets", fproc.getResponse());
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class SystemInfoHandler method initHostname.
private void initHostname() {
if (null != System.getProperty(PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP, null)) {
log.info("Resolving canonical hostname for local host prevented due to '{}' sysprop", PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP);
hostname = null;
return;
}
RTimer timer = new RTimer();
try {
InetAddress addr = InetAddress.getLocalHost();
hostname = addr.getCanonicalHostName();
} catch (Exception e) {
log.warn("Unable to resolve canonical hostname for local host, possible DNS misconfiguration. " + "Set the '" + PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP + "' sysprop to true on startup to " + "prevent future lookups if DNS can not be fixed.", e);
hostname = null;
return;
}
timer.stop();
if (15000D < timer.getTime()) {
String readableTime = String.format(Locale.ROOT, "%.3f", (timer.getTime() / 1000));
log.warn("Resolving canonical hostname for local host took {} seconds, possible DNS misconfiguration. " + "Set the '{}' sysprop to true on startup to prevent future lookups if DNS can not be fixed.", readableTime, PREVENT_REVERSE_DNS_OF_LOCALHOST_SYSPROP);
}
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class FacetComponent method getFacetCounts.
/**
* Looks at various Params to determining if any simple Facet Constraint count
* computations are desired.
*
* @see SimpleFacets#getFacetQueryCounts
* @see SimpleFacets#getFacetFieldCounts
* @see RangeFacetProcessor#getFacetRangeCounts
* @see RangeFacetProcessor#getFacetIntervalCounts
* @see FacetParams#FACET
* @return a NamedList of Facet Count info or null
*/
public static NamedList<Object> getFacetCounts(SimpleFacets simpleFacets, FacetDebugInfo fdebug) {
// if someone called this method, benefit of the doubt: assume true
if (!simpleFacets.getGlobalParams().getBool(FacetParams.FACET, true))
return null;
RangeFacetProcessor rangeFacetProcessor = new RangeFacetProcessor(simpleFacets.getRequest(), simpleFacets.getDocsOrig(), simpleFacets.getGlobalParams(), simpleFacets.getResponseBuilder());
NamedList<Object> counts = new SimpleOrderedMap<>();
try {
counts.add(FACET_QUERY_KEY, simpleFacets.getFacetQueryCounts());
if (fdebug != null) {
FacetDebugInfo fd = new FacetDebugInfo();
fd.putInfoItem("action", "field facet");
fd.setProcessor(simpleFacets.getClass().getSimpleName());
fdebug.addChild(fd);
simpleFacets.setFacetDebugInfo(fd);
final RTimer timer = new RTimer();
counts.add(FACET_FIELD_KEY, simpleFacets.getFacetFieldCounts());
long timeElapsed = (long) timer.getTime();
fd.setElapse(timeElapsed);
} else {
counts.add(FACET_FIELD_KEY, simpleFacets.getFacetFieldCounts());
}
counts.add(FACET_RANGES_KEY, rangeFacetProcessor.getFacetRangeCounts());
counts.add(FACET_INTERVALS_KEY, simpleFacets.getFacetIntervalCounts());
counts.add(SpatialHeatmapFacets.RESPONSE_KEY, simpleFacets.getHeatmapCounts());
} catch (IOException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, e);
} catch (SyntaxError e) {
throw new SolrException(ErrorCode.BAD_REQUEST, e);
}
return counts;
}
use of org.apache.solr.util.RTimer in project lucene-solr by apache.
the class FacetComponent method process.
/**
* Actually run the query
*/
@Override
public void process(ResponseBuilder rb) throws IOException {
if (rb.doFacets) {
SolrParams params = rb.req.getParams();
SimpleFacets f = newSimpleFacets(rb.req, rb.getResults().docSet, params, rb);
RTimer timer = null;
FacetDebugInfo fdebug = null;
if (rb.isDebug()) {
fdebug = new FacetDebugInfo();
rb.req.getContext().put("FacetDebugInfo-nonJson", fdebug);
timer = new RTimer();
}
NamedList<Object> counts = FacetComponent.getFacetCounts(f, fdebug);
String[] pivots = params.getParams(FacetParams.FACET_PIVOT);
if (!ArrayUtils.isEmpty(pivots)) {
PivotFacetProcessor pivotProcessor = new PivotFacetProcessor(rb.req, rb.getResults().docSet, params, rb);
SimpleOrderedMap<List<NamedList<Object>>> v = pivotProcessor.process(pivots);
if (v != null) {
counts.add(PIVOT_KEY, v);
}
}
if (fdebug != null) {
long timeElapsed = (long) timer.getTime();
fdebug.setElapse(timeElapsed);
}
rb.rsp.add("facet_counts", counts);
}
}
Aggregations