mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-3.0' into cassandra-3.1
This commit is contained in:
commit
6f7b38987e
|
|
@ -1,5 +1,6 @@
|
|||
3.1
|
||||
Merged from 3.0:
|
||||
* Keep the file open in trySkipCache (CASSANDRA-10669)
|
||||
* Updated trigger example (CASSANDRA-10257)
|
||||
Merged from 2.2:
|
||||
* (Hadoop) fix splits calculation (CASSANDRA-10640)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ public class SSTableRewriter extends Transactional.AbstractTransactional impleme
|
|||
// the set of final readers we will expose on commit
|
||||
private final LifecycleTransaction transaction; // the readers we are rewriting (updated as they are replaced)
|
||||
private final List<SSTableReader> preparedForCommit = new ArrayList<>();
|
||||
private final Map<Descriptor, Integer> fileDescriptors = new HashMap<>(); // the file descriptors for each reader descriptor we are rewriting
|
||||
|
||||
private long currentlyOpenedEarlyAt; // the position (in MB) in the target file we last (re)opened at
|
||||
|
||||
|
|
@ -87,8 +86,6 @@ public class SSTableRewriter extends Transactional.AbstractTransactional impleme
|
|||
public SSTableRewriter(LifecycleTransaction transaction, long maxAge, boolean isOffline, long preemptiveOpenInterval, boolean keepOriginals)
|
||||
{
|
||||
this.transaction = transaction;
|
||||
for (SSTableReader sstable : this.transaction.originals())
|
||||
fileDescriptors.put(sstable.descriptor, CLibrary.getfd(sstable.getFilename()));
|
||||
this.maxAge = maxAge;
|
||||
this.isOffline = isOffline;
|
||||
this.keepOriginals = keepOriginals;
|
||||
|
|
@ -160,7 +157,7 @@ public class SSTableRewriter extends Transactional.AbstractTransactional impleme
|
|||
for (SSTableReader reader : transaction.originals())
|
||||
{
|
||||
RowIndexEntry index = reader.getPosition(key, SSTableReader.Operator.GE);
|
||||
CLibrary.trySkipCache(fileDescriptors.get(reader.descriptor), 0, index == null ? 0 : index.position, reader.getFilename());
|
||||
CLibrary.trySkipCache(reader.getFilename(), 0, index == null ? 0 : index.position);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
*/
|
||||
package org.apache.cassandra.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
|
@ -148,7 +150,18 @@ public final class CLibrary
|
|||
|
||||
public static void trySkipCache(String path, long offset, long len)
|
||||
{
|
||||
trySkipCache(getfd(path), offset, len, path);
|
||||
File f = new File(path);
|
||||
if (!f.exists())
|
||||
return;
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(f))
|
||||
{
|
||||
trySkipCache(getfd(fis.getChannel()), offset, len, path);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.warn("Could not skip cache", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void trySkipCache(int fd, long offset, long len, String path)
|
||||
|
|
@ -326,18 +339,4 @@ public final class CLibrary
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getfd(String path)
|
||||
{
|
||||
try(FileChannel channel = FileChannel.open(Paths.get(path), StandardOpenOption.READ))
|
||||
{
|
||||
return getfd(channel);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
JVMStabilityInspector.inspectThrowable(e);
|
||||
// ignore
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ public class CLibraryTest
|
|||
{
|
||||
File file = FileUtils.createTempFile("testSkipCache", "1");
|
||||
|
||||
int fd = CLibrary.getfd(file.getPath());
|
||||
CLibrary.trySkipCache(fd, 0, 0, file.getPath());
|
||||
CLibrary.trySkipCache(file.getPath(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue