-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: keep request state in respective classes
(cherry picked from commit c26778b)
- Loading branch information
1 parent
00d3420
commit 52c9bba
Showing
3 changed files
with
135 additions
and
92 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...way/src/main/java/io/camunda/zeebe/gateway/impl/job/InflightActivateJobsRequestState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.gateway.impl.job; | ||
|
||
import io.camunda.zeebe.gateway.impl.broker.PartitionIdIterator; | ||
|
||
public class InflightActivateJobsRequestState { | ||
|
||
private final PartitionIdIterator iterator; | ||
private int remainingAmount; | ||
private boolean pollPrevPartition; | ||
private boolean resourceExhaustedWasPresent; | ||
|
||
public InflightActivateJobsRequestState( | ||
final PartitionIdIterator iterator, final int remainingAmount) { | ||
this.iterator = iterator; | ||
this.remainingAmount = remainingAmount; | ||
} | ||
|
||
private boolean hasNextPartition() { | ||
return iterator.hasNext(); | ||
} | ||
|
||
public int getCurrentPartition() { | ||
return iterator.getCurrentPartitionId(); | ||
} | ||
|
||
public int getNextPartition() { | ||
return pollPrevPartition ? iterator.getCurrentPartitionId() : iterator.next(); | ||
} | ||
|
||
public int getRemainingAmount() { | ||
return remainingAmount; | ||
} | ||
|
||
public void setRemainingAmount(int remainingAmount) { | ||
this.remainingAmount = remainingAmount; | ||
} | ||
|
||
public boolean wasResourceExhaustedPresent() { | ||
return resourceExhaustedWasPresent; | ||
} | ||
|
||
public void setResourceExhaustedWasPresent(final boolean resourceExhaustedWasPresent) { | ||
this.resourceExhaustedWasPresent = resourceExhaustedWasPresent; | ||
} | ||
|
||
public void setPollPrevPartition(boolean pollPrevPartition) { | ||
this.pollPrevPartition = pollPrevPartition; | ||
} | ||
|
||
public boolean shouldActivateJobs() { | ||
return remainingAmount > 0 && (pollPrevPartition || hasNextPartition()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters