private void logHashMismatch(GetDeltaRequest request, EndpointProfileDto profile, String endpointId) { if (profile.getConfigurationHash() != null && LOG.isWarnEnabled()) { String serverHash = ""; String clientHash = ""; if (profile.getConfigurationHash() != null) { serverHash = MessageEncoderDecoder.bytesToHex(profile.getConfigurationHash()); } if (request.getConfigurationHash() != null) { clientHash = MessageEncoderDecoder.bytesToHex(request.getConfigurationHash().getData()); } LOG.warn("[{}] Configuration hash mismatch! server {}, client {}", endpointId, serverHash, clientHash); } }
@Override public GetDeltaResponse getDelta(GetDeltaRequest request) throws GetDeltaException { GetDeltaResponse response; EndpointProfileDto profile = request.getEndpointProfile(); String endpointId = "N/A"; if (LOG.isDebugEnabled() && profile != null && profile.getEndpointKeyHash() != null) { endpointId = Base64Util.encode(profile.getEndpointKeyHash()); } LOG.debug("[{}][{}] Processing configuration request", request.getApplicationToken(), endpointId); boolean resync = false; if (request.isFirstRequest()) { resync = true; } else if (!request.getConfigurationHash().binaryEquals(profile.getConfigurationHash())) { logHashMismatch(request, profile, endpointId); resync = true; } if (resync) { EndpointConfigurationDto configurationDto = cacheService.getConfByHash( EndpointObjectHash.fromBytes(profile .getConfigurationHash())); response = new GetDeltaResponse(GetDeltaResponseType.CONF_RESYNC, new BaseBinaryDelta( configurationDto.getConfiguration())); } else { response = new GetDeltaResponse(GetDeltaResponseType.NO_DELTA); } LOG.debug("[{}][{}] Processed configuration request {}", request.getApplicationToken(), endpointId, response.getResponseType()); return response; }
this.profileVersion = dto.getClientProfileVersion(); this.serverProfileVersion = dto.getServerProfileVersion(); this.configurationHash = dto.getConfigurationHash(); this.userConfigurationHash = dto.getUserConfigurationHash(); this.configurationVersion = dto.getConfigurationVersion();
this.profileVersion = dto.getClientProfileVersion(); this.serverProfileVersion = dto.getServerProfileVersion(); this.configurationHash = getByteBuffer(dto.getConfigurationHash()); this.userConfigurationHash = getByteBuffer(dto.getUserConfigurationHash()); this.configurationVersion = dto.getConfigurationVersion();