public int getProtocolId() { return protocolVersionId.getProtocolId(); }
public int getProtocolVersion() { return protocolVersionId.getVersion(); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + accessPointId; result = prime * result + Arrays.hashCode(connectionData); result = prime * result + ((protocolVersionId == null) ? 0 : protocolVersionId.hashCode()); return result; }
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); }
private static List<ProtocolMetaData> convert(Set<ProtocolConnectionData> source) { if (source == null) { return Collections.emptyList(); } List<ProtocolMetaData> result = new ArrayList<>(source.size()); for (ProtocolConnectionData pcd : source) { result.add(new ProtocolMetaData( pcd.getAccessPointId(), new ProtocolVersionPair(pcd.getProtocolId(), pcd.getProtocolVersion()), ByteBuffer.wrap(pcd.getConnectionData()))); } return result; }
protected Set<ProtocolConnectionData> filterProtocolInstances(List<ProtocolVersionId> keys) { Set<ProtocolConnectionData> result = new HashSet<>(); for (ProtocolVersionId key : keys) { for (OperationsNodeInfo node : opsMap.values()) { for (TransportMetaData md : node.getTransports()) { if (md.getId() == key.getProtocolId() && md.getMinSupportedVersion() <= key.getVersion() && key.getVersion() <= md.getMaxSupportedVersion()) { result.addAll(toProtocolConnectionData(node, md, key.getVersion())); } } } } return result; }
private void parseBootstrapClientSync(ClientSync sync, ByteBuffer buf, int options, int payloadLength) { int requestId = buf.getShort(); int protocolCount = buf.getShort(); List<ProtocolVersionId> keys = new ArrayList<>(protocolCount); for (int i = 0; i < protocolCount; i++) { keys.add(new ProtocolVersionId(buf.getInt(), buf.getShort())); // reserved buf.getShort(); } sync.setBootstrapSync(new BootstrapClientSync(requestId, keys)); }
private Set<ProtocolConnectionData> toProtocolConnectionData(OperationsNodeInfo node, TransportMetaData md, int version) { byte[] connectionData = null; Set<ProtocolConnectionData> result = new HashSet<>(); for (VersionConnectionInfoPair pair : md.getConnectionInfo()) { if (version == pair.getVersion()) { result.add(new ProtocolConnectionData(ServerNameUtil.crc32(node.getConnectionInfo()), new ProtocolVersionId(md.getId(), version), pair.getConenctionInfo().array()) ); } } return result; }
@Override public void run() { MessageEncoderDecoder crypt = getOrInitCrypt(); Map<Integer, PlatformEncDec> platformEncDecMap = getOrInitMap(platformProtocols); try { ClientSync request = decodeRequest(message, crypt, platformEncDecMap); LOG.trace("Processing request {}", request); BootstrapClientSync bsRequest = request.getBootstrapSync(); Set<ProtocolConnectionData> transports = opsListService.filter(bsRequest.getKeys()); BootstrapServerSync bsResponse = new BootstrapServerSync( bsRequest.getRequestId(), transports); ServerSync response = new ServerSync(); response.setRequestId(request.getRequestId()); response.setStatus(SyncStatus.SUCCESS); response.setBootstrapSync(bsResponse); LOG.trace("Response {}", response); encodeAndForward(message, crypt, platformEncDecMap, response); LOG.trace("Response forwarded to specific transport {}", response); } catch (Exception ex) { processErrors(message.getChannelContext(), message.getErrorBuilder(), ex); } }
private static BootstrapSyncResponse convert(BootstrapServerSync bootstrapSync) { if (bootstrapSync == null) { return null; } return new BootstrapSyncResponse( bootstrapSync.getRequestId(), convert(bootstrapSync.getProtocolList())); }
private static List<ProtocolVersionId> convert(List<ProtocolVersionPair> supportedProtocols) { if (supportedProtocols == null) { return Collections.emptyList(); } List<ProtocolVersionId> result = new ArrayList<ProtocolVersionId>(supportedProtocols.size()); for (ProtocolVersionPair pair : supportedProtocols) { result.add(new ProtocolVersionId(pair.getId(), pair.getVersion())); } return result; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ProtocolConnectionData other = (ProtocolConnectionData) obj; if (accessPointId != other.accessPointId) { return false; } if (!Arrays.equals(connectionData, other.connectionData)) { return false; } if (protocolVersionId == null) { if (other.protocolVersionId != null) { return false; } } else if (!protocolVersionId.equals(other.protocolVersionId)) { return false; } return true; }
private static BootstrapClientSync convert(BootstrapSyncRequest source) { if (source == null) { return null; } return new BootstrapClientSync(source.getRequestId(), convert(source.getSupportedProtocols())); }
? !bootstrapSync.equals(that.bootstrapSync) : that.bootstrapSync != null) { return false;
? !bootstrapSync.equals(that.bootstrapSync) : that.bootstrapSync != null) { return false;
@Override public int hashCode() { int result = requestId; result = 31 * result + (clientSyncMetaData != null ? clientSyncMetaData.hashCode() : 0); result = 31 * result + (bootstrapSync != null ? bootstrapSync.hashCode() : 0); result = 31 * result + (profileSync != null ? profileSync.hashCode() : 0); result = 31 * result + (forceConfigurationSync ? 1 : 0); result = 31 * result + (configurationSync != null ? configurationSync.hashCode() : 0); result = 31 * result + (forceNotificationSync ? 1 : 0); result = 31 * result + (notificationSync != null ? notificationSync.hashCode() : 0); result = 31 * result + (userSync != null ? userSync.hashCode() : 0); result = 31 * result + (eventSync != null ? eventSync.hashCode() : 0); result = 31 * result + (logSync != null ? logSync.hashCode() : 0); result = 31 * result + (useConfigurationRawSchema ? 1 : 0); return result; }
@Override public int hashCode() { int result = requestId; result = 31 * result + (status != null ? status.hashCode() : 0); result = 31 * result + (bootstrapSync != null ? bootstrapSync.hashCode() : 0); result = 31 * result + (profileSync != null ? profileSync.hashCode() : 0); result = 31 * result + (configurationSync != null ? configurationSync.hashCode() : 0); result = 31 * result + (notificationSync != null ? notificationSync.hashCode() : 0); result = 31 * result + (userSync != null ? userSync.hashCode() : 0); result = 31 * result + (eventSync != null ? eventSync.hashCode() : 0); result = 31 * result + (redirectSync != null ? redirectSync.hashCode() : 0); result = 31 * result + (logSync != null ? logSync.hashCode() : 0); return result; }