Skip to content

Commit 7a1440b

Browse files
committed
Add more logging in ETL
1 parent f92cf41 commit 7a1440b

2 files changed

Lines changed: 37 additions & 8 deletions

File tree

mGAP/src/org/labkey/mgap/columnTransforms/AbstractVariantTransform.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ protected Integer getOrCreateOutputFile(Object dataFileUrl, Object folderName, S
131131

132132
File subDir = getLocalSubdir(folderName);
133133
File localCopy = doFileCopy(f, subDir, name);
134+
if (localCopy == null)
135+
{
136+
// TODO
137+
}
134138

135139
//first create the ExpData
136140
ExpData d = ExperimentService.get().getExpDataByURL(localCopy, getContainerUser().getContainer());
@@ -203,7 +207,11 @@ protected File getLocalSubdir(Object folderName) throws PipelineJobException
203207

204208
protected File doFileCopy(File f, File subdir, @Nullable String name) throws PipelineJobException
205209
{
206-
getStatusLogger().info("preparing to copy file: " + f.getPath());
210+
getStatusLogger().info("preparing to copy file: " + f.getPath() + ", with name: " + name);
211+
if (f.getName().equals("write.lock"))
212+
{
213+
return LuceneIndexTransform.doLuceneCopy(f, subdir, name, getStatusLogger(), getContainerUser().getContainer());
214+
}
207215

208216
//Copy file locally, plus index if exists:
209217
File localCopy = new File(subdir, name == null || f.getName().startsWith("mGap.v") ? f.getName() : FileUtil.makeLegalName(name).replaceAll(" ", "_") + ".vcf.gz");
@@ -227,6 +235,10 @@ protected File doFileCopy(File f, File subdir, @Nullable String name) throws Pip
227235
try
228236
{
229237
Files.delete(localCopy.toPath());
238+
if (localCopy.exists())
239+
{
240+
throw new PipelineJobException("Unable to delete file: " + localCopy.getPath());
241+
}
230242
}
231243
catch (IOException e)
232244
{
@@ -241,20 +253,24 @@ protected File doFileCopy(File f, File subdir, @Nullable String name) throws Pip
241253

242254
if (doCopy)
243255
{
244-
getStatusLogger().info("queueing file copy: " + localCopy.getPath());
256+
getStatusLogger().info("Creating symlink: " + f.getPath() + " / " + localCopy.getPath());
245257
try
246258
{
247259
if (!Files.isReadable(f.toPath()))
248260
{
249261
throw new PipelineJobException("Unable to read file: " + f.getPath());
250262
}
251263

264+
if (localCopy.exists())
265+
{
266+
throw new PipelineJobException("File should have been deleted: " + localCopy.getPath());
267+
}
268+
252269
Files.createSymbolicLink(f.toPath(), localCopy.toPath());
253270
}
254271
catch (IOException e)
255272
{
256-
getStatusLogger().error("Failed to create symlink: " + localCopy.getPath(), e);
257-
return null;
273+
throw new PipelineJobException("Failed to create symlink: " + localCopy.getPath(), e);
258274
}
259275
}
260276

@@ -270,16 +286,20 @@ protected File doFileCopy(File f, File subdir, @Nullable String name) throws Pip
270286

271287
if (!indexLocal.exists())
272288
{
273-
getStatusLogger().info("queueing copy of index: " + indexLocal.getPath());
289+
getStatusLogger().info("Creating symlink copy of VCF index: " + index.getPath() + " / " + indexLocal.getPath());
274290
try
275291
{
276-
Files.createSymbolicLink(f.toPath(), localCopy.toPath());
292+
Files.createSymbolicLink(index.toPath(), indexLocal.toPath());
277293
}
278294
catch (IOException e)
279295
{
280-
getStatusLogger().error("Failed to create symlink: " + localCopy.getPath(), e);
296+
getStatusLogger().error("Failed to create symlink: " + indexLocal.getPath(), e);
281297
}
282298
}
299+
else
300+
{
301+
getStatusLogger().info("Local index already exists: " + indexLocal.getPath());
302+
}
283303
}
284304

285305
return localCopy;

mGAP/src/org/labkey/mgap/columnTransforms/LuceneIndexTransform.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.labkey.mgap.columnTransforms;
22

3+
import org.apache.logging.log4j.Logger;
34
import org.jetbrains.annotations.Nullable;
5+
import org.labkey.api.data.Container;
46
import org.labkey.api.jbrowse.JBrowseService;
57
import org.labkey.api.pipeline.PipelineJobException;
68
import org.labkey.mgap.etl.EtlQueueManager;
@@ -21,11 +23,18 @@ protected Object doTransform(Object inputValue)
2123
@Override
2224
protected File doFileCopy(File f, File subdir, @Nullable String name) throws PipelineJobException
2325
{
26+
return doLuceneCopy(f, subdir, name, getStatusLogger(), getContainerUser().getContainer());
27+
}
28+
29+
public static File doLuceneCopy(File f, File subdir, @Nullable String name, Logger log, Container container) throws PipelineJobException
30+
{
31+
log.info("preparing to copy lucene index: " + f.getPath() + ", with name: " + name);
32+
2433
// NOTE: lucene is a special case since the DB tracks one file, but we need this whole folder:
2534
File sourceDir = f.getParentFile();
2635
File targetDir = new File(subdir, "LuceneIndex");
2736
JBrowseService.get().clearLuceneCacheEntry(targetDir);
28-
EtlQueueManager.get().queueRsyncCopy(getContainerUser().getContainer(), sourceDir, targetDir);
37+
EtlQueueManager.get().queueRsyncCopy(container, sourceDir, targetDir);
2938

3039
return new File(targetDir, sourceDir.getName() + "/" + f.getName());
3140
}

0 commit comments

Comments
 (0)