@DELETE @Path("/{inputId}") @Timed @ApiOperation(value = "Stop specified input in all nodes") @ApiResponses( value = { @ApiResponse(code = 404, message = "No such input."), }) public Map<String, Optional<InputDeleted>> stop( @ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) { final Map<String, Node> nodes = nodeService.allActive(); return nodes .entrySet() .stream() .parallel() .collect( Collectors.toMap( Map.Entry::getKey, entry -> { final RemoteInputStatesResource remoteInputStatesResource = remoteInterfaceProvider.get( entry.getValue(), this.authenticationToken, RemoteInputStatesResource.class); try { final Response<InputDeleted> response = remoteInputStatesResource.stop(inputId).execute(); if (response.isSuccess()) { return Optional.of(response.body()); } else { LOG.warn( "Unable to stop input on node {}: {}", entry.getKey(), response.message()); } } catch (IOException e) { LOG.warn("Unable to stop input on node {}:", entry.getKey(), e); } return Optional.absent(); })); }
@GET @Timed @ApiOperation(value = "Get all input states") @RequiresPermissions(RestPermissions.INPUTS_READ) public Map<String, Set<InputStateSummary>> get() { final Map<String, Node> nodes = nodeService.allActive(); return nodes .entrySet() .stream() .parallel() .collect( Collectors.toMap( Map.Entry::getKey, entry -> { final RemoteInputStatesResource remoteInputStatesResource = remoteInterfaceProvider.get( entry.getValue(), this.authenticationToken, RemoteInputStatesResource.class); try { final Response<InputStatesList> response = remoteInputStatesResource.list().execute(); if (response.isSuccess()) { return response.body().states(); } else { LOG.warn( "Unable to fetch input states from node {}: {}", entry.getKey(), response.message()); } } catch (IOException e) { LOG.warn("Unable to fetch input states from node {}:", entry.getKey(), e); } return Collections.emptySet(); })); }