/** * Gets metrics map. * * @return Metrics map. */ public ClusterMetrics metrics() { return ClusterMetricsSnapshot.deserialize(metrics, 0); }
/** * @return Deserialized metrics. */ public ClusterMetrics metrics() { return ClusterMetricsSnapshot.deserialize(metrics, 0); }
@Override public T2<UUID, ClusterMetrics> apply(byte[] bytes) { UUID nodeId = new UUID(U.bytesToLong(bytes, 0), U.bytesToLong(bytes, 8)); return new T2<>(nodeId, ClusterMetricsSnapshot.deserialize(bytes, 16)); } });
/** * Checks compatibility with old serialized metrics. */ @Test public void testMetricsCompatibility() { ClusterMetrics metrics = ClusterMetricsSnapshot.deserialize(METRICS_V1, 0); assert metrics != null; }
/** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = U.readUuid(in); consistentId = (Serializable) in.readObject(); internalId = in.readLong(); order = in.readLong(); ver = (IgniteProductVersion) in.readObject(); attrs = U.sealMap(U.readMap(in)); addrs = U.readCollection(in); hostNames = U.readCollection(in); sesTimeout = in.readLong(); flags = in.readByte(); // Cluster metrics byte[] mtr = U.readByteArray(in); if (mtr != null) metrics = ClusterMetricsSnapshot.deserialize(mtr, 0); }
metrics = ClusterMetricsSnapshot.deserialize(mtr, 0);
/** */ @Test public void testMetricsSize() { byte[] data = new byte[ClusterMetricsSnapshot.METRICS_SIZE]; // Test serialization. int off = ClusterMetricsSnapshot.serialize(data, 0, createMetrics()); assert off == ClusterMetricsSnapshot.METRICS_SIZE; // Test deserialization. ClusterMetrics res = ClusterMetricsSnapshot.deserialize(data, 0); assert res != null; }
/** */ @Test public void testSerialization() { byte[] data = new byte[ClusterMetricsSnapshot.METRICS_SIZE]; ClusterMetrics metrics1 = createMetrics(); // Test serialization. int off = ClusterMetricsSnapshot.serialize(data, 0, metrics1); assert off == ClusterMetricsSnapshot.METRICS_SIZE; // Test deserialization. ClusterMetrics metrics2 = ClusterMetricsSnapshot.deserialize(data, 0); assert metrics2 != null; assert isMetricsEquals(metrics1, metrics2); }
/** * @param discoCache Discovery data cache. * @param nodeId Node ID. * @param metricsBytes Marshalled metrics. */ private void updateNodeMetrics(DiscoCache discoCache, UUID nodeId, byte[] metricsBytes) { ClusterNode node = discoCache.node(nodeId); if (node == null || !discoCache.alive(nodeId)) return; try { ClusterNodeMetrics metrics = U.unmarshalZip(ctx.config().getMarshaller(), metricsBytes, null); assert node instanceof IgniteClusterNode : node; IgniteClusterNode node0 = (IgniteClusterNode)node; node0.setMetrics(ClusterMetricsSnapshot.deserialize(metrics.metrics(), 0)); node0.setCacheMetrics(metrics.cacheMetrics()); ctx.discovery().metricsUpdateEvent(discoCache, node0); } catch (IgniteCheckedException e) { U.warn(log, "Failed to unmarshal node metrics: " + e); } }
/** * @return Deserialized metrics. */ public ClusterMetrics metrics() { return ClusterMetricsSnapshot.deserialize(metrics, 0); }
/** * Gets metrics map. * * @return Metrics map. */ public ClusterMetrics metrics() { return ClusterMetricsSnapshot.deserialize(metrics, 0); }
@Override public T2<UUID, ClusterMetrics> apply(byte[] bytes) { UUID nodeId = new UUID(U.bytesToLong(bytes, 0), U.bytesToLong(bytes, 8)); return new T2<>(nodeId, ClusterMetricsSnapshot.deserialize(bytes, 16)); } });
metrics = ClusterMetricsSnapshot.deserialize(mtr, 0);
/** * @param discoCache Discovery data cache. * @param nodeId Node ID. * @param metricsBytes Marshalled metrics. */ private void updateNodeMetrics(DiscoCache discoCache, UUID nodeId, byte[] metricsBytes) { ClusterNode node = discoCache.node(nodeId); if (node == null || !discoCache.alive(nodeId)) return; try { ClusterNodeMetrics metrics = U.unmarshalZip(ctx.config().getMarshaller(), metricsBytes, null); assert node instanceof IgniteClusterNode : node; IgniteClusterNode node0 = (IgniteClusterNode)node; node0.setMetrics(ClusterMetricsSnapshot.deserialize(metrics.metrics(), 0)); node0.setCacheMetrics(metrics.cacheMetrics()); ctx.discovery().metricsUpdateEvent(discoCache, node0); } catch (IgniteCheckedException e) { U.warn(log, "Failed to unmarshal node metrics: " + e); } }