Skip to content

Instantly share code, notes, and snippets.

@snallami
Created July 7, 2019 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snallami/d917ec049e5d80e4206e2ce0cd2ef895 to your computer and use it in GitHub Desktop.
Save snallami/d917ec049e5d80e4206e2ce0cd2ef895 to your computer and use it in GitHub Desktop.
If minuphours = 0 , code will be evaluating other rules like idle termination time i.e. as if this option doesn't exist.See below code. It prints "Evaluate other rules" message if minUpHours=0
import java.util.concurrent.TimeUnit;
public class MinCheck {
public static void main(String[] args) {
// Check min number of hours instance must be up - if stayed up at least that minimum.
int minUpHours = 0;
long uptime = 5 * 60 * 1000; // 5 minutes
long minUpHoursInMills = TimeUnit.MILLISECONDS.toHours(minUpHours);
if (minUpHoursInMills > uptime) {
System.out.println("Do nothing, just return back ");
} else {
System.out.println("Evaluate other rules");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment