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);
}
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);
}
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;
}
}
Aggregations