Minor improvements
This commit is contained in:
parent
fe028a4fe5
commit
f6e9959ca5
@ -134,7 +134,6 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
|
|||||||
TenantProfile isolatedTbCoreProfile = new TenantProfile();
|
TenantProfile isolatedTbCoreProfile = new TenantProfile();
|
||||||
isolatedTbCoreProfile.setDefault(false);
|
isolatedTbCoreProfile.setDefault(false);
|
||||||
isolatedTbCoreProfile.setName("Isolated TB Core");
|
isolatedTbCoreProfile.setName("Isolated TB Core");
|
||||||
isolatedTbCoreProfile.setProfileData(new TenantProfileData());
|
|
||||||
isolatedTbCoreProfile.setDescription("Isolated TB Core tenant profile");
|
isolatedTbCoreProfile.setDescription("Isolated TB Core tenant profile");
|
||||||
isolatedTbCoreProfile.setIsolatedTbCore(true);
|
isolatedTbCoreProfile.setIsolatedTbCore(true);
|
||||||
isolatedTbCoreProfile.setIsolatedTbRuleEngine(false);
|
isolatedTbCoreProfile.setIsolatedTbRuleEngine(false);
|
||||||
@ -148,7 +147,6 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
|
|||||||
TenantProfile isolatedTbRuleEngineProfile = new TenantProfile();
|
TenantProfile isolatedTbRuleEngineProfile = new TenantProfile();
|
||||||
isolatedTbRuleEngineProfile.setDefault(false);
|
isolatedTbRuleEngineProfile.setDefault(false);
|
||||||
isolatedTbRuleEngineProfile.setName("Isolated TB Rule Engine");
|
isolatedTbRuleEngineProfile.setName("Isolated TB Rule Engine");
|
||||||
isolatedTbRuleEngineProfile.setProfileData(new TenantProfileData());
|
|
||||||
isolatedTbRuleEngineProfile.setDescription("Isolated TB Rule Engine tenant profile");
|
isolatedTbRuleEngineProfile.setDescription("Isolated TB Rule Engine tenant profile");
|
||||||
isolatedTbRuleEngineProfile.setIsolatedTbCore(false);
|
isolatedTbRuleEngineProfile.setIsolatedTbCore(false);
|
||||||
isolatedTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
|
isolatedTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
|
||||||
@ -163,7 +161,6 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
|
|||||||
TenantProfile isolatedTbCoreAndTbRuleEngineProfile = new TenantProfile();
|
TenantProfile isolatedTbCoreAndTbRuleEngineProfile = new TenantProfile();
|
||||||
isolatedTbCoreAndTbRuleEngineProfile.setDefault(false);
|
isolatedTbCoreAndTbRuleEngineProfile.setDefault(false);
|
||||||
isolatedTbCoreAndTbRuleEngineProfile.setName("Isolated TB Core and TB Rule Engine");
|
isolatedTbCoreAndTbRuleEngineProfile.setName("Isolated TB Core and TB Rule Engine");
|
||||||
isolatedTbCoreAndTbRuleEngineProfile.setProfileData(new TenantProfileData());
|
|
||||||
isolatedTbCoreAndTbRuleEngineProfile.setDescription("Isolated TB Core and TB Rule Engine tenant profile");
|
isolatedTbCoreAndTbRuleEngineProfile.setDescription("Isolated TB Core and TB Rule Engine tenant profile");
|
||||||
isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbCore(true);
|
isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbCore(true);
|
||||||
isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
|
isolatedTbCoreAndTbRuleEngineProfile.setIsolatedTbRuleEngine(true);
|
||||||
|
|||||||
@ -94,7 +94,9 @@ public class DefaultTbApiUsageClient implements TbApiUsageClient {
|
|||||||
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, tenantId).newByTopic(msgProducer.getDefaultTopic());
|
TopicPartitionInfo tpi = partitionService.resolve(ServiceType.TB_CORE, tenantId, tenantId).newByTopic(msgProducer.getDefaultTopic());
|
||||||
msgProducer.send(tpi, new TbProtoQueueMsg<>(UUID.randomUUID(), builder.build()), null);
|
msgProducer.send(tpi, new TbProtoQueueMsg<>(UUID.randomUUID(), builder.build()), null);
|
||||||
}));
|
}));
|
||||||
|
if (!report.isEmpty()) {
|
||||||
log.info("Report statistics for: {} tenants", report.size());
|
log.info("Report statistics for: {} tenants", report.size());
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to report statistics: ", e);
|
log.warn("Failed to report statistics: ", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -464,8 +464,10 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
|
|||||||
String userName = msg.payload().userName();
|
String userName = msg.payload().userName();
|
||||||
log.info("[{}] Processing connect msg for client with user name: {}!", sessionId, userName);
|
log.info("[{}] Processing connect msg for client with user name: {}!", sessionId, userName);
|
||||||
TransportProtos.ValidateBasicMqttCredRequestMsg.Builder request = TransportProtos.ValidateBasicMqttCredRequestMsg.newBuilder()
|
TransportProtos.ValidateBasicMqttCredRequestMsg.Builder request = TransportProtos.ValidateBasicMqttCredRequestMsg.newBuilder()
|
||||||
.setClientId(msg.payload().clientIdentifier())
|
.setClientId(msg.payload().clientIdentifier());
|
||||||
.setUserName(userName);
|
if (userName != null) {
|
||||||
|
request.setUserName(userName);
|
||||||
|
}
|
||||||
String password = msg.payload().password();
|
String password = msg.payload().password();
|
||||||
if (password != null) {
|
if (password != null) {
|
||||||
request.setPassword(password);
|
request.setPassword(password);
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import org.springframework.util.StringUtils;
|
|||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
import org.thingsboard.server.common.data.TenantProfile;
|
import org.thingsboard.server.common.data.TenantProfile;
|
||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
|
import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileConfiguration;
|
||||||
import org.thingsboard.server.common.data.tenant.profile.TenantProfileData;
|
import org.thingsboard.server.common.data.tenant.profile.TenantProfileData;
|
||||||
@ -77,6 +78,7 @@ public class DefaultTransportRateLimitService implements TransportRateLimitServi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(TenantProfileUpdateResult update) {
|
public void update(TenantProfileUpdateResult update) {
|
||||||
|
log.info("Received tenant profile update: {}", update.getProfile());
|
||||||
EntityTransportRateLimits tenantRateLimitPrototype = createRateLimits(update.getProfile(), true);
|
EntityTransportRateLimits tenantRateLimitPrototype = createRateLimits(update.getProfile(), true);
|
||||||
EntityTransportRateLimits deviceRateLimitPrototype = createRateLimits(update.getProfile(), false);
|
EntityTransportRateLimits deviceRateLimitPrototype = createRateLimits(update.getProfile(), false);
|
||||||
for (TenantId tenantId : update.getAffectedTenants()) {
|
for (TenantId tenantId : update.getAffectedTenants()) {
|
||||||
@ -114,16 +116,26 @@ public class DefaultTransportRateLimitService implements TransportRateLimitServi
|
|||||||
tenantAllowed.put(tenantId, allowed);
|
tenantAllowed.put(tenantId, allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void mergeLimits(T deviceId, EntityTransportRateLimits newRateLimits,
|
private <T extends EntityId> void mergeLimits(T entityId, EntityTransportRateLimits newRateLimits,
|
||||||
Function<T, EntityTransportRateLimits> getFunction,
|
Function<T, EntityTransportRateLimits> getFunction,
|
||||||
BiConsumer<T, EntityTransportRateLimits> putFunction) {
|
BiConsumer<T, EntityTransportRateLimits> putFunction) {
|
||||||
EntityTransportRateLimits oldRateLimits = getFunction.apply(deviceId);
|
EntityTransportRateLimits oldRateLimits = getFunction.apply(entityId);
|
||||||
if (oldRateLimits == null) {
|
if (oldRateLimits == null) {
|
||||||
putFunction.accept(deviceId, newRateLimits);
|
if (EntityType.TENANT.equals(entityId.getEntityType())) {
|
||||||
|
log.info("[{}] New rate limits: {}", entityId, newRateLimits);
|
||||||
|
} else {
|
||||||
|
log.debug("[{}] New rate limits: {}", entityId, newRateLimits);
|
||||||
|
}
|
||||||
|
putFunction.accept(entityId, newRateLimits);
|
||||||
} else {
|
} else {
|
||||||
EntityTransportRateLimits updated = merge(oldRateLimits, newRateLimits);
|
EntityTransportRateLimits updated = merge(oldRateLimits, newRateLimits);
|
||||||
if (updated != null) {
|
if (updated != null) {
|
||||||
putFunction.accept(deviceId, updated);
|
if (EntityType.TENANT.equals(entityId.getEntityType())) {
|
||||||
|
log.info("[{}] Updated rate limits: {}", entityId, updated);
|
||||||
|
} else {
|
||||||
|
log.debug("[{}] Updated rate limits: {}", entityId, updated);
|
||||||
|
}
|
||||||
|
putFunction.accept(entityId, updated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user