List of usage examples for io.netty.buffer ByteBuf readLong
public abstract long readLong();
From source file:qunar.tc.qmq.protocol.consumer.PullRequestSerde.java
License:Apache License
public PullRequest read(final int version, final ByteBuf in) { final String prefix = PayloadHolderUtils.readString(in); final String group = PayloadHolderUtils.readString(in); final String consumerId = PayloadHolderUtils.readString(in); final int requestNum = in.readInt(); final long offset = in.readLong(); final long pullOffsetBegin = in.readLong(); final long pullOffsetLast = in.readLong(); final long timeout = in.readLong(); final byte broadcast = in.readByte(); final List<PullFilter> filters = readFilters(version, in); final PullRequest request = new PullRequest(); request.setSubject(prefix);/*from ww w. j ava2 s. c om*/ request.setGroup(group); request.setConsumerId(consumerId); request.setRequestNum(requestNum); request.setOffset(offset); request.setPullOffsetBegin(pullOffsetBegin); request.setPullOffsetLast(pullOffsetLast); request.setTimeoutMillis(timeout); request.setBroadcast(broadcast != 0); request.setFilters(filters); return request; }
From source file:qunar.tc.qmq.protocol.QMQSerializer.java
License:Apache License
public static MessageHeader deserializeMessageHeader(ByteBuf body) { byte flag = body.readByte(); long createdTime = body.readLong(); long expiredTime = body.readLong(); String subject = PayloadHolderUtils.readString(body); String messageId = PayloadHolderUtils.readString(body); MessageHeader header = new MessageHeader(); if (Flags.hasTags(flag)) { final Set<String> tags = new HashSet<>(); final byte tagsSize = body.readByte(); for (int i = 0; i < tagsSize; i++) { String tag = PayloadHolderUtils.readString(body); tags.add(tag);// w w w.j a va2 s .c om } header.setTags(tags); } header.setFlag(flag); header.setCreateTime(createdTime); header.setExpireTime(expiredTime); header.setSubject(subject); header.setMessageId(messageId); return header; }
From source file:qunar.tc.qmq.sync.AbstractSyncLogProcessor.java
License:Apache License
@Override public void process(Datagram datagram) { final ByteBuf body = datagram.getBody(); final int size = body.readInt(); if (size == 0) { LOG.debug("sync data empty"); return;/*from ww w .j av a2 s. com*/ } final long startOffset = body.readLong(); appendLogs(startOffset, body); }
From source file:qunar.tc.qmq.sync.master.SyncLogProcessor.java
License:Apache License
private SyncRequest deserializeSyncRequest(final RemotingCommand request) { final ByteBuf body = request.getBody(); final int logType = body.readByte(); final long messageLogOffset = body.readLong(); final long actionLogOffset = body.readLong(); return new SyncRequest(logType, messageLogOffset, actionLogOffset); }
From source file:ratpack.session.clientside.internal.ClientSideSessionStore.java
License:Apache License
private boolean isValid(CookieStorage cookieStorage) throws Exception { ByteBuf payload = null; try {// w w w. ja v a 2 s . co m payload = deserialize(cookieStorage.lastAccessToken); if (payload.readableBytes() == 0) { reset(cookieStorage); return false; } long lastAccessTime = payload.readLong(); long currentTime = System.currentTimeMillis(); long maxInactivityIntervalMillis = config.getMaxInactivityInterval().toMillis(); if (currentTime - lastAccessTime > maxInactivityIntervalMillis) { reset(cookieStorage); return false; } } finally { if (payload != null) { payload.release(); } } return true; }
From source file:se.sics.caracaldb.flow.FlowMessageSerializer.java
License:Open Source License
private CTS ctsFromBinary(ByteBuf buf, MessageFields fields) { UUID flowId = (UUID) SpecialSerializers.UUIDSerializer.INSTANCE.fromBinary(buf, Optional.absent()); int clearId = buf.readInt(); int allowance = buf.readInt(); long valid = buf.readLong(); return new CTS(fields.src, fields.dst, fields.proto, flowId, clearId, allowance, valid); }
From source file:se.sics.caracaldb.global.LookupTable.java
License:Open Source License
public static LookupTable deserialise(byte[] bytes) throws IOException { ByteBuf buf = Unpooled.wrappedBuffer(bytes); INSTANCE = new LookupTable(); INSTANCE.versionId = buf.readLong(); INSTANCE.scatterWidth = buf.readInt(); // schemas// ww w . j ava2s . c o m INSTANCE.schemas = SchemaData.deserialise(buf); // hosts int numHosts = buf.readInt(); INSTANCE.hosts = new ArrayList<Address>(numHosts); for (int i = 0; i < numHosts; i++) { Address addr = (Address) SpecialSerializers.AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent()); INSTANCE.hosts.add(addr); } // replicationgroups int numRGs = buf.readInt(); INSTANCE.replicationSets = new ArrayList<Integer[]>(numRGs); INSTANCE.replicationSetVersions = new ArrayList<Integer>(numRGs); for (int i = 0; i < numRGs; i++) { Pair<Integer, Integer[]> group = deserialiseReplicationGroup(buf); INSTANCE.replicationSets.add(group.getValue1()); INSTANCE.replicationSetVersions.add(group.getValue0()); } // virtualHostGroups for (int i = 0; i < NUM_VIRT_GROUPS; i++) { INSTANCE.virtualHostGroupVersions[i] = buf.readLong(); int groupLength = buf.readInt(); byte[] groupBytes = new byte[groupLength]; buf.readBytes(groupBytes); INSTANCE.virtualHostGroups[i] = LookupGroup.deserialise(groupBytes); } return INSTANCE; }
From source file:se.sics.caracaldb.global.LUTUpdate.java
License:Open Source License
public static LUTUpdate deserialise(ByteBuf buf) throws InstantiationException, IllegalAccessException { long previousVersion = buf.readLong(); long version = buf.readLong(); int numActions = buf.readInt(); Action[] actions = new Action[numActions]; for (int i = 0; i < numActions; i++) { actions[i] = Action.deserialise(buf); }//from w ww . ja v a2 s. c om return new LUTUpdate(previousVersion, version, actions); }
From source file:se.sics.caracaldb.global.NodeStats.java
License:Open Source License
public static NodeStats deserialise(ByteBuf buf) throws IOException { Address node = (Address) SpecialSerializers.AddressSerializer.INSTANCE.fromBinary(buf, Optional.absent()); KeyRange range = CustomSerialisers.deserialiseKeyRange(buf); long storeSize = buf.readLong(); long storeNumberOfKeys = buf.readLong(); long ops = buf.readLong(); return new NodeStats(node, range, storeSize, storeNumberOfKeys, ops); }
From source file:se.sics.caracaldb.global.SchemaData.java
License:Open Source License
public static SchemaData deserialise(ByteBuf buf) { SchemaData sd = new SchemaData(); sd.version = buf.readLong(); deserialiseData(buf, sd);// w w w . ja v a 2 s. com return sd; }