@Test public void testMultipleTablets() throws IOException { KeyExtent e1 = new KeyExtent(TableId.of("1"), new Text("m"), null); KeyExtent e2 = new KeyExtent(TableId.of("1"), null, new Text("m")); Mutation m1 = new ServerMutation(new Text("b")); m1.put("f1", "q1", "v1"); Mutation m2 = new ServerMutation(new Text("b")); m2.put("f1", "q2", "v2"); Mutation m3 = new ServerMutation(new Text("s")); m3.put("f1", "q1", "v3"); Mutation m4 = new ServerMutation(new Text("s")); m4.put("f1", "q2", "v4"); KeyValue[] entries1 = {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 7, 10, e1), createKeyValue(DEFINE_TABLET, 5, 11, e2), createKeyValue(MUTATION, 8, 10, m1), createKeyValue(COMPACTION_START, 9, 10, "/t/f1"), createKeyValue(MUTATION, 10, 10, m2), createKeyValue(COMPACTION_FINISH, 10, 10, null), createKeyValue(MUTATION, 6, 11, m3), createKeyValue(COMPACTION_START, 7, 11, "/t/f2"), createKeyValue(MUTATION, 8, 11, m4)}; Arrays.sort(entries1); Map<String,KeyValue[]> logs = new TreeMap<>(); logs.put("entries1", entries1); List<Mutation> mutations1 = recover(logs, e1); assertEquals(1, mutations1.size()); assertEquals(m2, mutations1.get(0)); List<Mutation> mutations2 = recover(logs, e2); assertEquals(2, mutations2.size()); assertEquals(m3, mutations2.get(0)); assertEquals(m4, mutations2.get(1)); KeyValue[] entries2 = {createKeyValue(OPEN, 0, -1, "1"), createKeyValue(DEFINE_TABLET, 9, 11, e2), createKeyValue(COMPACTION_FINISH, 8, 11, null)}; Arrays.sort(entries2); logs.put("entries2", entries2); mutations2 = recover(logs, e2); assertEquals(1, mutations2.size()); assertEquals(m4, mutations2.get(0)); }
public void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles, MutationReceiver mr) throws IOException { Entry<Integer,List<Path>> maxEntry = findLogsThatDefineTablet(extent, recoveryLogs); int tabletId = maxEntry.getKey(); List<Path> logsThatDefineTablet = maxEntry.getValue(); if (tabletId == -1) { log.info("Tablet {} is not defined in recovery logs {} ", extent, asNames(recoveryLogs)); return; } else { log.info("Found {} of {} logs with max id {} for tablet {}", logsThatDefineTablet.size(), recoveryLogs.size(), tabletId, extent); } long recoverySeq = findRecoverySeq(logsThatDefineTablet, tabletFiles, tabletId); log.info("Recovering mutations, tablet:{} tabletId:{} seq:{} logs:{}", extent, tabletId, recoverySeq, asNames(logsThatDefineTablet)); playbackMutations(logsThatDefineTablet, mr, tabletId, recoverySeq); }
SortedLogRecovery { public void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles, MutationReceiver mr) throws IOException { Entry<Integer,List<Path>> maxEntry = findLogsThatDefineTablet(extent, recoveryLogs); int tabletId = maxEntry.getKey(); List<Path> logsThatDefineTablet = maxEntry.getValue(); if (tabletId == -1) { log.info("Tablet {} is not defined in recovery logs {} ", extent, asNames(recoveryLogs)); return; } else { log.info("Found {} of {} logs with max id {} for tablet {}", logsThatDefineTablet.size(), recoveryLogs.size(), tabletId, extent); } long recoverySeq = findRecoverySeq(logsThatDefineTablet, tabletFiles, tabletId); log.info("Recovering mutations, tablet:{} tabletId:{} seq:{} logs:{}", extent, tabletId, recoverySeq, asNames(logsThatDefineTablet)); playbackMutations(logsThatDefineTablet, mr, tabletId, recoverySeq); } }
SortedLogRecovery { public void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles, MutationReceiver mr) throws IOException { Entry<Integer,List<Path>> maxEntry = findLogsThatDefineTablet(extent, recoveryLogs); int tabletId = maxEntry.getKey(); List<Path> logsThatDefineTablet = maxEntry.getValue(); if (tabletId == -1) { log.info("Tablet {} is not defined in recovery logs {} ", extent, asNames(recoveryLogs)); return; } else { log.info("Found {} of {} logs with max id {} for tablet {}", logsThatDefineTablet.size(), recoveryLogs.size(), tabletId, extent); } long recoverySeq = findRecoverySeq(logsThatDefineTablet, tabletFiles, tabletId); log.info("Recovering mutations, tablet:{} tabletId:{} seq:{} logs:{}", extent, tabletId, recoverySeq, asNames(logsThatDefineTablet)); playbackMutations(logsThatDefineTablet, mr, tabletId, recoverySeq); } SortedLogRecovery(VolumeManager fs); }
SortedLogRecovery { public void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles, MutationReceiver mr) throws IOException { Entry<Integer,List<Path>> maxEntry = findLogsThatDefineTablet(extent, recoveryLogs); int tabletId = maxEntry.getKey(); List<Path> logsThatDefineTablet = maxEntry.getValue(); if (tabletId == -1) { log.info("Tablet {} is not defined in recovery logs {} ", extent, asNames(recoveryLogs)); return; } else { log.info("Found {} of {} logs with max id {} for tablet {}", logsThatDefineTablet.size(), recoveryLogs.size(), tabletId, extent); } long recoverySeq = findRecoverySeq(logsThatDefineTablet, tabletFiles, tabletId); log.info("Recovering mutations, tablet:{} tabletId:{} seq:{} logs:{}", extent, tabletId, recoverySeq, asNames(logsThatDefineTablet)); playbackMutations(logsThatDefineTablet, mr, tabletId, recoverySeq); } SortedLogRecovery(VolumeManager fs); void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles,
      MutationReceiver mr); }
SortedLogRecovery { public void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles, MutationReceiver mr) throws IOException { Entry<Integer,List<Path>> maxEntry = findLogsThatDefineTablet(extent, recoveryLogs); int tabletId = maxEntry.getKey(); List<Path> logsThatDefineTablet = maxEntry.getValue(); if (tabletId == -1) { log.info("Tablet {} is not defined in recovery logs {} ", extent, asNames(recoveryLogs)); return; } else { log.info("Found {} of {} logs with max id {} for tablet {}", logsThatDefineTablet.size(), recoveryLogs.size(), tabletId, extent); } long recoverySeq = findRecoverySeq(logsThatDefineTablet, tabletFiles, tabletId); log.info("Recovering mutations, tablet:{} tabletId:{} seq:{} logs:{}", extent, tabletId, recoverySeq, asNames(logsThatDefineTablet)); playbackMutations(logsThatDefineTablet, mr, tabletId, recoverySeq); } SortedLogRecovery(VolumeManager fs); void recover(KeyExtent extent, List<Path> recoveryLogs, Set<String> tabletFiles,
      MutationReceiver mr);  }