Add migration fail capture
This commit is contained in:
+3
-2
@@ -107,8 +107,7 @@ public class LegacyFullDataFileHandler
|
||||
// migration //
|
||||
//===========//
|
||||
|
||||
public int getDataSourceMigrationCount()
|
||||
{ return ((LegacyFullDataRepo) this.repo).getMigrationCount(); }
|
||||
public int getDataSourceMigrationCount() { return ((LegacyFullDataRepo) this.repo).getMigrationCount(); }
|
||||
|
||||
public ArrayList<CompleteFullDataSource> getDataSourcesToMigrate(int limit)
|
||||
{
|
||||
@@ -128,5 +127,7 @@ public class LegacyFullDataFileHandler
|
||||
return dataSourceList;
|
||||
}
|
||||
|
||||
public void markMigrationFailed(DhSectionPos pos) { ((LegacyFullDataRepo) this.repo).markMigrationFailed(pos); }
|
||||
|
||||
|
||||
}
|
||||
|
||||
+19
-7
@@ -313,15 +313,25 @@ public class NewFullDataFileHandler
|
||||
|
||||
for (int i = 0; i < legacyDataSourceList.size() && this.migrationThreadRunning.get(); i++)
|
||||
{
|
||||
// convert the legacy data source to the new format
|
||||
CompleteFullDataSource legacyDataSource = legacyDataSourceList.get(i);
|
||||
NewFullDataSource newDataSource = NewFullDataSource.createFromCompleteDataSource(legacyDataSource);
|
||||
newDataSource.applyToParent = true;
|
||||
|
||||
this.updateDataSourceAtPos(newDataSource.getSectionPos(), newDataSource, true);
|
||||
|
||||
// the legacy data source can now be deleted
|
||||
this.legacyFileHandler.repo.deleteWithKey(legacyDataSource.getSectionPos());
|
||||
try
|
||||
{
|
||||
// convert the legacy data source to the new format
|
||||
NewFullDataSource newDataSource = NewFullDataSource.createFromCompleteDataSource(legacyDataSource);
|
||||
newDataSource.applyToParent = true;
|
||||
|
||||
this.updateDataSourceAtPos(newDataSource.getSectionPos(), newDataSource, true);
|
||||
|
||||
// the legacy data source can now be deleted
|
||||
this.legacyFileHandler.repo.deleteWithKey(legacyDataSource.getSectionPos());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DhSectionPos migrationPos = legacyDataSource.getSectionPos();
|
||||
LOGGER.error("Unexpected issue migrating data source at pos "+migrationPos+". Error: "+e.getMessage(), e);
|
||||
this.legacyFileHandler.markMigrationFailed(migrationPos);
|
||||
}
|
||||
}
|
||||
|
||||
legacyDataSourceList = this.legacyFileHandler.getDataSourcesToMigrate(MIGRATION_BATCH_COUNT);
|
||||
@@ -342,6 +352,8 @@ public class NewFullDataFileHandler
|
||||
{
|
||||
LOGGER.info("No migration necessary.");
|
||||
}
|
||||
|
||||
this.migrationThreadRunning.set(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+12
-1
@@ -53,7 +53,7 @@ public class LegacyFullDataRepo extends AbstractLegacyDataSourceRepo
|
||||
public int getMigrationCount()
|
||||
{
|
||||
Map<String, Object> resultMap = this.queryDictionaryFirst(
|
||||
"select COUNT(*) as itemCount from "+this.getTableName());
|
||||
"select COUNT(*) as itemCount from "+this.getTableName()+" where MigrationFailed <> 1");
|
||||
|
||||
if (resultMap == null)
|
||||
{
|
||||
@@ -74,6 +74,7 @@ public class LegacyFullDataRepo extends AbstractLegacyDataSourceRepo
|
||||
List<Map<String, Object>> resultMapList = this.queryDictionary(
|
||||
"select DhSectionPos " +
|
||||
"from "+this.getTableName()+" " +
|
||||
"WHERE MigrationFailed <> 1 " +
|
||||
"LIMIT "+returnCount+";");
|
||||
|
||||
for (Map<String, Object> resultMap : resultMapList)
|
||||
@@ -86,6 +87,16 @@ public class LegacyFullDataRepo extends AbstractLegacyDataSourceRepo
|
||||
return list;
|
||||
}
|
||||
|
||||
public void markMigrationFailed(DhSectionPos pos)
|
||||
{
|
||||
String sql =
|
||||
"UPDATE "+this.getTableName()+" \n" +
|
||||
"SET MigrationFailed = 1 \n" +
|
||||
"WHERE DhSectionPos = '"+pos.serialize()+"'";
|
||||
|
||||
this.queryDictionaryFirst(sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+5
-1
@@ -1,5 +1,9 @@
|
||||
|
||||
ALTER TABLE `DhFullData` RENAME TO `Legacy_FullData_V1`;
|
||||
ALTER TABLE DhFullData RENAME TO Legacy_FullData_V1;
|
||||
|
||||
--batch--
|
||||
|
||||
ALTER TABLE Legacy_FullData_V1 ADD COLUMN MigrationFailed BIT NOT NULL DEFAULT 0;
|
||||
|
||||
--batch--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user