-
Notifications
You must be signed in to change notification settings - Fork 344
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
[CDAP-21096] Parametrize the AppFabricServiceRuntimeModule #15799
Conversation
566e50d
to
e2a249b
Compare
cdap-app-fabric/src/main/java/io/cdap/cdap/app/guice/AppFabricServiceRuntimeModule.java
Outdated
Show resolved
Hide resolved
e2a249b
to
417fabc
Compare
@@ -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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
417fabc
to
6226662
Compare
d1a8b10
to
7fec4b8
Compare
public static final String NOAUTH_ARTIFACT_REPO = "noAuthArtifactRepo"; | ||
|
||
public static final ServiceType[] ALL_SERVICE_TYPES = ServiceType.values(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Quality Gate passedIssues Measures |
7fec4b8
to
101dc46
Compare
CDAP-21096 Parametrize the AppFabricServiceRuntimeModule
Context: #15773 (comment)
Follow up of #15773
Testing