Coverage Report - org.apache.giraph.time.Time
 
Classes in this File Line Coverage Branch Coverage Complexity
Time
N/A
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 package org.apache.giraph.time;
 20  
 
 21  
 import java.util.Date;
 22  
 
 23  
 /**
 24  
  * Interface for handling Time related operations so that they can be mocked
 25  
  * for testing.
 26  
  */
 27  
 public interface Time {
 28  
   /** Microseconds per millisecond */
 29  
   long US_PER_MS = 1000;
 30  
   /** Nanoseconds per microsecond */
 31  
   long NS_PER_US = 1000;
 32  
   /** Nanoseconds per millisecond */
 33  
   long NS_PER_MS = US_PER_MS * NS_PER_US;
 34  
   /** Milliseconds per second */
 35  
   long MS_PER_SECOND = 1000;
 36  
   /** Milliseconds per second (as float) */
 37  
   float MS_PER_SECOND_AS_FLOAT = MS_PER_SECOND * 1f;
 38  
   /** Microseconds per second */
 39  
   long US_PER_SECOND = US_PER_MS * MS_PER_SECOND;
 40  
   /** Microseconds per second (as float) */
 41  
   float US_PER_SECOND_AS_FLOAT = US_PER_SECOND * 1f;
 42  
   /** Nanoseconds per second */
 43  
   long NS_PER_SECOND = NS_PER_US * US_PER_SECOND;
 44  
   /** Nanoseconds per second (as float) */
 45  
   float NS_PER_SECOND_AS_FLOAT = NS_PER_SECOND * 1f;
 46  
   /** Seconds per hour */
 47  
   long SECONDS_PER_HOUR = 60 * 60;
 48  
   /** Seconds per day */
 49  
   long SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
 50  
   /** Milliseconds per hour */
 51  
   long MS_PER_HOUR = SECONDS_PER_HOUR * MS_PER_SECOND;
 52  
   /** Milliseconds per day */
 53  
   long MS_PER_DAY = SECONDS_PER_DAY * MS_PER_SECOND;
 54  
 
 55  
   /**
 56  
    * Get the current milliseconds
 57  
    *
 58  
    * @return The difference, measured in milliseconds, between
 59  
    *         the current time and midnight, January 1, 1970 UTC.
 60  
    */
 61  
   long getMilliseconds();
 62  
 
 63  
   /**
 64  
    * Get the current microseconds
 65  
    *
 66  
    * @return The difference, measured in microseconds, between
 67  
    *         the current time and midnight, January 1, 1970 UTC.
 68  
    */
 69  
   long getMicroseconds();
 70  
 
 71  
   /**
 72  
    * Get the current nanoseconds
 73  
    *
 74  
    * @return The difference, measured in nanoseconds, between
 75  
    *         the current time and midnight, January 1, 1970 UTC.
 76  
    */
 77  
   long getNanoseconds();
 78  
 
 79  
   /**
 80  
    * Get the current seconds
 81  
    *
 82  
    * @return The difference, measured in seconds, between
 83  
    *         the current time and midnight, January 1, 1970 UTC.
 84  
    */
 85  
   int getSeconds();
 86  
 
 87  
   /**
 88  
    * Get the current date
 89  
    *
 90  
    * @return Current date
 91  
    */
 92  
   Date getCurrentDate();
 93  
 
 94  
   /**
 95  
    * Current thread should sleep for some number of milliseconds.
 96  
    *
 97  
    * @param milliseconds Milliseconds to sleep for
 98  
    * @throws InterruptedException
 99  
    */
 100  
   void sleep(long milliseconds) throws InterruptedException;
 101  
 }