+public final class RoutingTable implements BucketData<RoutingTable>, Serializable {
+ private static final class Proxy implements Externalizable {
+ private static final long serialVersionUID = 1L;
+
+ @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "We deal with the field in serialization methods.")
+ private Collection<DOMRpcIdentifier> rpcs;
+ private ActorRef rpcInvoker;
+
+ // checkstyle flags the public modifier as redundant however it is explicitly needed for Java serialization to
+ // be able to create instances via reflection.
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public Proxy() {
+ // For Externalizable
+ }
+
+ Proxy(final RoutingTable table) {
+ rpcs = table.getRoutes();
+ rpcInvoker = table.getRpcInvoker();
+ }
+
+ @Override
+ public void writeExternal(final ObjectOutput out) throws IOException {
+ out.writeObject(Serialization.serializedActorPath(rpcInvoker));
+
+ final NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(out);
+ nnout.writeInt(rpcs.size());
+ for (DOMRpcIdentifier id : rpcs) {
+ nnout.writeSchemaPath(id.getType());
+ nnout.writeYangInstanceIdentifier(id.getContextReference());
+ }
+ }
+
+ @Override
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+ rpcInvoker = JavaSerializer.currentSystem().value().provider().resolveActorRef((String) in.readObject());
+
+ final NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(in);
+ final int size = nnin.readInt();
+ rpcs = new ArrayList<>(size);
+ for (int i = 0; i < size; ++i) {
+ rpcs.add(DOMRpcIdentifier.create(nnin.readSchemaPath(), nnin.readYangInstanceIdentifier()));
+ }
+ }
+
+ private Object readResolve() {
+ return new RoutingTable(rpcInvoker, rpcs);
+ }
+ }
+