-
Notifications
You must be signed in to change notification settings - Fork 345
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] Split ProgramLifecycleService for Appfabric service and processor #15824
[CDAP-21096] Split ProgramLifecycleService for Appfabric service and processor #15824
Conversation
619b867
to
6a1e84d
Compare
6a1e84d
to
4b9b796
Compare
...fabric/src/main/java/io/cdap/cdap/internal/app/services/AbstractProgramLifecycleService.java
Outdated
Show resolved
Hide resolved
...-fabric/src/main/java/io/cdap/cdap/gateway/handlers/AbstractProgramLifecycleHttpHandler.java
Outdated
Show resolved
Hide resolved
...p-fabric/src/main/java/io/cdap/cdap/gateway/handlers/ProgramRuntimeLifecycleHttpHandler.java
Outdated
Show resolved
Hide resolved
...p-fabric/src/main/java/io/cdap/cdap/gateway/handlers/ProgramRuntimeLifecycleHttpHandler.java
Outdated
Show resolved
Hide resolved
...-fabric/src/main/java/io/cdap/cdap/internal/app/services/ProgramRuntimeLifecycleService.java
Outdated
Show resolved
Hide resolved
...-fabric/src/main/java/io/cdap/cdap/internal/app/services/ProgramRuntimeLifecycleService.java
Outdated
Show resolved
Hide resolved
4ded2d9
to
27a0875
Compare
27a0875
to
02796c6
Compare
cdap-app-fabric/src/main/java/io/cdap/cdap/app/guice/AppFabricServiceRuntimeModule.java
Outdated
Show resolved
Hide resolved
@@ -121,11 +127,18 @@ void setRemoteTwillRunnerService( | |||
@Override | |||
public final RuntimeInfo run(ProgramDescriptor programDescriptor, ProgramOptions options, | |||
RunId runId) { | |||
ProgramId programId = programDescriptor.getProgramId(); | |||
ProgramRunId programRunId = programId.run(runId); | |||
synchronized (this) { |
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.
You need to include updateRuntimeInfo into synchronized block to have atomicity, otherwise this synchronized block does not do anything.
Note that updateRuntimeInfo in a turn uses runtimeInfosLock.
So probably correct option would be to take write lock on runtimeInfosLock
instead of synchronized and hold onto it until after updateRuntimeInfo
. Note that write lock must be taken as upgrading from read to write is not possible
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
Acquired writeLock()
on the ReentrantReadWriteLock
before the runtimeInfo lookup()
till updateRuntimeInfo
.
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.
BTW: For information sharing sake, ReadWriteLock acquired through a factory was added in a bit "long look forward" thinking on the AppFabric horizontal scaling where there is a central locking service introduced. Not sure if it would ever be used as such as without batching lock service would probably add too much latency to be useful. But at least it marks the place where some non-horizontally-scalable stuff is happening
cdap-app-fabric/src/main/java/io/cdap/cdap/app/runtime/ProgramRuntimeService.java
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/app/store/Store.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/gateway/handlers/util/ProgramUtil.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/services/ProgramLifecycleService.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/services/ProgramLifecycleService.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/gateway/handlers/util/ProgramUtil.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/preview/DefaultPreviewRunner.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/gateway/handlers/util/ProgramUtil.java
Outdated
Show resolved
Hide resolved
02796c6
to
36a4832
Compare
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.
LGTM with small comments
cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/runtime/ProgramStartRequest.java
Outdated
Show resolved
Hide resolved
cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/services/ProgramLifecycleService.java
Outdated
Show resolved
Hide resolved
36a4832
to
14a767f
Compare
…processor Replace inheritance with composition
14a767f
to
ee0968a
Compare
Quality Gate failedFailed conditions |
Context
Multiple instances of
ProgramLifecycleService
cannot be run as they useProgramRuntimeService
which contains in-memory cache ofruntimeInfos
. Due to thisProgramLifecycleHttpHandler
was temporarily moved to singleton Appfabric processor. More details: #15773 (comment)Change Description
ProgramLifecycleHttpHandler
into ->ProgramLifecycleHttpHandler
(which runs onAppfabric
server) andProgramRuntimeHttpHandler
(which runs onAppfabric
processor).ProgramRuntimeHttpHandler
has handlers for managingruntimeInfo
.ProgramUtil
to avoid duplication.ProgramLifecycleService
into ->ProgramLifecycleService
(used byProgramLifecycleHttpHandler
) andProgramUtil
ProgramUtil
contains common utility for Programs used by handlers and services. Does not reference runtimeInfo.checkConcurrentExecution
.ProgramLifecycleService.checkConcurrentExecution()
-> uses store implementation instead of usingruntimeInfo
.RouterLookupPath
changes to route paths forProgramRuntimeHttpHandler
toAppfabric
processor.AppfabricServer
(This was temporary change made as per: [CDAP-21096] Split Appfabric into stateless service and stateful processor #15773 (comment)):AppLifecycleHttpHandler
AppLifecycleHttpHandlerInternal
ProgramLifecycleHttpHandler
ProgramLifecycleHttpHandlerInternal
WorkflowHttpHandler
Verification