LogFile(OperationType type, UUID id, List<File> replicas) { this(type, id); this.replicas.addReplicas(replicas); }
private boolean addRecord(LogRecord record) { if (records.contains(record)) return false; replicas.append(record); return records.add(record); }
public void close() { replicas.close(); }
boolean readRecords(Set<LogRecord> records) Map<LogReplica, List<String>> linesByReplica = replicas().stream() .collect(Collectors.toMap(Function.<LogReplica>identity(), LogReplica::readLines, if (!isPrefixMatch(firstLine, currentLine)) setError(record, "Duplicated record"); return false; setError(record, "This record should have been the last one in all replicas"); return false;
public String toString(boolean showContents) { StringBuilder str = new StringBuilder(); str.append('['); str.append(getFileName()); str.append(" in "); str.append(replicas.getDirectories()); str.append(']'); if (showContents) { str.append(System.lineSeparator()); str.append("Files and contents follow:"); str.append(System.lineSeparator()); replicas.printContentsWithAnyErrors(str); } return str.toString(); }
@VisibleForTesting List<String> getFilePaths() { return replicas.getFilePaths(); }
@VisibleForTesting List<File> getFiles() { return replicas.getFiles(); }
boolean exists() { return replicas.exists(); }
Throwable removeUnfinishedLeftovers(Throwable accumulate) { try { // we sync the parent directories before content deletion to ensure // any previously deleted files (see SSTableTider) are not // incorrectly picked up by record.getExistingFiles() in // deleteRecordFiles(), see CASSANDRA-12261 Throwables.maybeFail(syncDirectory(accumulate)); deleteFilesForRecordsOfType(committed() ? Type.REMOVE : Type.ADD); // we sync the parent directories between contents and log deletion // to ensure there is a happens before edge between them Throwables.maybeFail(syncDirectory(accumulate)); accumulate = replicas.delete(accumulate); } catch (Throwable t) { accumulate = merge(accumulate, t); } return accumulate; }
boolean readRecords(Set<LogRecord> records) Map<LogReplica, List<String>> linesByReplica = replicas().stream() .collect(Collectors.toMap(Function.<LogReplica>identity(), LogReplica::readLines, if (!isPrefixMatch(firstLine, currentLine)) setError(record, "Duplicated record"); return false; setError(record, "This record should have been the last one in all replicas"); return false;
public String toString(boolean showContents) { StringBuilder str = new StringBuilder(); str.append('['); str.append(getFileName()); str.append(" in "); str.append(replicas.getDirectories()); str.append(']'); if (showContents) { str.append(System.lineSeparator()); str.append("Files and contents follow:"); str.append(System.lineSeparator()); replicas.printContentsWithAnyErrors(str); } return str.toString(); }
@VisibleForTesting List<String> getFilePaths() { return replicas.getFilePaths(); }
@VisibleForTesting List<File> getFiles() { return replicas.getFiles(); }
boolean exists() { return replicas.exists(); }
Throwable removeUnfinishedLeftovers(Throwable accumulate) { try { // we sync the parent directories before content deletion to ensure // any previously deleted files (see SSTableTider) are not // incorrectly picked up by record.getExistingFiles() in // deleteRecordFiles(), see CASSANDRA-12261 Throwables.maybeFail(syncDirectory(accumulate)); deleteFilesForRecordsOfType(committed() ? Type.REMOVE : Type.ADD); // we sync the parent directories between contents and log deletion // to ensure there is a happens before edge between them Throwables.maybeFail(syncDirectory(accumulate)); accumulate = replicas.delete(accumulate); } catch (Throwable t) { accumulate = merge(accumulate, t); } return accumulate; }
boolean readRecords(Set<LogRecord> records) Map<LogReplica, List<String>> linesByReplica = replicas().stream() .collect(Collectors.toMap(Function.<LogReplica>identity(), LogReplica::readLines, if (!isPrefixMatch(firstLine, currentLine)) setError(record, "Duplicated record"); return false; setError(record, "This record should have been the last one in all replicas"); return false;
public String toString(boolean showContents) { StringBuilder str = new StringBuilder(); str.append('['); str.append(getFileName()); str.append(" in "); str.append(replicas.getDirectories()); str.append(']'); if (showContents) { str.append(System.lineSeparator()); str.append("Files and contents follow:"); str.append(System.lineSeparator()); replicas.printContentsWithAnyErrors(str); } return str.toString(); }
@VisibleForTesting List<String> getFilePaths() { return replicas.getFilePaths(); }
@VisibleForTesting List<File> getFiles() { return replicas.getFiles(); }
LogFile(OperationType type, UUID id, List<File> replicas) { this(type, id); this.replicas.addReplicas(replicas); }