public ExponentialBackoffStrategy(int initialDelay, double backoffFactor, long maxDelay, int maxRetries) { checkState(initialDelay > 0, "Initial delay should be bigger than 0"); this.initialDelay = initialDelay; this.backoffFactor = backoffFactor; this.maxDelay = maxDelay; this.maxRetries = maxRetries; }
public Lock(String eventName, String lockedBy, List<Partition> partitions) { checkState(!partitions.isEmpty(), "Locked partitions should not be empty"); this.eventName = eventName; this.lockedBy = lockedBy; this.partitions = Collections.unmodifiableList(new ArrayList<>(partitions)); }
public SubscriptionBuilder readFromBegin() { checkState(initialCursors == null, "Initial cursors can not be specified when reading from 'begin'"); return new SubscriptionBuilder(nakadiClient, applicationName, eventNames, consumerGroup, SubscriptionRequest.Position.BEGIN, null); }
public SubscriptionBuilder readFromEnd() { checkState(initialCursors == null, "Initial cursors can not be specified when reading from 'end'"); return new SubscriptionBuilder(nakadiClient, applicationName, eventNames, consumerGroup, SubscriptionRequest.Position.END, null); }
public StreamBuilder.SubscriptionStreamBuilder stream(Subscription subscription) { checkState(cursorManager instanceof ManagedCursorManager, "Subscription api requires a ManagedCursorManager"); return new StreamBuilders.SubscriptionStreamBuilderImpl(baseUri, clientHttpRequestFactory, cursorManager, objectMapper, subscription); }
NakadiReader(URI uri, RequestFactory requestFactory, BackoffStrategy backoffStrategy, CursorManager cursorManager, Set<String> eventNames, Optional<Subscription> subscription, Optional<Lock> lock, EventReader<T> eventReader, Listener<T> listener, BatchHandler batchHandler, final MetricsCollector metricsCollector) { checkState(subscription.isPresent() || eventNames.size() == 1, "Low level api only supports reading from a single event"); this.uri = uri; this.requestFactory = requestFactory; this.backoffStrategy = backoffStrategy; this.cursorManager = cursorManager; this.eventNames = eventNames; this.subscription = subscription; this.lock = lock; this.eventReader = eventReader; this.listener = listener; this.batchHandler = batchHandler; this.metricsCollector = metricsCollector; this.jsonFactory = DefaultObjectMapper.INSTANCE.getFactory(); this.cursorHeaderWriter = DefaultObjectMapper.INSTANCE.writerFor(COLLECTION_OF_CURSORS); }