7c35a3fd53081c47dd8eb821398733e7f6c56496
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / AbstractResponseEnvelopeProxy.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.access.concepts;
9
10 import java.io.IOException;
11 import java.io.ObjectInput;
12 import java.io.ObjectOutput;
13 import java.io.Serial;
14 import org.opendaylight.yangtools.concepts.WritableObjects;
15
16 abstract class AbstractResponseEnvelopeProxy<T extends Response<?, ?>> extends AbstractEnvelopeProxy<T> {
17     @Serial
18     private static final long serialVersionUID = 1L;
19
20     private long executionTimeNanos;
21
22     AbstractResponseEnvelopeProxy() {
23         // for Externalizable
24     }
25
26     AbstractResponseEnvelopeProxy(final ResponseEnvelope<T> envelope) {
27         super(envelope);
28         this.executionTimeNanos = envelope.getExecutionTimeNanos();
29     }
30
31     @Override
32     public final void writeExternal(final ObjectOutput out) throws IOException {
33         super.writeExternal(out);
34         WritableObjects.writeLong(out, executionTimeNanos);
35     }
36
37     @Override
38     public final void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
39         super.readExternal(in);
40         executionTimeNanos = WritableObjects.readLong(in);
41     }
42
43     @Override
44     final ResponseEnvelope<T> createEnvelope(final T message, final long sessionId, final long txSequence) {
45         return createEnvelope(message, sessionId, txSequence, executionTimeNanos);
46     }
47
48     @SuppressWarnings("checkstyle:hiddenField")
49     abstract ResponseEnvelope<T> createEnvelope(T message, long sessionId, long txSequence, long executionTimeNanos);
50 }