Bump cds-access-api ABIVersion
[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 org.opendaylight.yangtools.concepts.WritableObjects;
14
15 abstract class AbstractResponseEnvelopeProxy<T extends Response<?, ?>> extends AbstractEnvelopeProxy<T> {
16     private static final long serialVersionUID = 1L;
17
18     private long executionTimeNanos;
19
20     AbstractResponseEnvelopeProxy() {
21         // for Externalizable
22     }
23
24     AbstractResponseEnvelopeProxy(final ResponseEnvelope<T> envelope) {
25         super(envelope);
26         this.executionTimeNanos = envelope.getExecutionTimeNanos();
27     }
28
29     @Override
30     public final void writeExternal(final ObjectOutput out) throws IOException {
31         super.writeExternal(out);
32         WritableObjects.writeLong(out, executionTimeNanos);
33     }
34
35     @Override
36     public final void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
37         super.readExternal(in);
38         executionTimeNanos = WritableObjects.readLong(in);
39     }
40
41     @Override
42     final ResponseEnvelope<T> createEnvelope(final T message, final long sessionId, final long txSequence) {
43         return createEnvelope(message, sessionId, txSequence, executionTimeNanos);
44     }
45
46     @SuppressWarnings("checkstyle:hiddenField")
47     abstract ResponseEnvelope<T> createEnvelope(T message, long sessionId, long txSequence, long executionTimeNanos);
48 }