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

com.dtp.adapter.dubbo.alibaba.AlibabaDubboDtpAdapter Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.dtp.adapter.dubbo.alibaba;

import com.alibaba.dubbo.common.extension.ExtensionLoader;
import com.alibaba.dubbo.common.store.DataStore;
import com.dtp.adapter.common.AbstractDtpAdapter;
import com.dtp.common.properties.DtpProperties;
import com.dtp.core.support.ExecutorWrapper;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.collections.MapUtils;

import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;

import static com.alibaba.dubbo.common.Constants.EXECUTOR_SERVICE_COMPONENT_KEY;


/**
 * AlibabaDubboDtpAdapter related
 *
 * @author yanhom
 * @since 1.0.6
 */
@Slf4j
@SuppressWarnings("all")
public class AlibabaDubboDtpAdapter extends AbstractDtpAdapter {

    private static final String NAME = "dubboTp";

    @Override
    public void refresh(DtpProperties dtpProperties) {
        refresh(NAME, dtpProperties.getDubboTp(), dtpProperties.getPlatforms());
    }

    @Override
    protected void initialize() {
        super.initialize();
        DataStore dataStore = ExtensionLoader.getExtensionLoader(DataStore.class).getDefaultExtension();
        Map executorMap = dataStore.get(EXECUTOR_SERVICE_COMPONENT_KEY);
        if (MapUtils.isNotEmpty(executorMap)) {
            executorMap.forEach((k, v) -> {
                val name = genTpName(k);
                val executorWrapper = new ExecutorWrapper(name, (ThreadPoolExecutor) v);
                initNotifyItems(name, executorWrapper);
                executors.put(name, executorWrapper);
            });
        }
        log.info("DynamicTp adapter, alibaba dubbo provider executors init end, executors: {}", executors);
    }

    private String genTpName(String port) {
        return NAME + "#" + port;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy