Search in sources :

Example 1 with PendingStats

use of org.apache.cassandra.repair.consistent.admin.PendingStats in project cassandra by apache.

the class PendingRepairStatTest method pendingRepairStats.

@Test
public void pendingRepairStats() {
    InstrumentedLocalSessions sessions = new InstrumentedLocalSessions();
    sessions.start();
    cfs.disableAutoCompaction();
    SSTableReader sstable1 = createSSTable(0, 10);
    SSTableReader sstable2 = createSSTable(10, 10);
    SSTableReader sstable3 = createSSTable(10, 20);
    LocalSession session1 = createSession();
    sessions.putSessionUnsafe(session1);
    LocalSession session2 = createSession();
    sessions.putSessionUnsafe(session2);
    PendingStats stats;
    stats = sessions.getPendingStats(cfm.id, Collections.singleton(FULL_RANGE));
    Assert.assertEquals(0, stats.total.numSSTables);
    // set all sstables to pending
    mutateRepaired(sstable1, UNREPAIRED_SSTABLE, session1.sessionID);
    mutateRepaired(sstable2, UNREPAIRED_SSTABLE, session2.sessionID);
    mutateRepaired(sstable3, UNREPAIRED_SSTABLE, session2.sessionID);
    stats = sessions.getPendingStats(cfm.id, Collections.singleton(FULL_RANGE));
    Assert.assertEquals(Sets.newHashSet(session1.sessionID, session2.sessionID), stats.total.sessions);
    Assert.assertEquals(3, stats.total.numSSTables);
    Assert.assertEquals(3, stats.pending.numSSTables);
    Assert.assertEquals(0, stats.failed.numSSTables);
    Assert.assertEquals(0, stats.finalized.numSSTables);
    // set the 2 sessions to failed and finalized
    session1.setState(FAILED);
    sessions.save(session1);
    session2.setState(FINALIZED);
    sessions.save(session2);
    stats = sessions.getPendingStats(cfm.id, Collections.singleton(FULL_RANGE));
    Assert.assertEquals(3, stats.total.numSSTables);
    Assert.assertEquals(0, stats.pending.numSSTables);
    Assert.assertEquals(1, stats.failed.numSSTables);
    Assert.assertEquals(2, stats.finalized.numSSTables);
    // remove sstables from pending sets
    mutateRepaired(sstable1, UNREPAIRED_SSTABLE, NO_PENDING_REPAIR);
    mutateRepaired(sstable2, session2.repairedAt, NO_PENDING_REPAIR);
    mutateRepaired(sstable3, session2.repairedAt, NO_PENDING_REPAIR);
    stats = sessions.getPendingStats(cfm.id, Collections.singleton(FULL_RANGE));
    Assert.assertTrue(stats.total.sessions.isEmpty());
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) PendingStats(org.apache.cassandra.repair.consistent.admin.PendingStats) InstrumentedLocalSessions(org.apache.cassandra.repair.consistent.LocalSessionTest.InstrumentedLocalSessions) AbstractRepairTest(org.apache.cassandra.repair.AbstractRepairTest) Test(org.junit.Test)

Example 2 with PendingStats

use of org.apache.cassandra.repair.consistent.admin.PendingStats in project cassandra by apache.

the class LocalSessions method getPendingStats.

public PendingStats getPendingStats(TableId tid, Collection<Range<Token>> ranges) {
    ColumnFamilyStore cfs = Schema.instance.getColumnFamilyStoreInstance(tid);
    Preconditions.checkArgument(cfs != null);
    PendingStat.Builder pending = new PendingStat.Builder();
    PendingStat.Builder finalized = new PendingStat.Builder();
    PendingStat.Builder failed = new PendingStat.Builder();
    Map<UUID, PendingStat> stats = cfs.getPendingRepairStats();
    for (Map.Entry<UUID, PendingStat> entry : stats.entrySet()) {
        UUID sessionID = entry.getKey();
        PendingStat stat = entry.getValue();
        Verify.verify(sessionID.equals(Iterables.getOnlyElement(stat.sessions)));
        LocalSession session = sessions.get(sessionID);
        Verify.verifyNotNull(session);
        if (!Iterables.any(ranges, r -> r.intersects(session.ranges)))
            continue;
        switch(session.getState()) {
            case FINALIZED:
                finalized.addStat(stat);
                break;
            case FAILED:
                failed.addStat(stat);
                break;
            default:
                pending.addStat(stat);
        }
    }
    return new PendingStats(cfs.keyspace.getName(), cfs.name, pending.build(), finalized.build(), failed.build());
}
Also used : NoSuchRepairSessionException(org.apache.cassandra.repair.NoSuchRepairSessionException) KeyspaceRepairManager(org.apache.cassandra.repair.KeyspaceRepairManager) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) STATUS_REQ(org.apache.cassandra.net.Verb.STATUS_REQ) CompactionInterruptedException(org.apache.cassandra.db.compaction.CompactionInterruptedException) ByteBuffer(java.nio.ByteBuffer) BooleanSupplier(java.util.function.BooleanSupplier) Map(java.util.Map) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) PendingStats(org.apache.cassandra.repair.consistent.admin.PendingStats) Verify(com.google.common.base.Verify) ImmutableSet(com.google.common.collect.ImmutableSet) FBUtilities(org.apache.cassandra.utils.FBUtilities) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) Collection(java.util.Collection) FinalizeCommit(org.apache.cassandra.repair.messages.FinalizeCommit) Set(java.util.Set) UUID(java.util.UUID) Instant(java.time.Instant) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) RangesAtEndpoint(org.apache.cassandra.locator.RangesAtEndpoint) FinalizePropose(org.apache.cassandra.repair.messages.FinalizePropose) State(org.apache.cassandra.repair.consistent.ConsistentSession.State) List(java.util.List) FAILED_SESSION_MSG(org.apache.cassandra.net.Verb.FAILED_SESSION_MSG) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Future(org.apache.cassandra.utils.concurrent.Future) Throwables(org.apache.cassandra.utils.Throwables) FINALIZE_PROMISE_MSG(org.apache.cassandra.net.Verb.FINALIZE_PROMISE_MSG) FailureDetector(org.apache.cassandra.gms.FailureDetector) SchemaConstants(org.apache.cassandra.schema.SchemaConstants) DataInputBuffer(org.apache.cassandra.io.util.DataInputBuffer) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) Iterables(com.google.common.collect.Iterables) PendingStat(org.apache.cassandra.repair.consistent.admin.PendingStat) PrepareConsistentResponse(org.apache.cassandra.repair.messages.PrepareConsistentResponse) DataOutputBuffer(org.apache.cassandra.io.util.DataOutputBuffer) TableId(org.apache.cassandra.schema.TableId) PREPARE_CONSISTENT_RSP(org.apache.cassandra.net.Verb.PREPARE_CONSISTENT_RSP) Range(org.apache.cassandra.dht.Range) HashMap(java.util.HashMap) Message(org.apache.cassandra.net.Message) QueryProcessor(org.apache.cassandra.cql3.QueryProcessor) FinalizePromise(org.apache.cassandra.repair.messages.FinalizePromise) SystemKeyspace(org.apache.cassandra.db.SystemKeyspace) ArrayList(java.util.ArrayList) Schema(org.apache.cassandra.schema.Schema) HashSet(java.util.HashSet) UTF8Type(org.apache.cassandra.db.marshal.UTF8Type) Token(org.apache.cassandra.dht.Token) ActiveRepairService(org.apache.cassandra.service.ActiveRepairService) Lists(com.google.common.collect.Lists) CleanupSummary(org.apache.cassandra.repair.consistent.admin.CleanupSummary) STATUS_RSP(org.apache.cassandra.net.Verb.STATUS_RSP) ExecutorService(java.util.concurrent.ExecutorService) Nullable(javax.annotation.Nullable) MessagingService(org.apache.cassandra.net.MessagingService) Logger(org.slf4j.Logger) BytesType(org.apache.cassandra.db.marshal.BytesType) StatusResponse(org.apache.cassandra.repair.messages.StatusResponse) StorageService(org.apache.cassandra.service.StorageService) IOException(java.io.IOException) PrepareConsistentRequest(org.apache.cassandra.repair.messages.PrepareConsistentRequest) UnknownHostException(java.net.UnknownHostException) Ints(com.google.common.primitives.Ints) FutureCallback(com.google.common.util.concurrent.FutureCallback) Replica(org.apache.cassandra.locator.Replica) FailSession(org.apache.cassandra.repair.messages.FailSession) TimeUnit(java.util.concurrent.TimeUnit) RepairMessage(org.apache.cassandra.repair.messages.RepairMessage) UUIDType(org.apache.cassandra.db.marshal.UUIDType) IPartitioner(org.apache.cassandra.dht.IPartitioner) Global.executorFactory(org.apache.cassandra.concurrent.ExecutorFactory.Global.executorFactory) UntypedResultSet(org.apache.cassandra.cql3.UntypedResultSet) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StatusRequest(org.apache.cassandra.repair.messages.StatusRequest) PendingStats(org.apache.cassandra.repair.consistent.admin.PendingStats) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) UUID(java.util.UUID) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) PendingStat(org.apache.cassandra.repair.consistent.admin.PendingStat)

Example 3 with PendingStats

use of org.apache.cassandra.repair.consistent.admin.PendingStats in project cassandra by apache.

the class ActiveRepairService method getPendingStats.

@Override
public List<CompositeData> getPendingStats(List<String> schemaArgs, String rangeString) {
    List<CompositeData> stats = new ArrayList<>();
    Collection<Range<Token>> userRanges = rangeString != null ? RepairOption.parseRanges(rangeString, DatabaseDescriptor.getPartitioner()) : null;
    for (ColumnFamilyStore cfs : SchemaArgsParser.parse(schemaArgs)) {
        String keyspace = cfs.keyspace.getName();
        Collection<Range<Token>> ranges = userRanges != null ? userRanges : StorageService.instance.getLocalReplicas(keyspace).ranges();
        PendingStats cfStats = consistent.local.getPendingStats(cfs.metadata().id, ranges);
        stats.add(cfStats.toComposite());
    }
    return stats;
}
Also used : PendingStats(org.apache.cassandra.repair.consistent.admin.PendingStats) CompositeData(javax.management.openmbean.CompositeData) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) EndpointsByRange(org.apache.cassandra.locator.EndpointsByRange) EndpointsForRange(org.apache.cassandra.locator.EndpointsForRange) CommonRange(org.apache.cassandra.repair.CommonRange) Range(org.apache.cassandra.dht.Range)

Aggregations

PendingStats (org.apache.cassandra.repair.consistent.admin.PendingStats)3 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)2 Range (org.apache.cassandra.dht.Range)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Verify (com.google.common.base.Verify)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Ints (com.google.common.primitives.Ints)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 ByteBuffer (java.nio.ByteBuffer)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1