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


Java Connection.write方法代码示例

本文整理汇总了Java中org.glassfish.grizzly.Connection.write方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.write方法的具体用法?Java Connection.write怎么用?Java Connection.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.grizzly.Connection的用法示例。


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

示例1: sendRequest

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@Override
public Response sendRequest(Request request, Connection connection) {
    AsynReq asynReq = new AsynReq( request);
    try {
        AsynReq tmp = map.putIfAbsent(request.getHeader().getVersion(), asynReq);
        if ( tmp != null )
            throw new ConnectionException(request.getHeader().toString() +" was submitted twice");
        connection.write( request);
        boolean flag = false;
        asynReq.getLock().lock();
        try {
            // set enter flag to true, for notify message received thread
            asynReq.setEntered(true);
            flag = asynReq.getReady().await( timeout, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            //map.remove( request.getHeader().getVersion() );
            //swallow exception
            return new Response("InterruptedException", true);
        } finally {
            asynReq.getLock().unlock();
        }
        if ( flag == false ) {
            logger.error("map size "+map.size()+" "+dumpMap());
            throw new StoreException("time out ms "+timeout);
        }
        else
            return asynReq.getResponse() ;

    } finally {
        if ( asynReq != null ) {
            map.remove( asynReq.getRequest().getHeader().getVersion() );
        }
    }
    //return null;  //To change body of implemented methods use File | Settings | File Templates.
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:36,代码来源:ClientFilter.java

示例2: sendErrorResponse

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private void sendErrorResponse(final Connection connection, final RequestWrapper request) throws IOException {
  ResponseWrapper responseWrapper = new ResponseWrapper(request.getId(), request.getCodecType(), request.getProtocolType());
  responseWrapper.setException(new Exception("server threadpool full,maybe because server is slow or too many requests"));

  connection.write(responseWrapper, new EmptyCompletionHandler<WriteResult>() {

    @Override
    public void failed(Throwable throwable) {
      LOGGER.error("server write response error,request id is: " + request.getId());
    }

  });
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:15,代码来源:GrizzlyServerHandler.java

示例3: redirectToPeer

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
/**
 * Redirect data from {@link Connection} to its peer.
 *
 * @param context
 *            {@link FilterChainContext}
 * @param peerConnection
 *            peer {@link Connection}
 * @throws IOException
 */
@SuppressWarnings("unchecked")
private static void redirectToPeer(final FilterChainContext context,
        final Connection peerConnection, Object message) throws IOException {

    final Connection srcConnection = context.getConnection();
    logger.log(
            Level.FINE,
            "Redirecting from {0} to {1} message: {2}",
            new Object[] { srcConnection.getPeerAddress(),
                    peerConnection.getPeerAddress(), message });

    peerConnection.write(message);
}
 
开发者ID:chocotan,项目名称:kazeproxy,代码行数:23,代码来源:TunnelRedirectServerFilter.java

示例4: sendMessage

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
@Override
public void sendMessage(Request request, Connection connection) {
    connection.write( request);
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:5,代码来源:ClientFilter.java

示例5: writeMessage

import org.glassfish.grizzly.Connection; //导入方法依赖的package包/类
protected void writeMessage(WSMessage msg) {
	IWSCodec codec = getCodec();
	byte[] encode = codec.encode(msg);
	Connection<?> conn = ensureConnIsOpen();
	conn.write(Buffers.wrap(conn.getMemoryManager(), encode));
}
 
开发者ID:coderczp,项目名称:HtmlSocket,代码行数:7,代码来源:WebSocketImpl.java


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