use of com.bonree.brfs.common.utils.Pair in project BRFS by zhangnianli.
the class MachineResourceWriterSelector method covertValues.
public List<Pair<String, Integer>> covertValues(Collection<ResourceModel> resources, String path, int centSize) {
List<Pair<String, Double>> values = new ArrayList<>();
Pair<String, Double> tmpResource;
double sum;
String server;
for (ResourceModel resource : resources) {
server = resource.getServerId();
// 参数调整,disk写入io大的权重低
sum = resource.getDiskRemainValue(path) + 1 - resource.getDiskWriteValue(path);
tmpResource = new Pair<>(server, sum);
values.add(tmpResource);
}
return converDoublesToIntegers(values, centSize);
}
use of com.bonree.brfs.common.utils.Pair 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.common.utils.Pair 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.common.utils.Pair in project BRFS by zhangnianli.
the class MachineResourceWriterSelectorTest method testSelect01.
@Test
@SuppressWarnings("all")
public void testSelect01() {
String groupName = "a";
int centSize = 100;
MachineResourceWriterSelector selector = new MachineResourceWriterSelector(null, null, null, groupName, 5, centSize);
int num = 3;
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, 2);
show(wins);
}
use of com.bonree.brfs.common.utils.Pair in project BRFS by zhangnianli.
the class MachineResourceWriterSelectorTest method testSelect03.
@Test
public void testSelect03() {
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);
}
Collection<ResourceModel> wins = selector.selectNode(null, resourceModelMap, numList, sn, num);
show(wins);
}
Aggregations