Search in sources :

Example 1 with RepairJobDesc

use of org.apache.cassandra.repair.RepairJobDesc in project cassandra by apache.

the class ActiveRepairService method handleMessage.

public void handleMessage(InetAddress endpoint, RepairMessage message) {
    RepairJobDesc desc = message.desc;
    RepairSession session = sessions.get(desc.sessionId);
    if (session == null)
        return;
    switch(message.messageType) {
        case VALIDATION_COMPLETE:
            ValidationComplete validation = (ValidationComplete) message;
            session.validationComplete(desc, endpoint, validation.trees);
            break;
        case SYNC_COMPLETE:
            // one of replica is synced.
            SyncComplete sync = (SyncComplete) message;
            session.syncComplete(desc, sync.nodes, sync.success);
            break;
        default:
            break;
    }
}
Also used : RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) RepairSession(org.apache.cassandra.repair.RepairSession)

Example 2 with RepairJobDesc

use of org.apache.cassandra.repair.RepairJobDesc in project cassandra by apache.

the class CompactionManagerGetSSTablesForValidationTest method registerRepair.

private void registerRepair(boolean incremental) throws Exception {
    sessionID = UUIDGen.getTimeUUID();
    Range<Token> range = new Range<>(MT, MT);
    ActiveRepairService.instance.registerParentRepairSession(sessionID, coordinator, Lists.newArrayList(cfs), Sets.newHashSet(range), incremental, incremental ? System.currentTimeMillis() : ActiveRepairService.UNREPAIRED_SSTABLE, true);
    desc = new RepairJobDesc(sessionID, UUIDGen.getTimeUUID(), ks, tbl, Collections.singleton(range));
}
Also used : RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) Token(org.apache.cassandra.dht.Token) Range(org.apache.cassandra.dht.Range)

Example 3 with RepairJobDesc

use of org.apache.cassandra.repair.RepairJobDesc in project cassandra by apache.

the class SerializationsTest method defineSchema.

@BeforeClass
public static void defineSchema() throws Exception {
    DatabaseDescriptor.daemonInitialization();
    partitionerSwitcher = Util.switchPartitioner(RandomPartitioner.instance);
    RANDOM_UUID = UUID.fromString("b5c3d033-75aa-4c2f-a819-947aac7a0c54");
    FULL_RANGE = new Range<>(Util.testPartitioner().getMinimumToken(), Util.testPartitioner().getMinimumToken());
    DESC = new RepairJobDesc(RANDOM_UUID, RANDOM_UUID, "Keyspace1", "Standard1", Arrays.asList(FULL_RANGE));
}
Also used : RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) BeforeClass(org.junit.BeforeClass)

Example 4 with RepairJobDesc

use of org.apache.cassandra.repair.RepairJobDesc in project cassandra by apache.

the class LeveledCompactionStrategyTest method testValidationMultipleSSTablePerLevel.

/*
     * This exercises in particular the code of #4142
     */
@Test
public void testValidationMultipleSSTablePerLevel() throws Exception {
    byte[] b = new byte[100 * 1024];
    new Random().nextBytes(b);
    // 100 KiB value, make it easy to have multiple files
    ByteBuffer value = ByteBuffer.wrap(b);
    // Enough data to have a level 1 and 2
    int rows = 40;
    int columns = 20;
    // Adds enough data to trigger multiple sstable per level
    for (int r = 0; r < rows; r++) {
        UpdateBuilder update = UpdateBuilder.create(cfs.metadata(), String.valueOf(r));
        for (int c = 0; c < columns; c++) update.newRow("column" + c).add("val", value);
        update.applyUnsafe();
        cfs.forceBlockingFlush();
    }
    waitForLeveling(cfs);
    CompactionStrategyManager strategyManager = cfs.getCompactionStrategyManager();
    // Checking we're not completely bad at math
    assertTrue(strategyManager.getSSTableCountPerLevel()[1] > 0);
    assertTrue(strategyManager.getSSTableCountPerLevel()[2] > 0);
    Range<Token> range = new Range<>(Util.token(""), Util.token(""));
    int gcBefore = keyspace.getColumnFamilyStore(CF_STANDARDDLEVELED).gcBefore(FBUtilities.nowInSeconds());
    UUID parentRepSession = UUID.randomUUID();
    ActiveRepairService.instance.registerParentRepairSession(parentRepSession, FBUtilities.getBroadcastAddressAndPort(), Arrays.asList(cfs), Arrays.asList(range), false, ActiveRepairService.UNREPAIRED_SSTABLE, true, PreviewKind.NONE);
    RepairJobDesc desc = new RepairJobDesc(parentRepSession, UUID.randomUUID(), KEYSPACE1, CF_STANDARDDLEVELED, Arrays.asList(range));
    Validator validator = new Validator(desc, FBUtilities.getBroadcastAddressAndPort(), gcBefore, PreviewKind.NONE);
    ValidationManager.instance.submitValidation(cfs, validator).get();
}
Also used : Random(java.util.Random) RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) UpdateBuilder(org.apache.cassandra.UpdateBuilder) Token(org.apache.cassandra.dht.Token) Range(org.apache.cassandra.dht.Range) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer) Validator(org.apache.cassandra.repair.Validator) Test(org.junit.Test)

Example 5 with RepairJobDesc

use of org.apache.cassandra.repair.RepairJobDesc in project cassandra by apache.

the class ActiveRepairService method handleMessage.

public void handleMessage(Message<? extends RepairMessage> message) {
    RepairMessage payload = message.payload;
    RepairJobDesc desc = payload.desc;
    RepairSession session = sessions.get(desc.sessionId);
    if (session == null) {
        if (payload instanceof ValidationResponse) {
            // The trees may be off-heap, and will therefore need to be released.
            ValidationResponse validation = (ValidationResponse) payload;
            MerkleTrees trees = validation.trees;
            // The response from a failed validation won't have any trees.
            if (trees != null)
                trees.release();
        }
        return;
    }
    switch(message.verb()) {
        case VALIDATION_RSP:
            ValidationResponse validation = (ValidationResponse) payload;
            session.validationComplete(desc, message.from(), validation.trees);
            break;
        case SYNC_RSP:
            // one of replica is synced.
            SyncResponse sync = (SyncResponse) payload;
            session.syncComplete(desc, sync.nodes, sync.success, sync.summaries);
            break;
        default:
            break;
    }
}
Also used : RepairMessage(org.apache.cassandra.repair.messages.RepairMessage) MerkleTrees(org.apache.cassandra.utils.MerkleTrees) SyncResponse(org.apache.cassandra.repair.messages.SyncResponse) RepairJobDesc(org.apache.cassandra.repair.RepairJobDesc) ValidationResponse(org.apache.cassandra.repair.messages.ValidationResponse) RepairSession(org.apache.cassandra.repair.RepairSession)

Aggregations

RepairJobDesc (org.apache.cassandra.repair.RepairJobDesc)8 Range (org.apache.cassandra.dht.Range)3 Token (org.apache.cassandra.dht.Token)3 RepairSession (org.apache.cassandra.repair.RepairSession)2 Test (org.junit.Test)2 ByteBuffer (java.nio.ByteBuffer)1 Random (java.util.Random)1 UUID (java.util.UUID)1 UpdateBuilder (org.apache.cassandra.UpdateBuilder)1 Validator (org.apache.cassandra.repair.Validator)1 RepairMessage (org.apache.cassandra.repair.messages.RepairMessage)1 SyncResponse (org.apache.cassandra.repair.messages.SyncResponse)1 ValidationResponse (org.apache.cassandra.repair.messages.ValidationResponse)1 MerkleTrees (org.apache.cassandra.utils.MerkleTrees)1 BeforeClass (org.junit.BeforeClass)1