Package org.collectd.api

Examples of org.collectd.api.ValueList


   *                plugin instance will be used.
   */
  public void query (MBeanServerConnection conn, ObjectName objName, /* {{{ */
      PluginData pd)
  {
    ValueList vl;
    List<DataSource> dsrc;
    List<Object> values;
    List<String> instanceList;
    String instancePrefix;

    if (this._ds == null)
    {
      this._ds = Collectd.getDS (this._ds_name);
      if (this._ds == null)
      {
        Collectd.logError ("GenericJMXConfValue: Unknown type: "
            + this._ds_name);
        return;
      }
    }

    dsrc = this._ds.getDataSources ();
    if (dsrc.size () != this._attributes.size ())
    {
      Collectd.logError ("GenericJMXConfValue.query: The data set "
          + this._ds_name + " has " + this._ds.getDataSources ().size ()
          + " data sources, but there were " + this._attributes.size ()
          + " attributes configured. This doesn't match!");
      this._ds = null;
      return;
    }

    vl = new ValueList (pd);
    vl.setType (this._ds_name);

    /*
     * Build the instnace prefix from the fixed string prefix and the
     * properties of the objName.
     */
 
View Full Code Here


    Collectd.registerShutdown ("JMXMemory", this);
  }

  private void submit (String plugin_instance, MemoryUsage usage) /* {{{ */
  {
    ValueList vl;

    long mem_init;
    long mem_used;
    long mem_committed;
    long mem_max;

    mem_init = usage.getInit ();
    mem_used = usage.getUsed ();
    mem_committed = usage.getCommitted ();
    mem_max = usage.getMax ();

    Collectd.logDebug ("JMXMemory plugin: plugin_instance = " + plugin_instance + "; "
        + "mem_init = " + mem_init + "; "
        + "mem_used = " + mem_used + "; "
        + "mem_committed = " + mem_committed + "; "
        + "mem_max = " + mem_max + ";");

    vl = new ValueList ();

    vl.setHost ("localhost");
    vl.setPlugin ("JMXMemory");
    vl.setPluginInstance (plugin_instance);
    vl.setType ("memory");

    if (mem_init >= 0)
    {
      vl.addValue (mem_init);
      vl.setTypeInstance ("init");
      Collectd.dispatchValues (vl);
      vl.clearValues ();
    }

    if (mem_used >= 0)
    {
      vl.addValue (mem_used);
      vl.setTypeInstance ("used");
      Collectd.dispatchValues (vl);
      vl.clearValues ();
    }

    if (mem_committed >= 0)
    {
      vl.addValue (mem_committed);
      vl.setTypeInstance ("committed");
      Collectd.dispatchValues (vl);
      vl.clearValues ();
    }

    if (mem_max >= 0)
    {
      vl.addValue (mem_max);
      vl.setTypeInstance ("max");
      Collectd.dispatchValues (vl);
      vl.clearValues ();
    }
  } /* }}} void submit */
 
View Full Code Here

    public static Test suite() {
        return new TestSuite(ValueListTest.class);
    }

    private ValueList dummyValueList() {
        ValueList vl = new ValueList();
        vl.setHost(HOST);
        vl.setInterval(interval);
        vl.setTime(now);
        vl.setPlugin(PLUGIN);
        vl.setPluginInstance(ValueListTest.class.getName());
        for (int i=0; i<values.length; i++) {
            vl.addValue(new Double(values[i]));
        }
        return vl;
    }
View Full Code Here

            dummyAssert(vl);
        }       
    }

    public void testWriter() throws IOException {
        ValueList vl = dummyValueList();
        PacketWriter pw = new PacketWriter();
        pw.write(vl);
        UdpReceiver receiver = new UdpReceiver();
        TestPacketDispatcher dispatcher = new TestPacketDispatcher();
        receiver.setDispatcher(dispatcher);
View Full Code Here

        String pluginInstance = query.getPluginInstance();
        if (pluginInstance == null) {
            pluginInstance = _sender.getInstanceName();
        }
        String beanName = query.getAlias();
        ValueList vl = new ValueList();
        vl.setInterval(getInterval());
        vl.setPlugin(plugin);
        if (beanName == null){
            beanName = getBeanName(null, name);
        }
        else if (query.getName().isPattern()) {
            String instName = getBeanName(query.getName(), name);
            if (instName != null) {
                beanName += " " + instName;
            }
        }
        vl.setPluginInstance(pluginInstance + "-" + beanName);
        vl.setType(attr.getTypeName());
        vl.setTypeInstance(typeInstance);
        vl.addValue(val);
        _sender.dispatch(vl);
    }
View Full Code Here

        super.tearDown();
        _receiverTest.tearDown();
    }

    private ValueList newValueList() {
        ValueList vl = new ValueList();
        vl.setPlugin(PLUGIN);
        vl.setPluginInstance(PLUGIN_INSTANCE);
        vl.setInterval(INTERVAL);
        vl.setType(TYPE);
        return vl;
    }
View Full Code Here

        _sender.flush();
        Thread.sleep(500);
    }

    public void testGauge() throws Exception {
        ValueList vl = newValueList();
        for (double val : dvals) {
            vl.addValue(new Double(val));
        }
        _sender.dispatch(vl);
        String host = vl.getHost();
        long time = vl.getTime() / 1000;
        flush();
        assertTrue(_values.size() == 1);
        vl = _values.get(0);
        assertValueList(vl, host, time);
        assertTrue(vl.getValues().size() == dvals.length);
        int i=0;
        for (Number num : vl.getValues()) {
            assertTrue(num.getClass() == Double.class);
            assertTrue(num.doubleValue() == dvals[i++]);
        }
        _values.clear();
    }
View Full Code Here

        }
        _values.clear();
    }

    public void testCounter() throws Exception {
        ValueList vl = newValueList();
        for (long val : lvals) {
            vl.addValue(new Long(val));
        }
        _sender.dispatch(vl);
        String host = vl.getHost();
        long time = vl.getTime() / 1000;
        flush();
        assertTrue(_values.size() == 1);
        vl = _values.get(0);
        assertValueList(vl, host, time);
        assertTrue(vl.getValues().size() == lvals.length);
        int i=0;
        for (Number num : vl.getValues()) {
            assertTrue(num.getClass() == Long.class);
            assertTrue(num.longValue() == lvals[i++]);
        }
        _values.clear();
    }
View Full Code Here

    public void dispatch(Notification notification) {
       
    }

    public void dispatch(ValueList vl) {
        _values.add(new ValueList(vl));
    }
View Full Code Here

        writeString(Network.TYPE_PLUGIN_INSTANCE, data.getPluginInstance());
        writeString(Network.TYPE_TYPE, type);
        writeString(Network.TYPE_TYPE_INSTANCE, data.getTypeInstance());
       
        if (data instanceof ValueList) {
            ValueList vl = (ValueList)data;
            List<DataSource> ds = _types.getType(type);
            List<Number> values = vl.getValues();

            if ((ds != null) && (ds.size() != values.size())) {
                String msg =
                    type + " datasource mismatch, expecting " +
                    ds.size() + ", given " + values.size();
                throw new IOException(msg);
            }

            writeNumber(Network.TYPE_INTERVAL, vl.getInterval());
            writeValues(ds, values);
        }
        else {
            //XXX Notification
        }
View Full Code Here

TOP

Related Classes of org.collectd.api.ValueList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.