blob: 5ef8c32a7447f21169d29d8f9ca2951910b6cf59 [file] [log] [blame]
Madan Jampani05833872016-07-12 23:01:39 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Madan Jampani05833872016-07-12 23:01:39 -07003 *
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 */
16package org.onosproject.core;
17
18import org.onosproject.store.service.WallClockTimestamp;
19
20/**
21 * The <a href="http://www.cse.buffalo.edu/tech-reports/2014-04.pdf">hybrid logical time</a> keeper service.
22 */
23public interface HybridLogicalClockService {
24
25 /**
26 * Returns the current hybrid logical time.
27 * @return current hybrid logical time
28 */
29 HybridLogicalTime timeNow();
30
31 /**
32 * Records a (receive) event and accordingly makes adjustments to the hybrid logical time.
33 * @param time received event time
34 */
35 void recordEventTime(HybridLogicalTime time);
36
37 /**
38 * Returns the current time derived from the hybrid logical time.
39 * @return current system time
40 */
41 default long now() {
42 return timeNow().time();
43 }
44
45 /**
46 * Returns the current time as a {@code WallClockTimestamp}.
47 * @return wall clock timestamp
48 */
49 default WallClockTimestamp wallClockTimestamp() {
50 return new WallClockTimestamp(now());
51 }
52}