use of com.yahoo.messagebus.StaticThrottlePolicy in project vespa by vespa-engine.
the class MbusSessionKeyTestCase method staticThrottlePolicySignature.
@Test
public final void staticThrottlePolicySignature() {
final StaticThrottlePolicy base = new StaticThrottlePolicy();
final StaticThrottlePolicy other = new StaticThrottlePolicy();
other.setMaxPendingCount(500);
other.setMaxPendingSize(500 * 1000 * 1000);
base.setMaxPendingCount(1);
base.setMaxPendingSize(1000);
final StaticThrottlePolicySignature sigBase = new StaticThrottlePolicySignature(base);
final StaticThrottlePolicySignature sigOther = new StaticThrottlePolicySignature(other);
assertFalse("The policies are different, but signatures are equal.", sigBase.equals(sigOther));
assertTrue("Sigs created from same policy evaluated as different.", sigBase.equals(new StaticThrottlePolicySignature(base)));
other.setMaxPendingCount(1);
other.setMaxPendingSize(1000);
assertTrue("Sigs created from different policies with same settings evaluated as different.", sigBase.equals(new StaticThrottlePolicySignature(other)));
}
use of com.yahoo.messagebus.StaticThrottlePolicy in project vespa by vespa-engine.
the class MbusSessionKeyTestCase method unknownThrottlePolicySignature.
@Test
public final void unknownThrottlePolicySignature() {
final UnknownThrottlePolicySignature baseSig = new UnknownThrottlePolicySignature(new StaticThrottlePolicy());
final UnknownThrottlePolicySignature otherSig = new UnknownThrottlePolicySignature(new StaticThrottlePolicy());
assertEquals(baseSig, baseSig);
assertFalse(otherSig.equals(baseSig));
}
use of com.yahoo.messagebus.StaticThrottlePolicy in project vespa by vespa-engine.
the class SimpleFeeder method newSession.
private static SourceSession newSession(RPCMessageBus mbus, ReplyHandler replyHandler, boolean serial) {
SourceSessionParams params = new SourceSessionParams();
params.setReplyHandler(replyHandler);
if (serial) {
params.setThrottlePolicy(new StaticThrottlePolicy().setMaxPendingCount(1));
}
return mbus.getMessageBus().createSourceSession(params);
}
use of com.yahoo.messagebus.StaticThrottlePolicy in project vespa by vespa-engine.
the class VisitSearcher method getVisitorParameters.
public VisitorParameters getVisitorParameters(Query query, Result result) throws Exception {
String documentSelection = query.properties().getString("visit.selection");
if (documentSelection == null) {
documentSelection = "";
}
VisitorParameters params = new VisitorParameters(documentSelection);
params.setMaxBucketsPerVisitor(query.properties().getInteger("visit.maxBucketsPerVisitor", 1));
params.setMaxPending(query.properties().getInteger("visit.maxPendingMessagesPerVisitor", 32));
params.setMaxFirstPassHits(query.properties().getInteger("visit.approxMaxDocs", 1));
params.setMaxTotalHits(query.properties().getInteger("visit.approxMaxDocs", 1));
params.setThrottlePolicy(new StaticThrottlePolicy().setMaxPendingCount(query.properties().getInteger("visit.maxPendingVisitors", 1)));
params.setToTimestamp(query.properties().getLong("visit.toTimestamp", 0L));
params.setFromTimestamp(query.properties().getLong("visit.fromTimestamp", 0L));
String pri = query.properties().getString("visit.priority");
if (pri != null) {
params.setPriority(DocumentProtocol.Priority.valueOf(pri));
}
if (query.properties().getBoolean("visit.visitInconsistentBuckets")) {
params.visitInconsistentBuckets(true);
}
String ordering = query.properties().getString("visit.order");
if (!"ascending".equalsIgnoreCase(ordering)) {
params.setVisitorOrdering(VisitorOrdering.ASCENDING);
} else {
params.setVisitorOrdering(VisitorOrdering.DESCENDING);
}
String remoteCluster = query.properties().getString("visit.dataHandler");
if (remoteCluster != null) {
params.setRemoteDataHandler(remoteCluster);
} else {
params.setLocalDataHandler(new HitDataHandler(result, query.properties().getBoolean("populatehitfields", false)));
}
String fieldSet = query.properties().getString("visit.fieldSet");
if (fieldSet != null) {
params.fieldSet(fieldSet);
}
String continuation = query.properties().getString("visit.continuation");
if (continuation != null) {
params.setResumeToken(ContinuationHit.getToken(continuation));
}
params.setVisitRemoves(query.properties().getBoolean("visit.visitRemoves"));
MessagePropertyProcessor.PropertySetter propertySetter;
propertySetter = context.getPropertyProcessor().buildPropertySetter(query.getHttpRequest());
propertySetter.process(params);
if (context.getClusterList().getStorageClusters().size() == 0) {
throw new IllegalArgumentException("No content clusters have been defined");
}
String route = query.properties().getString("visit.cluster");
ClusterDef found = null;
if (route != null) {
String names = "";
for (ClusterDef c : context.getClusterList().getStorageClusters()) {
if (c.getName().equals(route)) {
found = c;
}
if (!names.isEmpty()) {
names += ", ";
}
names += c.getName();
}
if (found == null) {
throw new IllegalArgumentException("Your vespa cluster contains the storage clusters " + names + ", not " + route + ". Please select a valid vespa cluster.");
}
} else if (context.getClusterList().getStorageClusters().size() == 1) {
found = context.getClusterList().getStorageClusters().get(0);
} else {
throw new IllegalArgumentException("Multiple content clusters are defined, select one using the \"visit.cluster\" option");
}
params.setRoute("[Storage:cluster=" + found.getName() + ";clusterconfigid=" + found.getConfigId() + "]");
return params;
}
use of com.yahoo.messagebus.StaticThrottlePolicy in project vespa by vespa-engine.
the class OperationHandlerImpl method createVisitorParameters.
private VisitorParameters createVisitorParameters(RestUri restUri, String documentSelection, VisitOptions options) throws RestApiException {
StringBuilder selection = new StringBuilder();
if (!documentSelection.isEmpty()) {
// TODO shouldn't selection be wrapped in () itself ?
selection.append("(").append(documentSelection).append(" and ");
}
selection.append(restUri.getDocumentType()).append(" and (id.namespace=='").append(restUri.getNamespace()).append("')");
if (!documentSelection.isEmpty()) {
selection.append(")");
}
VisitorParameters params = new VisitorParameters(selection.toString());
// Only return fieldset that is part of the document.
params.fieldSet(options.fieldSet.orElse(restUri.getDocumentType() + ":[document]"));
params.setMaxBucketsPerVisitor(1);
params.setMaxPending(32);
params.setMaxFirstPassHits(1);
params.setMaxTotalHits(options.wantedDocumentCount.map(n -> Math.min(Math.max(n, 1), WANTED_DOCUMENT_COUNT_UPPER_BOUND)).orElse(1));
params.setThrottlePolicy(new StaticThrottlePolicy().setMaxPendingCount(options.concurrency.orElse(1)));
params.setToTimestamp(0L);
params.setFromTimestamp(0L);
params.setSessionTimeoutMs(VISIT_TIMEOUT_MS);
// TODO document this as part of consistency doc
params.visitInconsistentBuckets(true);
params.setVisitorOrdering(VisitorOrdering.ASCENDING);
BucketSpaceRoute bucketSpaceRoute = resolveBucketSpaceRoute(options.cluster, restUri.getDocumentType());
params.setRoute(bucketSpaceRoute.getClusterRoute());
params.setBucketSpace(bucketSpaceRoute.getBucketSpace());
params.setTraceLevel(0);
params.setPriority(DocumentProtocol.Priority.NORMAL_4);
params.setVisitRemoves(false);
if (options.continuation.isPresent()) {
try {
params.setResumeToken(ContinuationHit.getToken(options.continuation.get()));
} catch (Exception e) {
throw new RestApiException(Response.createErrorResponse(500, ExceptionUtils.getStackTrace(e), restUri, RestUri.apiErrorCodes.UNSPECIFIED));
}
}
return params;
}
Aggregations