Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-13823 WAL iterator WRITE permission requirement removed. #8549

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ protected AbstractReadFileHandle initReadHandle(
SegmentIO fileIO = null;

try {
fileIO = desc.toIO(ioFactory);
fileIO = desc.toReadOnlyIO(ioFactory);

SegmentHeader segmentHeader;

Expand Down Expand Up @@ -513,6 +513,6 @@ protected interface AbstractFileDescriptor {
* @return One of implementation of {@link FileIO}.
* @throws IOException if creation of fileIo was not success.
*/
SegmentIO toIO(FileIOFactory fileIOFactory) throws IOException;
SegmentIO toReadOnlyIO(FileIOFactory fileIOFactory) throws IOException;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.jetbrains.annotations.Nullable;

import static java.nio.file.StandardOpenOption.READ;

/**
* WAL file descriptor.
*/
Expand Down Expand Up @@ -144,8 +146,8 @@ public String getAbsolutePath() {
}

/** {@inheritDoc} */
@Override public SegmentIO toIO(FileIOFactory fileIOFactory) throws IOException {
FileIO fileIO = isCompressed() ? new UnzipFileIO(file()) : fileIOFactory.create(file());
@Override public SegmentIO toReadOnlyIO(FileIOFactory fileIOFactory) throws IOException {
FileIO fileIO = isCompressed() ? new UnzipFileIO(file()) : fileIOFactory.create(file(), READ);

return new SegmentIO(idx, fileIO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ private long lastArchivedIndex() {
@Nullable private FileDescriptor readFileDescriptor(File file, FileIOFactory ioFactory) {
FileDescriptor ds = new FileDescriptor(file);

try (SegmentIO fileIO = ds.toIO(ioFactory)) {
try (SegmentIO fileIO = ds.toReadOnlyIO(ioFactory)) {
// File may be empty when LOG_ONLY mode is enabled and mmap is disabled.
if (fileIO.size() == 0)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public LockedSegmentFileInputFactory(
id -> {
FileDescriptor segment = segmentRouter.findSegment(id);

return segment.toIO(fileIOFactory);
return segment.toReadOnlyIO(fileIOFactory);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private FileDescriptor readFileDescriptor(File file, FileIOFactory ioFactory) {
FileDescriptor ds = new FileDescriptor(file);

try (
SegmentIO fileIO = ds.toIO(ioFactory);
SegmentIO fileIO = ds.toReadOnlyIO(ioFactory);
ByteBufferExpander buf = new ByteBufferExpander(HEADER_RECORD_SIZE, ByteOrder.nativeOrder())
) {
final DataInput in = segmentFileInputFactory.createFileInput(fileIO, buf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ private boolean checkBounds(long idx) {
SegmentHeader segmentHeader;
while (true) {
try {
fileIO = fd.toIO(ioFactory);
fileIO = fd.toReadOnlyIO(ioFactory);

segmentHeader = readSegmentHeader(fileIO, FILE_INPUT_FACTORY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.OpenOption;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -261,6 +264,8 @@ private String getArchiveWalDirPath(Ignite ignite) throws IgniteCheckedException
private static class CountedFileIOFactory extends RandomAccessFileIOFactory {
/** {@inheritDoc} */
@Override public FileIO create(File file, OpenOption... modes) throws IOException {
assertEquals(Collections.singletonList(StandardOpenOption.READ), Arrays.asList(modes));

return new CountedFileIO(file, modes);
}
}
Expand Down