List of usage examples for java.lang Long MIN_VALUE
long MIN_VALUE
To view the source code for java.lang Long MIN_VALUE.
Click Source Link
From source file:br.com.autonomiccs.cloudTraces.main.CloudTracesSimulator.java
public static void main(String[] args) { validateInputFile(args);// w ww .j a va 2 s .com String cloudTracesFile = args[0]; Collection<VirtualMachine> virtualMachines = getAllVirtualMachinesFromCloudTraces(cloudTracesFile); logger.info(String.format("#VirtualMachines [%d] found on [%s].", virtualMachines.size(), cloudTracesFile)); Map<Integer, List<VirtualMachine>> mapVirtualMachinesTaskExecutionByTime = createMapVirtualMachinesTaskExecutionByTime( virtualMachines); logger.info(String.format("#Times [%d] that have tasks being executed by VMs ", mapVirtualMachinesTaskExecutionByTime.size())); Cloud cloud = createCloudEnvirtonmentToStartsimulation(); logger.info("Cloud configuration: " + cloud); List<Integer> timesToExecuteTasks = new ArrayList<>(mapVirtualMachinesTaskExecutionByTime.keySet()); Collections.sort(timesToExecuteTasks); Integer firstTimeInTimeUnitOfUsedCloudData = timesToExecuteTasks.get(0); Integer lastTimeInTimeUnitOfUserCloudData = timesToExecuteTasks.get(timesToExecuteTasks.size() - 1); logger.info("First time: " + firstTimeInTimeUnitOfUsedCloudData); logger.info("Last time: " + lastTimeInTimeUnitOfUserCloudData); double timeUnitPerLoopIteration = getTimeUnitPerLoopIteration(firstTimeInTimeUnitOfUsedCloudData, lastTimeInTimeUnitOfUserCloudData); logger.info("The time unit converted to trace time: " + timeUnitPerLoopIteration); double currentTime = firstTimeInTimeUnitOfUsedCloudData; long highetResourceAllocation = Long.MIN_VALUE; String cloudStateHighestMemoryAllocation = ""; while (currentTime < lastTimeInTimeUnitOfUserCloudData + 2 * timeUnitPerLoopIteration) { logger.debug("Current time of iteration: " + currentTime); if (cloud.getMemoryAllocatedInBytes() > highetResourceAllocation) { highetResourceAllocation = cloud.getMemoryAllocatedInBytes(); cloudStateHighestMemoryAllocation = cloud.toString(); } applyLoadOnCloudForCurrentTime(mapVirtualMachinesTaskExecutionByTime, cloud, currentTime); destroyVirtualMachinesIfNeeded(cloud, currentTime); logger.info(String.format("Time [%.3f], cloud state [%s] ", currentTime, cloud)); executeManagement(cloud, currentTime); logClustersConfigurationsAndStdAtTime(cloud.getClusters(), currentTime); currentTime += timeUnitPerLoopIteration; } logger.info("Cloud configuration after simulation: " + cloud); logger.info("Cloud highestResourceUsage: " + cloudStateHighestMemoryAllocation); }
From source file:Main.java
public static void writeDate(Parcel parcel, Date date) { if (date == null) { parcel.writeLong(Long.MIN_VALUE); } else {//from w ww . jav a2 s .c o m parcel.writeLong(date.getTime()); } }
From source file:Main.java
public static String getDailyDate(long millis) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); if (millis != Long.MIN_VALUE) { Date dt = new Date(millis); return sdf.format(dt); } else {// w ww . j a v a2s .co m return ""; } }
From source file:Main.java
public static String GetDateStringFromLong(long millis) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if (millis != Long.MIN_VALUE) { java.util.Date dt = new Date(millis); return sdf.format(dt); } else {//from ww w . j a va2 s . co m return "1900-01-01 00:00:00"; } }
From source file:Main.java
public static long betweenSecond1(String t1, String t2, String... patterns) { long betweenSecond = betweenMilli1(t1, t2, patterns); if (betweenSecond != Long.MIN_VALUE) { betweenSecond /= 1000;/*from w ww . j a va 2 s . c o m*/ } return betweenSecond; }
From source file:Main.java
public static long betweenMinute1(String t1, String t2, String... patterns) { long betweenMinute = betweenSecond1(t1, t2, patterns); if (betweenMinute != Long.MIN_VALUE) { betweenMinute /= 60;/*from w w w .j ava 2s . co m*/ } return betweenMinute; }
From source file:Main.java
/** Helper method - gets a named attribute's value as a <I>long</I>. @param pNodeMap The <I>NamedNodeMap</I>. @param strName Name of the attribute. @return Value of the attribute./*from w ww . j a v a 2s .co m*/ */ public static long getAttributeLong(NamedNodeMap pNodeMap, String strName) throws ClassCastException, NumberFormatException { String strValue = getAttributeString(pNodeMap, strName); if (null == strValue) return Long.MIN_VALUE; return Long.parseLong(strValue); }
From source file:Main.java
/** Helper method - gets a named element's value as a <I>long</I>. @param pElement The parent <I>Element</I>. @param strName Name of the element./*www .j a v a 2 s. co m*/ @return Value of the element. */ public static long getElementLong(Element pElement, String strName) throws ClassCastException, NumberFormatException { String strValue = getElementString(pElement, strName); if (null == strValue) return Long.MIN_VALUE; return Long.parseLong(strValue); }
From source file:Main.java
public static long pmax(final long[][] arr, int numThreads) { ExecutorService pool = Executors.newFixedThreadPool(numThreads); try {// w ww. j ava 2 s. c o m List<Future<Long>> list = new ArrayList<Future<Long>>(); for (int i = 0; i < arr.length; i++) { final long[] subArr = arr[i]; list.add(pool.submit(new Callable<Long>() { public Long call() { long max = Long.MIN_VALUE; for (int j = 0; j < subArr.length; j++) { if (subArr[j] > max) { max = subArr[j]; } } return max; } })); } // find the max of each slice's max: long max = Long.MIN_VALUE; for (Future<Long> future : list) { long threadMax = future.get(); System.out.println("threadMax: " + threadMax); if (threadMax > max) { max = threadMax; } } return max; } catch (Exception e) { System.out.println(e); return -1; } finally { pool.shutdown(); } }
From source file:Main.java
public static android.location.Location getLastBestLocation(Context _context) { if (locManager == null) locManager = (LocationManager) _context.getSystemService(Context.LOCATION_SERVICE); int minDistance = (int) 500; long minTime = System.currentTimeMillis() - (900 * 1000); android.location.Location bestResult = null; float bestAccuracy = Float.MAX_VALUE; long bestTime = Long.MIN_VALUE; // Iterate through all the providers on the system, keeping // note of the most accurate result within the acceptable time limit. // If no result is found within maxTime, return the newest Location. List<String> matchingProviders = locManager.getAllProviders(); for (String provider : matchingProviders) { android.location.Location location = locManager.getLastKnownLocation(provider); if (location != null) { // log(TAG, " location: " + location.getLatitude() + "," + location.getLongitude() + "," + location.getAccuracy() + "," + location.getSpeed() + "m/s"); float accuracy = location.getAccuracy(); long time = location.getTime(); // log(TAG, "time>minTime: " + (time > minTime) + ", accuracy<bestAccuracy: " + (accuracy < bestAccuracy)); // if ((time > minTime && accuracy < bestAccuracy)) { if (accuracy < bestAccuracy) { bestResult = location;// w w w . j a v a2 s . c o m bestAccuracy = accuracy; bestTime = time; } } } return bestResult; }