@Inject public ServiceInventoryResource(NodeInfo nodeInfo) { environment = nodeInfo.getEnvironment(); descriptor.set(new ServiceDescriptorsRepresentation(environment, ImmutableList.<ServiceDescriptor>of())); }
@GET @Produces(MediaType.APPLICATION_JSON) public Response getServiceInventory() { return Response.ok(new ServiceDescriptorsRepresentation(environment, serviceInventory.getServiceInventory(coordinator.getAllSlotStatus()))).build(); } }
private void updateServiceInventory() { List<ServiceDescriptor> inventory = serviceInventory.getServiceInventory(coordinator.getAllSlotStatus()); ServiceDescriptorsRepresentation serviceDescriptors = new ServiceDescriptorsRepresentation(environment, inventory); File serviceInventoryFile = new File(localDirectory, "service-inventory.json"); try { Files.write(SERVICE_DESCRIPTORS_CODEC.toJson(serviceDescriptors), serviceInventoryFile, Charsets.UTF_8); } catch (IOException e) { System.out.println("Unable to write " + serviceInventoryFile); } } }
private void updateServiceInventory() { List<ServiceDescriptor> inventory = serviceInventory.getServiceInventory(coordinator.getAllSlotStatus()); ServiceDescriptorsRepresentation serviceDescriptors = new ServiceDescriptorsRepresentation(environment, inventory); File serviceInventoryFile = new File(localDirectory, "service-inventory.json"); try { Files.write(SERVICE_DESCRIPTORS_CODEC.toJson(serviceDescriptors), serviceInventoryFile, Charsets.UTF_8); } catch (IOException e) { System.out.println("Unable to write " + serviceInventoryFile); } } }
.setUri(uriBuilderFrom(internalUri).replacePath("/v1/serviceInventory").build()) .setHeader(CONTENT_TYPE, APPLICATION_JSON) .setBodyGenerator(jsonBodyGenerator(serviceDescriptorsCodec, new ServiceDescriptorsRepresentation(environment, serviceInventory))) .build();