List of usage examples for io.netty.buffer ByteBuf toString
public abstract String toString(int index, int length, Charset charset);
From source file:org.dcache.xrootd.protocol.messages.SetRequest.java
License:Open Source License
public SetRequest(ByteBuf buffer) { super(buffer, kXR_set); int dlen = buffer.getInt(20); data = buffer.toString(24, dlen, US_ASCII); }
From source file:org.dcache.xrootd.protocol.messages.StatxRequest.java
License:Open Source License
public StatxRequest(ByteBuf buffer) { super(buffer, kXR_statx); int dlen = buffer.getInt(20); paths = buffer.toString(24, dlen, US_ASCII).split("\n"); opaques = new String[paths.length]; for (int i = 0; i < paths.length; i++) { String path = paths[i];//from w ww. j a v a 2s.c o m int pos = path.indexOf('?'); if (pos > -1) { paths[i] = path.substring(0, pos); opaques[i] = path.substring(pos + 1); } } }
From source file:org.dcache.xrootd.tpc.protocol.messages.InboundAttnResponse.java
License:Open Source License
private void parseParameters(ByteBuf buffer, int len) { switch (actnum) { case kXR_asyncab: case kXR_asyncms: message = buffer.toString(12, len, US_ASCII); break;//from www .j a va 2 s. co m case kXR_asyncdi: wsec = buffer.getInt(12); msec = buffer.getInt(16); break; case kXR_asyncrd: port = buffer.getInt(12); redirectData = buffer.toString(16, len - 4, US_ASCII); break; case kXR_asynresp: rStreamId = buffer.getUnsignedShort(16); rStat = buffer.getUnsignedShort(18); int dlen = buffer.getInt(20); if (dlen > 0) { rData = new byte[dlen]; buffer.getBytes(24, rData); } break; case kXR_asyncwt: wsec = buffer.getInt(12); break; default: break; } }
From source file:org.dcache.xrootd.tpc.protocol.messages.InboundChecksumResponse.java
License:Open Source License
public InboundChecksumResponse(ByteBuf buffer) throws ParseException { super(buffer); int len = buffer.getInt(4); if (len > 0) { parse(buffer.toString(8, len, StandardCharsets.US_ASCII)); }// ww w. j a va2s. c o m }
From source file:org.dcache.xrootd.tpc.protocol.messages.InboundErrorResponse.java
License:Open Source License
public InboundErrorResponse(ByteBuf buffer) { super(buffer); int len = buffer.getInt(4); error = buffer.getInt(8);//from www .j a va2s . c o m errorMessage = buffer.toString(12, len - 4, US_ASCII); }
From source file:org.dcache.xrootd.tpc.protocol.messages.InboundLoginResponse.java
License:Open Source License
public InboundLoginResponse(ByteBuf buffer) throws XrootdException { super(buffer); if (buffer.readableBytes() > 8) { int slen = buffer.getInt(4) - SESSION_ID_SIZE; byte[] session = new byte[SESSION_ID_SIZE]; buffer.getBytes(8, session);//from w ww. ja va 2s . c o m sessionId = new XrootdSessionIdentifier(session); if (slen > 0) { protocols = new ArrayList<>(); String sec = buffer.toString(24, slen, US_ASCII); for (String description : Splitter.on('&').trimResults().omitEmptyStrings().split(sec)) { if (!description.startsWith(PROTOCOL_PREFIX)) { throw new XrootdException(kXR_error, "Malformed 'sec': " + sec); } protocols.add(new SecurityInfo(description.substring(PROTOCOL_PREFIX.length()))); } } else { protocols = Collections.EMPTY_LIST; } } else { sessionId = null; protocols = Collections.EMPTY_LIST; } protocolMap = protocols.stream().collect(Collectors.toMap((p) -> p.getProtocol(), (p) -> p)); }
From source file:org.dcache.xrootd.tpc.protocol.messages.InboundOpenReadOnlyResponse.java
License:Open Source License
public InboundOpenReadOnlyResponse(ByteBuf buffer) { super(buffer); resplen = buffer.getInt(4);// w w w . ja v a2s . c om fhandle = buffer.getInt(8); cpsize = buffer.getInt(12); cptype = buffer.getInt(16); int len = resplen - 12; if (len > 0) { info = buffer.toString(20, len, StandardCharsets.US_ASCII); } else { info = null; } }
From source file:org.dcache.xrootd.tpc.protocol.messages.InboundRedirectResponse.java
License:Open Source License
public InboundRedirectResponse(ByteBuf buffer, int requestId) throws ParseException { super(buffer); this.requestId = requestId; int len = buffer.getInt(4); port = buffer.getInt(8);//from w ww. ja v a 2 s.co m parseRedirectString(buffer.toString(12, len - 4, StandardCharsets.US_ASCII)); wsec = 0; msec = 0; }
From source file:org.hawkular.metrics.clients.ptrans.collectd.packet.CollectdPacketDecoder.java
License:Apache License
private String readStringPartContent(ByteBuf content, int length) { String string = content.toString(content.readerIndex(), length - 1 /* collectd strings are \0 terminated */, CharsetUtil.US_ASCII);/*from w ww .j a va 2 s . c om*/ content.skipBytes(length); // the previous call does not move the readerIndex return string; }
From source file:org.redisson.client.handler.CommandDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { QueueCommand data = ctx.channel().attr(CommandsQueue.CURRENT_COMMAND).get(); if (log.isTraceEnabled()) { log.trace("channel: {} message: {}", ctx.channel(), in.toString(0, in.writerIndex(), CharsetUtil.UTF_8)); }/*from w w w . j av a2s . c o m*/ if (state() == null) { boolean makeCheckpoint = data != null; if (data != null) { if (data instanceof CommandsData) { makeCheckpoint = false; } else { CommandData<Object, Object> cmd = (CommandData<Object, Object>) data; if (cmd.getCommand().getReplayMultiDecoder() != null && (NestedMultiDecoder.class .isAssignableFrom(cmd.getCommand().getReplayMultiDecoder().getClass()) || SlotsDecoder.class .isAssignableFrom(cmd.getCommand().getReplayMultiDecoder().getClass()) || ListMultiDecoder.class .isAssignableFrom(cmd.getCommand().getReplayMultiDecoder().getClass()))) { makeCheckpoint = false; } } } state(new State(makeCheckpoint)); } state().setDecoderState(null); if (data == null) { decode(in, null, null, ctx.channel()); } else if (data instanceof CommandData) { CommandData<Object, Object> cmd = (CommandData<Object, Object>) data; try { if (state().getLevels().size() > 0) { decodeFromCheckpoint(ctx, in, data, cmd); } else { decode(in, cmd, null, ctx.channel()); } } catch (Exception e) { cmd.tryFailure(e); } } else if (data instanceof CommandsData) { CommandsData commands = (CommandsData) data; try { decodeCommandBatch(ctx, in, data, commands); } catch (Exception e) { commands.getPromise().tryFailure(e); } return; } ctx.pipeline().get(CommandsQueue.class).sendNextCommand(ctx.channel()); state(null); }