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


Java AsynchronousCloseException类代码示例

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


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

示例1: stop

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
@Override
public void stop(boolean waitDone) throws IOException, InterruptedException {
    final CountDownLatch latch = connectionLatch;
    if (running.compareAndSet(true, false)) {
        try {
            if (serverSocketChannel != null) {
                serverSocketChannel.close();
                serverSocketChannel = null;
            }
        } catch (AsynchronousCloseException e) {
            e.printStackTrace();
        } finally {
            if (waitDone) {
                latch.await();
            }
        }
    }
}
 
开发者ID:altiplanogao,项目名称:io-comparison,代码行数:19,代码来源:AioServer.java

示例2: failed

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
@Override
public void failed(Throwable exc,  ByteBuffer buffer) {
	if((exc instanceof AsynchronousCloseException) ||
			(exc instanceof ClosedChannelException)){
		return;
	}

	if(exc instanceof Exception){

		Exception e = (Exception)exc;

		//兼容 windows 的 "java.io.IOException: 指定的网络名不再可用" 错误
		if(e.getStackTrace()[0].getClassName().contains("sun.nio.ch")){
			session.close();
			return;
		}

		//触发 onException 事件
		EventTrigger.fireExceptionThread(session, (Exception)exc);
	}
}
 
开发者ID:helyho,项目名称:Voovan,代码行数:22,代码来源:ReadCompletionHandler.java

示例3: end

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * Indicates the end of a code section that has been started with
 * {@code begin()} and that includes a potentially blocking I/O operation.
 *
 * @param success
 *            pass {@code true} if the blocking operation has succeeded and
 *            has had a noticeable effect; {@code false} otherwise.
 * @throws AsynchronousCloseException
 *             if this channel is closed by another thread while this method
 *             is executing.
 * @throws ClosedByInterruptException
 *             if another thread interrupts the calling thread while this
 *             method is executing.
 */
protected final void end(boolean success) throws AsynchronousCloseException {
    // FIXME: be accommodate before VM actually provides
    // setInterruptAction method
    if (setInterruptAction != null) {
        try {
            setInterruptAction.invoke(Thread.currentThread(),
                    new Object[] { null });
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (interrupted) {
            interrupted = false;
            throw new ClosedByInterruptException();
        }
    }
    if (!success && closed) {
        throw new AsynchronousCloseException();
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:34,代码来源:AbstractInterruptibleChannel.java

示例4: testSerializationSelf

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "AsynchronousCloseException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new AsynchronousCloseException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:AsynchronousCloseExceptionTest.java

示例5: testSerializationCompatibility

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "AsynchronousCloseException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new AsynchronousCloseException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:AsynchronousCloseExceptionTest.java

示例6: transferStreams

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
private void transferStreams( BufferedReader reader, PrintWriter writer, boolean receive ) throws IOException
{
    try {
        String line;
        while( ( line = reader.readLine() ) != null ) {
            writer.println( line );
            writer.flush();
            if( receive ) {
                publishProgress( CONNECTED.toString(), output.toString() );
            }
       }
    } catch( AsynchronousCloseException e ) {
        // This exception is thrown when socket for receiver thread is closed by netcat
        Log.w( CLASS_NAME, e.toString() );
    }
}
 
开发者ID:dddpaul,项目名称:android-SimpleNetCat,代码行数:17,代码来源:TcpNetCat.java

示例7: end

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * Indicates the end of a code section that has been started with
 * {@code begin()} and that includes a potentially blocking I/O operation.
 * 
 * @param success
 *            pass {@code true} if the blocking operation has succeeded and
 *            has had a noticeable effect; {@code false} otherwise.
 * @throws AsynchronousCloseException
 *             if this channel is closed by another thread while this method
 *             is executing.
 * @throws ClosedByInterruptException
 *             if another thread interrupts the calling thread while this
 *             method is executing.
 */
protected final void end(boolean success) throws AsynchronousCloseException {
    // FIXME: be accommodate before VM actually provides
    // setInterruptAction method
    if (setInterruptAction != null) {
        try {
            setInterruptAction.invoke(Thread.currentThread(),
                    new Object[] { null });
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (interrupted) {
            interrupted = false;
            throw new ClosedByInterruptException();
        }
    }
    if (!success && closed) {
        throw new AsynchronousCloseException();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:AbstractInterruptibleChannel.java

示例8: end

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * End an IO operation that was previously started with <code>begin()</code>.
 * 
 * @param success
 *            pass true if the operation succeeded and had a side effect on
 *            the Java system, or false if not.
 * @throws AsynchronousCloseException
 *             the channel was closed while the IO operation was in
 *             progress.
 * @throws java.nio.channels.ClosedByInterruptException
 *             the thread conducting the IO operation was interrupted.
 */
protected final void end(boolean success) throws AsynchronousCloseException {
    // FIXME: be accommodate before VM actually provides
    // setInterruptAction method
    if (setInterruptAction != null) {
        try {
            setInterruptAction.invoke(Thread.currentThread(),
                    new Object[] { null });
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (interrupted) {
            interrupted = false;
            throw new ClosedByInterruptException();
        }
    }
    if (!success && closed) {
        throw new AsynchronousCloseException();
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:32,代码来源:AbstractInterruptibleChannel.java

示例9: readMessages

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * Reads the incoming network data from the socket and retrieves the OF
 * messages.
 *
 * @return list of OF messages
 * @throws Exception
 */
@Override
public List<OFMessage> readMessages() throws IOException {
    if (!socket.isOpen()) {
        return null;
    }

    List<OFMessage> msgs = null;
    int bytesRead = -1;
    bytesRead = socket.read(inBuffer);
    if (bytesRead < 0) {
        throw new AsynchronousCloseException();
    }

    inBuffer.flip();
    msgs = factory.parseMessages(inBuffer);
    if (inBuffer.hasRemaining()) {
        inBuffer.compact();
    } else {
        inBuffer.clear();
    }
    return msgs;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:30,代码来源:MessageReadWriteService.java

示例10: unreferenceCheckClosed

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
/**
 * Decrement the reference count, checking to make sure that the
 * CloseableReferenceCount is not closed.
 *
 * @throws AsynchronousCloseException  If the status is closed.
 */
public void unreferenceCheckClosed() throws ClosedChannelException {
  int newVal = status.decrementAndGet();
  if ((newVal & STATUS_CLOSED_MASK) != 0) {
    throw new AsynchronousCloseException();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:13,代码来源:CloseableReferenceCount.java

示例11: failed

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
@Override
public void failed(Throwable exc, AioServer serverHandler) {
    if (exc instanceof AsynchronousCloseException) {
        connectionLatch.countDown();
    } else {
        exc.printStackTrace();
    }
}
 
开发者ID:altiplanogao,项目名称:io-comparison,代码行数:9,代码来源:AioServer.java

示例12: processOnce

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
public void processOnce() throws IOException {
    // set status of query to OK.
    ctx.getState().reset();
    executor = null;

    // reset sequence id of MySQL protocol
    final MysqlChannel channel = ctx.getMysqlChannel();
    channel.setSequenceId(0);
    // read packet from channel
    try {
        packetBuf = channel.fetchOnePacket();
        if (packetBuf == null) {
            logger.warn("Null packet received from network. remote: {}", channel.getRemote());
            throw new IOException("Error happened when receiving packet.");
        }
    } catch (AsynchronousCloseException e) {
        // when this happened, timeout checker close this channel
        // killed flag in ctx has been already set, just return
        return;
    }

    // dispatch
    dispatch();
    // finalize
    finalizeCommand();

    ctx.setCommand(MysqlCommand.COM_SLEEP);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:29,代码来源:ConnectProcessor.java

示例13: failed

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
@Override
public void failed(Throwable exc, AioSocketChannel channel) {

    if (exc instanceof AsynchronousCloseException) {
        //FIXME 产生该异常的原因是shutdownOutput后对方收到 read(-1)然后调用shutdownOutput,本地在收到read(-1)之前关闭了连接
        return;
    }

    logger.error(exc.getMessage() + ", channel:" + channel, exc);

    CloseUtil.close(channel);
}
 
开发者ID:generallycloud,项目名称:baseio,代码行数:13,代码来源:ReadCompletionHandler.java

示例14: onFailed

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
void onFailed(Throwable e) {
    if (e instanceof AsynchronousCloseException) {
        onClosed();
        return;
    }

    if (!connected) return;

    synchronized (sendSync) {
        connected = false;
        completeOutstandingRequestsExceptionally(e);
    }
}
 
开发者ID:oneam,项目名称:pirec,代码行数:14,代码来源:RedisClient.java

示例15: read

import java.nio.channels.AsynchronousCloseException; //导入依赖的package包/类
private int read(ByteBuffer[] dsts, int offset, int length, AtomicInteger posToUpdate)
		throws IOException {
	if(!isOpenForRead){
		throw new NonReadableChannelException();
	}

	throwExceptionIfClosed();

	int counter = 0;

	synchronized(readWriteMonitor){
		for(int j=offset; j<length; j++){
			ByteBuffer dst = dsts[j];
			int r = dst.remaining();
			for(int i=0; i<r; i++){
				int b = NativeMockedIO.read(path, posToUpdate);
				if(b < 0){ //end of stream
					return -1;
				}

				if(closed){
					throw new AsynchronousCloseException();
				}

				if(Thread.currentThread().isInterrupted()){
					close();
					throw new ClosedByInterruptException();
				}

				dst.put((byte)b);
				counter++;
			}
		}
	}

	return counter;		
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:38,代码来源:EvoFileChannel.java


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