90fe7beb11e72a92111f4eeea323aaa8c48b9516
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / concepts / ResponseEnvelope.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 com.google.common.base.Preconditions;
11 import java.io.Serial;
12
13 public abstract class ResponseEnvelope<T extends Response<?, ?>> extends Envelope<T> {
14     @Serial
15     private static final long serialVersionUID = 1L;
16
17     private final long executionTimeNanos;
18
19     ResponseEnvelope(final T message, final long sessionId, final long txSequence, final long executionTimeNanos) {
20         super(message, sessionId, txSequence);
21         Preconditions.checkArgument(executionTimeNanos >= 0);
22         this.executionTimeNanos = executionTimeNanos;
23     }
24
25     /**
26      * Return the time the request took to execute in nanoseconds. This may not reflect the actual CPU time, but rather
27      * a measure of the complexity involved in servicing the original request.
28      *
29      * @return Time the request took to execute in nanoseconds
30      */
31     public final long getExecutionTimeNanos() {
32         return executionTimeNanos;
33     }
34
35     @Override
36     abstract AbstractResponseEnvelopeProxy<T> createProxy();
37 }