use of com.bonree.brfs.resourceschedule.model.ResourceModel in project BRFS by zhangnianli.
the class MachineResourceWriterSelectorTest method testSendEmail.
@Test
@SuppressWarnings("all")
public void testSendEmail() {
String groupName = "a";
String sn = "11";
int centSize = 100;
MachineResourceWriterSelector selector = new MachineResourceWriterSelector(null, null, null, groupName, 5, centSize);
int num = 2;
List<ResourceModel> list = new ArrayList<>();
List<Pair<String, Integer>> numList = new ArrayList<>();
ResourceModel obj;
Map<String, ResourceModel> resourceModelMap = new HashMap<>();
for (int i = 0; i < num; i++) {
obj = new ResourceModel();
obj.setHost("192.168.1.1");
obj.setServerId(String.valueOf(i));
list.add(obj);
numList.add(new Pair<>(String.valueOf(i), 100));
resourceModelMap.put(String.valueOf(i), obj);
}
selector.sendSelectEmail(list, sn, num);
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of com.bonree.brfs.resourceschedule.model.ResourceModel in project BRFS by zhangnianli.
the class MachineResourceWriterSelectorTest method testFiler01.
@Test
public void testFiler01() {
String groupName = "a";
int centSize = 100;
LimitServerResource limit = new LimitServerResource();
limit.setForceWriteValue(0.9);
limit.setForceDiskRemainRate(0.01);
limit.setDiskWriteValue(0.8);
limit.setDiskRemainRate(0.05);
limit.setRemainForceSize(20000000);
limit.setRemainWarnSize(20000000);
MachineResourceWriterSelector selector = new MachineResourceWriterSelector(null, null, limit, groupName, 5, centSize);
int num = 1;
List<ResourceModel> list = new ArrayList<>();
List<Pair<String, Integer>> numList = new ArrayList<>();
ResourceModel obj;
String mount = "tmp";
Map<String, Double> remainRateMap = new HashMap<>();
remainRateMap.put("tmp", 0.04);
Map<String, Double> writValue = new HashMap<>();
writValue.put("tmp", 0.999);
String sn = "sn";
Map<String, String> snMap = new HashMap<>();
snMap.put(sn, mount);
for (int i = 0; i < num; i++) {
obj = new ResourceModel();
obj.setHost("192.168.3." + i);
obj.setDiskSize(20000000L);
obj.setServerId(String.valueOf(i));
obj.setLocalDiskRemainRate(remainRateMap);
obj.setDiskWriteValue(writValue);
obj.setStorageNameOnPartitionMap(snMap);
list.add(obj);
numList.add(new Pair<>(String.valueOf(i), 100));
}
Collection<ResourceModel> wins = selector.filterService(list, sn);
show(wins);
}
use of com.bonree.brfs.resourceschedule.model.ResourceModel in project BRFS by zhangnianli.
the class RandomAvailable method convertList.
public List<ResourceModel> convertList(Map<String, ResourceModel> resourceMap, List<String> errors, int sence, LimitServerResource limit, String snName) {
List<ResourceModel> resources = new ArrayList<ResourceModel>();
if (resourceMap.isEmpty()) {
return resources;
}
String serverId = null;
ResourceModel r = null;
double remainValue = 0.0;
for (Map.Entry<String, ResourceModel> entry : resourceMap.entrySet()) {
serverId = entry.getKey();
if (errors != null && errors.contains(serverId)) {
continue;
}
if (sence == 1) {
remainValue = entry.getValue().getDiskRemainValue(snName);
if (remainValue <= limit.getDiskRemainRate()) {
continue;
}
}
r = entry.getValue();
if (r == null) {
continue;
}
resources.add(r);
}
return resources;
}
use of com.bonree.brfs.resourceschedule.model.ResourceModel in project BRFS by zhangnianli.
the class GatherResource method calcResource.
/**
* 概述:计算本机可用指标
* @param base
* @param stat
* @return
* @user <a href=mailto:zhucg@bonree.com>朱成岗</a>
*/
public static ResourceModel calcResource(BaseServerModel base, ServerStatModel stat) {
ResourceModel obj = new ResourceModel();
obj.setServerId(base.getServerId());
Map<String, PatitionStatModel> patMap = stat.getPatitionStatInfoMap();
Map<String, String> snToPat = base.getSnToDiskMap();
long totalDisk = base.getTotalPatitionSize();
long remain = 0;
String sn = null;
String mount = null;
PatitionStatModel pat = null;
NetStatModel net = null;
for (Map.Entry<String, Long> entry : stat.getSnRemainSizeMap().entrySet()) {
sn = entry.getKey();
remain = entry.getValue();
mount = snToPat.get(sn);
// 没有挂载点的数据为最低
if (mount == null) {
obj.putClientSNRead(sn, 0.0);
obj.putClientSNWrite(sn, 0.0);
continue;
}
pat = patMap.get(mount);
// 无磁盘状态信息的数据为最低
if (pat == null) {
obj.putClientSNRead(sn, 0.0);
obj.putClientSNWrite(sn, 0.0);
continue;
}
// 1.计算写请求 磁盘剩余率 +I/O请求
double wValue = (double) remain / totalDisk + (pat.getWriteMaxSpeed() - pat.getWriteSpeed() / pat.getCount()) / pat.getWriteMaxSpeed();
double rValue = (double) (pat.getReadMaxSpeed() - pat.getReadSpeed() / pat.getCount()) / pat.getReadMaxSpeed();
double remainValue = (double) remain / (pat.getRemainSize() + pat.getUsedSize());
obj.putClientSNRead(sn, rValue);
obj.putClientSNWrite(sn, wValue);
obj.putSnRemainRate(sn, remainValue);
}
return null;
}
use of com.bonree.brfs.resourceschedule.model.ResourceModel in project BRFS by zhangnianli.
the class MachineResourceWriterSelectorTest method testSelect02.
@Test
public void testSelect02() {
String groupName = "a";
int centSize = 100;
MachineResourceWriterSelector selector = new MachineResourceWriterSelector(null, null, null, groupName, 5, centSize);
int num = 2;
List<ResourceModel> list = new ArrayList<>();
List<Pair<String, Integer>> numList = new ArrayList<>();
ResourceModel obj;
Map<String, ResourceModel> resourceModelMap = new HashMap<>();
for (int i = 0; i < num; i++) {
obj = new ResourceModel();
obj.setHost("192.168.3." + i);
obj.setServerId(String.valueOf(i));
list.add(obj);
numList.add(new Pair<>(String.valueOf(i), 100));
resourceModelMap.put(String.valueOf(i), obj);
}
Collection<ResourceModel> wins = selector.selectNode(null, resourceModelMap, numList, groupName, 3);
show(wins);
}
Aggregations