[ https://issues.apache.org/jira/browse/GOBBLIN-1025?focusedWorklogId=378982&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-378982 ]
ASF GitHub Bot logged work on GOBBLIN-1025: ------------------------------------------- Author: ASF GitHub Bot Created on: 29/Jan/20 19:36 Start Date: 29/Jan/20 19:36 Worklog Time Spent: 10m Work Description: arekusuri commented on pull request #2868: GOBBLIN-1025: Add retry for PK-Chuking iterator URL: https://github.com/apache/incubator-gobblin/pull/2868#discussion_r372589295 ########## File path: gobblin-salesforce/src/main/java/org/apache/gobblin/salesforce/QueryResultIterator.java ########## @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.gobblin.salesforce; + +import com.google.gson.JsonElement; +import java.util.Iterator; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.apache.gobblin.source.extractor.DataRecordException; +import org.apache.gobblin.source.extractor.watermark.Predicate; +import org.apache.gobblin.source.workunit.WorkUnit; + + +/** + * Iterator for rest api query + */ +@Slf4j +public class QueryResultIterator implements Iterator<JsonElement> { + + private int recordCount = 0; + private SalesforceExtractor extractor; + private String schema; + private String entity; + private WorkUnit workUnit; + private List<Predicate> predicateList; + + private Iterator<JsonElement> queryResultIter; + + public QueryResultIterator( + SalesforceExtractor extractor, + String schema, + String entity, + WorkUnit workUnit, + List<Predicate> predicateList + ) { + log.info("create query result iterator."); + this.extractor = extractor; + this.schema = schema; + this.entity = entity; + this.workUnit = workUnit; + this.predicateList = predicateList; + } + + @Override + public boolean hasNext() { + if (queryResultIter == null) { + initQueryResultIter(); + } + if (!queryResultIter.hasNext()) { + // no more data, print out total + log.info("Soft delete records total:{}", recordCount); + } + return queryResultIter.hasNext(); + } + + private void initQueryResultIter() { + try { + log.info("Pull soft delete records"); Review comment: good catch! Fixed it. It is general. In our case we only use it for soft delete. QueryResultIterator is a iterate wrap for function RestApiExtractor.getRecordSet() getRecordSet was called 2 places: 1. soft delete 2. QueryBasedExtractor.getIterator function. (using in simple mode) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 378982) Time Spent: 2h 50m (was: 2h 40m) > Add retry for PK-Chunking iterator > ---------------------------------- > > Key: GOBBLIN-1025 > URL: https://issues.apache.org/jira/browse/GOBBLIN-1025 > Project: Apache Gobblin > Issue Type: Improvement > Reporter: Alex Li > Priority: Major > Time Spent: 2h 50m > Remaining Estimate: 0h > > In SFDC connector, there is a class called `ResultIterator` (I will change > the name to SalesforceRecordIterator). > It was using by only PK-Chunking currently. It encapsulated fetching a list > of result files to a record iterator. > However, the csvReader.nextRecord() may throw out network IO exception. We > should do retry in this case. > When a result file is fetched partly and one network IO exception happens, we > are in a special situation - first half of the file is already fetched to our > local, but another half of the file is still on datasource. > We need to > 1. reopen the file stream > 2. skip all the records that we already fetched, seek the cursor to the > record which we haven't fetched yet. -- This message was sent by Atlassian Jira (v8.3.4#803005)