當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。