Exemplo n.º 1
0
  @Override
  public boolean ssh(SlotFilter slotFilter, String command) {
    URI uri = slotFilter.toUri(uriBuilderFrom(coordinatorUri).replacePath("/v1/slot"));
    Request request = RequestBuilder.prepareGet().setUri(uri).build();

    List<SlotStatusRepresentation> slots =
        client.execute(request, createJsonResponseHandler(SLOTS_CODEC));
    if (slots.isEmpty()) {
      return false;
    }
    SlotStatusRepresentation slot = slots.get(0);
    String host;
    if (useInternalAddress) {
      host = slot.getInternalHost();
    } else {
      host = slot.getExternalHost();
    }
    Exec.execRemote(host, slot.getInstallPath(), command);
    return true;
  }
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public Response getAllSlots(@Context UriInfo uriInfo) {
   Predicate<RemoteSlot> slotFilter = SlotFilterBuilder.build(uriInfo);
   List<SlotStatusRepresentation> representations = Lists.newArrayList();
   for (RemoteSlot remoteSlot : coordinator.getAllSlots()) {
     if (slotFilter.apply(remoteSlot)) {
       representations.add(SlotStatusRepresentation.from(remoteSlot.status()));
     }
   }
   return Response.ok(representations).build();
 }