Search in sources :

Example 56 with ClosedChannelException

use of java.nio.channels.ClosedChannelException in project hadoop by apache.

the class FsDatasetImpl method getStorageReports.

// FsDatasetSpi
@Override
public StorageReport[] getStorageReports(String bpid) throws IOException {
    List<StorageReport> reports;
    synchronized (statsLock) {
        List<FsVolumeImpl> curVolumes = volumes.getVolumes();
        reports = new ArrayList<>(curVolumes.size());
        for (FsVolumeImpl volume : curVolumes) {
            try (FsVolumeReference ref = volume.obtainReference()) {
                StorageReport sr = new StorageReport(volume.toDatanodeStorage(), false, volume.getCapacity(), volume.getDfsUsed(), volume.getAvailable(), volume.getBlockPoolUsed(bpid), volume.getNonDfsUsed());
                reports.add(sr);
            } catch (ClosedChannelException e) {
                continue;
            }
        }
    }
    return reports.toArray(new StorageReport[reports.size()]);
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) FsVolumeReference(org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference) StorageReport(org.apache.hadoop.hdfs.server.protocol.StorageReport)

Example 57 with ClosedChannelException

use of java.nio.channels.ClosedChannelException in project hadoop by apache.

the class FsVolumeImpl method setClosed.

/**
   * Close this volume.
   * @throws IOException if the volume is closed.
   */
void setClosed() throws IOException {
    try {
        this.reference.setClosed();
        dataset.stopAllDataxceiverThreads(this);
    } catch (ClosedChannelException e) {
        throw new IOException("The volume has already closed.", e);
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) IOException(java.io.IOException)

Example 58 with ClosedChannelException

use of java.nio.channels.ClosedChannelException in project netty by netty.

the class PooledDirectByteBuf method setBytes.

@Override
public int setBytes(int index, FileChannel in, long position, int length) throws IOException {
    checkIndex(index, length);
    ByteBuffer tmpBuf = internalNioBuffer();
    index = idx(index);
    tmpBuf.clear().position(index).limit(index + length);
    try {
        return in.read(tmpBuf, position);
    } catch (ClosedChannelException ignored) {
        return -1;
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) ByteBuffer(java.nio.ByteBuffer)

Example 59 with ClosedChannelException

use of java.nio.channels.ClosedChannelException in project netty by netty.

the class PooledDirectByteBuf method setBytes.

@Override
public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
    checkIndex(index, length);
    ByteBuffer tmpBuf = internalNioBuffer();
    index = idx(index);
    tmpBuf.clear().position(index).limit(index + length);
    try {
        return in.read(tmpBuf);
    } catch (ClosedChannelException ignored) {
        return -1;
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) ByteBuffer(java.nio.ByteBuffer)

Example 60 with ClosedChannelException

use of java.nio.channels.ClosedChannelException in project netty by netty.

the class PooledUnsafeDirectByteBuf method setBytes.

@Override
public int setBytes(int index, FileChannel in, long position, int length) throws IOException {
    checkIndex(index, length);
    ByteBuffer tmpBuf = internalNioBuffer();
    index = idx(index);
    tmpBuf.clear().position(index).limit(index + length);
    try {
        return in.read(tmpBuf, position);
    } catch (ClosedChannelException ignored) {
        return -1;
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ClosedChannelException (java.nio.channels.ClosedChannelException)211 ByteBuffer (java.nio.ByteBuffer)67 IOException (java.io.IOException)60 Test (org.junit.Test)23 InetSocketAddress (java.net.InetSocketAddress)19 SelectionKey (java.nio.channels.SelectionKey)18 SocketChannel (java.nio.channels.SocketChannel)15 ArrayList (java.util.ArrayList)13 NotYetConnectedException (java.nio.channels.NotYetConnectedException)11 InterruptedIOException (java.io.InterruptedIOException)10 CancelledKeyException (java.nio.channels.CancelledKeyException)10 ShutdownCommand (com.cloud.agent.api.ShutdownCommand)9 File (java.io.File)9 ServerSocketChannel (java.nio.channels.ServerSocketChannel)9 PooledByteBuffer (io.undertow.connector.PooledByteBuffer)8 FileChannel (java.nio.channels.FileChannel)8 ConnectException (java.net.ConnectException)7 FsVolumeReference (org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeReference)6 AgentControlCommand (com.cloud.agent.api.AgentControlCommand)5 Command (com.cloud.agent.api.Command)5