Revision 46765
Added by Alessia Bardi about 7 years ago
SftpIterator.java | ||
---|---|---|
10 | 10 |
import java.util.*; |
11 | 11 |
|
12 | 12 |
import com.jcraft.jsch.*; |
13 |
import eu.dnetlib.data.collector.ThreadSafeIterator; |
|
13 | 14 |
import eu.dnetlib.rmi.data.CollectorServiceRuntimeException; |
14 | 15 |
import org.apache.commons.io.output.ByteArrayOutputStream; |
15 | 16 |
import org.apache.commons.lang3.StringUtils; |
... | ... | |
19 | 20 |
/** |
20 | 21 |
* Created by andrea on 11/01/16. |
21 | 22 |
*/ |
22 |
public class SftpIterator implements Iterator<String> {
|
|
23 |
public class SftpIterator extends ThreadSafeIterator {
|
|
23 | 24 |
|
24 | 25 |
private static final Log log = LogFactory.getLog(SftpIterator.class); |
25 | 26 |
|
... | ... | |
214 | 215 |
} |
215 | 216 |
|
216 | 217 |
@Override |
217 |
public boolean hasNext() {
|
|
218 |
public boolean doHasNext() {
|
|
218 | 219 |
return !queue.isEmpty(); |
219 | 220 |
} |
220 | 221 |
|
221 | 222 |
@Override |
222 |
public String next() { |
|
223 |
public String doNext() { |
|
224 |
if(queue.isEmpty()) |
|
225 |
throw new CollectorServiceRuntimeException("Unexpected empty queue in next()"); |
|
223 | 226 |
String nextRemotePath = queue.remove(); |
224 | 227 |
int nRepeat = 0; |
225 | 228 |
String fullPathFile = ""; |
Also available in: Unified diff
Need synchronized next() method to avoid issues when collecting while getting the wf status/history