congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Sample
Code IndexAdd Tabnine to your IDE (free)

How to use
Sample
in
org.rrd4j.core

Best Java code snippets using org.rrd4j.core.Sample (Showing top 19 results out of 315)

origin: codice/ddf

private void updateSample(long now, double val) throws IOException {
 LOGGER.debug(
   "Sample time is [{}], updating metric [{}] with value [{}]",
   MetricsUtil.getCalendarTime(now),
   mbeanName,
   val);
 sample.setTime(now);
 sample.setValue(rrdDataSourceName, val);
 sample.update();
}
origin: org.fusesource.rrd4j/rrd4j

  String getRrdToolCommand() {
    return dump();
  }
}
origin: org.rrd4j/rrd4j

/**
 * <p>Creates new sample with the given timestamp and all datasource values set to
 * 'unknown'. Use returned <code>Sample</code> object to specify
 * datasource values for the given timestamp. See documentation for
 * {@link Sample Sample} for an explanation how to do this.</p>
 * <p>Once populated with data source values, call Sample's
 * {@link org.rrd4j.core.Sample#update() update()} method to actually
 * store sample in the RRD associated with it.</p>
 *
 * @param time Sample timestamp rounded to the nearest second (without milliseconds).
 * @return Fresh sample with the given timestamp and all data source values set to 'unknown'.
 * @throws java.io.IOException Thrown in case of I/O error.
 */
public Sample createSample(long time) throws IOException {
  return new Sample(this, time);
}
origin: org.fusesource.rrd4j/rrd4j

/**
 * <p>Creates sample with the timestamp and data source values supplied
 * in the argument string and stores sample in the corresponding RRD.
 * This method is just a shortcut for:</p>
 * <pre>
 *     set(timeAndValues);
 *     update();
 * </pre>
 *
 * @param timeAndValues String made by concatenating sample timestamp with corresponding
 *                      data source values delmited with colons. For example:<br>
 *                      <code>1005234132:12.2:35.6:U:24.5</code><br>
 *                      <code>NOW:12.2:35.6:U:24.5</code>
 * @throws IOException Thrown in case of I/O error.
 */
public void setAndUpdate(String timeAndValues) throws IOException {
  set(timeAndValues);
  update();
}
origin: org.apache.marmotta/marmotta-loader-core

  @Override
  public void run() {
    try {
      long time = System.currentTimeMillis() / 1000;
      synchronized (statSample) {
        statSample.setTime(time);
        statSample.setValues(handler.triples);
        statSample.update();
      }
    } catch (Exception e) {
      log.warn("could not update statistics database: {}", e.getMessage());
    }
  }
}
origin: org.fusesource.rrd4j/rrd4j

sample.setTime(t);
sample.setValue("sun", sunSource.getValue());
sample.setValue("shade", shadeSource.getValue());
log.println(sample.dump());
sample.update();
t += RANDOM.nextDouble() * MAX_STEP + 1;
if (((++n) % 1000) == 0) {
origin: fbacchella/jrds

public void commit(JrdsSample sample) {
  RrdDb rrdDb = null;
  try {
    rrdDb = factory.getRrd(getPath());
    Sample onesample = rrdDb.createSample(sample.getTime().getTime() / 1000);
    for(Map.Entry<String, Number> e: sample.entrySet()) {
      onesample.setValue(e.getKey(), e.getValue().doubleValue());
    }
    if(p.getNamedLogger().isDebugEnabled())
      log(Level.DEBUG, "%s", onesample.dump());
    onesample.update();
  } catch (IOException e) {
    log(Level.ERROR, e, "Error while collecting: %s", e.getMessage());
  } finally {
    if(rrdDb != null)
      factory.releaseRrd(rrdDb);
  }
}
origin: frenchc/jetm

protected void flushStatus() {
 if (transactions > 0) {
  try {
   Sample sample = db.createSample(endInterval);
   if (transactionsEnabled) {
    sample.setValue("transactions!", transactions);
   }
   if (minEnabled) {
    sample.setValue("min", min);
   }
   if (maxEnabled) {
    sample.setValue("max", max);
   }
   if (averageEnabled) {
    double value = total / (double) transactions;
    sample.setValue("average", value);
   }
   sample.update();
  } catch (IOException e) {
   throw new EtmException(e);
  }
 }
}
origin: org.rrd4j/rrd4j

final synchronized void store(Sample sample) throws IOException {
  if (closed) {
    throw new IllegalStateException("RRD already closed, cannot store this sample");
  }
  long newTime = sample.getTime();
  long lastTime = header.getLastUpdateTime();
  if (lastTime >= newTime) {
    throw new IllegalArgumentException("Bad sample time: " + newTime +
        ". Last update time was " + lastTime + ", at least one second step is required");
  }
  double[] newValues = sample.getValues();
  for (int i = 0; i < datasources.length; i++) {
    double newValue = newValues[i];
    datasources[i].process(newTime, newValue);
  }
  header.setLastUpdateTime(newTime);
}
origin: org.fusesource.rrd4j/rrd4j

Sample(RrdDb parentDb, long time) throws IOException {
  this.parentDb = parentDb;
  this.time = time;
  this.dsNames = parentDb.getDsNames();
  values = new double[dsNames.length];
  clearValues();
}
origin: apache/marmotta

  @Override
  public void run() {
    try {
      long time = System.currentTimeMillis() / 1000;
      synchronized (statSample) {
        statSample.setTime(time);
        statSample.setValues(handler.triples);
        statSample.update();
      }
    } catch (Exception e) {
      log.warn("could not update statistics database: {}", e.getMessage());
    }
  }
}
origin: org.fusesource.rrd4j/rrd4j

sample.setValue("a", Math.sin(t / 3000.0) * 50 + 50);
sample.update();
origin: org.rrd4j/rrd4j

/**
 * Creates sample with the timestamp and data source values supplied
 * in the argument string and stores sample in the corresponding RRD.
 * This method is just a shortcut for:
 * <pre>
 *     set(timeAndValues);
 *     update();
 * </pre>
 *
 * @param timeAndValues String made by concatenating sample timestamp with corresponding
 *                      data source values delmited with colons. For example:<br>
 *                      <code>1005234132:12.2:35.6:U:24.5</code><br>
 *                      <code>NOW:12.2:35.6:U:24.5</code>
 * @throws java.io.IOException Thrown in case of I/O error.
 */
public void setAndUpdate(String timeAndValues) throws IOException {
  set(timeAndValues);
  update();
}
origin: org.fusesource.rrd4j/rrd4j

final synchronized void store(Sample sample) throws IOException {
  if (closed) {
    throw new IllegalStateException("RRD already closed, cannot store this sample");
  }
  long newTime = sample.getTime();
  long lastTime = header.getLastUpdateTime();
  if (lastTime >= newTime) {
    throw new IllegalArgumentException("Bad sample time: " + newTime +
        ". Last update time was " + lastTime + ", at least one second step is required");
  }
  double[] newValues = sample.getValues();
  for (int i = 0; i < datasources.length; i++) {
    double newValue = newValues[i];
    datasources[i].process(newTime, newValue);
  }
  header.setLastUpdateTime(newTime);
}
origin: org.fusesource.rrd4j/rrd4j

/**
 * Stores sample in the corresponding RRD. If the update operation succeeds,
 * all datasource values in the sample will be set to Double.NaN (unknown) values.
 *
 * @throws IOException Thrown in case of I/O error.
 */
public void update() throws IOException {
  parentDb.store(this);
  clearValues();
}
origin: org.rrd4j/rrd4j

  String getRrdToolCommand() {
    return dump();
  }
}
origin: org.rrd4j/rrd4j

Sample(RrdDb parentDb, long time) throws IOException {
  this.parentDb = parentDb;
  this.time = time;
  this.dsNames = parentDb.getDsNames();
  values = new double[dsNames.length];
  clearValues();
}
origin: org.fusesource.rrd4j/rrd4j

/**
 * <p>Creates new sample with the given timestamp and all datasource values set to
 * 'unknown'. Use returned <code>Sample</code> object to specify
 * datasource values for the given timestamp. See documentation for
 * {@link Sample Sample} for an explanation how to do this.</p>
 * <p/>
 * <p>Once populated with data source values, call Sample's
 * {@link Sample#update() update()} method to actually
 * store sample in the RRD associated with it.</p>
 *
 * @param time Sample timestamp rounded to the nearest second (without milliseconds).
 * @return Fresh sample with the given timestamp and all data source values set to 'unknown'.
 * @throws IOException Thrown in case of I/O error.
 */
public Sample createSample(long time) throws IOException {
  return new Sample(this, time);
}
origin: org.rrd4j/rrd4j

/**
 * Stores sample in the corresponding RRD. If the update operation succeeds,
 * all datasource values in the sample will be set to Double.NaN (unknown) values.
 *
 * @throws java.io.IOException Thrown in case of I/O error.
 */
public void update() throws IOException {
  parentDb.store(this);
  clearValues();
}
org.rrd4j.coreSample

Javadoc

Class to represent data source values for the given timestamp. Objects of this class are never created directly (no public constructor is provided). To learn more how to update RRDs, see RRDTool's rrdupdate man page.

To update a RRD with Rrd4j use the following procedure:

  1. Obtain empty Sample object by calling method org.rrd4j.core.RrdDb#createSample(long) on respective RrdDb object.
  2. Adjust Sample timestamp if necessary (see #setTime(long) method).
  3. Supply data source values (see #setValue(String,double)).
  4. Call Sample's #update() method.

Newly created Sample object contains all data source values set to 'unknown'. You should specify only 'known' data source values. However, if you want to specify 'unknown' values too, use Double.NaN.

Most used methods

  • update
    Stores sample in the corresponding RRD. If the update operation succeeds, all datasource values in t
  • setValue
    Sets single data source value in the sample.
  • dump
    Dumps sample content using the syntax of RRDTool's update command.
  • setTime
    Sets sample timestamp. Timestamp should be defined in seconds (without milliseconds).
  • <init>
  • clearValues
  • getTime
    Returns sample timestamp (in seconds, without milliseconds).
  • getValues
    Returns all current data source values in the sample.
  • set
    Sets sample timestamp and data source values in a fashion similar to RRDTool. Argument string should
  • setAndUpdate
    Creates sample with the timestamp and data source values supplied in the argument string and stores
  • setValues
    Sets some (possibly all) data source values in bulk. Data source values are assigned in the order of
  • setValues

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Join (org.hibernate.mapping)
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now