Search in sources :

Example 1 with MemoryBasedConnectionLimitStrategy

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;
}
Also used : MemoryBasedConnectionLimitStrategy(org.eclipse.hono.adapter.limiting.MemoryBasedConnectionLimitStrategy) NetworkConfig(org.eclipse.californium.core.network.config.NetworkConfig) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint) Endpoint(org.eclipse.californium.core.network.Endpoint)

Aggregations

CoapEndpoint (org.eclipse.californium.core.network.CoapEndpoint)1 Endpoint (org.eclipse.californium.core.network.Endpoint)1 NetworkConfig (org.eclipse.californium.core.network.config.NetworkConfig)1 MemoryBasedConnectionLimitStrategy (org.eclipse.hono.adapter.limiting.MemoryBasedConnectionLimitStrategy)1