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

[FEATURE] Create a Rest Endpoint for findLock method in LockService #313

Open
vibrantvarun opened this issue Feb 13, 2023 · 1 comment
Open
Labels
CCI College Contributor Initiative PRs enhancement New feature or request good first issue Good for newcomers

Comments

@vibrantvarun
Copy link
Member

vibrantvarun commented Feb 13, 2023

Is your feature request related to a problem?
LockService has a method named findlock. It does not have a rest end point. Therefore, it is needed to create a rest end point in order to make debugging easier. This method is being heavily used in AcquireLock API and ReleaseLockApi, therefore in case of failure it will be super easy to debug.

What solution would you like?
Create a rest end point in SPI interface of Job Scheduler on path find/lock/{lockId} . Create a class named RestFindLockAction and define suitable extension points in JobScheduler Plugin like GetActions.

Do you have any additional context?

  1. Understand the code-flow of AcquireLock and ReleaseLock API and try to understand how everything is working.
  2. Create a new package with name rest under org.opensearch.jobscheduler.spi
  3. Create a class named RestFindLockAction.
  4. RestFindLockAction should extend abstract class BaseRestHandler
  5. Override routes() and prepareRequest() method in RestFindLockAction class
  6. Define two static strings in class
    public static final String FIND_LOCK_ACTION = "find_lock_action";
    public static final String LOCK_ID = "lock_id";
  7. In routes method return a list of route with given Route below
    new Route(GET, String.format(Locale.ROOT, "%s/%s/{%s}", JobSchedulerPlugin.JS_BASE_URI, "_find_lock", LOCK_ID))
  8. Override getName() method and return FIND_LOCK_ACTION
  9. Create a public constructor in RestFindLockAction with LockService as argument and initialize the local variable
public RestFIndLockAction(LockService lockService){
this.lockService=lockService;
}
  1. In prepareRequest method
    a) First fetch lockId from the RestRequest (refer ReleaseLockAction prepare request method)
    b) Initialize CompletableFuture object to make the search async
    c) Call lockService.findLock (refer ReleaseLockAction prepare request method)
    d) Return the channel response with the lockModel object
@vibrantvarun vibrantvarun added enhancement New feature or request good first issue Good for newcomers untriaged labels Feb 13, 2023
@minalsha minalsha added the CCI College Contributor Initiative PRs label Apr 6, 2023
@nandiniverma08
Copy link

nandiniverma08 commented Jan 13, 2024

@vibrantvarun hey, Is this issue still open ? I wanted to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCI College Contributor Initiative PRs enhancement New feature or request good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

4 participants