blob: 76b44a008ced3c64e2a4bf9272e9b92291abdeb5 [file] [log] [blame]
Carmelo Cascone6a0b5a32017-11-20 23:08:32 -08001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.drivers.p4runtime.mirror;
18
19import org.onosproject.net.pi.runtime.PiEntity;
20import org.onosproject.store.service.WallClockTimestamp;
21
22public class TimedEntry<E extends PiEntity> {
23
24 private final long timestamp;
25 private final E entity;
26
27 TimedEntry(long timestamp, E entity) {
28 this.timestamp = timestamp;
29 this.entity = entity;
30 }
31
32 public long timestamp() {
33 return timestamp;
34 }
35
36 public E entry() {
37 return entity;
38 }
39
40 public long lifeSec() {
41 final long now = new WallClockTimestamp().unixTimestamp();
42 return (now - timestamp) / 1000;
43 }
44}