当前位置: 首页>>代码示例>>Java>>正文


Java Validator.complete方法代码示例

本文整理汇总了Java中org.apache.cassandra.repair.Validator.complete方法的典型用法代码示例。如果您正苦于以下问题:Java Validator.complete方法的具体用法?Java Validator.complete怎么用?Java Validator.complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.repair.Validator的用法示例。


在下文中一共展示了Validator.complete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doValidationCompaction

import org.apache.cassandra.repair.Validator; //导入方法依赖的package包/类
/**
 * Performs a readonly "compaction" of all sstables in order to validate complete rows,
 * but without writing the merge result
 */
private void doValidationCompaction(ColumnFamilyStore cfs, Validator validator) throws IOException
{
    // this isn't meant to be race-proof, because it's not -- it won't cause bugs for a CFS to be dropped
    // mid-validation, or to attempt to validate a droped CFS.  this is just a best effort to avoid useless work,
    // particularly in the scenario where a validation is submitted before the drop, and there are compactions
    // started prior to the drop keeping some sstables alive.  Since validationCompaction can run
    // concurrently with other compactions, it would otherwise go ahead and scan those again.
    if (!cfs.isValid())
        return;

    Collection<SSTableReader> sstables;
    String snapshotName = validator.desc.sessionId.toString();
    int gcBefore;
    boolean isSnapshotValidation = cfs.snapshotExists(snapshotName);
    if (isSnapshotValidation)
    {
        // If there is a snapshot created for the session then read from there.
        sstables = cfs.getSnapshotSSTableReader(snapshotName);

        // Computing gcbefore based on the current time wouldn't be very good because we know each replica will execute
        // this at a different time (that's the whole purpose of repair with snaphsot). So instead we take the creation
        // time of the snapshot, which should give us roughtly the same time on each replica (roughtly being in that case
        // 'as good as in the non-snapshot' case)
        gcBefore = cfs.gcBefore(cfs.getSnapshotCreationTime(snapshotName));
    }
    else
    {
        // flush first so everyone is validating data that is as similar as possible
        StorageService.instance.forceKeyspaceFlush(cfs.keyspace.getName(), cfs.name);

        // we don't mark validating sstables as compacting in DataTracker, so we have to mark them referenced
        // instead so they won't be cleaned up if they do get compacted during the validation
        sstables = cfs.markCurrentSSTablesReferenced();
        if (validator.gcBefore > 0)
            gcBefore = validator.gcBefore;
        else
            gcBefore = getDefaultGcBefore(cfs);
    }

    CompactionIterable ci = new ValidationCompactionIterable(cfs, sstables, validator.desc.range, gcBefore);
    CloseableIterator<AbstractCompactedRow> iter = ci.iterator();
    metrics.beginCompaction(ci);
    try
    {
        // validate the CF as we iterate over it
        validator.prepare(cfs);
        while (iter.hasNext())
        {
            if (ci.isStopRequested())
                throw new CompactionInterruptedException(ci.getCompactionInfo());
            AbstractCompactedRow row = iter.next();
            validator.add(row);
        }
        validator.complete();
    }
    finally
    {
        iter.close();
        if (isSnapshotValidation)
        {
            for (SSTableReader sstable : sstables)
                FileUtils.closeQuietly(sstable);
            cfs.clearSnapshot(snapshotName);
        }
        else
        {
            SSTableReader.releaseReferences(sstables);
        }

        metrics.finishCompaction(ci);
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:77,代码来源:CompactionManager.java

示例2: doValidationCompaction

import org.apache.cassandra.repair.Validator; //导入方法依赖的package包/类
/**
 * Performs a readonly "compaction" of all sstables in order to validate complete rows,
 * but without writing the merge result
 */
private void doValidationCompaction(ColumnFamilyStore cfs, Validator validator) throws IOException
{
    // this isn't meant to be race-proof, because it's not -- it won't cause bugs for a CFS to be dropped
    // mid-validation, or to attempt to validate a droped CFS.  this is just a best effort to avoid useless work,
    // particularly in the scenario where a validation is submitted before the drop, and there are compactions
    // started prior to the drop keeping some sstables alive.  Since validationCompaction can run
    // concurrently with other compactions, it would otherwise go ahead and scan those again.
    if (!cfs.isValid())
        return;

    Collection<SSTableReader> sstables;
    String snapshotName = validator.desc.sessionId.toString();
    int gcBefore;
    boolean isSnapshotValidation = cfs.snapshotExists(snapshotName);
    if (isSnapshotValidation)
    {
        // If there is a snapshot created for the session then read from there.
        sstables = cfs.getSnapshotSSTableReader(snapshotName);

        // Computing gcbefore based on the current time wouldn't be very good because we know each replica will execute
        // this at a different time (that's the whole purpose of repair with snaphsot). So instead we take the creation
        // time of the snapshot, which should give us roughtly the same time on each replica (roughtly being in that case
        // 'as good as in the non-snapshot' case)
        gcBefore = cfs.gcBefore(cfs.getSnapshotCreationTime(snapshotName));
    }
    else
    {
        // flush first so everyone is validating data that is as similar as possible
        StorageService.instance.forceKeyspaceFlush(cfs.keyspace.getName(), cfs.name);
        // we don't mark validating sstables as compacting in DataTracker, so we have to mark them referenced
        // instead so they won't be cleaned up if they do get compacted during the validation
        if (validator.desc.parentSessionId == null || ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId) == null)
            sstables = cfs.markCurrentSSTablesReferenced();
        else
            sstables = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId).getAndReferenceSSTables(cfs.metadata.cfId);

        if (validator.gcBefore > 0)
            gcBefore = validator.gcBefore;
        else
            gcBefore = getDefaultGcBefore(cfs);
    }

    CompactionIterable ci = new ValidationCompactionIterable(cfs, sstables, validator.desc.range, gcBefore);
    CloseableIterator<AbstractCompactedRow> iter = ci.iterator();
    metrics.beginCompaction(ci);
    try
    {
        // validate the CF as we iterate over it
        validator.prepare(cfs);
        while (iter.hasNext())
        {
            if (ci.isStopRequested())
                throw new CompactionInterruptedException(ci.getCompactionInfo());
            AbstractCompactedRow row = iter.next();
            validator.add(row);
        }
        validator.complete();
    }
    finally
    {
        iter.close();
        SSTableReader.releaseReferences(sstables);
        if (isSnapshotValidation)
        {
            cfs.clearSnapshot(snapshotName);
        }

        metrics.finishCompaction(ci);
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:75,代码来源:CompactionManager.java


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