-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2205 from HubSpot/lb_impl_2
Refactor the LoadBalancerClient
- Loading branch information
Showing
24 changed files
with
566 additions
and
352 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
SingularityBase/src/main/java/com/hubspot/singularity/LoadBalancerRequestState.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,46 @@ | ||
package com.hubspot.singularity; | ||
|
||
import com.hubspot.baragon.models.BaragonRequestState; | ||
|
||
public enum LoadBalancerRequestState { | ||
UNKNOWN(false), | ||
FAILED(false), | ||
WAITING(true), | ||
SUCCESS(false), | ||
CANCELING(true), | ||
CANCELED(false), | ||
INVALID_REQUEST_NOOP(false); | ||
|
||
private final boolean inProgress; | ||
|
||
LoadBalancerRequestState(boolean inProgress) { | ||
this.inProgress = inProgress; | ||
} | ||
|
||
public boolean isInProgress() { | ||
return inProgress; | ||
} | ||
|
||
public static LoadBalancerRequestState fromBaragonRequestState( | ||
BaragonRequestState baragonRequestState | ||
) { | ||
switch (baragonRequestState) { | ||
case WAITING: | ||
return WAITING; | ||
case SUCCESS: | ||
return SUCCESS; | ||
case UNKNOWN: | ||
return UNKNOWN; | ||
case FAILED: | ||
return FAILED; | ||
case CANCELED: | ||
return CANCELED; | ||
case CANCELING: | ||
return CANCELING; | ||
case INVALID_REQUEST_NOOP: | ||
return INVALID_REQUEST_NOOP; | ||
default: | ||
return null; | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
SingularityBase/src/main/java/com/hubspot/singularity/LoadBalancerUpstream.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,76 @@ | ||
package com.hubspot.singularity; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.common.base.MoreObjects; | ||
import com.hubspot.baragon.models.UpstreamInfo; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public class LoadBalancerUpstream { | ||
private final String upstream; | ||
private final String group; | ||
private final Optional<String> rackId; | ||
|
||
@JsonCreator | ||
public LoadBalancerUpstream( | ||
@JsonProperty("upstream") String upstream, | ||
@JsonProperty("group") String group, | ||
@JsonProperty("rackId") Optional<String> rackId | ||
) { | ||
this.upstream = upstream; | ||
this.group = group; | ||
this.rackId = rackId; | ||
} | ||
|
||
public static LoadBalancerUpstream fromBaragonUpstream(UpstreamInfo upstreamInfo) { | ||
return new LoadBalancerUpstream( | ||
upstreamInfo.getUpstream(), | ||
upstreamInfo.getGroup(), | ||
upstreamInfo.getRackId().toJavaUtil() | ||
); | ||
} | ||
|
||
public String getUpstream() { | ||
return upstream; | ||
} | ||
|
||
public String getGroup() { | ||
return group; | ||
} | ||
|
||
public Optional<String> getRackId() { | ||
return rackId; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
LoadBalancerUpstream that = (LoadBalancerUpstream) o; | ||
return ( | ||
Objects.equals(upstream, that.upstream) && | ||
Objects.equals(group, that.group) && | ||
Objects.equals(rackId, that.rackId) | ||
); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(upstream, group, rackId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects | ||
.toStringHelper(this) | ||
.add("upstream", upstream) | ||
.add("group", group) | ||
.add("rackId", rackId) | ||
.toString(); | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
...ularityBase/src/main/java/com/hubspot/singularity/SingularityCheckingUpstreamsUpdate.java
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.