当前位置: 首页>>代码示例>>Java>>正文


Java PosixFileOperations类代码示例

本文整理汇总了Java中com.indeed.util.core.shell.PosixFileOperations的典型用法代码示例。如果您正苦于以下问题:Java PosixFileOperations类的具体用法?Java PosixFileOperations怎么用?Java PosixFileOperations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PosixFileOperations类属于com.indeed.util.core.shell包,在下文中一共展示了PosixFileOperations类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearTempDir

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
private void clearTempDir(String directory) throws IOException {
    File tmpDir = new File(directory);

    if (!tmpDir.exists()) {
        throw new IOException(directory + " does not exist.");
    }
    if (!tmpDir.isDirectory()) {
        throw new IOException(directory + " is not a directory.");
    }

    for (File f : tmpDir.listFiles()) {
        if (f.isDirectory() && f.getName().endsWith(".optimization_log")) {
            /* an optimized index */
            PosixFileOperations.rmrf(f);
        }
        if (!f.isDirectory() && f.getName().startsWith(".tmp")) {
            /* an optimization log */
            f.delete();
        }
    }

}
 
开发者ID:indeedeng,项目名称:imhotep,代码行数:23,代码来源:CachingLocalImhotepServiceCore.java

示例2: clearTempDir

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
private void clearTempDir(String directory) throws IOException {
    final File tmpDir = new File(directory);

    if (!tmpDir.exists()) {
        throw new IOException(directory + " does not exist.");
    }
    if (!tmpDir.isDirectory()) {
        throw new IOException(directory + " is not a directory.");
    }

    for (File f : tmpDir.listFiles()) {
        if (f.isDirectory() && f.getName().endsWith(".optimization_log")) {
            /* an optimized index */
            PosixFileOperations.rmrf(f);
        }
        if (!f.isDirectory() && f.getName().startsWith(".tmp")) {
            /* an optimization log */
            f.delete();
        }
    }

}
 
开发者ID:indeedeng,项目名称:imhotep,代码行数:23,代码来源:LocalImhotepServiceCore.java

示例3: checkpoint

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
public void checkpoint(File checkpointDir) throws IOException {
    final SharedReference<GenerationState<K, V>> localState = generationState.getCopy();
    try {
        if (localState == null) {
            throw new IOException("store is closed");
        }
        checkpointDir.mkdirs();
        localState.get().volatileGeneration.checkpoint(checkpointDir);
        for (Generation<K, V> generation : localState.get().stableGenerations) {
            generation.checkpoint(checkpointDir);
        }
        PosixFileOperations.cplr(new File(localState.get().path, "state"), checkpointDir);
    } finally {
        Closeables2.closeQuietly(localState, log);
    }
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:17,代码来源:Store.java

示例4: startNewLog

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
private GenerationState<K, V> startNewLog(final GenerationState<K, V> localState) throws IOException {
    //create new volatile generation and checkpoint
    final File newLog = getNextLogFile();
    final VolatileGeneration<K,V> nextVolatileGeneration = new VolatileGeneration<K, V>(newLog, keySerializer, valueSerializer, comparator);
    final List<SharedReference<? extends Generation<K,V>>> nextStableGenerations = Lists.newArrayList();
    nextStableGenerations.add(localState.volatileGenerationReference.copy());
    for (SharedReference<? extends Generation<K, V>> reference : localState.stableGenerationReferences) {
        nextStableGenerations.add(reference.copy());
    }
    final File checkpointDir = getNextCheckpointDir();
    checkpointDir.mkdirs();
    final GenerationState<K,V> nextState = new GenerationState<K, V>(nextStableGenerations, SharedReference.create(nextVolatileGeneration), checkpointDir);
    checkpointGenerationState(nextState, checkpointDir);
    //there will be a brief period of time where there is no writable generation, put and delete will block during this time
    localState.volatileGeneration.closeWriter();
    PosixFileOperations.atomicLink(checkpointDir, new File(root, "latest"));
    final SharedReference<GenerationState<K, V>> oldState = Preconditions.checkNotNull(generationState.getAndSet(nextState));
    oldState.get().delete();
    Closeables2.closeQuietly(oldState, log);
    return nextState;
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:22,代码来源:Store.java

示例5: checkpointGenerationState

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
private void checkpointGenerationState(GenerationState<K,V> state, File checkpointDir) throws IOException {
    final Map<String, Object> map = new HashMap<String, Object>();
    final List<String> stableGenerationNames = new ArrayList<String>();
    for (Generation<K,V> generation : state.stableGenerations) {
        final File generationPath = generation.getPath();
        final String generationName = generationPath.getName();
        stableGenerationNames.add(generationName);
        PosixFileOperations.link(generationPath, new File(checkpointDir, generationName));
    }
    map.put("stableGenerations", stableGenerationNames);
    final File volatileGenerationPath = state.volatileGeneration.getPath();
    final String volatileGenerationName = volatileGenerationPath.getName();
    map.put("volatileGeneration", volatileGenerationName);
    PosixFileOperations.link(volatileGenerationPath, new File(checkpointDir, volatileGenerationName));
    final Yaml yaml = new Yaml();
    final String generationStateString = yaml.dump(map);
    RandomAccessFile raf = null;
    FileChannel channel = null;
    try {
        raf = new RandomAccessFile(new File(checkpointDir, "state"), "rw");
        channel = raf.getChannel();
        final byte[] bytes = generationStateString.getBytes(Charsets.UTF_8);
        final ByteBuffer buffer = ByteBuffer.wrap(bytes);
        while (buffer.remaining() > 0) {
            channel.write(buffer);
        }
        channel.force(true);
    } finally {
        Closeables2.closeQuietly(channel, log);
        Closeables2.closeQuietly(raf, log);
    }
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:33,代码来源:Store.java

示例6: finishCompaction

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
private void finishCompaction(final Set<String> compactedGenerations, final List<Generation<K, V>> toCompactGenerations, final Generation<K, V> stableGeneration) throws IOException {
    final List<SharedReference<? extends Generation<K,V>>> nextStableGenerations = Lists.newArrayList();
    final SharedReference<GenerationState<K, V>> stateReference = Preconditions.checkNotNull(generationState.getCopy());
    final GenerationState<K,V> state = stateReference.get();
    try {
        boolean compactionAdded = false;
        for (SharedReference<? extends Generation<K, V>> reference : state.stableGenerationReferences) {
            final String name = reference.get().getPath().getName();
            if (!compactedGenerations.contains(name)) {
                nextStableGenerations.add(reference.copy());
            } else {
                if (!compactionAdded) {
                    nextStableGenerations.add(SharedReference.create(stableGeneration));
                    compactionAdded = true;
                }
                currentlyCompacting.remove(name);
            }
        }
        final File checkpointDir = getNextCheckpointDir();
        checkpointDir.mkdirs();
        final GenerationState<K,V> nextState = new GenerationState<K, V>(nextStableGenerations, state.volatileGenerationReference.copy(), checkpointDir);
        checkpointGenerationState(nextState, checkpointDir);
        PosixFileOperations.atomicLink(checkpointDir, new File(root, "latest"));
        final SharedReference<GenerationState<K, V>> oldState = Preconditions.checkNotNull(generationState.getAndSet(nextState));
        oldState.get().delete();
        Closeables2.closeQuietly(oldState, log);
        for (Generation<K, V> generation : toCompactGenerations) {
            final long sizeInBytes = generation.sizeInBytes();
            generation.delete();
            totalGenerationSpace.addAndGet(-sizeInBytes);
        }
    } finally {
        Closeables2.closeQuietly(stateReference, log);
    }
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:36,代码来源:Store.java

示例7: tearDown

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
@After
public void tearDown() throws Exception {
    PosixFileOperations.rmrf(tmpDir);
}
 
开发者ID:indeedeng,项目名称:imhotep,代码行数:5,代码来源:TestMemoryFlamdex.java

示例8: checkpoint

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
@Override
public void checkpoint(File checkpointPath) throws IOException {
    PosixFileOperations.cplr(indexFile, checkpointPath.toPath());
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:5,代码来源:ImmutableBTreeIndex.java

示例9: delete

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
@Override
public void delete() throws IOException {
    log.info("deleting " + getPath());
    PosixFileOperations.rmrf(getPath());
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:6,代码来源:StableGeneration.java

示例10: checkpoint

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
@Override
public void checkpoint(final File checkpointPath) throws IOException {
    PosixFileOperations.cplr(file, checkpointPath);
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:5,代码来源:StableGeneration.java

示例11: delete

import com.indeed.util.core.shell.PosixFileOperations; //导入依赖的package包/类
public void delete() throws IOException {
    log.info("deleting "+path);
    PosixFileOperations.rmrf(path);
}
 
开发者ID:indeedeng,项目名称:lsmtree,代码行数:5,代码来源:Store.java


注:本文中的com.indeed.util.core.shell.PosixFileOperations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。