package com.lanyuanxiaoyao.service.yarn;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.eclipsecollections.EclipseCollectionsModule;

/**
 * @author lanyuanxiaoyao
 * @date 2023-05-29
 */
public class QueueResponseParseTest {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new EclipseCollectionsModule());
        mapper.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
        /*String response = HttpUtil.get("http://b5m2.hdp.dc:8088/ws/v1/cluster/scheduler");
        QueueListResponse queueListResponse = mapper.readValue(response, QueueListResponse.class);
        queueListResponse.getScheduler().getSchedulerInfo().getQueues().getQueue().forEach(q -> {
            System.out.println(q.getQueueName());
            if (ObjectUtil.isNotNull(q.getQueues())) {
                q.getQueues().getQueue().forEach(q1 -> System.out.println(q1.getQueueName()));
            }
        });*/

        /*YarnConfiguration configuration = new YarnConfiguration();
        configuration.setCluster("b5");
        configuration.setWebUrl("http://b5m2.hdp.dc:8088");
        QueueServiceImpl service = new QueueServiceImpl(mapper, configuration);
        for (YarnQueue yarnQueue : service.list()) {
            System.out.println(yarnQueue.getQueueName());
        }*/
    }
}
