-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try pre-fetch into memory for PscMemqConsumer to catch SdkClientExcep…
…tion
- Loading branch information
Showing
2 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
psc/src/main/java/com/pinterest/psc/consumer/memq/MemqPreFetchIteratorAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.pinterest.psc.consumer.memq; | ||
|
||
import com.pinterest.psc.common.CloseableIterator; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class MemqPreFetchIteratorAdapter<T> implements CloseableIterator<T> { | ||
|
||
private final List<T> messages; | ||
private int index = 0; | ||
|
||
public MemqPreFetchIteratorAdapter(List<T> messages) { | ||
this.messages = messages; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
messages.clear(); | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return index < messages.size(); | ||
} | ||
|
||
@Override | ||
public T next() { | ||
return messages.get(index++); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters