• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RestorableMeter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.cassandra.metrics.RestorableMeter的典型用法代码示例。如果您正苦于以下问题:Java RestorableMeter类的具体用法?Java RestorableMeter怎么用?Java RestorableMeter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RestorableMeter类属于org.apache.cassandra.metrics包,在下文中一共展示了RestorableMeter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getSSTableReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
/**
 * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
 * from values in system.sstable_activity if present.
 * @param keyspace the keyspace the sstable belongs to
 * @param table the table the sstable belongs to
 * @param generation the generation number for the sstable
 */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
    String cql = "SELECT * FROM %s WHERE keyspace_name='%s' and columnfamily_name='%s' and generation=%d";
    UntypedResultSet results = processInternal(String.format(cql,
                                                             SSTABLE_ACTIVITY_CF,
                                                             keyspace,
                                                             table,
                                                             generation));

    if (results.isEmpty())
        return new RestorableMeter();

    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:SystemKeyspace.java


示例2: getSSTableReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
/**
 * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
 * from values in system.sstable_activity if present.
 * @param keyspace the keyspace the sstable belongs to
 * @param table the table the sstable belongs to
 * @param generation the generation number for the sstable
 */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
    String cql = "SELECT * FROM system.%s WHERE keyspace_name=? and columnfamily_name=? and generation=?";
    UntypedResultSet results = executeInternal(String.format(cql, SSTABLE_ACTIVITY_CF), keyspace, table, generation);

    if (results.isEmpty())
        return new RestorableMeter();

    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:SystemKeyspace.java


示例3: persistSSTableReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
/**
 * Writes the current read rates for a given SSTable to system.sstable_activity
 */
public static void persistSSTableReadMeter(String keyspace, String table, int generation, RestorableMeter meter)
{
    // Store values with a one-day TTL to handle corner cases where cleanup might not occur
    String cql = "INSERT INTO system.%s (keyspace_name, columnfamily_name, generation, rate_15m, rate_120m) VALUES (?, ?, ?, ?, ?) USING TTL 864000";
    executeInternal(String.format(cql, SSTABLE_ACTIVITY_CF),
                    keyspace,
                    table,
                    generation,
                    meter.fifteenMinuteRate(),
                    meter.twoHourRate());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:SystemKeyspace.java


示例4: persistSSTableReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
/**
 * Writes the current read rates for a given SSTable to system.sstable_activity
 */
public static void persistSSTableReadMeter(String keyspace, String table, int generation, RestorableMeter meter)
{
    // Store values with a one-day TTL to handle corner cases where cleanup might not occur
    String cql = "INSERT INTO %s (keyspace_name, columnfamily_name, generation, rate_15m, rate_120m) VALUES ('%s', '%s', %d, %f, %f) USING TTL 864000";
    processInternal(String.format(cql,
                                  SSTABLE_ACTIVITY_CF,
                                  keyspace,
                                  table,
                                  generation,
                                  meter.fifteenMinuteRate(),
                                  meter.twoHourRate()));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:16,代码来源:SystemKeyspace.java


示例5: getSSTableReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
/**
 * Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
 * from values in system.sstable_activity if present.
 * @param keyspace the keyspace the sstable belongs to
 * @param table the table the sstable belongs to
 * @param generation the generation number for the sstable
 */
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
    String cql = "SELECT * FROM system.%s WHERE keyspace_name=? and columnfamily_name=? and generation=?";
    UntypedResultSet results = executeInternal(String.format(cql, SSTABLE_ACTIVITY), keyspace, table, generation);

    if (results.isEmpty())
        return new RestorableMeter();

    UntypedResultSet.Row row = results.one();
    double m15rate = row.getDouble("rate_15m");
    double m120rate = row.getDouble("rate_120m");
    return new RestorableMeter(m15rate, m120rate);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:SystemKeyspace.java


示例6: persistSSTableReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
/**
 * Writes the current read rates for a given SSTable to system.sstable_activity
 */
public static void persistSSTableReadMeter(String keyspace, String table, int generation, RestorableMeter meter)
{
    // Store values with a one-day TTL to handle corner cases where cleanup might not occur
    String cql = "INSERT INTO system.%s (keyspace_name, columnfamily_name, generation, rate_15m, rate_120m) VALUES (?, ?, ?, ?, ?) USING TTL 864000";
    executeInternal(String.format(cql, SSTABLE_ACTIVITY),
                    keyspace,
                    table,
                    generation,
                    meter.fifteenMinuteRate(),
                    meter.twoHourRate());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:SystemKeyspace.java


示例7: overrideReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
@VisibleForTesting
public void overrideReadMeter(RestorableMeter readMeter)
{
    this.readMeter = tidy.global.readMeter = readMeter;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:6,代码来源:SSTableReader.java


示例8: getReadMeter

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
public RestorableMeter getReadMeter()
{
    return readMeter;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:SSTableReader.java


示例9: testPrepBucket

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
@Test
public void testPrepBucket() throws Exception
{
    String ksname = "Keyspace1";
    String cfname = "Standard1";
    Keyspace keyspace = Keyspace.open(ksname);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
    cfs.truncateBlocking();
    cfs.disableAutoCompaction();

    ByteBuffer value = ByteBuffer.wrap(new byte[100]);

    // create 3 sstables
    int numSSTables = 3;
    for (int r = 0; r < numSSTables; r++)
    {
        DecoratedKey key = Util.dk(String.valueOf(r));
        Mutation rm = new Mutation(ksname, key.getKey());
        rm.add(cfname, Util.cellname("column"), value, 0);
        rm.apply();
        cfs.forceBlockingFlush();
    }
    cfs.forceBlockingFlush();

    List<SSTableReader> sstrs = new ArrayList<>(cfs.getSSTables());
    Pair<List<SSTableReader>, Double> bucket;

    List<SSTableReader> interestingBucket = mostInterestingBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32);
    assertTrue("nothing should be returned when all buckets are below the min threshold", interestingBucket.isEmpty());

    sstrs.get(0).overrideReadMeter(new RestorableMeter(100.0, 100.0));
    sstrs.get(1).overrideReadMeter(new RestorableMeter(200.0, 200.0));
    sstrs.get(2).overrideReadMeter(new RestorableMeter(300.0, 300.0));

    long estimatedKeys = sstrs.get(0).estimatedKeys();

    // if we have more than the max threshold, the coldest should be dropped
    bucket = trimToThresholdWithHotness(sstrs, 2);
    assertEquals("one bucket should have been dropped", 2, bucket.left.size());
    double expectedBucketHotness = (200.0 + 300.0) / estimatedKeys;
    assertEquals(String.format("bucket hotness (%f) should be close to %f", bucket.right, expectedBucketHotness),
                 expectedBucketHotness, bucket.right, 1.0);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:44,代码来源:SizeTieredCompactionStrategyTest.java


示例10: testPrepBucket

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
@Test
public void testPrepBucket() throws Exception
{
    String ksname = KEYSPACE1;
    String cfname = "Standard1";
    Keyspace keyspace = Keyspace.open(ksname);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
    cfs.truncateBlocking();
    cfs.disableAutoCompaction();

    ByteBuffer value = ByteBuffer.wrap(new byte[100]);

    // create 3 sstables
    int numSSTables = 3;
    for (int r = 0; r < numSSTables; r++)
    {
        String key = String.valueOf(r);
        new RowUpdateBuilder(cfs.metadata, 0, key)
            .clustering("column").add("val", value)
            .build().applyUnsafe();
        cfs.forceBlockingFlush();
    }
    cfs.forceBlockingFlush();

    List<SSTableReader> sstrs = new ArrayList<>(cfs.getLiveSSTables());
    Pair<List<SSTableReader>, Double> bucket;

    List<SSTableReader> interestingBucket = mostInterestingBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32);
    assertTrue("nothing should be returned when all buckets are below the min threshold", interestingBucket.isEmpty());

    sstrs.get(0).overrideReadMeter(new RestorableMeter(100.0, 100.0));
    sstrs.get(1).overrideReadMeter(new RestorableMeter(200.0, 200.0));
    sstrs.get(2).overrideReadMeter(new RestorableMeter(300.0, 300.0));

    long estimatedKeys = sstrs.get(0).estimatedKeys();

    // if we have more than the max threshold, the coldest should be dropped
    bucket = trimToThresholdWithHotness(sstrs, 2);
    assertEquals("one bucket should have been dropped", 2, bucket.left.size());
    double expectedBucketHotness = (200.0 + 300.0) / estimatedKeys;
    assertEquals(String.format("bucket hotness (%f) should be close to %f", bucket.right, expectedBucketHotness),
                 expectedBucketHotness, bucket.right, 1.0);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:44,代码来源:SizeTieredCompactionStrategyTest.java


示例11: testCancelIndex

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
@Test
public void testCancelIndex() throws Exception
{
    String ksname = KEYSPACE1;
    String cfname = CF_STANDARDLOWiINTERVAL; // index interval of 8, no key caching
    Keyspace keyspace = Keyspace.open(ksname);
    final ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
    final int numSSTables = 4;
    int numRows = 256;
    createSSTables(ksname, cfname, numSSTables, numRows);

    final List<SSTableReader> sstables = new ArrayList<>(cfs.getLiveSSTables());
    for (SSTableReader sstable : sstables)
        sstable.overrideReadMeter(new RestorableMeter(100.0, 100.0));

    final long singleSummaryOffHeapSpace = sstables.get(0).getIndexSummaryOffHeapSize();

    // everything should get cut in half
    final AtomicReference<CompactionInterruptedException> exception = new AtomicReference<>();

    Thread t = new Thread(new Runnable()
    {
        public void run()
        {
            try
            {
                // Don't leave enough space for even the minimal index summaries
                try (LifecycleTransaction txn = cfs.getTracker().tryModify(sstables, OperationType.UNKNOWN))
                {
                    redistributeSummaries(Collections.EMPTY_LIST, of(cfs.metadata.cfId, txn), singleSummaryOffHeapSpace);
                }
            }
            catch (CompactionInterruptedException ex)
            {
                exception.set(ex);
            }
            catch (IOException ignored)
            {
            }
        }
    });
    t.start();
    while (CompactionManager.instance.getActiveCompactions() == 0 && t.isAlive())
        Thread.sleep(1);
    CompactionManager.instance.stopCompaction("INDEX_SUMMARY");
    t.join();

    assertNotNull("Expected compaction interrupted exception", exception.get());
    assertTrue("Expected no active compactions", CompactionMetrics.getCompactions().isEmpty());

    Set<SSTableReader> beforeRedistributionSSTables = new HashSet<>(sstables);
    Set<SSTableReader> afterCancelSSTables = new HashSet<>(cfs.getLiveSSTables());
    Set<SSTableReader> disjoint = Sets.symmetricDifference(beforeRedistributionSSTables, afterCancelSSTables);
    assertTrue(String.format("Mismatched files before and after cancelling redistribution: %s",
                             Joiner.on(",").join(disjoint)),
               disjoint.isEmpty());

    validateData(cfs, numRows);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:60,代码来源:IndexSummaryManagerTest.java


示例12: testPrepBucket

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
@Test
public void testPrepBucket() throws Exception
{
    String ksname = KEYSPACE1;
    String cfname = "Standard1";
    Keyspace keyspace = Keyspace.open(ksname);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
    cfs.truncateBlocking();
    cfs.disableAutoCompaction();

    ByteBuffer value = ByteBuffer.wrap(new byte[100]);

    // create 3 sstables
    int numSSTables = 3;
    for (int r = 0; r < numSSTables; r++)
    {
        DecoratedKey key = Util.dk(String.valueOf(r));
        Mutation rm = new Mutation(ksname, key.getKey());
        rm.add(cfname, Util.cellname("column"), value, 0);
        rm.applyUnsafe();
        cfs.forceBlockingFlush();
    }
    cfs.forceBlockingFlush();

    List<SSTableReader> sstrs = new ArrayList<>(cfs.getSSTables());
    Pair<List<SSTableReader>, Double> bucket;

    List<SSTableReader> interestingBucket = mostInterestingBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32);
    assertTrue("nothing should be returned when all buckets are below the min threshold", interestingBucket.isEmpty());

    sstrs.get(0).readMeter = new RestorableMeter(100.0, 100.0);
    sstrs.get(1).readMeter = new RestorableMeter(200.0, 200.0);
    sstrs.get(2).readMeter = new RestorableMeter(300.0, 300.0);

    long estimatedKeys = sstrs.get(0).estimatedKeys();

    // if we have more than the max threshold, the coldest should be dropped
    bucket = trimToThresholdWithHotness(sstrs, 2);
    assertEquals("one bucket should have been dropped", 2, bucket.left.size());
    double expectedBucketHotness = (200.0 + 300.0) / estimatedKeys;
    assertEquals(String.format("bucket hotness (%f) should be close to %f", bucket.right, expectedBucketHotness),
                 expectedBucketHotness, bucket.right, 1.0);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:44,代码来源:SizeTieredCompactionStrategyTest.java


示例13: testPrepBucket

import org.apache.cassandra.metrics.RestorableMeter; //导入依赖的package包/类
@Test
public void testPrepBucket() throws Exception
{
    String ksname = "Keyspace1";
    String cfname = "Standard1";
    Keyspace keyspace = Keyspace.open(ksname);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);
    cfs.truncateBlocking();
    cfs.disableAutoCompaction();

    ByteBuffer value = ByteBuffer.wrap(new byte[100]);

    // create 3 sstables
    int numSSTables = 3;
    for (int r = 0; r < numSSTables; r++)
    {
        DecoratedKey key = Util.dk(String.valueOf(r));
        Mutation rm = new Mutation(ksname, key.key);
        rm.add(cfname, Util.cellname("column"), value, 0);
        rm.apply();
        cfs.forceBlockingFlush();
    }
    cfs.forceBlockingFlush();

    List<SSTableReader> sstrs = new ArrayList<>(cfs.getSSTables());
    Pair<List<SSTableReader>, Double> bucket;

    List<SSTableReader> interestingBucket = mostInterestingBucket(Collections.singletonList(sstrs.subList(0, 2)), 4, 32);
    assertTrue("nothing should be returned when all buckets are below the min threshold", interestingBucket.isEmpty());

    sstrs.get(0).readMeter = new RestorableMeter(100.0, 100.0);
    sstrs.get(1).readMeter = new RestorableMeter(200.0, 200.0);
    sstrs.get(2).readMeter = new RestorableMeter(300.0, 300.0);

    long estimatedKeys = sstrs.get(0).estimatedKeys();

    // if we have more than the max threshold, the coldest should be dropped
    bucket = trimToThresholdWithHotness(sstrs, 2);
    assertEquals("one bucket should have been dropped", 2, bucket.left.size());
    double expectedBucketHotness = (200.0 + 300.0) / estimatedKeys;
    assertEquals(String.format("bucket hotness (%f) should be close to %f", bucket.right, expectedBucketHotness),
                 expectedBucketHotness, bucket.right, 1.0);
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:44,代码来源:SizeTieredCompactionStrategyTest.java



注:本文中的org.apache.cassandra.metrics.RestorableMeter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Anchor类代码示例发布时间:2022-05-23
下一篇:
Java JobEntryJob类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap