Skip to content

Commit

Permalink
Titus - sets capacity group for v3 grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaslin committed Mar 26, 2018
1 parent 4abd3aa commit 30a8d6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ public int getGpu() {
return gpu;
}

public void setRetries() { this.retries = retries; }
public void setRetries() { this.retries = retries; }

public int getRetries() { return retries; }
public int getRetries() { return retries; }

public int getRuntimeLimitSecs() {
return runtimeLimitSecs;
Expand Down Expand Up @@ -405,7 +405,7 @@ public JobDescriptor getGrpcJobDescriptor() {

SecurityProfile.Builder securityProfile = SecurityProfile.newBuilder();

if (securityGroups!= null && !securityGroups.isEmpty()) {
if (securityGroups != null && !securityGroups.isEmpty()) {
securityGroups.forEach(sg ->
{
securityProfile.addSecurityGroups(sg);
Expand Down Expand Up @@ -441,7 +441,7 @@ public JobDescriptor getGrpcJobDescriptor() {
Capacity.Builder jobCapacity = Capacity.newBuilder();
jobCapacity.setMin(instancesMin).setMax(instancesMax).setDesired(instancesDesired);

if (type == "service") {
if (type.equals("service")) {
JobGroupInfo.Builder jobGroupInfoBuilder = JobGroupInfo.newBuilder();
if (jobGroupStack != null) {
jobGroupInfoBuilder.setStack(jobGroupStack);
Expand All @@ -453,11 +453,11 @@ public JobDescriptor getGrpcJobDescriptor() {
jobDescriptorBuilder.setJobGroupInfo(jobGroupInfoBuilder);
jobDescriptorBuilder.setService(
ServiceJobSpec.newBuilder().setEnabled(inService)
.setCapacity(jobCapacity)
.setRetryPolicy(RetryPolicy.newBuilder().setExponentialBackOff(RetryPolicy.ExponentialBackOff.newBuilder().setInitialDelayMs(5000).setMaxDelayIntervalMs(300000))));
.setCapacity(jobCapacity)
.setRetryPolicy(RetryPolicy.newBuilder().setExponentialBackOff(RetryPolicy.ExponentialBackOff.newBuilder().setInitialDelayMs(5000).setMaxDelayIntervalMs(300000))));
}

if (type == "batch") {
if (type.equals("batch")) {
BatchJobSpec.Builder batchJobSpec = BatchJobSpec.newBuilder();
batchJobSpec.setSize(instancesDesired);
if (runtimeLimitSecs != 0) {
Expand All @@ -467,6 +467,12 @@ public JobDescriptor getGrpcJobDescriptor() {
jobDescriptorBuilder.setBatch(batchJobSpec);
}

if (capacityGroup == null || capacityGroup.isEmpty()) {
jobDescriptorBuilder.setCapacityGroup(jobDescriptorBuilder.getApplicationName());
} else {
jobDescriptorBuilder.setCapacityGroup(capacityGroup);
}

return jobDescriptorBuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class RegionScopedV3TitusClientSpec extends Specification {
then:
logger.info("job {}", job);
job != null
job.capacityGroup == "helix_hello_world_server";

when:
job = titusClient.findJobByName(submitJobRequest.getJobName());
Expand Down

0 comments on commit 30a8d6a

Please sign in to comment.