Skip to content

Commit

Permalink
Docker test version, removed log statements
Browse files Browse the repository at this point in the history
  • Loading branch information
dashrath-chauhan committed Sep 30, 2024
1 parent da8aae4 commit ac3b9d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Standard Tests
#on: [push, pull_request, workflow_dispatch] #workflow_dispatch works only if its active in the main branch
on: [pull_request, workflow_dispatch] #workflow_dispatch works only if its active in the main branch
on: [push, pull_request, workflow_dispatch] #workflow_dispatch works only if its active in the main branch
#on: [pull_request, workflow_dispatch] #workflow_dispatch works only if its active in the main branch
jobs:
Unit-Test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ configurations.all {

archivesBaseName = 'ga4gh-starter-kit-drs'
group 'org.ga4gh'
version '0.3.2'
version '0.3.3-test'

repositories {
// Use jcenter for resolving dependencies.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.ga4gh.starterkit.drs.app;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.catalina.connector.Connector;
import org.apache.commons.cli.Options;
import org.ga4gh.starterkit.common.config.DatabaseProps;
import org.ga4gh.starterkit.common.config.ServerProps;
import org.ga4gh.starterkit.common.hibernate.HibernateEntity;
import org.ga4gh.starterkit.common.util.CliYamlConfigLoader;
import org.ga4gh.starterkit.common.util.DeepObjectMerger;
Expand All @@ -11,19 +12,9 @@
import org.ga4gh.starterkit.common.util.webserver.AdminEndpointsFilter;
import org.ga4gh.starterkit.common.util.webserver.CorsFilterBuilder;
import org.ga4gh.starterkit.common.util.webserver.TomcatMultiConnectorServletWebServerFactoryCustomizer;
import org.apache.catalina.connector.Connector;
import org.apache.commons.cli.Options;
import org.ga4gh.starterkit.common.config.DatabaseProps;
import org.ga4gh.starterkit.common.config.ServerProps;
import org.ga4gh.starterkit.drs.config.DrsServiceProps;
import org.ga4gh.starterkit.drs.exception.DrsCustomExceptionHandling;
import org.ga4gh.starterkit.drs.model.AwsS3AccessObject;
import org.ga4gh.starterkit.drs.model.Checksum;
import org.ga4gh.starterkit.drs.model.DrsObject;
import org.ga4gh.starterkit.drs.model.DrsServiceInfo;
import org.ga4gh.starterkit.drs.model.FileAccessObject;
import org.ga4gh.starterkit.drs.model.PassportBroker;
import org.ga4gh.starterkit.drs.model.PassportVisa;
import org.ga4gh.starterkit.drs.model.*;
import org.ga4gh.starterkit.drs.utils.cache.AccessCache;
import org.ga4gh.starterkit.drs.utils.hibernate.DrsHibernateUtil;
import org.ga4gh.starterkit.drs.utils.passport.UserPassportMapVerifier;
Expand All @@ -45,6 +36,10 @@
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.filter.CorsFilter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
* Contains Spring bean definitions that are to be loaded for the DRS service
* under all deployment contexts (ie as part of both standalone and GA4GH
Expand Down Expand Up @@ -283,7 +278,7 @@ public AccessRequestHandler accessRequestHandler() {
return new AccessRequestHandler();
}

@Bean
@Bean
@RequestScope
public AuthInfoRequestHandler authInfoRequestHandler() {
return new AuthInfoRequestHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,52 +270,39 @@ private List<FileAccessObject> createAndReturnFileObjects(DrsObject drsObject, S
public <I extends Serializable, T extends HibernateEntity<I>> List<DrsObject> performBulkInsertWithExecutor(
List<DrsObject> objectList, int numThreads, int batchSize, List<DrsObject> failedRecords) throws Exception {

//loggingUtil.info("1");
ExecutorService executor = Executors.newFixedThreadPool(numThreads);
List<Future<List<DrsObject>>> futures = new ArrayList<>();
int totalSize = objectList.size();

try {
//loggingUtil.info("2");
for (int i = 0; i < totalSize; i += batchSize) {
//loggingUtil.info("3");
List<DrsObject> batch = objectList.subList(i, Math.min(i + batchSize, totalSize));

futures.add(executor.submit(() -> {
//loggingUtil.info("4");
List<DrsObject> failedBatch = new ArrayList<>();

Session session = null;
Transaction tx = null;

try {
// Use reflection to access the private getSessionFactory() method
Method method = HibernateUtil.class.getDeclaredMethod("getSessionFactory");
method.setAccessible(true); // Bypass private access
SessionFactory sessionFactory = (SessionFactory) method.invoke(hibernateUtil);

session = sessionFactory.openSession();
tx = session.beginTransaction();
//loggingUtil.info("5");
//loggingUtil.info("7");
for (DrsObject object : batch) {
try {
//loggingUtil.info("8");
session.save(object);
//loggingUtil.info("9");
} catch (HibernateException ex) {
//loggingUtil.info("10");
loggingUtil.error("HibernateException occurred: " + ex);
failedBatch.add(object);
}
}
//loggingUtil.info("11");
session.flush();
session.clear();
tx.commit();
//loggingUtil.info("12");
} catch (Exception ex) {
//loggingUtil.info("13");
if (tx != null) {
tx.rollback();
}
Expand All @@ -327,21 +314,16 @@ public <I extends Serializable, T extends HibernateEntity<I>> List<DrsObject> pe
session.close();
}
}

//loggingUtil.info("14");
return failedBatch;
}));
}
//loggingUtil.info("15");

List<DrsObject> allFailedRecords = new ArrayList<>();
for (Future<List<DrsObject>> future : futures) {
allFailedRecords.addAll(future.get());
}
//loggingUtil.info("16");
return allFailedRecords;
} finally {
//loggingUtil.info("17");
executor.shutdown();
}
}
Expand Down

0 comments on commit ac3b9d6

Please sign in to comment.