@Override protected Resource parse(String argument) throws NumberFormatException, CmdLineException { return new Resource(argument); }
private Resource resourceFor(String name) { return new Resource(String.format("%s-%s", this.name, name)); }
private Resource resourceFor(String name) { return new Resource(String.format("%s-%s", this.name, name)); }
Query(String resource, Timestamp start, Timestamp end, Duration resolution) { m_resource = new Resource(checkNotNull(resource, "resource argument")); m_start = checkNotNull(start, "start argument"); m_end = checkNotNull(end, "end argument"); m_resolution = checkNotNull(resolution, "resolution argument"); }
static Resource parseResource(String[] path) { Map<String, String> attributes = Maps.newHashMap(); for (int i = 0; i < path.length; i++) { attributes.put(index(i), path[i]); } return new Resource(s_pathJoiner.join(path), Optional.of(attributes)); }
public SampleGenerator(String resource, String metric, Timestamp start, Timestamp end, Duration interval) { m_resource = new Resource(checkNotNull(resource, "resource argument")); m_metric = checkNotNull(metric, "metric argument"); checkNotNull(start, "start argument"); checkNotNull(end, "end argument"); checkNotNull(interval, "interval argument"); m_intervals = new IntervalGenerator(start, end, interval); }
private static Resource getResource(com.datastax.driver.core.Row row) { return new Resource(row.getString(SchemaConstants.F_RESOURCE)); }
public List<Sample> getSamplesToIndex() { final List<Sample> samples = Lists.newLinkedList(); // Convert string attributes to samples for (Entry<ResourcePath, Map<String, String>> entry : m_stringAttributesByPath.entrySet()) { Resource resource = new Resource(toResourceId(entry.getKey()), Optional.of(entry.getValue())); samples.add(NewtsUtils.createSampleForIndexingStrings(m_context, resource)); } return samples; }
public List<Sample> getSamplesToIndex() { final List<Sample> samples = Lists.newLinkedList(); // Convert string attributes to samples for (Entry<ResourcePath, Map<String, String>> entry : m_stringAttributesByPath.entrySet()) { Resource resource = new Resource(toResourceId(entry.getKey()), Optional.of(entry.getValue())); samples.add(NewtsUtils.createSampleForIndexingStrings(m_context, resource)); } return samples; }
@Override public void setStringAttribute(ResourcePath path, String key, String value) { // Create a mock sample referencing the resource Map<String, String> attributes = new ImmutableMap.Builder<String, String>() .put(key, value) .build(); Resource resource = new Resource(toResourceId(path), Optional.of(attributes)); Sample sample = NewtsUtils.createSampleForIndexingStrings(m_context, resource); // Index, but do not insert the sample(s) // The key/value pair specified in the attributes map will be merged with the others. m_newtsWriter.index(Lists.newArrayList(sample)); }
@Override public void setStringAttribute(ResourcePath path, String key, String value) { // Create a mock sample referencing the resource Map<String, String> attributes = new ImmutableMap.Builder<String, String>() .put(key, value) .build(); Resource resource = new Resource(toResourceId(path), Optional.of(attributes)); Sample sample = NewtsUtils.createSampleForIndexingStrings(m_context, resource); // Index, but do not insert the sample(s) // The key/value pair specified in the attributes map will be merged with the others. m_newtsWriter.index(Lists.newArrayList(sample)); }
private void injectStringPropertiesToNewts(final ResourcePath resourcePath, final Map<String, String> stringProperties) { final Resource resource = new Resource(NewtsUtils.toResourceId(resourcePath), Optional.of(stringProperties)); final Sample sample = new Sample(EPOCH, resource, "strings", MetricType.GAUGE, ZERO); indexer.update(Lists.newArrayList(sample)); }
/** Perform simple query; Establishes only that we can go to the database without excepting. */ @Override protected Result check() throws Exception { m_repository.select(Context.DEFAULT_CONTEXT, new Resource("notreal"), Optional.of(Timestamp.fromEpochMillis(0)), Optional.of(Timestamp.fromEpochMillis(0))); return Result.healthy(); }
/** Perform simple query; Establishes only that we can go to the database without excepting. */ @Override protected Result check() throws Exception { m_repository.select(Context.DEFAULT_CONTEXT, new Resource("notreal"), Optional.of(Timestamp.fromEpochMillis(0)), Optional.of(Timestamp.fromEpochMillis(0))); return Result.healthy(); }
Resource resource = new Resource(NewtsUtils.toResourceId(path), Optional.of(m_metaData));
Resource resource = new Resource(NewtsUtils.toResourceId(path), Optional.of(m_metaData));
@Override public Collection<Row<Measurement>> call() throws Exception { ResultDescriptor resultDescriptor = new ResultDescriptor(lag.getInterval()); for (Source source : listOfSources) { // Use the datasource as the metric name if set, otherwise use the name of the attribute final String metricName = source.getDataSource() != null ? source.getDataSource() : source.getAttribute(); final String name = source.getLabel(); final AggregationFunction fn = toAggregationFunction(source.getAggregation()); resultDescriptor.datasource(name, metricName, lag.getHeartbeat(), fn); resultDescriptor.export(name); } LOG.debug("Querying Newts for resource id {} with result descriptor: {}", newtsResourceId, resultDescriptor); Results<Measurement> results = m_sampleRepository.select(m_context, new Resource(newtsResourceId), start, end, resultDescriptor, Optional.of(Duration.millis(lag.getStep())), limitConcurrentAggregationsCallback); Collection<Row<Measurement>> rows = results.getRows(); LOG.debug("Found {} rows.", rows.size()); return rows; } };
@Override public Collection<Row<Measurement>> call() throws Exception { ResultDescriptor resultDescriptor = new ResultDescriptor(lag.getInterval()); for (Source source : listOfSources) { // Use the datasource as the metric name if set, otherwise use the name of the attribute final String metricName = source.getDataSource() != null ? source.getDataSource() : source.getAttribute(); final String name = source.getLabel(); final AggregationFunction fn = toAggregationFunction(source.getAggregation()); resultDescriptor.datasource(name, metricName, lag.getHeartbeat(), fn); resultDescriptor.export(name); } LOG.debug("Querying Newts for resource id {} with result descriptor: {}", newtsResourceId, resultDescriptor); Results<Measurement> results = m_sampleRepository.select(m_context, new Resource(newtsResourceId), start, end, resultDescriptor, Optional.of(Duration.millis(lag.getStep())), limitConcurrentAggregationsCallback); Collection<Row<Measurement>> rows = results.getRows(); LOG.debug("Found {} rows.", rows.size()); return rows; } };
@Override public Sample apply(SampleDTO input) { return new Sample( Timestamp.fromEpochMillis(input.getTimestamp()), input.getContext(), new Resource(input.getResource().getId(), wrapMap(input.getResource().getAttributes())), input.getName(), input.getType(), ValueType.compose(input.getValue(), input.getType()), input.getAttributes()); } };
@Override public Sample apply(SampleDTO input) { return new Sample( Timestamp.fromEpochMillis(input.getTimestamp()), input.getContext(), new Resource(input.getResource().getId(), wrapMap(input.getResource().getAttributes())), input.getName(), input.getType(), ValueType.compose(input.getValue(), input.getType()), input.getAttributes()); } };