private byte[] hash(OperationsNodeInfo node, int replica) { byte[] key = node.getConnectionInfo().getPublicKey().array(); ByteBuffer data = ByteBuffer.wrap(new byte[key.length + SIZE_OF_INT]); data.put(key); data.putInt(replica); return md5.get().digest(data.array()); }
/** * Use when one need to write an OperationsNodeInfo instance to logs. The OperationsNodeInfo * instance has ByteBuffer fields which should be represented in log files as null because their * values are unrepresentative and redundant. * * @param format the format string * @param node the instance of OperationsNodeInfo * @param resolver the instance of OperationsServerResolver */ private void writeLogWithoutByteBuffer(String format, OperationsNodeInfo node, OperationsServerResolver resolver) { // Temporary remove connection info for transports Map<TransportMetaData, Map<VersionConnectionInfoPair, ByteBuffer>> transportMetaData = new HashMap<>(); node.getTransports().forEach(transport -> transportMetaData.put(transport, removeTransportConnectionInfo(transport))); // Temporary remove public key final ByteBuffer publicKey = node.getConnectionInfo().getPublicKey(); node.getConnectionInfo().setPublicKey(null); LOG.info(format, node, resolver); // Restore connection info for transports node.getTransports().forEach(transport -> restoreTransportConnectionInfo(transport, transportMetaData.get(transport))); // Restore public key node.getConnectionInfo().setPublicKey(publicKey); }