edu.cmu.sei.ams.cloudlet.rank.CpuBasedRanker Maven / Gradle / Ivy
/*
KVM-based Discoverable Cloudlet (KD-Cloudlet)
Copyright (c) 2015 Carnegie Mellon University.
All Rights Reserved.
THIS SOFTWARE IS PROVIDED "AS IS," WITH NO WARRANTIES WHATSOEVER. CARNEGIE MELLON UNIVERSITY EXPRESSLY DISCLAIMS TO THE FULLEST EXTENT PERMITTEDBY LAW ALL EXPRESS, IMPLIED, AND STATUTORY WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY RIGHTS.
Released under a modified BSD license, please see license.txt for full terms.
DM-0002138
KD-Cloudlet includes and/or makes use of the following Third-Party Software subject to their own licenses:
MiniMongo
Copyright (c) 2010-2014, Steve Lacy
All rights reserved. Released under BSD license.
https://github.com/MiniMongo/minimongo/blob/master/LICENSE
Bootstrap
Copyright (c) 2011-2015 Twitter, Inc.
Released under the MIT License
https://github.com/twbs/bootstrap/blob/master/LICENSE
jQuery JavaScript Library v1.11.0
http://jquery.com/
Includes Sizzle.js
http://sizzlejs.com/
Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
Released under the MIT license
http://jquery.org/license
*/
package edu.cmu.sei.ams.cloudlet.rank;
import edu.cmu.sei.ams.cloudlet.Cloudlet;
import edu.cmu.sei.ams.cloudlet.CloudletException;
import edu.cmu.sei.ams.cloudlet.CloudletSystemInfo;
import edu.cmu.sei.ams.cloudlet.Service;
import edu.cmu.sei.ams.cloudlet.impl.CloudletImpl;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/**
* Attempts to rank the cloudlet based on how much free CPU power there is.
* This calculation is done with: (max_cores * 100.0) - usage
* User: jdroot
* Date: 4/4/14
* Time: 3:45 PM
*/
public class CpuBasedRanker implements CloudletRanker
{
private static final XLogger log = XLoggerFactory.getXLogger(CpuBasedRanker.class);
@Override
public double rankCloudlet(Service service, Cloudlet cloudlet) throws CloudletException
{
log.entry(service, cloudlet);
CloudletSystemInfo info = cloudlet.getSystemInfo();
double ranking = (100.0 * info.getCPUInfo().getTotalCores()) - info.getCPUInfo().getUsage();
log.exit(ranking);
return ranking;
}
}