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


Java TransformationException类代码示例

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


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

示例1: transformImpl

import org.glassfish.grizzly.TransformationException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected final TransformationResult<MessageLite, Buffer> transformImpl(
        final AttributeStorage storage, final @NonNull MessageLite input)
        throws TransformationException {
    final MemoryManager memoryManager = obtainMemoryManager(storage);
    final BufferOutputStream outputStream = new BufferOutputStream(memoryManager);

    final byte[] encodedMessage = input.toByteArray();
    try {
        writeHeader(outputStream, encodedMessage.length);

        outputStream.write(encodedMessage);
        outputStream.close();
    } catch (final IOException e) {
        final String msg = "Error writing protobuf message to output stream.";
        log.warn(msg, e);
        return createErrorResult(IO_WRITE_ERROR, msg);
    }

    return createCompletedResult(outputStream.getBuffer().flip(), null);
}
 
开发者ID:novabyte,项目名称:grizzly-protobuf,代码行数:23,代码来源:AbstractProtobufEncoder.java

示例2: transformImpl

import org.glassfish.grizzly.TransformationException; //导入依赖的package包/类
@Override
protected TransformationResult<Request, Buffer> transformImpl(AttributeStorage storage, Request request) throws TransformationException {
    byte ver = request.getHeader().getSerializeVersion() ;
    int pLen = request.getPayload() == null ? 0 : request.getPayload().length;
    byte[] header = request.getHeader().toByte();
    // encoding length , and check the max value of integer, should be 2GB
    int totalLen = OFFSET + header.length + pLen + R_SIZE + H_SIZE;
    if ( totalLen > Integer.MAX_VALUE ) {
        throw new TransformationException( totalLen +" exceeding Integer.MAX_VALUE");
    }
    //logger.info("total "+totalLen+" hd "+header.length+" payload "+pLen);
    // Retrieve the memory manager
    //final MemoryManager memoryManager = ctx.getConnection().getTransport().getMemoryManager();

    // allocate the buffer of required size
    final Buffer bout = obtainMemoryManager(storage).allocate(totalLen);
    // Instruct the FilterChain to call the next filter
    bout.put(SIGNATURE);
    bout.put(ver);
    bout.putInt(totalLen);
    bout.putShort((short) header.length);
    bout.put(header);
    // request type
    bout.put((byte) request.getType().ordinal());
    bout.put( request.getPayload());

    bout.flip();
    bout.allowBufferDispose(true);

    return TransformationResult.createCompletedResult(bout, null);
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:32,代码来源:RequestEncoder.java

示例3: transformImpl

import org.glassfish.grizzly.TransformationException; //导入依赖的package包/类
@Override
protected TransformationResult<Buffer, Request> transformImpl(AttributeStorage storage, Buffer input) throws TransformationException {
    //Integer packSize = lengthAttribute.get(storage);
    VersionLength versionLength = lengthAttribute.get(storage);
    if (versionLength == null) {
        if (input.remaining() < OFFSET) {
            return TransformationResult.createIncompletedResult(input);
        }
        byte signature = input.get();
        byte ver = input.get();
        int packSize = input.getInt();
        if (signature != SIGNATURE  ) {
            //channel.close();
            throw new TransformationException("expect "+SIGNATURE+" but get "+signature+" "+" "+input.toString());
        }
        if ( packSize < 0 || packSize > MAX_LEN ) {
            //channel.close();
            throw new TransformationException(packSize+" Exceed Integer.MAX_VALUE or MAX_LEN");
        }
        //use versionlength
        versionLength = new VersionLength(packSize, ver);
        //lengthAttribute.set(storage, packSize);
        lengthAttribute.set(storage, versionLength);
    }

    if (input.remaining() < (versionLength.getLength() -OFFSET) ) {
        //logger.info("packSize "+versionLength.getLength() + " remaining "+input.remaining() );
        return TransformationResult.createIncompletedResult(input);
    }
    int tmpLimit = input.limit();
    input.limit(input.position() + (versionLength.getLength() -OFFSET) );
    Request request= doDecode(input, versionLength.getLength(), versionLength.getVersion()  );
    input.position(input.limit());
    input.limit(tmpLimit);
    return TransformationResult.createCompletedResult(
            request, input);
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:38,代码来源:RequestDecoder.java


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