21
21
22
22
import java .io .IOException ;
23
23
import java .time .Duration ;
24
+ import java .util .List ;
24
25
import java .util .Timer ;
25
26
import java .util .TimerTask ;
26
27
@@ -35,10 +36,11 @@ public class ExpiringResourceClaim extends ResourceClaim {
35
36
public final static Duration DEFAULT_ACQUISITION_TIMEOUT = Duration .ofMinutes (10 );
36
37
37
38
ExpiringResourceClaim (Client etcd ,
38
- int poolSize ,
39
+ int maxGeneratorCount ,
40
+ List <Integer > clusterIds ,
39
41
Duration claimHold ,
40
42
Duration acquisitionTimeout ) throws IOException {
41
- super (etcd , poolSize , acquisitionTimeout );
43
+ super (etcd , maxGeneratorCount , clusterIds , acquisitionTimeout );
42
44
new Timer ().schedule (new TimerTask () {
43
45
@ Override
44
46
public void run () {
@@ -50,28 +52,30 @@ public void run() {
50
52
/**
51
53
* Claim a resource.
52
54
*
53
- * @param etcd Etcd connection to use.
54
- * @param poolSize Size of the resource pool .
55
+ * @param etcd Etcd connection to use.
56
+ * @param maxGeneratorCount Maximum number of generators possible .
55
57
* @return A resource claim.
56
58
*/
57
- public static ResourceClaim claimExpiring (Client etcd , int poolSize )
59
+ public static ResourceClaim claimExpiring (Client etcd , int maxGeneratorCount , List < Integer > clusterIds )
58
60
throws IOException {
59
- return claimExpiring (etcd , poolSize , DEFAULT_CLAIM_HOLD , DEFAULT_ACQUISITION_TIMEOUT );
61
+ return claimExpiring (etcd , maxGeneratorCount , clusterIds , DEFAULT_CLAIM_HOLD , DEFAULT_ACQUISITION_TIMEOUT );
60
62
}
61
63
62
64
/**
63
65
* Claim a resource.
64
66
*
65
67
* @param etcd Etcd connection to use.
66
- * @param poolSize Size of the resource pool.
68
+ * @param maxGeneratorCount Maximum number of generators possible.
69
+ * @param clusterIds Cluster Ids available to use.
67
70
* @param claimHold How long the claim should be held. May be {@code null} for the default value of
68
71
* {@link #DEFAULT_CLAIM_HOLD}.
69
72
* @param acquisitionTimeout How long to keep trying to acquire a claim. May be {@code null} to keep trying
70
73
* indefinitely.
71
74
* @return A resource claim.
72
75
*/
73
76
public static ResourceClaim claimExpiring (Client etcd ,
74
- int poolSize ,
77
+ int maxGeneratorCount ,
78
+ List <Integer > clusterIds ,
75
79
Duration claimHold ,
76
80
Duration acquisitionTimeout )
77
81
throws IOException {
@@ -81,6 +85,6 @@ public static ResourceClaim claimExpiring(Client etcd,
81
85
logger .debug ("Preparing expiring resource-claim; will release it in {}ms." , claimHold .toMillis ());
82
86
}
83
87
84
- return new ExpiringResourceClaim (etcd , poolSize , claimHold , acquisitionTimeout );
88
+ return new ExpiringResourceClaim (etcd , maxGeneratorCount , clusterIds , claimHold , acquisitionTimeout );
85
89
}
86
90
}
0 commit comments