@Override public String getKey() { return String.format("(ATTRS,%s,%s)", m_context.getId(), m_resourceId); }
public Context getContext() { return new Context(m_id); }
@Override public void serialize(SampleDTO value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("name", value.getName()); jgen.writeNumberField("timestamp", value.getTimestamp()); jgen.writeStringField("type", value.getType().toString()); jgen.writeObjectField("value", value.getValue()); // Since attributes is optional, be compact and omit from JSON output when unused. if (value.getAttributes() != null && !value.getAttributes().isEmpty()) { jgen.writeObjectField("attributes", value.getAttributes()); } // Omit the context field when it is set to the default if (!Context.DEFAULT_CONTEXT.equals(value.getContext())) { jgen.writeStringField("context", value.getContext().getId()); } jgen.writeEndObject(); }
@Override public void serialize(SampleDTO value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("name", value.getName()); jgen.writeNumberField("timestamp", value.getTimestamp()); jgen.writeStringField("type", value.getType().toString()); jgen.writeObjectField("value", value.getValue()); // Since attributes is optional, be compact and omit from JSON output when unused. if (value.getAttributes() != null && !value.getAttributes().isEmpty()) { jgen.writeObjectField("attributes", value.getAttributes()); } // Omit the context field when it is set to the default if (!Context.DEFAULT_CONTEXT.equals(value.getContext())) { jgen.writeStringField("context", value.getContext().getId()); } jgen.writeEndObject(); }
@Override public String getKey() { return String.format("(METRICS,%s,%s)", m_context.getId(), m_resourceId); }
public Context getContext() { return new Context(m_id); }
@Override public String getKey() { return String.format("(METRICS,%s,%s)", m_context.getId(), m_resourceId); }
@JsonCreator public SampleDTO(@JsonProperty("timestamp") long timestamp, @JsonProperty("resource") ResourceDTO resource, @JsonProperty("name") String name, @JsonProperty("type") MetricType type, @JsonProperty("value") Number value, @JsonProperty("attributes") Map<String, String> attributes, @JsonProperty("context") String context) { m_timestamp = checkNotNull(timestamp, "m_timestamp argument"); m_resource = checkNotNull(resource, "m_resource argument"); m_name = checkNotNull(name, "m_name argument"); m_type = checkNotNull(type, "m_type argument"); m_value = checkNotNull(value, "m_value argument"); m_attributes = attributes; m_context = context != null ? new Context(context) : Context.DEFAULT_CONTEXT; }
private String key(Context context, String resourceId) { return m_keyJoiner.join(context.getId(), resourceId); }
@JsonCreator public SampleDTO(@JsonProperty("timestamp") long timestamp, @JsonProperty("resource") ResourceDTO resource, @JsonProperty("name") String name, @JsonProperty("type") MetricType type, @JsonProperty("value") Number value, @JsonProperty("attributes") Map<String, String> attributes, @JsonProperty("context") String context) { m_timestamp = checkNotNull(timestamp, "m_timestamp argument"); m_resource = checkNotNull(resource, "m_resource argument"); m_name = checkNotNull(name, "m_name argument"); m_type = checkNotNull(type, "m_type argument"); m_value = checkNotNull(value, "m_value argument"); m_attributes = attributes; m_context = context != null ? new Context(context) : Context.DEFAULT_CONTEXT; }
private String key(Context context, String resourceId) { return m_keyJoiner.join(context.getId(), resourceId); }
@DELETE @Timed @Path("/{resource}") public void deleteSamples(@PathParam("resource") Resource resource, @QueryParam("context") Optional<String> contextId) { final Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT; m_sampleRepository.delete(context, resource); m_indexer.delete(context, resource); } }
@Override public String getKey() { return String.format("(ATTRS,%s,%s)", m_context.getId(), m_resourceId); }
@DELETE @Timed @Path("/{resource}") public void deleteSamples(@PathParam("resource") Resource resource, @QueryParam("context") Optional<String> contextId) { final Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT; m_sampleRepository.delete(context, resource); m_indexer.delete(context, resource); } }
private String resourceId(Context context, String key) { return key.substring(context.getId().length() + 1); }
@GET @Timed @Path("/{resource}") public Collection<Collection<SampleDTO>> getSamples(@PathParam("resource") Resource resource, @QueryParam("start") Optional<TimestampParam> start, @QueryParam("end") Optional<TimestampParam> end, @QueryParam("context") Optional<String> contextId) { Optional<Timestamp> lower = Transform.toTimestamp(start); Optional<Timestamp> upper = Transform.toTimestamp(end); Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT; return Transform.sampleDTOs(m_sampleRepository.select(context, resource, lower, upper)); }
private String resourceId(Context context, String key) { return key.substring(context.getId().length() + 1); }
@GET @Timed public Collection<SearchResultDTO> search(@QueryParam("q") Optional<String> query, @QueryParam("context") Optional<String> contextId) { checkArgument(query.isPresent(), "missing required query parameter (q=<argument>)"); QueryParser qp = new QueryParser(); Query parsedQuery; try { parsedQuery = qp.parse(query.get()); } catch (ParseException e) { throw new WebApplicationException(e, Response.status(Status.BAD_REQUEST).entity("Invalid query " + query.get()).build()); } Context context = contextId.isPresent() ? new Context(contextId.get()) : Context.DEFAULT_CONTEXT; return Transform.searchResultDTOs(m_searcher.search(context, parsedQuery)); }