Search in sources :

Example 1 with QueryMetrics

use of org.apache.ignite.cache.query.QueryMetrics in project ignite by apache.

the class PlatformCache method processOutStream.

/**
 * {@inheritDoc}
 */
@Override
public void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
    switch(type) {
        case OP_GET_NAME:
            writer.writeObject(cache.getName());
            break;
        case OP_LOCAL_METRICS:
            {
                CacheMetrics metrics = cache.localMetrics();
                writeCacheMetrics(writer, metrics);
                break;
            }
        case OP_GLOBAL_METRICS:
            {
                CacheMetrics metrics = cache.metrics();
                writeCacheMetrics(writer, metrics);
                break;
            }
        case OP_GET_CONFIG:
            CacheConfiguration ccfg = ((IgniteCache<Object, Object>) cache).getConfiguration(CacheConfiguration.class);
            PlatformConfigurationUtils.writeCacheConfiguration(writer, ccfg);
            break;
        case OP_GET_LOST_PARTITIONS:
            Collection<Integer> parts = cache.lostPartitions();
            writer.writeInt(parts.size());
            for (int p : parts) {
                writer.writeInt(p);
            }
            break;
        case OP_QUERY_METRICS:
            {
                QueryMetrics metrics = cache.queryMetrics();
                writeQueryMetrics(writer, metrics);
                break;
            }
        default:
            super.processOutStream(type, writer);
    }
}
Also used : CacheMetrics(org.apache.ignite.cache.CacheMetrics) QueryMetrics(org.apache.ignite.cache.query.QueryMetrics) IgniteCache(org.apache.ignite.IgniteCache) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 2 with QueryMetrics

use of org.apache.ignite.cache.query.QueryMetrics in project ignite by apache.

the class CacheAbstractQueryMetricsSelfTest method checkMetrics.

/**
 * Check metrics.
 *
 * @param cache Cache to check metrics.
 * @param execs Expected number of executions.
 * @param completions Expected number of completions.
 * @param failures Expected number of failures.
 * @param first {@code true} if metrics checked for first query only.
 */
private void checkMetrics(IgniteCache<Integer, String> cache, int execs, int completions, int failures, boolean first) {
    QueryMetrics m = cache.queryMetrics();
    assertNotNull(m);
    info("Metrics: " + m);
    assertEquals("Executions", execs, m.executions());
    assertEquals("Completions", completions, m.executions() - m.fails());
    assertEquals("Failures", failures, m.fails());
    assertTrue(m.averageTime() >= 0);
    assertTrue(m.maximumTime() >= 0);
    assertTrue(m.minimumTime() >= 0);
    if (first)
        assertEquals("On first execution minTime == maxTime", m.minimumTime(), m.maximumTime());
}
Also used : QueryMetrics(org.apache.ignite.cache.query.QueryMetrics)

Aggregations

QueryMetrics (org.apache.ignite.cache.query.QueryMetrics)2 IgniteCache (org.apache.ignite.IgniteCache)1 CacheMetrics (org.apache.ignite.cache.CacheMetrics)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1