Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDAP-21096] Parametrize the AppFabricServiceRuntimeModule #15799

Conversation

vsethi09
Copy link
Contributor

@vsethi09 vsethi09 commented Jan 12, 2025

CDAP-21096 Parametrize the AppFabricServiceRuntimeModule

Context: #15773 (comment)

Follow up of #15773

Testing

  • Unit Tests
  • CDAP Sandbox
  • Docker Image

@vsethi09 vsethi09 added the build Triggers github actions build label Jan 12, 2025
@vsethi09 vsethi09 force-pushed the feature/CDAP-21096_parameterize_AppFabricServiceRuntimeModule_2 branch from 566e50d to e2a249b Compare January 12, 2025 17:50
@vsethi09 vsethi09 marked this pull request as ready for review January 12, 2025 17:50
@vsethi09 vsethi09 force-pushed the feature/CDAP-21096_parameterize_AppFabricServiceRuntimeModule_2 branch from e2a249b to 417fabc Compare January 13, 2025 12:33
@@ -156,7 +158,8 @@ protected void bindKeyManager(Binder binder) {
new AuthorizationModule(),
new AuthorizationEnforcementModule().getMasterModule(),
new AuditLogWriterModule(cConf).getDistributedModules(),
Modules.override(new AppFabricServiceRuntimeModule(cConf).getDistributedModules())
Modules.override(new AppFabricServiceRuntimeModule(cConf, EnumSet.allOf(ServiceType.class))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create an constant for EnumSet.allOf(ServiceType.class) in the AppFabricServiceRuntimeModule? This should make this lines less cluttered. Or, alternatively, move to factory methods (e.g. AppFabricServiceRuntimeModule.for(ServiceType.PROCESSOR) and AppFabricServiceRuntimeModule.forCombinedService() or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -98,7 +100,8 @@ protected List<Module> getServiceModules(MasterEnvironment masterEnv,
new AuditModule(),
new AuthorizationModule(),
new AuthorizationEnforcementModule().getMasterModule(),
Modules.override(new AppFabricServiceRuntimeModule(cConf).getDistributedModules())
Modules.override(new AppFabricServiceRuntimeModule(cConf, EnumSet.of(ServiceType.PROCESSOR))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create an overloaded constructor taking ServiceType ... vararg parameter and doing the EnumSet. This would make client calls simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

public static final String NOAUTH_ARTIFACT_REPO = "noAuthArtifactRepo";

private final CConfiguration cConf;
private final Set<ServiceType> serviceType;

@Inject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can @Inject it with the serviceType parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed @Inject as the constructor is called directly to initialize.


@Inject
public AppFabricServiceRuntimeModule(CConfiguration cConf) {
public AppFabricServiceRuntimeModule(CConfiguration cConf, Set<ServiceType> serviceType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name it serviceTypes as it's a set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Renamed to serviceTypes.

Multibinder<HttpHandler> handlerBinder = Multibinder.newSetBinder(
binder(), HttpHandler.class, Names.named(Constants.AppFabric.SERVER_HANDLERS_BINDING));
handlerBinder.addBinding().to(BootstrapHttpHandler.class);
handlerBinder.addBinding().to(AppLifecycleHttpHandler.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused. Should not this go the processor (the singleton one) since it's dependent on ProgramRuntimeService? I get it's "In Memory call", so serviceType would be "all" but still it's better to be consistent. Also why do we have it both here and in AppFabricServiceModule?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done for some of the Unit Tests.

Eventually we will move the handlers back to Appfabric HTTP Service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand on this? According to the comment above I would expect this section to be in if (serviceTypes.contains(ServiceType.PROCESSOR)) if. Unit tests shoudl nto care as they should create AppFabricServiceRuntimeModule for both services

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased the TODO to remove additional binding from in-memory and use binding from AppFabricServiceModule.

Context:
For some of the unit tests replying on AppFabricTestBase, the handlers need to be in both service and processor. Eg. AppLifecycleHttpHandlerTest, ApplicationLifecycleServiceTest.

AppFabricTestBase uses appFabricEndpointStrategy which points to only appfabric service. However, it needs to make requests to handlers in both service and processor. So for in-memory modules some of the handlers are kept in both service and processor.

Eventually we plan to move these handlers back to the appfabric HTTP service.

@vsethi09 vsethi09 force-pushed the feature/CDAP-21096_parameterize_AppFabricServiceRuntimeModule_2 branch from 417fabc to 6226662 Compare January 16, 2025 18:08
@vsethi09 vsethi09 requested a review from tivv January 16, 2025 18:42
@vsethi09 vsethi09 force-pushed the feature/CDAP-21096_parameterize_AppFabricServiceRuntimeModule_2 branch 2 times, most recently from d1a8b10 to 7fec4b8 Compare January 16, 2025 20:54
public static final String NOAUTH_ARTIFACT_REPO = "noAuthArtifactRepo";

public static final ServiceType[] ALL_SERVICE_TYPES = ServiceType.values();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do it an immutable set. Arrays are mutable and it's an antipattern to have a mutable static method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@vsethi09 vsethi09 force-pushed the feature/CDAP-21096_parameterize_AppFabricServiceRuntimeModule_2 branch from 7fec4b8 to 101dc46 Compare January 21, 2025 15:24
@vsethi09 vsethi09 merged commit 7e3b514 into develop Jan 22, 2025
8 of 9 checks passed
@vsethi09 vsethi09 deleted the feature/CDAP-21096_parameterize_AppFabricServiceRuntimeModule_2 branch January 22, 2025 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Triggers github actions build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants