public Installation toInstallation() { Installation installation = new Installation(shortName, assignment.toAssignment(), URI.create(binaryFile), URI.create(configFile), resources); return installation; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } InstallationRepresentation that = (InstallationRepresentation) o; if (assignment != null ? !assignment.equals(that.assignment) : that.assignment != null) { return false; } return true; }
@Override public int hashCode() { return assignment != null ? assignment.hashCode() : 0; }
public static InstallationRepresentation from(Installation installation) { Assignment assignment = installation.getAssignment(); return new InstallationRepresentation( installation.getShortName(), AssignmentRepresentation.from(assignment), installation.getBinaryFile().toString(), installation.getConfigFile().toString(), installation.getResources()); }
public static AssignmentRepresentation from(Assignment assignment) { return new AssignmentRepresentation(assignment.getBinary(), assignment.getConfig()); }
public static DeploymentRepresentation from(Deployment deployment) { return new DeploymentRepresentation( deployment.getNodeId(), AssignmentRepresentation.from(deployment.getAssignment()), deployment.getResources()); }
@Override public List<SlotStatusRepresentation> install(AgentFilter agentFilter, int count, Assignment assignment, String expectedVersion) { URI uri = agentFilter.toUri(uriBuilderFrom(coordinatorUri).replacePath("/v1/slot").addParameter("limit", String.valueOf(count))); RequestBuilder requestBuilder = RequestBuilder.preparePost() .setUri(uri) .setHeader("Content-Type", "application/json") .setBodyGenerator(jsonBodyGenerator(ASSIGNMENT_CODEC, AssignmentRepresentation.from(assignment))); if (expectedVersion != null) { requestBuilder.setHeader(GALAXY_SLOTS_VERSION_HEADER, expectedVersion); } List<SlotStatusRepresentation> slots = client.execute(requestBuilder.build(), createJsonResponseHandler(SLOTS_CODEC)); return slots; }
public Deployment toDeployment(File deploymentDir, File dataDir, String location) { return new Deployment(nodeId, location, deploymentDir, dataDir, assignment.toAssignment(), resources); }
@Override public int hashCode() { int result = (nodeId != null ? nodeId.hashCode() : 0); result = 31 * result + (assignment != null ? assignment.hashCode() : 0); result = 31 * result + (resources != null ? resources.hashCode() : 0); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DeploymentRepresentation that = (DeploymentRepresentation) o; if (assignment != null ? !assignment.equals(that.assignment) : that.assignment != 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; }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response install( AssignmentRepresentation assignmentRepresentation, @DefaultValue("1") @QueryParam("limit") int limit, @Context UriInfo uriInfo, @HeaderParam(GALAXY_AGENTS_VERSION_HEADER) String expectedAgentsVersion) { Preconditions.checkNotNull(assignmentRepresentation, "assignmentRepresentation must not be null"); Preconditions.checkArgument(limit > 0, "limit must be at least 1"); Assignment assignment = assignmentRepresentation.toAssignment(); // select the target agents Predicate<AgentStatus> agentFilter = AgentFilterBuilder.build(uriInfo, transform(coordinator.getAgents(), idGetter()), transform(coordinator.getAllSlotStatus(), uuidGetter()), false, repository); List<AgentStatus> agents = coordinator.getAgents(agentFilter); // verify the expected status of agents checkAgentsVersion(expectedAgentsVersion, agents); // install the software List<SlotStatus> slots = coordinator.install(agentFilter, limit, assignment); // calculate unique prefix size with the new slots included return Response.ok(transform(slots, fromSlotStatus(coordinator.getAllSlotStatus(), repository))) .header(GALAXY_SLOTS_VERSION_HEADER, createSlotsVersion(slots)) .build(); }