Search in sources :

Example 1 with Pair

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);
}
Also used : ResourceModel(com.bonree.brfs.resourceschedule.model.ResourceModel) Pair(com.bonree.brfs.common.utils.Pair)

Example 2 with Pair

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();
    }
}
Also used : ResourceModel(com.bonree.brfs.resourceschedule.model.ResourceModel) Pair(com.bonree.brfs.common.utils.Pair) Test(org.junit.Test)

Example 3 with Pair

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);
}
Also used : ResourceModel(com.bonree.brfs.resourceschedule.model.ResourceModel) LimitServerResource(com.bonree.brfs.resourceschedule.model.LimitServerResource) Pair(com.bonree.brfs.common.utils.Pair) Test(org.junit.Test)

Example 4 with Pair

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);
}
Also used : ResourceModel(com.bonree.brfs.resourceschedule.model.ResourceModel) Pair(com.bonree.brfs.common.utils.Pair) Test(org.junit.Test)

Example 5 with Pair

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);
}
Also used : ResourceModel(com.bonree.brfs.resourceschedule.model.ResourceModel) Pair(com.bonree.brfs.common.utils.Pair) Test(org.junit.Test)

Aggregations

Pair (com.bonree.brfs.common.utils.Pair)14 ResourceModel (com.bonree.brfs.resourceschedule.model.ResourceModel)8 Test (org.junit.Test)6 StorageRegion (com.bonree.brfs.duplication.storageregion.StorageRegion)4 TaskModel (com.bonree.brfs.schedulers.task.model.TaskModel)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 AtomTaskModel (com.bonree.brfs.schedulers.task.model.AtomTaskModel)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 HashedMap (org.apache.commons.collections.map.HashedMap)2 LimitServerResource (com.bonree.brfs.resourceschedule.model.LimitServerResource)1 TaskServerNodeModel (com.bonree.brfs.schedulers.task.model.TaskServerNodeModel)1 Map (java.util.Map)1 JobDataMap (org.quartz.JobDataMap)1