Search in sources :

Example 1 with NormalizedNodeDataInput

use of org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput in project controller by opendaylight.

the class DataChanged method readExternal.

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    // Read the version
    in.readShort();
    NormalizedNodeDataInput streamReader = NormalizedNodeInputOutput.newDataInputWithoutValidation(in);
    // Note: the scope passed to builder is not actually used.
    Builder builder = DOMImmutableDataChangeEvent.builder(DataChangeScope.SUBTREE);
    // Read created data
    int size = in.readInt();
    for (int i = 0; i < size; i++) {
        YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
        NormalizedNode<?, ?> node = streamReader.readNormalizedNode();
        builder.addCreated(path, node);
    }
    // Read updated data
    size = in.readInt();
    for (int i = 0; i < size; i++) {
        YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
        NormalizedNode<?, ?> before = streamReader.readNormalizedNode();
        NormalizedNode<?, ?> after = streamReader.readNormalizedNode();
        builder.addUpdated(path, before, after);
    }
    // Read removed data
    size = in.readInt();
    for (int i = 0; i < size; i++) {
        YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier();
        NormalizedNode<?, ?> node = streamReader.readNormalizedNode();
        builder.addRemoved(path, node);
    }
    // Read original subtree
    boolean present = in.readBoolean();
    if (present) {
        builder.setBefore(streamReader.readNormalizedNode());
    }
    // Read updated subtree
    present = in.readBoolean();
    if (present) {
        builder.setAfter(streamReader.readNormalizedNode());
    }
    change = builder.build();
}
Also used : Builder(org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder) NormalizedNodeDataInput(org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 2 with NormalizedNodeDataInput

use of org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput in project controller by opendaylight.

the class DataTreeCandidateInputOutput method readDataTreeCandidate.

public static DataTreeCandidate readDataTreeCandidate(final DataInput in) throws IOException {
    final NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(in);
    final YangInstanceIdentifier rootPath = reader.readYangInstanceIdentifier();
    final byte type = reader.readByte();
    final DataTreeCandidateNode rootNode;
    switch(type) {
        case APPEARED:
            rootNode = ModifiedDataTreeCandidateNode.create(ModificationType.APPEARED, readChildren(reader));
            break;
        case DELETE:
            rootNode = DeletedDataTreeCandidateNode.create();
            break;
        case DISAPPEARED:
            rootNode = ModifiedDataTreeCandidateNode.create(ModificationType.DISAPPEARED, readChildren(reader));
            break;
        case SUBTREE_MODIFIED:
            rootNode = ModifiedDataTreeCandidateNode.create(ModificationType.SUBTREE_MODIFIED, readChildren(reader));
            break;
        case WRITE:
            rootNode = DataTreeCandidateNodes.fromNormalizedNode(reader.readNormalizedNode());
            break;
        case UNMODIFIED:
            rootNode = AbstractDataTreeCandidateNode.createUnmodified();
            break;
        default:
            throw new IllegalArgumentException("Unhandled node type " + type);
    }
    return DataTreeCandidates.newDataTreeCandidate(rootPath, rootNode);
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) NormalizedNodeDataInput(org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 3 with NormalizedNodeDataInput

use of org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput in project controller by opendaylight.

the class ModifyTransactionRequestProxyV1 method readExternal.

@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);
    protocol = Optional.ofNullable(PersistenceProtocol.readFrom(in));
    final int size = in.readInt();
    if (size != 0) {
        modifications = new ArrayList<>(size);
        final NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(in);
        for (int i = 0; i < size; ++i) {
            modifications.add(TransactionModification.readFrom(nnin));
        }
    } else {
        modifications = ImmutableList.of();
    }
}
Also used : NormalizedNodeDataInput(org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput)

Aggregations

NormalizedNodeDataInput (org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 Builder (org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder)1 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode)1