Skip to content

refactor: collapse server modules, flatten structure, eliminate internal Thrift clients#601

Merged
yasithdev merged 21 commits intomasterfrom
feat/server-collapse
Mar 29, 2026
Merged

refactor: collapse server modules, flatten structure, eliminate internal Thrift clients#601
yasithdev merged 21 commits intomasterfrom
feat/server-collapse

Conversation

@yasithdev
Copy link
Copy Markdown
Contributor

@yasithdev yasithdev commented Mar 28, 2026

Summary

Structure

  • Module flattening: modules/{research-service,agent-service,file-server}airavata-api/ sub-modules
  • Server collapse: airavata-rest-server, airavata-grpc-server, airavata-thrift-serverairavata-server/{rest,grpc,thrift} sub-modules
  • Non-Java restored: airavata-agent/, airavata-fuse/, airavata-jupyterhub/, dev-tools/simexr_mod/
  • Proto moved: agent-service/proto/agent-service/src/main/proto/
  • integration-tests merged into airavata-api test sources

Persistence

  • Single EMF: 6 persistence units + 7 JPAUtils + 4 catalog abstract repos → one Spring-managed EntityManagerFactory
  • Hibernate 6: 48 entity mapping fixes, orphanRemoval, FlushMode.MANUAL for reads, cascading FK deletes

Thrift Client Elimination

  • 29 internal Thrift sites → direct Spring bean injection (zero network round-trips within JVM)
  • Deleted: SharingRegistryServiceClientFactory, CredentialStoreClientFactory

Dozer → MapStruct

  • 63 repositories migrated from runtime Dozer reflection to compile-time MapStruct
  • 5 mapper interfaces (Execution, Compute, Storage, Sharing, Profile)
  • Deleted: dozer_mapping.xml, 3 ObjectMapperSingleton, CustomBeanFactory, converters

Build & Test

  • Surefire 3.5.5, forkCount=1C, JUnit 5 parallel execution
  • Per-test transaction rollback replacing truncate-all-tables (enables parallel integration tests)
  • Integration: 2:45 → 1:15 (54% faster, 340% CPU utilization)
  • 20 disabled tests re-enabled (33 → 13 remaining)
  • Clean profile split: mvn test (unit, parallel), mvn test -Pintegration (parallel, Testcontainers)
  • @Tag("runtime") for health checks requiring full tilt stack

Final structure

airavata/
├── airavata-api/                    (core lib)
│   ├── research-service/
│   ├── agent-service/
│   └── file-server/
├── airavata-server/                 (unified server)
│   ├── rest/
│   ├── grpc/
│   └── thrift/
├── airavata-agent/                  (Go)
├── airavata-fuse/                   (Go)
├── airavata-jupyterhub/             (Python/config)
└── dev-tools/

686 files changed, -3,082 lines net

Test Results

  • mvn test — 179 unit tests pass (52s, parallel)
  • mvn test -Pintegration — 119 integration tests pass (1:15, parallel, Testcontainers)
  • mvn clean install -DskipTests -T4 — all modules build
  • Zero internal ThriftClientPool/ClientFactory in app code
  • Zero Dozer usage — all MapStruct

🤖 Generated with Claude Code

Move airavata-rest-server, airavata-grpc-server, and airavata-thrift-server
into airavata-server/{rest,grpc,thrift}/ sub-modules with unified package
namespace org.apache.airavata.server.{rest,grpc,thrift}.
…injection

Replace all internal ThriftClientPool<RegistryService.Client> and
RegistryServiceClientFactory usages in airavata-api with direct calls
to the RegistryServerHandler @component via RegistryService.Iface.

The handler is registered as a global static reference via Utils.setRegistryHandler()
from a @PostConstruct in RegistryServerHandler. All pool/factory patterns
(getResource/returnResource/returnBrokenResource, ThriftUtils.close) are removed.
…ect injection

- Replace CredentialStoreClientFactory usages with direct CredentialStoreServerHandler
  instantiation in SSHAccountManager, GatewayGroupsInitializer, AgentUtils,
  IamAdminServicesHandler, TenantProfileServiceHandler, and AiravataDataMigrator
- Replace ProfileServiceClientFactory usages:
  - AiravataTask/TaskContext: use UserProfileRepository directly instead of
    UserProfileService Thrift client (avoids circular dep with airavata-server)
  - UserProfileServiceHandler: use IamAdminServicesHandler directly
  - AiravataDataMigrator: use TenantManagementKeycloakImpl directly
  - AiravataService (research-service): use UserProfileRepository directly
- Remove unused getCredentialStoreServiceClient from KeyCloakSecurityManager
- Delete CredentialStoreClientFactory (no remaining references)
- Keep ProfileServiceClientFactory (still used by example clients)
…tion

Replace RegistryServiceClientFactory usages in SSHAccountManager,
AiravataDataMigrator, KeyCloakSecurityManager, GatewayGroupsInitializer,
OrchestratorServerHandler, and IamAdminServicesHandler with direct
RegistryServerHandler instantiation. Remove SharingRegistryServiceClientFactory
and update GroupManagerServiceHandler and SharingServiceDBEventHandler likewise.
…EntityManagerFactory

- Delete 7 JPAUtils classes, 4 catalog-specific abstract repos, 6 JDBCConfig impls
- Create EntityManagerFactoryHolder (static bridge) + EntityManagerFactoryRegistrar (@component)
- 52 concrete repos now extend base AbstractRepository directly
- Fix ~70 entity classes for Hibernate 6 column mapping strictness
- Test persistence.xml (test-scope) with single "airavata" unit
- 199 unit tests pass, 0 failures
Replace @transient with proper @manytoone @joincolumn(insertable=false, updatable=false)
on 48 fields across 47 entity files. Fix duplicate column mappings.
Integration tests: 50 pass, 18 errors (test data issues), 33 skipped.
…in/proto

Recover directories lost in 384281d when modules/ was removed:
- modules/agent-framework/airavata-agent → airavata-agent/
- modules/agent-framework/airavata-fuse → airavata-fuse/
- modules/research-framework/research-hub → airavata-jupyterhub/
- modules/research-framework/simexr_mod → dev-tools/simexr_mod/

Move agent-service proto files to src/main/proto/ for consistency
with research-service layout, and update pom.xml sourceDirectory.
- Fix JPQL alias case mismatch (dp → DP) in QueryConstants
- Fix ComputeResourceRepository remove operations using orphanRemoval
- Fix SharingRegistry cascade (remove CascadeType.PERSIST from UserGroupEntity.groupAdmins)
- Fix AbstractRepository.get() with FlushMode.MANUAL to prevent cascade-persist
- Fix AbstractRepository.select() to call initializeEntity on results
- Replace PersistentMap with HashMap in DataReplicaLocationRepository.initializeEntity
- Fix DataReplicaLocationRepositoryTest to avoid duplicate key insertion

Integration tests: 102 run, 0 failures, 0 errors, 33 skipped
Unit tests: 199 run, 0 failures, 0 errors, 26 skipped
…erge integration-tests

- Surefire 3.5.5 with forkCount=1C (1 fork per CPU)
- JUnit 5 parallel execution for unit tests (concurrent classes + methods)
- @execution(SAME_THREAD) on non-thread-safe tests (DB, SFTP, ServiceLoader)
- Clean profile split: mvn test (unit, parallel), mvn test -Pintegration (sequential)
- @tag("runtime") for health checks that need full tilt stack
- Merge integration-tests module into airavata-api test sources
- Fix SharedMariaDBLauncherSessionListener to detect surefire.groups property
- Remove build cache extension (Java 25 incompatible)

Unit: 182 pass, 0 fail | Integration: 119 pass, 0 fail
Enable SharingServiceIntegrationTest (13 tests) and WorkflowRepositoryTest
(1 test) which now pass with the consolidated persistence setup. Fix test
logic in addAndRemoveGroupAdmin (user must be group member before admin).
Update @disabled reasons on remaining tests to reflect actual root causes
(Dozer mapping, FK constraints, test isolation).
- Enable SharingServiceIntegrationTest (13 tests) — single EMF resolved caching issue
- Enable WorkflowRepositoryTest (1 test) — works with Hibernate 6
- Fix addAndRemoveGroupAdmin test — user must be added to group before admin
- Remaining 19 disabled: all Dozer mapping issues (MapStruct migration needed)

Unit: 182 pass, 0 fail, 26 skip | Integration: 119 pass, 0 fail, 19 skip
…READ

- ObjectMapperSingleton: eager static init (eliminates 2-3s first-test penalty)
- SFTPDeleteDirTest: use OS-assigned port (no more port conflicts, can run parallel)
- Fixes race condition in ObjectMapperSingleton (was lazy init without synchronization)

Unit: 52s wall clock, 182 pass | Integration: 2:45, 119 pass
5 MapStruct mappers replacing runtime Dozer reflection with compile-time code.
63 repos updated, 3 AbstractRepository bases cleaned, Dozer dependency removed.

Unit: 179 pass, 0 fail | Integration: 119 pass, 0 fail
Replace truncate-all-tables cleanup with per-test transaction rollback:
- EntityManagerFactoryHolder: ThreadLocal test EntityManager support
- 3 AbstractRepository bases: test mode skips transaction management
- TestBase: @beforeeach begins transaction, @AfterEach rolls back
- 33 test constructors updated (removed Database enum)
- Integration profile: classes run in parallel (ForkJoinPool)

Integration tests: 2:23 (was 2:45) — 22s saved from parallelism
Unit: 179 pass | Integration: 119 pass | 0 failures
…r gaps

Re-enabled tests:
- ComputeResourceRepositoryTest: listComputeResourcesTest, updateComputeResourceTest,
  addComputeResourceTest, addUnicoreDataMovementTest
- ExperimentStatusRepositoryTest: ExperimentStatusRepositoryTest

Mapper fixes:
- BatchQueue: maxRuntime <-> maxRunTime field name mismatch
- UnicoreDataMovement: unicoreEndpointUrl <-> unicoreEndPointURL mismatch
- ApplicationDeployment: defaultWallTime <-> defaultWalltime mismatch
- UserResourceProfile: gatewayId <-> gatewayID mismatch
- GatewayResourceProfile: gatewayId <-> gatewayID mismatch

JPA fixes:
- Add insertable=false to @joincolumn on GroupComputeResourcePrefEntity,
  BatchQueueResourcePolicyEntity, ComputeResourcePolicyEntity to prevent
  duplicate column mapping with @id fields

Updated @disabled reasons on 14 remaining tests to reflect actual root causes.
Add @onetomany(cascade=ALL, orphanRemoval=true) on ResourceJobManagerEntity
for JobManagerCommandEntity and ParallelismCommandEntity children, enabling
cascading deletes. Re-enable deleteResourceJobManagerTest.

Switch integration test parallelism from same_thread to concurrent for methods,
increase dynamic factor to 2, add forkCount=1C. Guard deadlock-prone tests
(ApplicationInterfaceRepositoryTest, SharingServiceIntegrationTest,
DatabaseTestCases) with @execution(SAME_THREAD).
@yasithdev yasithdev merged commit b41fbfa into master Mar 29, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant