Skip to content

Commit

Permalink
refactor: moved some inner types of write cache to own files
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Sep 25, 2023
1 parent e16a4db commit 4f7dbc8
Show file tree
Hide file tree
Showing 12 changed files with 658 additions and 548 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.orientechnologies.orient.core.storage.cache.local;

import com.orientechnologies.common.util.ORawPair;
import java.util.concurrent.Callable;

final class DeleteFileTask implements Callable<ORawPair<String, String>> {
/** */
private final OWOWCache cache;

private final long externalFileId;

DeleteFileTask(OWOWCache owowCache, long externalFileId) {
cache = owowCache;
this.externalFileId = externalFileId;
}

@Override
public ORawPair<String, String> call() throws Exception {
return cache.executeDeleteFile(externalFileId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.orientechnologies.orient.core.storage.cache.local;

import java.util.concurrent.CountDownLatch;

final class ExclusiveFlushTask implements Runnable {
/** */
private final OWOWCache cache;

private final CountDownLatch cacheBoundaryLatch;
private final CountDownLatch completionLatch;

ExclusiveFlushTask(
OWOWCache owowCache,
final CountDownLatch cacheBoundaryLatch,
final CountDownLatch completionLatch) {
cache = owowCache;
this.cacheBoundaryLatch = cacheBoundaryLatch;
this.completionLatch = completionLatch;
}

@Override
public void run() {
cache.executeFlush(cacheBoundaryLatch, completionLatch);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.orientechnologies.orient.core.storage.cache.local;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Callable;

final class FileFlushTask implements Callable<Void> {
/** */
private final OWOWCache cache;

private final Set<Integer> fileIdSet;

FileFlushTask(OWOWCache owowCache, final Collection<Integer> fileIds) {
cache = owowCache;
this.fileIdSet = new HashSet<>(fileIds);
}

@Override
public Void call() throws Exception {
return cache.executeFileFlush(this.fileIdSet);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.orientechnologies.orient.core.storage.cache.local;

import java.util.concurrent.Callable;

final class FindMinDirtySegment implements Callable<Long> {
/** */
private final OWOWCache cache;

/** @param owowCache */
FindMinDirtySegment(OWOWCache owowCache) {
cache = owowCache;
}

@Override
public Long call() {
return cache.executeFindDirtySegment();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.orientechnologies.orient.core.storage.cache.local;

import java.util.concurrent.Callable;

final class FlushTillSegmentTask implements Callable<Void> {
/** */
private final OWOWCache cache;

private final long segmentId;

FlushTillSegmentTask(OWOWCache owowCache, final long segmentId) {
cache = owowCache;
this.segmentId = segmentId;
}

@Override
public Void call() throws Exception {
return cache.executeFlushTillSegment(this.segmentId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.orientechnologies.orient.core.storage.cache.local;

final class NameFileIdEntry {
private final String name;
private final int fileId;
private final String fileSystemName;

public NameFileIdEntry(final String name, final int fileId) {
this.name = name;
this.fileId = fileId;
this.fileSystemName = name;
}

public NameFileIdEntry(final String name, final int fileId, final String fileSystemName) {
this.name = name;
this.fileId = fileId;
this.fileSystemName = fileSystemName;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

final NameFileIdEntry that = (NameFileIdEntry) o;

if (getFileId() != that.getFileId()) {
return false;
}
if (!getName().equals(that.getName())) {
return false;
}
return getFileSystemName().equals(that.getFileSystemName());
}

@Override
public int hashCode() {
int result = getName().hashCode();
result = 31 * result + getFileId();
result = 31 * result + getFileSystemName().hashCode();
return result;
}

String getName() {
return name;
}

int getFileId() {
return fileId;
}

String getFileSystemName() {
return fileSystemName;
}
}
Loading

0 comments on commit 4f7dbc8

Please sign in to comment.