public DistributorSelectionLogic(Parameters params, ExternalSlobrokPolicy policy) { this.hostFetcher = params.createHostFetcher(policy); this.hostFetcher.setRequiredUpPercentageToSendToKnownGoodNodes(params.getRequiredUpPercentageToSendToKnownGoodNodes()); this.distribution = params.createDistribution(policy); persistentFailureChecker = new InstabilityChecker(params.getAttemptRandomOnFailuresLimit()); maxOldClusterVersionBeforeSendingRandom = params.maxOldClusterStatesSeenBeforeThrowingCachedState(); }
private boolean resourceWasFound(Reply r) { if (r instanceof RemoveDocumentReply) { return ((RemoveDocumentReply) r).wasFound(); } if (r instanceof UpdateDocumentReply) { return ((UpdateDocumentReply) r).wasFound(); } if (r instanceof GetDocumentReply) { return ((GetDocumentReply) r).getLastModified() > 0; } return false; }
public Builder(DocumentrouteselectorpolicyConfig config) { for (Route r : config.route()) { route(new Route.Builder(r)); } }
@Override protected DocumentMessage doDecode(DocumentDeserializer buffer) { final LazyDecoder decoder = (obj, buf) -> { decodeInto((UpdateDocumentMessage) obj, buf); }; return new UpdateDocumentMessage(decoder, buffer); }
@Override protected DocumentMessage doDecode(DocumentDeserializer buffer) { final LazyDecoder decoder = (obj, buf) -> { decodeInto((PutDocumentMessage) obj, buf); }; return new PutDocumentMessage(decoder, buffer); }
@Override protected DocumentMessage doDecode(DocumentDeserializer buf) { RemoveDocumentMessage msg = new RemoveDocumentMessage(); decodeInto(msg, buf); return msg; }
@Override public int getPriority() { return requestMsg.getPriority().getValue(); }
@Override protected DocumentReply doDecode(DocumentDeserializer buf) { WrongDistributionReply reply = new WrongDistributionReply(); reply.setSystemState(decodeString(buf)); return reply; }
public DocumentProtocolRoutingPolicy createPolicy(String param) { ExternPolicy ret = new ExternPolicy(param); String error = ret.getError(); if (error != null) { return new ErrorPolicy(error); } return ret; }
private String cachingGetTargetSpec(Integer distributor, RoutingContext context, GenerationCache cache) { String cachedTarget = cache.get(distributor); if (cachedTarget != null) { return cachedTarget; } // Mirror _may_ be at a higher version if we race with generation read, but that is OK since // we'll either way get the most up-to-date mapping and the cache will be invalidated on the // next invocation. String resolvedTarget = super.getTargetSpec(distributor, context); cache.put(distributor, resolvedTarget); return resolvedTarget; }
@Override protected DocumentMessage doDecode(DocumentDeserializer buf) { DestroyVisitorMessage msg = new DestroyVisitorMessage(); msg.setInstanceId(decodeString(buf)); return msg; }
@Override protected DocumentReply doDecode(DocumentDeserializer buf) { StatBucketReply reply = new StatBucketReply(); reply.setResults(decodeString(buf)); return reply; }
@Override protected boolean doEncode(DocumentMessage obj, DocumentSerializer buf) { DestroyVisitorMessage msg = (DestroyVisitorMessage)obj; encodeString(msg.getInstanceId(), buf); return true; } }
/** Finds the TCP address of the target. @return Returns a hop representing the TCP address of the target, or null if none could be found. */ LoadBalancer.Node getRecipient(RoutingContext context) { Mirror.Entry [] lastLookup = lookup(context, pattern); return loadBalancer.getRecipient(lastLookup); }
@Override protected boolean doEncode(DocumentMessage obj, DocumentSerializer buf) { RemoveLocationMessage msg = (RemoveLocationMessage)obj; encodeString(msg.getDocumentSelection(), buf); return true; } }
@Override public void init() { super.init(); this.distributorSelectionLogic = new DistributorSelectionLogic(parameters, this); }
@Override protected boolean doEncode(DocumentReply obj, DocumentSerializer buf) { WrongDistributionReply reply = (WrongDistributionReply)obj; encodeString(reply.getSystemState(), buf); return true; } }
@Override protected boolean doEncode(DocumentReply obj, DocumentSerializer buf) { StatBucketReply reply = (StatBucketReply)obj; encodeString(reply.getResults(), buf); return true; } }
public SlobrokHostPatternGenerator createPatternGenerator() { return new SlobrokHostPatternGenerator(getClusterName()); } public HostFetcher createHostFetcher(ExternalSlobrokPolicy policy) {