private void encode(GrowingByteBuffer buf, RedirectServerSync redirectSync) { buildExtensionHeader(buf, EVENT_EXTENSION_ID, NOTHING, NOTHING, 4); buf.putInt(redirectSync.getAccessPointId()); }
private void buildExtensionHeader(GrowingByteBuffer buf, short extensionId, byte optionA, byte optionB, int length) { buf.putShort(extensionId); buf.put(optionA); buf.put(optionB); buf.putInt(length); }
private void encode(GrowingByteBuffer buf, LogServerSync logSync) { List<LogDeliveryStatus> statusList = logSync.getDeliveryStatuses(); int extensionSize = 4; if (statusList != null) { extensionSize += 4 * statusList.size(); } buildExtensionHeader(buf, LOGGING_EXTENSION_ID, NOTHING, NOTHING, extensionSize); if (statusList != null && !statusList.isEmpty()) { buf.putInt(statusList.size()); for (LogDeliveryStatus status : statusList) { buf.putShort((short) status.getRequestId()); buf.put(status.getResult() == SyncStatus.SUCCESS ? SUCCESS : FAILURE); buf.put(status.getErrorCode() != null ? (byte) status.getErrorCode().ordinal() : NOTHING); } } else { buf.putInt(0); } }
private void encode(GrowingByteBuffer buf, BootstrapServerSync bootstrapSync) { buildExtensionHeader(buf, BOOTSTRAP_EXTENSION_ID, NOTHING, NOTHING, 0); final int extPosition = buf.position(); buf.putShort((short) bootstrapSync.getRequestId()); buf.putShort((short) bootstrapSync.getProtocolList().size()); for (ProtocolConnectionData data : bootstrapSync.getProtocolList()) { buf.putInt(data.getAccessPointId()); buf.putInt(data.getProtocolId()); buf.putShort((short) data.getProtocolVersion()); buf.putShort((short) data.getConnectionData().length); put(buf, data.getConnectionData()); } buf.putInt(extPosition - SIZE_OF_INT, buf.position() - extPosition); }
switch (status) { case NO_DELTA: buf.putInt(0); break; case DELTA: buf.putInt(1); break; case RESYNC: buf.putInt(2); break; default: buf.putShort((short) notificationSync.getNotifications().size()); for (Notification nf : notificationSync.getNotifications()) { buf.putInt((nf.getSeqNumber() != null) ? nf.getSeqNumber() : 0); buf.put(nf.getType() == NotificationType.SYSTEM ? SYSTEM : CUSTOM); buf.put(NOTHING); buf.putShort(nf.getUid() != null ? (short) nf.getUid().length() : (short) 0); buf.putInt(nf.getBody().array().length); long topicId = nf.getTopicId() != null ? nf.getTopicIdAsLong() : 0L; buf.putLong(topicId); buf.putInt(extPosition - SIZE_OF_INT, buf.position() - extPosition);
buf.putInt(eventSync.getEventSequenceNumberResponse().getSeqNum()); buf.putShort(response.getResult() == SyncStatus.SUCCESS ? SUCCESS : FAILURE); if (response.getListeners() != null) { buf.putInt(response.getListeners().size()); for (String listener : response.getListeners()) { put(buf, Base64Util.decode(listener)); buf.putInt(0); buf.putInt(event.getEventData().array().length); buf.putInt(extPosition - SIZE_OF_INT, buf.position() - extPosition);
LOG.trace("Encoding server sync {}", sync); GrowingByteBuffer buf = new GrowingByteBuffer(DEFAULT_BUFFER_SIZE); buf.putInt(getId()); buf.putShort(PROTOCOL_VERSION);
buf.putInt(extPosition - SIZE_OF_INT, buf.position() - extPosition);