Merge pull request #5577 from YevhenBondarenko/feature/lwm2m-improvements
[3.3.3] added ability to configure network configuration for lwm2m
This commit is contained in:
		
						commit
						a89b40de46
					
				@ -818,6 +818,9 @@ transport:
 | 
			
		||||
    clean_period_in_sec: "${LWM2M_CLEAN_PERIOD_IN_SEC:2}"
 | 
			
		||||
    # Use redis for Security and Registration stores
 | 
			
		||||
    redis.enabled: "${LWM2M_REDIS_ENABLED:false}"
 | 
			
		||||
    network_config: # In this section you can specify custom parameters for LwM2M network configuration and expose the env variables to configure outside
 | 
			
		||||
#      - key: "PROTOCOL_STAGE_THREAD_COUNT"
 | 
			
		||||
#        value: "${LWM2M_PROTOCOL_STAGE_THREAD_COUNT:4}"
 | 
			
		||||
  snmp:
 | 
			
		||||
    enabled: "${SNMP_ENABLED:true}"
 | 
			
		||||
    response_processing:
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
package org.thingsboard.server.queue.kafka;
 | 
			
		||||
package org.thingsboard.server.common.data;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@ import lombok.Data;
 | 
			
		||||
 * Created by ashvayka on 25.09.18.
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
public class TbKafkaProperty {
 | 
			
		||||
public class TbProperty {
 | 
			
		||||
 | 
			
		||||
    private String key;
 | 
			
		||||
    private String value;
 | 
			
		||||
@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Value;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
import org.thingsboard.server.common.data.TbProperty;
 | 
			
		||||
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
@ -104,10 +105,10 @@ public class TbKafkaSettings {
 | 
			
		||||
    private String securityProtocol;
 | 
			
		||||
 | 
			
		||||
    @Setter
 | 
			
		||||
    private List<TbKafkaProperty> other;
 | 
			
		||||
    private List<TbProperty> other;
 | 
			
		||||
 | 
			
		||||
    @Setter
 | 
			
		||||
    private Map<String, List<TbKafkaProperty>> consumerPropertiesPerTopic = Collections.emptyMap();
 | 
			
		||||
    private Map<String, List<TbProperty>> consumerPropertiesPerTopic = Collections.emptyMap();
 | 
			
		||||
 | 
			
		||||
    public Properties toAdminProps() {
 | 
			
		||||
        Properties props = toProps();
 | 
			
		||||
 | 
			
		||||
@ -25,17 +25,16 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
import org.thingsboard.server.common.data.ResourceUtils;
 | 
			
		||||
import org.thingsboard.server.common.data.TbProperty;
 | 
			
		||||
import org.thingsboard.server.common.transport.config.ssl.SslCredentials;
 | 
			
		||||
import org.thingsboard.server.common.transport.config.ssl.SslCredentialsConfig;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.PostConstruct;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.security.KeyStore;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Component
 | 
			
		||||
@ConditionalOnExpression("('${service.type:null}'=='tb-transport' && '${transport.lwm2m.enabled:false}'=='true') || '${service.type:null}'=='monolith' || '${service.type:null}'=='tb-core'")
 | 
			
		||||
@ConfigurationProperties(prefix = "transport.lwm2m")
 | 
			
		||||
public class LwM2MTransportServerConfig implements LwM2MSecureServerConfig {
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
@ -98,6 +97,10 @@ public class LwM2MTransportServerConfig implements LwM2MSecureServerConfig {
 | 
			
		||||
    @Value("${transport.lwm2m.paging_transmission_window:10000}")
 | 
			
		||||
    private long pagingTransmissionWindow;
 | 
			
		||||
 | 
			
		||||
    @Getter
 | 
			
		||||
    @Setter
 | 
			
		||||
    private List<TbProperty> networkConfig;
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    @ConfigurationProperties(prefix = "transport.lwm2m.server.security.credentials")
 | 
			
		||||
    public SslCredentialsConfig lwm2mServerCredentials() {
 | 
			
		||||
 | 
			
		||||
@ -17,6 +17,7 @@ package org.thingsboard.server.transport.lwm2m.server;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.californium.core.network.config.NetworkConfig;
 | 
			
		||||
import org.eclipse.californium.core.network.config.NetworkConfigDefaults;
 | 
			
		||||
import org.springframework.util.CollectionUtils;
 | 
			
		||||
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
 | 
			
		||||
 | 
			
		||||
import static org.eclipse.californium.core.network.config.NetworkConfigDefaults.DEFAULT_BLOCKWISE_STATUS_LIFETIME;
 | 
			
		||||
@ -25,8 +26,8 @@ public class LwM2mNetworkConfig {
 | 
			
		||||
 | 
			
		||||
    public static NetworkConfig getCoapConfig(Integer serverPortNoSec, Integer serverSecurePort, LwM2MTransportServerConfig config) {
 | 
			
		||||
        NetworkConfig coapConfig = new NetworkConfig();
 | 
			
		||||
        coapConfig.setInt(NetworkConfig.Keys.COAP_PORT,serverPortNoSec);
 | 
			
		||||
        coapConfig.setInt(NetworkConfig.Keys.COAP_SECURE_PORT,serverSecurePort);
 | 
			
		||||
        coapConfig.setInt(NetworkConfig.Keys.COAP_PORT, serverPortNoSec);
 | 
			
		||||
        coapConfig.setInt(NetworkConfig.Keys.COAP_SECURE_PORT, serverSecurePort);
 | 
			
		||||
        /**
 | 
			
		||||
         Example:Property for large packet:
 | 
			
		||||
         #NetworkConfig config = new NetworkConfig();
 | 
			
		||||
@ -105,6 +106,10 @@ public class LwM2mNetworkConfig {
 | 
			
		||||
 | 
			
		||||
        coapConfig.setInt(NetworkConfig.Keys.MAX_RETRANSMIT, 10);
 | 
			
		||||
 | 
			
		||||
        if (!CollectionUtils.isEmpty(config.getNetworkConfig())) {
 | 
			
		||||
            config.getNetworkConfig().forEach(p -> coapConfig.setString(p.getKey(), p.getValue()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return coapConfig;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -203,6 +203,9 @@ transport:
 | 
			
		||||
    paging_transmission_window: "${LWM2M_PAGING_TRANSMISSION_WINDOW:10000}"
 | 
			
		||||
    # Use redis for Security and Registration stores
 | 
			
		||||
    redis.enabled: "${LWM2M_REDIS_ENABLED:false}"
 | 
			
		||||
    network_config: # In this section you can specify custom parameters for LwM2M network configuration and expose the env variables to configure outside
 | 
			
		||||
  #      - key: "PROTOCOL_STAGE_THREAD_COUNT"
 | 
			
		||||
  #        value: "${LWM2M_PROTOCOL_STAGE_THREAD_COUNT:4}"
 | 
			
		||||
  stats:
 | 
			
		||||
    enabled: "${TB_TRANSPORT_STATS_ENABLED:true}"
 | 
			
		||||
    print-interval-ms: "${TB_TRANSPORT_STATS_PRINT_INTERVAL_MS:60000}"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user