use of org.eclipse.hono.adapter.limiting.MemoryBasedConnectionLimitStrategy in project hono by eclipse.
the class ConfigBasedCoapEndpointFactory method newDefaultNetworkConfig.
private NetworkConfig newDefaultNetworkConfig() {
final NetworkConfig networkConfig = new NetworkConfig();
networkConfig.setInt(Keys.PROTOCOL_STAGE_THREAD_COUNT, config.getCoapThreads());
networkConfig.setInt(Keys.NETWORK_STAGE_RECEIVER_THREAD_COUNT, config.getConnectorThreads());
networkConfig.setInt(Keys.NETWORK_STAGE_SENDER_THREAD_COUNT, config.getConnectorThreads());
networkConfig.setInt(Keys.MAX_RESOURCE_BODY_SIZE, config.getMaxPayloadSize());
networkConfig.setInt(Keys.EXCHANGE_LIFETIME, config.getExchangeLifetime());
networkConfig.setBoolean(Keys.USE_MESSAGE_OFFLOADING, config.isMessageOffloadingEnabled());
networkConfig.setString(Keys.DEDUPLICATOR, Keys.DEDUPLICATOR_PEERS_MARK_AND_SWEEP);
final int maxConnections = config.getMaxConnections();
if (maxConnections == 0) {
final MemoryBasedConnectionLimitStrategy limits = new MemoryBasedConnectionLimitStrategy(MINIMAL_MEMORY, MEMORY_PER_CONNECTION);
networkConfig.setInt(Keys.MAX_ACTIVE_PEERS, limits.getRecommendedLimit());
} else {
networkConfig.setInt(Keys.MAX_ACTIVE_PEERS, maxConnections);
}
return networkConfig;
}
Aggregations