dcapwell commented on code in PR #3954:
URL: https://github.com/apache/cassandra/pull/3954#discussion_r1992444373
##########
src/java/org/apache/cassandra/service/accord/serializers/TopologySerializers.java:
##########
@@ -101,96 +77,85 @@ public <V> Node.Id deserialize(ByteBuffer src, int
position)
return new Node.Id(src.getInt(position));
}
- public int serializedSize()
- {
- return TypeSizes.INT_SIZE; // id.id
- }
-
@Override
- public long serializedSize(Node.Id id, int version)
+ public long serializedSize(Node.Id id)
{
- return serializedSize();
- }
-
- @Override
- public long serializedSize(Node.Id t, Version version)
- {
- return serializedSize();
+ return TypeSizes.INT_SIZE; // id.id
}
- };
+ }
- public static final IVersionedSerializer<Shard> shard = new
ShardSerializer((IVersionedSerializer<Range>)
-
(IVersionedSerializer<?>)
-
TokenRange.serializer);
+ public static final Serializer<Shard> shard = new
ShardSerializer((Serializer<Range>)
+
(Serializer<?>)
+
TokenRange.serializer);
- public static class ShardSerializer implements IVersionedSerializer<Shard>
+ public static class ShardSerializer implements Serializer<Shard>
{
- protected IVersionedSerializer<Range> range;
+ protected Serializer<Range> range;
- public ShardSerializer(IVersionedSerializer<Range> range)
+ public ShardSerializer(Serializer<Range> range)
{
this.range = range;
}
@Override
- public void serialize(Shard shard, DataOutputPlus out, int version)
throws IOException
+ public void serialize(Shard shard, DataOutputPlus out) throws
IOException
{
- range.serialize(shard.range, out, version);
- CollectionSerializers.serializeList(shard.nodes, out, version,
nodeId);
- CollectionSerializers.serializeList(shard.notInFastPath, out,
version, nodeId);
- CollectionSerializers.serializeList(shard.joining, out, version,
nodeId);
+ range.serialize(shard.range, out);
+ CollectionSerializers.serializeList(shard.nodes, out, nodeId);
+ CollectionSerializers.serializeList(shard.notInFastPath, out,
nodeId);
+ CollectionSerializers.serializeList(shard.joining, out, nodeId);
out.writeUnsignedVInt32(shard.flags().bitset());
}
@Override
- public Shard deserialize(DataInputPlus in, int version) throws
IOException
+ public Shard deserialize(DataInputPlus in) throws IOException
{
- Range range = ShardSerializer.this.range.deserialize(in, version);
- SortedArrayList<Node.Id> nodes =
CollectionSerializers.deserializeSortedArrayList(in, version, nodeId,
Node.Id[]::new);
- SortedArrayList<Node.Id> notInFastPath =
CollectionSerializers.deserializeSortedArrayList(in, version, nodeId,
Node.Id[]::new);
- SortedArrayList<Node.Id> joining =
CollectionSerializers.deserializeSortedArrayList(in, version, nodeId,
Node.Id[]::new);
+ Range range = ShardSerializer.this.range.deserialize(in);
+ SortedArrayList<Node.Id> nodes =
CollectionSerializers.deserializeSortedArrayList(in, nodeId, Node.Id[]::new);
+ SortedArrayList<Node.Id> notInFastPath =
CollectionSerializers.deserializeSortedArrayList(in, nodeId, Node.Id[]::new);
+ SortedArrayList<Node.Id> joining =
CollectionSerializers.deserializeSortedArrayList(in, nodeId, Node.Id[]::new);
int flags = in.readUnsignedVInt32();
return Shard.SerializerSupport.create(range, nodes, notInFastPath,
joining, new TinyEnumSet<>(flags));
}
@Override
- public long serializedSize(Shard shard, int version)
+ public long serializedSize(Shard shard)
{
- long size = range.serializedSize(shard.range, version);
- size += CollectionSerializers.serializedListSize(shard.nodes,
version, nodeId);
- size +=
CollectionSerializers.serializedListSize(shard.notInFastPath, version, nodeId);
- size += CollectionSerializers.serializedListSize(shard.joining,
version, nodeId);
+ long size = range.serializedSize(shard.range);
+ size += CollectionSerializers.serializedListSize(shard.nodes,
nodeId);
+ size +=
CollectionSerializers.serializedListSize(shard.notInFastPath, nodeId);
+ size += CollectionSerializers.serializedListSize(shard.joining,
nodeId);
size += TypeSizes.sizeofUnsignedVInt(shard.flags().bitset());
return size;
}
- };
+ }
- public static final IVersionedSerializer<Topology> topology = new
IVersionedSerializer<>()
+ public static final Serializer<Topology> topology = new Serializer<>()
{
@Override
- public void serialize(Topology topology, DataOutputPlus out, int
version) throws IOException
+ public void serialize(Topology topology, DataOutputPlus out) throws
IOException
{
out.writeLong(topology.epoch());
- ArraySerializers.serializeArray(topology.unsafeGetShards(), out,
version, shard);
Review Comment:
`unsafeGetShards` is unsafe and causes this to fail. we have a `local` and
`global` topology we serialize, but the `local` topology comes back as `global`
when we deserialize! moving to `shards` makes sure we respect this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]