All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.baidu.formula.discovery.autoconfigure.FormulaDiscoveryServerUtils Maven / Gradle / Ivy

package com.baidu.formula.discovery.autoconfigure;

import com.baidu.discovery.client.model.Instance;
import org.apache.http.client.utils.DateUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Bowu Dong ([email protected])
 */
public class FormulaDiscoveryServerUtils {
    public static Map getMetadata(Instance instance) {
        HashMap map = new HashMap<>();
        map.put("productName", instance.getProductName());
        map.put("environment", instance.getEnvironment());
        map.put("region", instance.getRegion());
        map.put("appName", instance.getAppName());
        map.put("scheme", instance.getScheme());
        map.put("host", instance.getHost());
        map.put("path", instance.getPath());
        map.put("type", instance.getType());
        map.put("status", String.valueOf(instance.getStatus()));
        map.put("zone", String.valueOf(instance.getZone()));
        map.put("tags", instance.getTags() == null ? "" : String.join(",", instance.getTags()));
        map.put("startTime", DateUtils.formatDate(instance.getStartTime(), "yyyy-MM-dd HH:mm:ss"));

        if (instance.getCustoms() != null ) {
            instance.getCustoms().forEach((key, value) -> {
                if (!map.containsKey(key)) {
                    map.put(key, value);
                }
            });
        }
        return map;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy