Search in sources :

Example 1 with ServerConnectorConfigImpl

use of com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl in project sofa-rpc by sofastack.

the class PolarisRegistry method init.

@Override
public void init() {
    if (providerAPI != null) {
        return;
    }
    ConfigurationImpl configuration = new ConfigurationImpl();
    // init configuration
    configuration.setDefault();
    ServerConnectorConfigImpl serverConnector = configuration.getGlobal().getServerConnector();
    serverConnector.setAddresses(Arrays.asList(registryConfig.getAddress()));
    serverConnector.setConnectTimeout((long) registryConfig.getConnectTimeout());
    serverConnector.setProtocol(properties.getConnectorProtocol());
    providerAPI = DiscoveryAPIFactory.createProviderAPIByConfig(configuration);
    consumerAPI = DiscoveryAPIFactory.createConsumerAPIByConfig(configuration);
    int coreSize = properties.getHeartbeatCoreSize();
    heartbeatExecutor = Executors.newScheduledThreadPool(coreSize);
}
Also used : ServerConnectorConfigImpl(com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl) ConfigurationImpl(com.tencent.polaris.factory.config.ConfigurationImpl)

Example 2 with ServerConnectorConfigImpl

use of com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl in project spring-cloud-tencent by Tencent.

the class ConsulContextPropertiesTest method testModify.

@Test
public void testModify() {
    assertThat(sdkContext).isNotNull();
    com.tencent.polaris.api.config.Configuration configuration = sdkContext.getConfig();
    List<ServerConnectorConfigImpl> serverConnectorConfigs = configuration.getGlobal().getServerConnectors();
    Map<String, String> metadata = null;
    for (ServerConnectorConfigImpl serverConnectorConfig : serverConnectorConfigs) {
        if (serverConnectorConfig.getId().equals("consul")) {
            metadata = serverConnectorConfig.getMetadata();
        }
    }
    assertThat(metadata).isNotNull();
    assertThat(metadata.get(SERVICE_NAME_KEY)).isEqualTo(SERVICE_PROVIDER);
    assertThat(metadata.get(INSTANCE_ID_KEY)).isEqualTo("ins-test");
    assertThat(metadata.get(PREFER_IP_ADDRESS_KEY)).isEqualTo("true");
    assertThat(metadata.get(IP_ADDRESS_KEY)).isEqualTo(HOST);
}
Also used : ServerConnectorConfigImpl(com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ServerConnectorConfigImpl

use of com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl in project polaris-java by polarismesh.

the class CompositeConnector method init.

@Override
public void init(InitContext ctx) throws PolarisException {
    if (getName().equals(ctx.getValueContext().getServerConnectorProtocol())) {
        if (CollectionUtils.isEmpty(serverConnectors)) {
            serverConnectors = new ArrayList<>();
        }
        List<ServerConnectorConfigImpl> serverConnectorConfigs = ctx.getConfig().getGlobal().getServerConnectors();
        for (ServerConnectorConfigImpl serverConnectorConfig : serverConnectorConfigs) {
            DestroyableServerConnector serverConnector = (DestroyableServerConnector) ctx.getPlugins().getPlugin(PluginTypes.SERVER_CONNECTOR.getBaseType(), serverConnectorConfig.getProtocol());
            serverConnector.init(ctx);
            serverConnectors.add(serverConnector);
        }
        sendDiscoverExecutor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory(getName() + "-send-discovery"), new CallerRunsPolicy());
        sendDiscoverExecutor.setMaximumPoolSize(1);
        updateServiceExecutor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory(getName() + "-update-service"));
        updateServiceExecutor.setMaximumPoolSize(1);
        initialized = true;
    }
}
Also used : ServerConnectorConfigImpl(com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NamedThreadFactory(com.tencent.polaris.client.util.NamedThreadFactory) CallerRunsPolicy(java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy) DestroyableServerConnector(com.tencent.polaris.plugins.connector.common.DestroyableServerConnector)

Aggregations

ServerConnectorConfigImpl (com.tencent.polaris.factory.config.global.ServerConnectorConfigImpl)3 NamedThreadFactory (com.tencent.polaris.client.util.NamedThreadFactory)1 ConfigurationImpl (com.tencent.polaris.factory.config.ConfigurationImpl)1 DestroyableServerConnector (com.tencent.polaris.plugins.connector.common.DestroyableServerConnector)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 CallerRunsPolicy (java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1