public static Assignment resolveAssignment(Repository repository, Assignment assignment) { // resolve assignment String resolvedBinary = repository.binaryResolve(assignment.getBinary()); Preconditions.checkArgument(resolvedBinary != null, "Unknown binary " + assignment.getBinary()); String resolvedConfig = repository.configResolve(assignment.getConfig()); Preconditions.checkArgument(resolvedConfig != null, "Unknown config " + assignment.getConfig()); assignment = new Assignment(resolvedBinary, resolvedConfig); return assignment; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Installation that = (Installation) o; if (!assignment.equals(that.assignment)) { return false; } return true; }
public Assignment toAssignment() { Assignment assignment = new Assignment(binary, config); return assignment; }
"/location", UNKNOWN, new Assignment("io.airlift:sample-server:tar.gz:distribution:0.35-SNAPSHOT", APPLE_ASSIGNMENT.getConfig()), "/install-path", ImmutableMap.<String, Integer>of());
@JsonProperty public String getBinary() { if (assignment == null) { return null; } return assignment.getBinary(); }
@JsonProperty public String getConfig() { if (assignment == null) { return null; } return assignment.getConfig(); }
@Override public int hashCode() { return assignment.hashCode(); }
@JsonCreator public ExpectedSlotStatus( @JsonProperty("id") UUID id, @JsonProperty("status") SlotLifecycleState status, @JsonProperty("binary") String binarySpec, @JsonProperty("config") String configSpec) { this.id = id; this.status = status; this.assignment = new Assignment(binarySpec, configSpec); }
"/location", UNKNOWN, new Assignment("io.airlift:sample-server:tar.gz:distribution:0.35-SNAPSHOT", APPLE_ASSIGNMENT.getConfig()), "/install-path", ImmutableMap.<String, Integer>of());
public static Map<String, Integer> readResources(Repository repository, Assignment assignment) { ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder(); ByteSource resourcesFile = newConfigEntrySupplier(repository, assignment.getConfig(), "airship-resources.properties"); if (resourcesFile != null) { try { Properties resources = new Properties(); resources.load(resourcesFile.openStream()); for (Entry<Object, Object> entry : resources.entrySet()) { builder.put((String) entry.getKey(), Integer.valueOf((String) entry.getValue())); } } catch (IOException ignored) { } } return builder.build(); } }
@Override public int hashCode() { int result = (nodeId != null ? nodeId.hashCode() : 0); result = 31 * result + (location != null ? location.hashCode() : 0); result = 31 * result + (deploymentDir != null ? deploymentDir.hashCode() : 0); result = 31 * result + (dataDir != null ? dataDir.hashCode() : 0); result = 31 * result + (assignment != null ? assignment.hashCode() : 0); result = 31 * result + (resources != null ? resources.hashCode() : 0); return result; }
public Assignment upgradeAssignment(Repository repository, Assignment assignment) { Preconditions.checkNotNull(assignment, "assignment is null"); String binary = assignment.getBinary(); if (binaryVersion != null) { binary = repository.binaryUpgrade(binary, binaryVersion); checkArgument(binary != null, "Can not upgrade binary " + assignment.getBinary() + " to " + binaryVersion); } else { checkArgument(repository.binaryToHttpUri(assignment.getBinary()) != null, "Can not locate existing binary " + assignment.getBinary() + " for upgrade"); } String config = assignment.getConfig(); if (configVersion != null) { config = repository.configUpgrade(config, configVersion); checkArgument(config != null, "Can not upgrade config " + assignment.getConfig() + " to " + configVersion); } else { checkArgument(repository.configToHttpUri(assignment.getConfig()) != null, "Can not locate existing config " + assignment.getConfig() + " for upgrade"); } return new Assignment(binary, config); }
public Assignment forceAssignment(Repository repository) { checkState((binaryVersion != null) && (configVersion != null), "Binary and config must be specified to upgrade missing assignment"); String binary = repository.binaryResolve(binaryVersion); checkArgument(binary != null, "Unknown binary " + binaryVersion); String config = repository.configResolve(configVersion); checkArgument(config != null, "Unknown config " + configVersion); return new Assignment(binary, config); }
@Override public boolean apply(@Nullable SlotStatus slotStatus) { return (slotStatus != null) && (slotStatus.getAssignment() != null) && glob.apply(slotStatus.getAssignment().getBinary()); } }
@Override public boolean apply(@Nullable SlotStatus slotStatus) { return (slotStatus != null) && (slotStatus.getAssignment() != null) && glob.apply(slotStatus.getAssignment().getConfig()); } }
@Override public int hashCode() { int result = id.hashCode(); result = 31 * result + self.hashCode(); result = 31 * result + externalUri.hashCode(); result = 31 * result + instanceId.hashCode(); result = 31 * result + location.hashCode(); result = 31 * result + (assignment != null ? assignment.hashCode() : 0); result = 31 * result + state.hashCode(); result = 31 * result + version.hashCode(); result = 31 * result + (installPath != null ? installPath.hashCode() : 0); result = 31 * result + resources.hashCode(); result = 31 * result + (expectedState != null ? expectedState.hashCode() : 0); result = 31 * result + (expectedAssignment != null ? expectedAssignment.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Deployment that = (Deployment) o; if (assignment != null ? !assignment.equals(that.assignment) : that.assignment != null) { return false; } if (dataDir != null ? !dataDir.equals(that.dataDir) : that.dataDir != null) { return false; } if (deploymentDir != null ? !deploymentDir.equals(that.deploymentDir) : that.deploymentDir != null) { return false; } if (location != null ? !location.equals(that.location) : that.location != null) { return false; } if (nodeId != null ? !nodeId.equals(that.nodeId) : that.nodeId != null) { return false; } if (resources != null ? !resources.equals(that.resources) : that.resources != null) { return false; } return true; }