Adding default cache stub
This commit is contained in:
parent
c70ab1fc72
commit
66b809ef7b
2 changed files with 48 additions and 7 deletions
|
|
@ -0,0 +1,48 @@
|
|||
package com.amazonaws.services.kinesis.clientlibrary.lib.worker;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.amazonaws.services.kinesis.model.GetRecordsResult;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.apachecommons.CommonsLog;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@CommonsLog
|
||||
public class DefaultGetRecordsCache implements GetRecordsCache {
|
||||
private static final int DEFAULT_MAX_SIZE = 1;
|
||||
private static final int DEFAULT_MAX_BYTE_SIZE = 1;
|
||||
private static final int DEFAULT_MAX_RECORDS_COUNT = 1;
|
||||
|
||||
private final Queue<GetRecordsResult> getRecordsResultQueue;
|
||||
private final int maxSize;
|
||||
private final int maxByteSize;
|
||||
private final int maxRecordsCount;
|
||||
private final int maxRecordsPerCall;
|
||||
@NonNull
|
||||
private final GetRecordsRetrievalStrategy getRecordsRetrievalStrategy;
|
||||
|
||||
public DefaultGetRecordsCache(final Optional<Integer> maxSize, final Optional<Integer> maxByteSize, final Optional<Integer> maxRecordsCount,
|
||||
final int maxRecordsPerCall, final GetRecordsRetrievalStrategy getRecordsRetrievalStrategy) {
|
||||
this.getRecordsResultQueue = new ConcurrentLinkedQueue<>();
|
||||
this.maxSize = maxSize.orElse(DEFAULT_MAX_SIZE);
|
||||
this.maxByteSize = maxByteSize.orElse(DEFAULT_MAX_BYTE_SIZE);
|
||||
this.maxRecordsCount = maxRecordsCount.orElse(DEFAULT_MAX_RECORDS_COUNT);
|
||||
this.maxRecordsPerCall = maxRecordsPerCall;
|
||||
this.getRecordsRetrievalStrategy = getRecordsRetrievalStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetRecordsResult getNextResult() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -6,11 +6,6 @@ import com.amazonaws.services.kinesis.model.GetRecordsResult;
|
|||
* This class is used as a cache for Prefetching data from Kinesis.
|
||||
*/
|
||||
public interface GetRecordsCache {
|
||||
/**
|
||||
* This method dispatches the next call to getRecords from Kinesis.
|
||||
*/
|
||||
void dispatchNextCall();
|
||||
|
||||
/**
|
||||
* This method returns the next set of records from the Cache if present, or blocks the request till it gets the
|
||||
* next set of records back from Kinesis.
|
||||
|
|
@ -19,7 +14,5 @@ public interface GetRecordsCache {
|
|||
*/
|
||||
GetRecordsResult getNextResult();
|
||||
|
||||
void addGetRecordsResultToCache(GetRecordsResult getRecordsResult);
|
||||
|
||||
void shutdown();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue