SOLR-4376: DataImportHandler uses wrong date format for last_index_time if a delta-import is run first before any full-imports

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1544421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2013-11-22 06:45:14 +00:00
parent 69bb099bd8
commit eb1dcbaa70
5 changed files with 27 additions and 4 deletions

View File

@ -135,6 +135,10 @@ Bug Fixes
in zookeeper as UTF-8. This bug was found after upgrading to forbidden-apis
1.4. (Uwe Schindler)
* SOLR-4376: DataImportHandler uses wrong date format for last_index_time if
a delta-import is run first before any full-imports.
(Sebastien Lorber, Arcadius Ahouansou via shalin)
Optimizations
----------------------

View File

@ -37,6 +37,8 @@ public abstract class DIHProperties {
public abstract Map<String, Object> readIndexerProperties();
public abstract String convertDateToString(Date d);
public Date getCurrentTimestamp() {
return new Date();
}

View File

@ -117,6 +117,7 @@ public class DocBuilder {
private VariableResolver getVariableResolver() {
try {
VariableResolver resolver = null;
String epoch = propWriter.convertDateToString(EPOCH);
if(dataImporter != null && dataImporter.getCore() != null
&& dataImporter.getCore().getResourceLoader().getCoreProperties() != null){
resolver = new VariableResolver(dataImporter.getCore().getResourceLoader().getCoreProperties());
@ -129,7 +130,7 @@ public class DocBuilder {
indexerNamespace.put(LAST_INDEX_TIME, persistedProperties.get(LAST_INDEX_TIME));
} else {
// set epoch
indexerNamespace.put(LAST_INDEX_TIME, EPOCH);
indexerNamespace.put(LAST_INDEX_TIME, epoch);
}
indexerNamespace.put(INDEX_START_TIME, dataImporter.getIndexStartTime());
indexerNamespace.put("request", new HashMap<String,Object>(reqParams.getRawParams()));
@ -140,7 +141,7 @@ public class DocBuilder {
if (lastIndex != null) {
entityNamespace.put(SolrWriter.LAST_INDEX_KEY, lastIndex);
} else {
entityNamespace.put(SolrWriter.LAST_INDEX_KEY, EPOCH);
entityNamespace.put(SolrWriter.LAST_INDEX_KEY, epoch);
}
indexerNamespace.put(entity.getName(), entityNamespace);
}

View File

@ -130,7 +130,8 @@ public class SimplePropertiesWriter extends DIHProperties {
}
protected String convertDateToString(Date d) {
@Override
public String convertDateToString(Date d) {
return dateFormat.format(d);
}
protected Date convertStringToDate(String s) {

View File

@ -23,7 +23,7 @@ import org.junit.Test;
*/
/**
* Test with various combinations of parameters, child entites, transformers.
* Test with various combinations of parameters, child entities, transformers.
*/
public class TestSqlEntityProcessorDelta extends AbstractSqlEntityProcessorTestCase {
private boolean delta = false;
@ -48,6 +48,21 @@ public class TestSqlEntityProcessorDelta extends AbstractSqlEntityProcessorTestC
singleEntity(c);
validateChanges();
}
@Test
public void testDeltaImportWithoutInitialFullImport() throws Exception {
log.debug("testDeltaImportWithoutInitialFullImport delta-import...");
countryEntity = false;
delta = true;
/*
* We need to add 2 in total:
* +1 for deltaQuery i.e identifying id of items to update,
* +1 for deletedPkQuery i.e delete query
*/
singleEntity(totalPeople() + 2);
validateChanges();
}
@Test
public void testWithSimpleTransformer() throws Exception {
log.debug("testWithSimpleTransformer full-import...");