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


Java FSReadError类代码示例

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


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

示例1: read

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public int read(ByteBuffer buffer, long position)
{
    int size = 0;
    byte[] temBuff = null;

    try {
        if (buffer.isDirect()) {
            //TODO: have a better way to allocate this using thread local or pooling
            temBuff = new byte[buffer.capacity()];
            size = read(position, temBuff, 0, buffer.limit());
            buffer.put(temBuff, 0, size);
        } else {
            temBuff = buffer.array();
            size = read(position, temBuff, 0, buffer.limit());
            buffer.limit(buffer.capacity());
            buffer.position(size);
        }
        return size;
    } catch (IOException e) {
        throw new FSReadError(e, filePath.getName());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:ChannelProxy.java

示例2: size

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public long size()
{
    if (this.fileLength != -1)
        return fileLength;

    try
    {
        if (fs != null && filePath != null) {
            FileStatus fileStatus = fs.getFileStatus(filePath);
            fileLength = fileStatus.getLen();
            return fileLength;
        }

        return -1;
    } catch (IOException e)
    {
        throw new FSReadError(e, filePath.getName());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:20,代码来源:ChannelProxy.java

示例3: handleFSError

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public static void handleFSError(FSError e)
{
    JVMStabilityInspector.inspectThrowable(e);
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
        case stop:
            StorageService.instance.stopTransports();
            break;
        case best_effort:
            // for both read and write errors mark the path as unwritable.
            BlacklistedDirectories.maybeMarkUnwritable(e.path);
            if (e instanceof FSReadError)
            {
                File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
                if (directory != null)
                    Keyspace.removeUnreadableSSTables(directory);
            }
            break;
        case ignore:
            // already logged, so left nothing to do
            break;
        default:
            throw new IllegalStateException();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:FileUtils.java

示例4: next

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public FileDataInput next()
{
    long position = nextpos;
    if (position >= length)
        throw new NoSuchElementException();

    FileDataInput segment = getSegment(nextpos);
    try
    {
        nextpos = nextpos + segment.bytesRemaining();
    }
    catch (IOException e)
    {
        throw new FSReadError(e, path);
    }
    return segment;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:SegmentedFile.java

示例5: RandomAccessReader

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
protected RandomAccessReader(File file, int bufferSize, PoolingSegmentedFile owner) throws FileNotFoundException
{
    super(file, "r");

    this.owner = owner;

    channel = super.getChannel();
    filePath = file.getAbsolutePath();

    // allocating required size of the buffer
    if (bufferSize <= 0)
        throw new IllegalArgumentException("bufferSize must be positive");

    buffer = new byte[bufferSize];

    // we can cache file length in read-only mode
    try
    {
        fileLength = channel.size();
    }
    catch (IOException e)
    {
        throw new FSReadError(e, filePath);
    }
    validBufferBytes = -1; // that will trigger reBuffer() on demand by read/seek operations
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:27,代码来源:RandomAccessReader.java

示例6: dispatch

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
private void dispatch()
{
    while (true)
    {
        if (isPaused.get())
            break;

        HintsDescriptor descriptor = store.poll();
        if (descriptor == null)
            break;

        try
        {
            if (!dispatch(descriptor))
                break;
        }
        catch (FSReadError e)
        {
            logger.error("Failed to dispatch hints file {}: file is corrupted ({})", descriptor.fileName(), e);
            store.cleanUp(descriptor);
            store.blacklist(descriptor);
            throw e;
        }
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:HintsDispatchExecutor.java

示例7: load

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
/**
 * Loads hints stores from a given directory.
 */
static HintsCatalog load(File hintsDirectory, ImmutableMap<String, Object> writerParams)
{
    try
    {
        Map<UUID, List<HintsDescriptor>> stores =
            Files.list(hintsDirectory.toPath())
                 .filter(HintsDescriptor::isHintFileName)
                 .map(HintsDescriptor::readFromFile)
                 .collect(groupingBy(h -> h.hostId));
        return new HintsCatalog(hintsDirectory, writerParams, stores);
    }
    catch (IOException e)
    {
        throw new FSReadError(e, hintsDirectory);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:HintsCatalog.java

示例8: open

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
@SuppressWarnings("resource") // HintsReader owns input
static HintsReader open(File file, RateLimiter rateLimiter)
{
    ChecksummedDataInput reader = ChecksummedDataInput.open(file);
    try
    {
        HintsDescriptor descriptor = HintsDescriptor.deserialize(reader);
        if (descriptor.isCompressed())
        {
            // since the hints descriptor is always uncompressed, it needs to be read with the normal ChecksummedDataInput.
            // The compressed input is instantiated with the uncompressed input's position
            reader = CompressedChecksummedDataInput.upgradeInput(reader, descriptor.createCompressor());
        }
        return new HintsReader(descriptor, file, reader, rateLimiter);
    }
    catch (IOException e)
    {
        reader.close();
        throw new FSReadError(e, file);
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:22,代码来源:HintsReader.java

示例9: handleFSError

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public static void handleFSError(FSError e)
{
    switch (DatabaseDescriptor.getDiskFailurePolicy())
    {
        case stop_paranoid:
        case stop:
            StorageService.instance.stopTransports();
            break;
        case best_effort:
            // for both read and write errors mark the path as unwritable.
            BlacklistedDirectories.maybeMarkUnwritable(e.path);
            if (e instanceof FSReadError)
            {
                File directory = BlacklistedDirectories.maybeMarkUnreadable(e.path);
                if (directory != null)
                    Keyspace.removeUnreadableSSTables(directory);
            }
            break;
        case ignore:
            // already logged, so left nothing to do
            break;
        default:
            throw new IllegalStateException();
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:26,代码来源:FileUtils.java

示例10: deallocate

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public void deallocate()
{
    buffer = null; // makes sure we don't use this after it's ostensibly closed

    if (skipIOCache && bytesSinceCacheFlush > 0)
        CLibrary.trySkipCache(fd, 0, 0);

    try
    {
        super.close();
    }
    catch (IOException e)
    {
        throw new FSReadError(e, filePath);
    }
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:17,代码来源:RandomAccessReader.java

示例11: chunkOffsetBy

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
/**
 * Get a chunk offset by it's index.
 *
 * @param chunkIndex Index of the chunk.
 * @return offset of the chunk in the compressed file.
 */
public long chunkOffsetBy(int chunkIndex) {
    if (dataLengthOffset == -1)
        throw new IllegalStateException("writeHeader wasn't called");

    try {
        long position = getFilePointer();

        // seek to the position of the given chunk
        seek(dataLengthOffset
                + 8 // size reserved for uncompressed data length
                + 4 // size reserved for chunk count
                + (chunkIndex * 8L));

        try {
            return readLong();
        } finally {
            // back to the original position
            seek(position);
        }
    } catch (IOException e) {
        throw new FSReadError(e, filePath);
    }
}
 
开发者ID:fullcontact,项目名称:hadoop-sstable,代码行数:30,代码来源:CompressionMetadata.java

示例12: reBuffer

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
/**
 * Read data from file starting from current currentOffset to populate buffer.
 */
protected void reBuffer() {
    resetBuffer();

    try {
        if (bufferOffset >= fs.getFileStatus(inputPath).getLen()) // TODO: is this equivalent?
            return;

        input.seek(bufferOffset);

        int read = 0;

        while (read < buffer.length) {
            int n = input.read(buffer, read, buffer.length - read);
            if (n < 0)
                break;
            read += n;
        }

        validBufferBytes = read;
        bytesSinceCacheFlush += read;
    } catch (IOException e) {
        throw new FSReadError(e, filePath);
    }
}
 
开发者ID:fullcontact,项目名称:hadoop-sstable,代码行数:28,代码来源:RandomAccessReader.java

示例13: perform

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public static Throwable perform(Throwable accumulate, String filePath, FileOpType opType, Stream<DiscreteAction<? extends IOException>> actions)
{
    return perform(accumulate, actions.map((action) -> () ->
    {
        try
        {
            action.perform();
        }
        catch (IOException e)
        {
            throw (opType == FileOpType.WRITE) ? new FSWriteError(e, filePath) : new FSReadError(e, filePath);
        }
    }));
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:15,代码来源:Throwables.java

示例14: getCanonicalPath

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
public static String getCanonicalPath(String filename)
{
    try
    {
        return new File(filename).getCanonicalPath();
    }
    catch (IOException e)
    {
        throw new FSReadError(e, filename);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:FileUtils.java

示例15: readChunk

import org.apache.cassandra.io.FSReadError; //导入依赖的package包/类
@Override
public void readChunk(long position, ByteBuffer buffer)
{
    buffer.clear();

    //TODO: will make the retry look nicer with an abstraction class
    int attempt = 0;
    int maxAttempt = 3;
    boolean isSuccess = false;
    while (!isSuccess) {
        if (attempt > 0)
           FBUtilities.sleepQuietly((int) Math.round(Math.pow(2, attempt)) * 1000);
        try {
            channel.read(buffer, position);
            isSuccess = true;
        }
        catch (FSReadError e)
        {
           attempt++;
           channel.reopenInputStream();
           if (attempt == maxAttempt) {
              //TODO: what if this is still a network issue, not data corruption
              throw new FSReadError(e, "Error on reading " + channel.filePath() +
                    " on num. attempt " + maxAttempt + " at position " + position);
           }
        }
    }
    buffer.flip();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:30,代码来源:SimpleChunkReader.java


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