Commit 67014b45a0c30eaa7ad24cb805960f2b44eb923c
Committed by
GitHub
Merge pull request #5178 from smatvienko-tb/thread-pool-naming-aug-2021
Thread pool naming (aug 2021)
Showing
31 changed files
with
147 additions
and
53 deletions
application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
23 | import org.springframework.beans.factory.annotation.Value; | 23 | import org.springframework.beans.factory.annotation.Value; |
24 | import org.springframework.context.annotation.Lazy; | 24 | import org.springframework.context.annotation.Lazy; |
25 | import org.springframework.stereotype.Service; | 25 | import org.springframework.stereotype.Service; |
26 | +import org.thingsboard.common.util.ThingsBoardExecutors; | ||
26 | import org.thingsboard.common.util.ThingsBoardThreadFactory; | 27 | import org.thingsboard.common.util.ThingsBoardThreadFactory; |
27 | import org.thingsboard.rule.engine.api.MailService; | 28 | import org.thingsboard.rule.engine.api.MailService; |
28 | import org.thingsboard.server.common.data.ApiFeature; | 29 | import org.thingsboard.server.common.data.ApiFeature; |
@@ -486,7 +487,7 @@ public class DefaultTbApiUsageStateService extends TbApplicationEventListener<Pa | @@ -486,7 +487,7 @@ public class DefaultTbApiUsageStateService extends TbApplicationEventListener<Pa | ||
486 | log.info("Initializing tenant states."); | 487 | log.info("Initializing tenant states."); |
487 | updateLock.lock(); | 488 | updateLock.lock(); |
488 | try { | 489 | try { |
489 | - ExecutorService tmpInitExecutor = Executors.newWorkStealingPool(20); | 490 | + ExecutorService tmpInitExecutor = ThingsBoardExecutors.newWorkStealingPool(20, "init-tenant-states-from-db"); |
490 | try { | 491 | try { |
491 | PageDataIterable<Tenant> tenantIterator = new PageDataIterable<>(tenantService::findTenants, 1024); | 492 | PageDataIterable<Tenant> tenantIterator = new PageDataIterable<>(tenantService::findTenants, 1024); |
492 | List<Future<?>> futures = new ArrayList<>(); | 493 | List<Future<?>> futures = new ArrayList<>(); |
@@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; | @@ -19,6 +19,7 @@ import com.fasterxml.jackson.databind.JsonNode; | ||
19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
20 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
21 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
22 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
22 | import org.thingsboard.server.common.data.edge.Edge; | 23 | import org.thingsboard.server.common.data.edge.Edge; |
23 | import org.thingsboard.server.common.data.edge.EdgeEvent; | 24 | import org.thingsboard.server.common.data.edge.EdgeEvent; |
24 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; | 25 | import org.thingsboard.server.common.data.edge.EdgeEventActionType; |
@@ -79,7 +80,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | @@ -79,7 +80,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { | ||
79 | 80 | ||
80 | @PostConstruct | 81 | @PostConstruct |
81 | public void initExecutor() { | 82 | public void initExecutor() { |
82 | - tsCallBackExecutor = Executors.newSingleThreadExecutor(); | 83 | + tsCallBackExecutor = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName("edge-notifications")); |
83 | } | 84 | } |
84 | 85 | ||
85 | @PreDestroy | 86 | @PreDestroy |
@@ -103,8 +103,8 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService< | @@ -103,8 +103,8 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService< | ||
103 | private final ConcurrentMap<String, TbRuleEngineQueueConfiguration> consumerConfigurations = new ConcurrentHashMap<>(); | 103 | private final ConcurrentMap<String, TbRuleEngineQueueConfiguration> consumerConfigurations = new ConcurrentHashMap<>(); |
104 | private final ConcurrentMap<String, TbRuleEngineConsumerStats> consumerStats = new ConcurrentHashMap<>(); | 104 | private final ConcurrentMap<String, TbRuleEngineConsumerStats> consumerStats = new ConcurrentHashMap<>(); |
105 | private final ConcurrentMap<String, TbTopicWithConsumerPerPartition> topicsConsumerPerPartition = new ConcurrentHashMap<>(); | 105 | private final ConcurrentMap<String, TbTopicWithConsumerPerPartition> topicsConsumerPerPartition = new ConcurrentHashMap<>(); |
106 | - final ExecutorService submitExecutor = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName("tb-rule-engine-consumer-service-submit-executor")); | ||
107 | - final ScheduledExecutorService repartitionExecutor = Executors.newScheduledThreadPool(1, ThingsBoardThreadFactory.forName("tb-rule-engine-consumer-repartition-executor")); | 106 | + final ExecutorService submitExecutor = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName("tb-rule-engine-consumer-submit")); |
107 | + final ScheduledExecutorService repartitionExecutor = Executors.newScheduledThreadPool(1, ThingsBoardThreadFactory.forName("tb-rule-engine-consumer-repartition")); | ||
108 | 108 | ||
109 | public DefaultTbRuleEngineConsumerService(TbRuleEngineProcessingStrategyFactory processingStrategyFactory, | 109 | public DefaultTbRuleEngineConsumerService(TbRuleEngineProcessingStrategyFactory processingStrategyFactory, |
110 | TbRuleEngineSubmitStrategyFactory submitStrategyFactory, | 110 | TbRuleEngineSubmitStrategyFactory submitStrategyFactory, |
@@ -146,6 +146,7 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService< | @@ -146,6 +146,7 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService< | ||
146 | public void stop() { | 146 | public void stop() { |
147 | super.destroy(); | 147 | super.destroy(); |
148 | submitExecutor.shutdownNow(); | 148 | submitExecutor.shutdownNow(); |
149 | + repartitionExecutor.shutdownNow(); | ||
149 | ruleEngineSettings.getQueues().forEach(config -> consumerConfigurations.put(config.getName(), config)); | 150 | ruleEngineSettings.getQueues().forEach(config -> consumerConfigurations.put(config.getName(), config)); |
150 | } | 151 | } |
151 | 152 |
@@ -21,6 +21,7 @@ import org.junit.Assert; | @@ -21,6 +21,7 @@ import org.junit.Assert; | ||
21 | import org.junit.Test; | 21 | import org.junit.Test; |
22 | import org.junit.runner.RunWith; | 22 | import org.junit.runner.RunWith; |
23 | import org.mockito.junit.MockitoJUnitRunner; | 23 | import org.mockito.junit.MockitoJUnitRunner; |
24 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
24 | import org.thingsboard.server.gen.transport.TransportProtos; | 25 | import org.thingsboard.server.gen.transport.TransportProtos; |
25 | import org.thingsboard.server.queue.common.TbProtoQueueMsg; | 26 | import org.thingsboard.server.queue.common.TbProtoQueueMsg; |
26 | import org.thingsboard.server.service.queue.processing.TbRuleEngineSubmitStrategy; | 27 | import org.thingsboard.server.service.queue.processing.TbRuleEngineSubmitStrategy; |
@@ -59,7 +60,7 @@ public class TbMsgPackProcessingContextTest { | @@ -59,7 +60,7 @@ public class TbMsgPackProcessingContextTest { | ||
59 | //log.warn("preparing the test..."); | 60 | //log.warn("preparing the test..."); |
60 | int msgCount = 1000; | 61 | int msgCount = 1000; |
61 | int parallelCount = 5; | 62 | int parallelCount = 5; |
62 | - executorService = Executors.newFixedThreadPool(parallelCount); | 63 | + executorService = Executors.newFixedThreadPool(parallelCount, ThingsBoardThreadFactory.forName(getClass().getSimpleName() + "-test-scope")); |
63 | 64 | ||
64 | ConcurrentMap<UUID, TbProtoQueueMsg<TransportProtos.ToRuleEngineMsg>> messages = new ConcurrentHashMap<>(msgCount); | 65 | ConcurrentMap<UUID, TbProtoQueueMsg<TransportProtos.ToRuleEngineMsg>> messages = new ConcurrentHashMap<>(msgCount); |
65 | for (int i = 0; i < msgCount; i++) { | 66 | for (int i = 0; i < msgCount; i++) { |
@@ -52,6 +52,16 @@ import static org.junit.Assert.assertNotNull; | @@ -52,6 +52,16 @@ import static org.junit.Assert.assertNotNull; | ||
52 | @Slf4j | 52 | @Slf4j |
53 | public abstract class AbstractCoapIntegrationTest extends AbstractTransportIntegrationTest { | 53 | public abstract class AbstractCoapIntegrationTest extends AbstractTransportIntegrationTest { |
54 | 54 | ||
55 | + protected CoapClient client; | ||
56 | + | ||
57 | + @Override | ||
58 | + protected void processAfterTest() throws Exception { | ||
59 | + if (client != null) { | ||
60 | + client.shutdown(); | ||
61 | + } | ||
62 | + super.processAfterTest(); | ||
63 | + } | ||
64 | + | ||
55 | protected void processBeforeTest(String deviceName, CoapDeviceType coapDeviceType, TransportPayloadType payloadType) throws Exception { | 65 | protected void processBeforeTest(String deviceName, CoapDeviceType coapDeviceType, TransportPayloadType payloadType) throws Exception { |
56 | this.processBeforeTest(deviceName, coapDeviceType, payloadType, null, null, null, null, null, null, DeviceProfileProvisionType.DISABLED); | 66 | this.processBeforeTest(deviceName, coapDeviceType, payloadType, null, null, null, null, null, null, DeviceProfileProvisionType.DISABLED); |
57 | } | 67 | } |
@@ -75,7 +75,7 @@ public abstract class AbstractCoapAttributesRequestIntegrationTest extends Abstr | @@ -75,7 +75,7 @@ public abstract class AbstractCoapAttributesRequestIntegrationTest extends Abstr | ||
75 | 75 | ||
76 | String keys = "attribute1,attribute2,attribute3,attribute4,attribute5"; | 76 | String keys = "attribute1,attribute2,attribute3,attribute4,attribute5"; |
77 | String featureTokenUrl = getFeatureTokenUrl(accessToken, FeatureType.ATTRIBUTES) + "?clientKeys=" + keys + "&sharedKeys=" + keys; | 77 | String featureTokenUrl = getFeatureTokenUrl(accessToken, FeatureType.ATTRIBUTES) + "?clientKeys=" + keys + "&sharedKeys=" + keys; |
78 | - CoapClient client = getCoapClient(featureTokenUrl); | 78 | + client = getCoapClient(featureTokenUrl); |
79 | 79 | ||
80 | CoapResponse getAttributesResponse = client.setTimeout(CLIENT_REQUEST_TIMEOUT).get(); | 80 | CoapResponse getAttributesResponse = client.setTimeout(CLIENT_REQUEST_TIMEOUT).get(); |
81 | validateResponse(getAttributesResponse); | 81 | validateResponse(getAttributesResponse); |
@@ -83,7 +83,7 @@ public abstract class AbstractCoapAttributesRequestIntegrationTest extends Abstr | @@ -83,7 +83,7 @@ public abstract class AbstractCoapAttributesRequestIntegrationTest extends Abstr | ||
83 | 83 | ||
84 | protected void postAttributes() throws Exception { | 84 | protected void postAttributes() throws Exception { |
85 | doPostAsync("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/attributes/SHARED_SCOPE", POST_ATTRIBUTES_PAYLOAD, String.class, status().isOk()); | 85 | doPostAsync("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/attributes/SHARED_SCOPE", POST_ATTRIBUTES_PAYLOAD, String.class, status().isOk()); |
86 | - CoapClient client = getCoapClient(FeatureType.ATTRIBUTES); | 86 | + client = getCoapClient(FeatureType.ATTRIBUTES); |
87 | CoapResponse coapResponse = client.setTimeout(CLIENT_REQUEST_TIMEOUT).post(POST_ATTRIBUTES_PAYLOAD.getBytes(), MediaTypeRegistry.APPLICATION_JSON); | 87 | CoapResponse coapResponse = client.setTimeout(CLIENT_REQUEST_TIMEOUT).post(POST_ATTRIBUTES_PAYLOAD.getBytes(), MediaTypeRegistry.APPLICATION_JSON); |
88 | assertEquals(CoAP.ResponseCode.CREATED, coapResponse.getCode()); | 88 | assertEquals(CoAP.ResponseCode.CREATED, coapResponse.getCode()); |
89 | } | 89 | } |
@@ -21,7 +21,6 @@ import com.google.protobuf.DynamicMessage; | @@ -21,7 +21,6 @@ import com.google.protobuf.DynamicMessage; | ||
21 | import com.google.protobuf.InvalidProtocolBufferException; | 21 | import com.google.protobuf.InvalidProtocolBufferException; |
22 | import com.squareup.wire.schema.internal.parser.ProtoFileElement; | 22 | import com.squareup.wire.schema.internal.parser.ProtoFileElement; |
23 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; |
24 | -import org.eclipse.californium.core.CoapClient; | ||
25 | import org.eclipse.californium.core.CoapResponse; | 24 | import org.eclipse.californium.core.CoapResponse; |
26 | import org.eclipse.californium.core.coap.CoAP; | 25 | import org.eclipse.californium.core.coap.CoAP; |
27 | import org.eclipse.californium.core.coap.MediaTypeRegistry; | 26 | import org.eclipse.californium.core.coap.MediaTypeRegistry; |
@@ -124,7 +123,7 @@ public abstract class AbstractCoapAttributesRequestProtoIntegrationTest extends | @@ -124,7 +123,7 @@ public abstract class AbstractCoapAttributesRequestProtoIntegrationTest extends | ||
124 | .setField(postAttributesMsgDescriptor.findFieldByName("attribute5"), jsonObject) | 123 | .setField(postAttributesMsgDescriptor.findFieldByName("attribute5"), jsonObject) |
125 | .build(); | 124 | .build(); |
126 | byte[] payload = postAttributesMsg.toByteArray(); | 125 | byte[] payload = postAttributesMsg.toByteArray(); |
127 | - CoapClient client = getCoapClient(FeatureType.ATTRIBUTES); | 126 | + client = getCoapClient(FeatureType.ATTRIBUTES); |
128 | CoapResponse coapResponse = client.setTimeout(CLIENT_REQUEST_TIMEOUT).post(payload, MediaTypeRegistry.APPLICATION_JSON); | 127 | CoapResponse coapResponse = client.setTimeout(CLIENT_REQUEST_TIMEOUT).post(payload, MediaTypeRegistry.APPLICATION_JSON); |
129 | assertEquals(CoAP.ResponseCode.CREATED, coapResponse.getCode()); | 128 | assertEquals(CoAP.ResponseCode.CREATED, coapResponse.getCode()); |
130 | } | 129 | } |
@@ -71,7 +71,7 @@ public abstract class AbstractCoapAttributesUpdatesIntegrationTest extends Abstr | @@ -71,7 +71,7 @@ public abstract class AbstractCoapAttributesUpdatesIntegrationTest extends Abstr | ||
71 | if (!emptyCurrentStateNotification) { | 71 | if (!emptyCurrentStateNotification) { |
72 | doPostAsync("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/attributes/SHARED_SCOPE", POST_ATTRIBUTES_PAYLOAD_ON_CURRENT_STATE_NOTIFICATION, String.class, status().isOk()); | 72 | doPostAsync("/api/plugins/telemetry/DEVICE/" + savedDevice.getId().getId() + "/attributes/SHARED_SCOPE", POST_ATTRIBUTES_PAYLOAD_ON_CURRENT_STATE_NOTIFICATION, String.class, status().isOk()); |
73 | } | 73 | } |
74 | - CoapClient client = getCoapClient(FeatureType.ATTRIBUTES); | 74 | + client = getCoapClient(FeatureType.ATTRIBUTES); |
75 | 75 | ||
76 | CountDownLatch latch = new CountDownLatch(1); | 76 | CountDownLatch latch = new CountDownLatch(1); |
77 | TestCoapCallback callback = new TestCoapCallback(latch); | 77 | TestCoapCallback callback = new TestCoapCallback(latch); |
@@ -90,7 +90,7 @@ public abstract class AbstractCoapClaimDeviceTest extends AbstractCoapIntegratio | @@ -90,7 +90,7 @@ public abstract class AbstractCoapClaimDeviceTest extends AbstractCoapIntegratio | ||
90 | 90 | ||
91 | protected void processTestClaimingDevice(boolean emptyPayload) throws Exception { | 91 | protected void processTestClaimingDevice(boolean emptyPayload) throws Exception { |
92 | log.warn("[testClaimingDevice] Device: {}, Transport type: {}", savedDevice.getName(), savedDevice.getType()); | 92 | log.warn("[testClaimingDevice] Device: {}, Transport type: {}", savedDevice.getName(), savedDevice.getType()); |
93 | - CoapClient client = getCoapClient(FeatureType.CLAIM); | 93 | + client = getCoapClient(FeatureType.CLAIM); |
94 | byte[] payloadBytes; | 94 | byte[] payloadBytes; |
95 | byte[] failurePayloadBytes; | 95 | byte[] failurePayloadBytes; |
96 | if (emptyPayload) { | 96 | if (emptyPayload) { |
@@ -49,7 +49,7 @@ public abstract class AbstractCoapClaimProtoDeviceTest extends AbstractCoapClaim | @@ -49,7 +49,7 @@ public abstract class AbstractCoapClaimProtoDeviceTest extends AbstractCoapClaim | ||
49 | 49 | ||
50 | @Override | 50 | @Override |
51 | protected void processTestClaimingDevice(boolean emptyPayload) throws Exception { | 51 | protected void processTestClaimingDevice(boolean emptyPayload) throws Exception { |
52 | - CoapClient client = getCoapClient(FeatureType.CLAIM); | 52 | + client = getCoapClient(FeatureType.CLAIM); |
53 | byte[] payloadBytes; | 53 | byte[] payloadBytes; |
54 | if (emptyPayload) { | 54 | if (emptyPayload) { |
55 | TransportApiProtos.ClaimDevice claimDevice = getClaimDevice(0, emptyPayload); | 55 | TransportApiProtos.ClaimDevice claimDevice = getClaimDevice(0, emptyPayload); |
@@ -180,7 +180,7 @@ public abstract class AbstractCoapProvisionJsonDeviceTest extends AbstractCoapIn | @@ -180,7 +180,7 @@ public abstract class AbstractCoapProvisionJsonDeviceTest extends AbstractCoapIn | ||
180 | 180 | ||
181 | private CoapResponse createCoapClientAndPublish(String deviceCredentials) throws Exception { | 181 | private CoapResponse createCoapClientAndPublish(String deviceCredentials) throws Exception { |
182 | String provisionRequestMsg = createTestProvisionMessage(deviceCredentials); | 182 | String provisionRequestMsg = createTestProvisionMessage(deviceCredentials); |
183 | - CoapClient client = getCoapClient(FeatureType.PROVISION); | 183 | + client = getCoapClient(FeatureType.PROVISION); |
184 | return postProvision(client, provisionRequestMsg.getBytes()); | 184 | return postProvision(client, provisionRequestMsg.getBytes()); |
185 | } | 185 | } |
186 | 186 |
@@ -172,11 +172,13 @@ public abstract class AbstractCoapProvisionProtoDeviceTest extends AbstractCoapI | @@ -172,11 +172,13 @@ public abstract class AbstractCoapProvisionProtoDeviceTest extends AbstractCoapI | ||
172 | 172 | ||
173 | private CoapResponse createCoapClientAndPublish() throws Exception { | 173 | private CoapResponse createCoapClientAndPublish() throws Exception { |
174 | byte[] provisionRequestMsg = createTestProvisionMessage(); | 174 | byte[] provisionRequestMsg = createTestProvisionMessage(); |
175 | - return createCoapClientAndPublish(provisionRequestMsg); | 175 | + CoapResponse coapResponse = createCoapClientAndPublish(provisionRequestMsg); |
176 | + Assert.assertNotNull("COAP response", coapResponse); | ||
177 | + return coapResponse; | ||
176 | } | 178 | } |
177 | 179 | ||
178 | private CoapResponse createCoapClientAndPublish(byte[] provisionRequestMsg) throws Exception { | 180 | private CoapResponse createCoapClientAndPublish(byte[] provisionRequestMsg) throws Exception { |
179 | - CoapClient client = getCoapClient(FeatureType.PROVISION); | 181 | + client = getCoapClient(FeatureType.PROVISION); |
180 | return postProvision(client, provisionRequestMsg); | 182 | return postProvision(client, provisionRequestMsg); |
181 | } | 183 | } |
182 | 184 |
@@ -54,7 +54,7 @@ public abstract class AbstractCoapServerSideRpcIntegrationTest extends AbstractC | @@ -54,7 +54,7 @@ public abstract class AbstractCoapServerSideRpcIntegrationTest extends AbstractC | ||
54 | } | 54 | } |
55 | 55 | ||
56 | protected void processOneWayRpcTest() throws Exception { | 56 | protected void processOneWayRpcTest() throws Exception { |
57 | - CoapClient client = getCoapClient(FeatureType.RPC); | 57 | + client = getCoapClient(FeatureType.RPC); |
58 | client.useCONs(); | 58 | client.useCONs(); |
59 | 59 | ||
60 | CountDownLatch latch = new CountDownLatch(1); | 60 | CountDownLatch latch = new CountDownLatch(1); |
@@ -82,7 +82,7 @@ public abstract class AbstractCoapServerSideRpcIntegrationTest extends AbstractC | @@ -82,7 +82,7 @@ public abstract class AbstractCoapServerSideRpcIntegrationTest extends AbstractC | ||
82 | } | 82 | } |
83 | 83 | ||
84 | protected void processTwoWayRpcTest(String expectedResponseResult) throws Exception { | 84 | protected void processTwoWayRpcTest(String expectedResponseResult) throws Exception { |
85 | - CoapClient client = getCoapClient(FeatureType.RPC); | 85 | + client = getCoapClient(FeatureType.RPC); |
86 | client.useCONs(); | 86 | client.useCONs(); |
87 | 87 | ||
88 | CountDownLatch latch = new CountDownLatch(1); | 88 | CountDownLatch latch = new CountDownLatch(1); |
@@ -69,7 +69,7 @@ public abstract class AbstractCoapAttributesIntegrationTest extends AbstractCoap | @@ -69,7 +69,7 @@ public abstract class AbstractCoapAttributesIntegrationTest extends AbstractCoap | ||
69 | } | 69 | } |
70 | 70 | ||
71 | protected void processAttributesTest(List<String> expectedKeys, byte[] payload, boolean presenceFieldsTest) throws Exception { | 71 | protected void processAttributesTest(List<String> expectedKeys, byte[] payload, boolean presenceFieldsTest) throws Exception { |
72 | - CoapClient client = getCoapClient(FeatureType.ATTRIBUTES); | 72 | + client = getCoapClient(FeatureType.ATTRIBUTES); |
73 | 73 | ||
74 | postAttributes(client, payload); | 74 | postAttributes(client, payload); |
75 | 75 |
@@ -71,8 +71,8 @@ public abstract class AbstractCoapTimeseriesIntegrationTest extends AbstractCoap | @@ -71,8 +71,8 @@ public abstract class AbstractCoapTimeseriesIntegrationTest extends AbstractCoap | ||
71 | } | 71 | } |
72 | 72 | ||
73 | protected void processTestPostTelemetry(byte[] payloadBytes, List<String> expectedKeys, boolean withTs, boolean presenceFieldsTest) throws Exception { | 73 | protected void processTestPostTelemetry(byte[] payloadBytes, List<String> expectedKeys, boolean withTs, boolean presenceFieldsTest) throws Exception { |
74 | - CoapClient coapClient = getCoapClient(FeatureType.TELEMETRY); | ||
75 | - postTelemetry(coapClient, payloadBytes); | 74 | + client = getCoapClient(FeatureType.TELEMETRY); |
75 | + postTelemetry(client, payloadBytes); | ||
76 | 76 | ||
77 | String deviceId = savedDevice.getId().getId().toString(); | 77 | String deviceId = savedDevice.getId().getId().toString(); |
78 | 78 |
@@ -23,6 +23,7 @@ import org.eclipse.leshan.core.node.LwM2mResource; | @@ -23,6 +23,7 @@ import org.eclipse.leshan.core.node.LwM2mResource; | ||
23 | import org.eclipse.leshan.core.response.ExecuteResponse; | 23 | import org.eclipse.leshan.core.response.ExecuteResponse; |
24 | import org.eclipse.leshan.core.response.ReadResponse; | 24 | import org.eclipse.leshan.core.response.ReadResponse; |
25 | import org.eclipse.leshan.core.response.WriteResponse; | 25 | import org.eclipse.leshan.core.response.WriteResponse; |
26 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
26 | 27 | ||
27 | import javax.security.auth.Destroyable; | 28 | import javax.security.auth.Destroyable; |
28 | import java.util.Arrays; | 29 | import java.util.Arrays; |
@@ -37,7 +38,7 @@ public class FwLwM2MDevice extends BaseInstanceEnabler implements Destroyable { | @@ -37,7 +38,7 @@ public class FwLwM2MDevice extends BaseInstanceEnabler implements Destroyable { | ||
37 | 38 | ||
38 | private static final List<Integer> supportedResources = Arrays.asList(0, 1, 2, 3, 5, 6, 7, 9); | 39 | private static final List<Integer> supportedResources = Arrays.asList(0, 1, 2, 3, 5, 6, 7, 9); |
39 | 40 | ||
40 | - private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); | 41 | + private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName(getClass().getSimpleName() + "-test-scope")); |
41 | 42 | ||
42 | private final AtomicInteger state = new AtomicInteger(0); | 43 | private final AtomicInteger state = new AtomicInteger(0); |
43 | 44 |
@@ -45,6 +45,7 @@ import org.eclipse.leshan.core.request.BootstrapRequest; | @@ -45,6 +45,7 @@ import org.eclipse.leshan.core.request.BootstrapRequest; | ||
45 | import org.eclipse.leshan.core.request.DeregisterRequest; | 45 | import org.eclipse.leshan.core.request.DeregisterRequest; |
46 | import org.eclipse.leshan.core.request.RegisterRequest; | 46 | import org.eclipse.leshan.core.request.RegisterRequest; |
47 | import org.eclipse.leshan.core.request.UpdateRequest; | 47 | import org.eclipse.leshan.core.request.UpdateRequest; |
48 | +import org.junit.Assert; | ||
48 | 49 | ||
49 | import java.io.IOException; | 50 | import java.io.IOException; |
50 | import java.net.InetSocketAddress; | 51 | import java.net.InetSocketAddress; |
@@ -65,8 +66,11 @@ public class LwM2MTestClient { | @@ -65,8 +66,11 @@ public class LwM2MTestClient { | ||
65 | private final ScheduledExecutorService executor; | 66 | private final ScheduledExecutorService executor; |
66 | private final String endpoint; | 67 | private final String endpoint; |
67 | private LeshanClient client; | 68 | private LeshanClient client; |
69 | + private FwLwM2MDevice fwLwM2MDevice; | ||
70 | + private SwLwM2MDevice swLwM2MDevice; | ||
68 | 71 | ||
69 | public void init(Security security, NetworkConfig coapConfig) throws InvalidDDFFileException, IOException { | 72 | public void init(Security security, NetworkConfig coapConfig) throws InvalidDDFFileException, IOException { |
73 | + Assert.assertNull("client already initialized", client); | ||
70 | String[] resources = new String[]{"0.xml", "1.xml", "2.xml", "3.xml", "5.xml", "9.xml"}; | 74 | String[] resources = new String[]{"0.xml", "1.xml", "2.xml", "3.xml", "5.xml", "9.xml"}; |
71 | List<ObjectModel> models = new ArrayList<>(); | 75 | List<ObjectModel> models = new ArrayList<>(); |
72 | for (String resourceName : resources) { | 76 | for (String resourceName : resources) { |
@@ -77,8 +81,8 @@ public class LwM2MTestClient { | @@ -77,8 +81,8 @@ public class LwM2MTestClient { | ||
77 | initializer.setInstancesForObject(SECURITY, security); | 81 | initializer.setInstancesForObject(SECURITY, security); |
78 | initializer.setInstancesForObject(SERVER, new Server(123, 300)); | 82 | initializer.setInstancesForObject(SERVER, new Server(123, 300)); |
79 | initializer.setInstancesForObject(DEVICE, new SimpleLwM2MDevice()); | 83 | initializer.setInstancesForObject(DEVICE, new SimpleLwM2MDevice()); |
80 | - initializer.setInstancesForObject(FIRMWARE, new FwLwM2MDevice()); | ||
81 | - initializer.setInstancesForObject(SOFTWARE_MANAGEMENT, new SwLwM2MDevice()); | 84 | + initializer.setInstancesForObject(FIRMWARE, fwLwM2MDevice = new FwLwM2MDevice()); |
85 | + initializer.setInstancesForObject(SOFTWARE_MANAGEMENT, swLwM2MDevice = new SwLwM2MDevice()); | ||
82 | initializer.setClassForObject(LwM2mId.ACCESS_CONTROL, DummyInstanceEnabler.class); | 86 | initializer.setClassForObject(LwM2mId.ACCESS_CONTROL, DummyInstanceEnabler.class); |
83 | 87 | ||
84 | DtlsConnectorConfig.Builder dtlsConfig = new DtlsConnectorConfig.Builder(); | 88 | DtlsConnectorConfig.Builder dtlsConfig = new DtlsConnectorConfig.Builder(); |
@@ -229,6 +233,12 @@ public class LwM2MTestClient { | @@ -229,6 +233,12 @@ public class LwM2MTestClient { | ||
229 | 233 | ||
230 | public void destroy() { | 234 | public void destroy() { |
231 | client.destroy(true); | 235 | client.destroy(true); |
236 | + if (fwLwM2MDevice != null) { | ||
237 | + fwLwM2MDevice.destroy(); | ||
238 | + } | ||
239 | + if (swLwM2MDevice != null) { | ||
240 | + swLwM2MDevice.destroy(); | ||
241 | + } | ||
232 | } | 242 | } |
233 | 243 | ||
234 | } | 244 | } |
@@ -24,6 +24,7 @@ import org.eclipse.leshan.core.node.LwM2mResource; | @@ -24,6 +24,7 @@ import org.eclipse.leshan.core.node.LwM2mResource; | ||
24 | import org.eclipse.leshan.core.response.ExecuteResponse; | 24 | import org.eclipse.leshan.core.response.ExecuteResponse; |
25 | import org.eclipse.leshan.core.response.ReadResponse; | 25 | import org.eclipse.leshan.core.response.ReadResponse; |
26 | import org.eclipse.leshan.core.response.WriteResponse; | 26 | import org.eclipse.leshan.core.response.WriteResponse; |
27 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
27 | 28 | ||
28 | import javax.security.auth.Destroyable; | 29 | import javax.security.auth.Destroyable; |
29 | import java.util.Arrays; | 30 | import java.util.Arrays; |
@@ -38,7 +39,7 @@ public class SwLwM2MDevice extends BaseInstanceEnabler implements Destroyable { | @@ -38,7 +39,7 @@ public class SwLwM2MDevice extends BaseInstanceEnabler implements Destroyable { | ||
38 | 39 | ||
39 | private static final List<Integer> supportedResources = Arrays.asList(0, 1, 2, 3, 4, 6, 7, 9); | 40 | private static final List<Integer> supportedResources = Arrays.asList(0, 1, 2, 3, 4, 6, 7, 9); |
40 | 41 | ||
41 | - private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); | 42 | + private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName(getClass().getSimpleName() + "-test-scope")); |
42 | 43 | ||
43 | private final AtomicInteger state = new AtomicInteger(0); | 44 | private final AtomicInteger state = new AtomicInteger(0); |
44 | 45 |
@@ -17,10 +17,12 @@ package org.thingsboard.server.util; | @@ -17,10 +17,12 @@ package org.thingsboard.server.util; | ||
17 | 17 | ||
18 | import com.google.common.util.concurrent.MoreExecutors; | 18 | import com.google.common.util.concurrent.MoreExecutors; |
19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
20 | +import org.junit.After; | ||
20 | import org.junit.Test; | 21 | import org.junit.Test; |
21 | import org.junit.runner.RunWith; | 22 | import org.junit.runner.RunWith; |
22 | import org.mockito.Mockito; | 23 | import org.mockito.Mockito; |
23 | import org.mockito.junit.MockitoJUnitRunner; | 24 | import org.mockito.junit.MockitoJUnitRunner; |
25 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
24 | import org.thingsboard.server.utils.EventDeduplicationExecutor; | 26 | import org.thingsboard.server.utils.EventDeduplicationExecutor; |
25 | 27 | ||
26 | import java.util.concurrent.ExecutorService; | 28 | import java.util.concurrent.ExecutorService; |
@@ -31,6 +33,16 @@ import java.util.function.Consumer; | @@ -31,6 +33,16 @@ import java.util.function.Consumer; | ||
31 | @RunWith(MockitoJUnitRunner.class) | 33 | @RunWith(MockitoJUnitRunner.class) |
32 | public class EventDeduplicationExecutorTest { | 34 | public class EventDeduplicationExecutorTest { |
33 | 35 | ||
36 | + ThingsBoardThreadFactory threadFactory = ThingsBoardThreadFactory.forName(getClass().getSimpleName()); | ||
37 | + ExecutorService executor; | ||
38 | + | ||
39 | + @After | ||
40 | + public void tearDown() throws Exception { | ||
41 | + if (executor != null) { | ||
42 | + executor.shutdownNow(); | ||
43 | + } | ||
44 | + } | ||
45 | + | ||
34 | @Test | 46 | @Test |
35 | public void testSimpleFlowSameThread() throws InterruptedException { | 47 | public void testSimpleFlowSameThread() throws InterruptedException { |
36 | simpleFlow(MoreExecutors.newDirectExecutorService()); | 48 | simpleFlow(MoreExecutors.newDirectExecutorService()); |
@@ -48,32 +60,38 @@ public class EventDeduplicationExecutorTest { | @@ -48,32 +60,38 @@ public class EventDeduplicationExecutorTest { | ||
48 | 60 | ||
49 | @Test | 61 | @Test |
50 | public void testSimpleFlowSingleThread() throws InterruptedException { | 62 | public void testSimpleFlowSingleThread() throws InterruptedException { |
51 | - simpleFlow(Executors.newSingleThreadExecutor()); | 63 | + executor = Executors.newSingleThreadExecutor(threadFactory); |
64 | + simpleFlow(executor); | ||
52 | } | 65 | } |
53 | 66 | ||
54 | @Test | 67 | @Test |
55 | public void testPeriodicFlowSingleThread() throws InterruptedException { | 68 | public void testPeriodicFlowSingleThread() throws InterruptedException { |
56 | - periodicFlow(Executors.newSingleThreadExecutor()); | 69 | + executor = Executors.newSingleThreadExecutor(threadFactory); |
70 | + periodicFlow(executor); | ||
57 | } | 71 | } |
58 | 72 | ||
59 | @Test | 73 | @Test |
60 | public void testExceptionFlowSingleThread() throws InterruptedException { | 74 | public void testExceptionFlowSingleThread() throws InterruptedException { |
61 | - exceptionFlow(Executors.newSingleThreadExecutor()); | 75 | + executor = Executors.newSingleThreadExecutor(threadFactory); |
76 | + exceptionFlow(executor); | ||
62 | } | 77 | } |
63 | 78 | ||
64 | @Test | 79 | @Test |
65 | public void testSimpleFlowMultiThread() throws InterruptedException { | 80 | public void testSimpleFlowMultiThread() throws InterruptedException { |
66 | - simpleFlow(Executors.newFixedThreadPool(3)); | 81 | + executor = Executors.newFixedThreadPool(3, threadFactory); |
82 | + simpleFlow(executor); | ||
67 | } | 83 | } |
68 | 84 | ||
69 | @Test | 85 | @Test |
70 | public void testPeriodicFlowMultiThread() throws InterruptedException { | 86 | public void testPeriodicFlowMultiThread() throws InterruptedException { |
71 | - periodicFlow(Executors.newFixedThreadPool(3)); | 87 | + executor = Executors.newFixedThreadPool(3, threadFactory); |
88 | + periodicFlow(executor); | ||
72 | } | 89 | } |
73 | 90 | ||
74 | @Test | 91 | @Test |
75 | public void testExceptionFlowMultiThread() throws InterruptedException { | 92 | public void testExceptionFlowMultiThread() throws InterruptedException { |
76 | - exceptionFlow(Executors.newFixedThreadPool(3)); | 93 | + executor = Executors.newFixedThreadPool(3, threadFactory); |
94 | + exceptionFlow(executor); | ||
77 | } | 95 | } |
78 | 96 | ||
79 | private void simpleFlow(ExecutorService executorService) throws InterruptedException { | 97 | private void simpleFlow(ExecutorService executorService) throws InterruptedException { |
@@ -22,6 +22,8 @@ import org.junit.Before; | @@ -22,6 +22,8 @@ import org.junit.Before; | ||
22 | import org.junit.Test; | 22 | import org.junit.Test; |
23 | import org.junit.runner.RunWith; | 23 | import org.junit.runner.RunWith; |
24 | import org.mockito.junit.MockitoJUnitRunner; | 24 | import org.mockito.junit.MockitoJUnitRunner; |
25 | +import org.thingsboard.common.util.ThingsBoardExecutors; | ||
26 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
25 | import org.thingsboard.server.common.data.id.DeviceId; | 27 | import org.thingsboard.server.common.data.id.DeviceId; |
26 | 28 | ||
27 | import java.util.ArrayList; | 29 | import java.util.ArrayList; |
@@ -45,6 +47,7 @@ public class ActorSystemTest { | @@ -45,6 +47,7 @@ public class ActorSystemTest { | ||
45 | 47 | ||
46 | private volatile TbActorSystem actorSystem; | 48 | private volatile TbActorSystem actorSystem; |
47 | private volatile ExecutorService submitPool; | 49 | private volatile ExecutorService submitPool; |
50 | + private ExecutorService executor; | ||
48 | private int parallelism; | 51 | private int parallelism; |
49 | 52 | ||
50 | @Before | 53 | @Before |
@@ -53,54 +56,64 @@ public class ActorSystemTest { | @@ -53,54 +56,64 @@ public class ActorSystemTest { | ||
53 | parallelism = Math.max(2, cores / 2); | 56 | parallelism = Math.max(2, cores / 2); |
54 | TbActorSystemSettings settings = new TbActorSystemSettings(5, parallelism, 42); | 57 | TbActorSystemSettings settings = new TbActorSystemSettings(5, parallelism, 42); |
55 | actorSystem = new DefaultTbActorSystem(settings); | 58 | actorSystem = new DefaultTbActorSystem(settings); |
56 | - submitPool = Executors.newFixedThreadPool(parallelism); //order guaranteed | 59 | + submitPool = Executors.newFixedThreadPool(parallelism, ThingsBoardThreadFactory.forName(getClass().getSimpleName() + "-submit-test-scope")); //order guaranteed |
57 | } | 60 | } |
58 | 61 | ||
59 | @After | 62 | @After |
60 | public void shutdownActorSystem() { | 63 | public void shutdownActorSystem() { |
61 | actorSystem.stop(); | 64 | actorSystem.stop(); |
62 | submitPool.shutdownNow(); | 65 | submitPool.shutdownNow(); |
66 | + if (executor != null) { | ||
67 | + executor.shutdownNow(); | ||
68 | + } | ||
63 | } | 69 | } |
64 | 70 | ||
65 | @Test | 71 | @Test |
66 | public void test1actorsAnd100KMessages() throws InterruptedException { | 72 | public void test1actorsAnd100KMessages() throws InterruptedException { |
67 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 73 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
74 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
68 | testActorsAndMessages(1, _100K, 1); | 75 | testActorsAndMessages(1, _100K, 1); |
69 | } | 76 | } |
70 | 77 | ||
71 | @Test | 78 | @Test |
72 | public void test10actorsAnd100KMessages() throws InterruptedException { | 79 | public void test10actorsAnd100KMessages() throws InterruptedException { |
73 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 80 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
81 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
74 | testActorsAndMessages(10, _100K, 1); | 82 | testActorsAndMessages(10, _100K, 1); |
75 | } | 83 | } |
76 | 84 | ||
77 | @Test | 85 | @Test |
78 | public void test100KActorsAnd1Messages5timesSingleThread() throws InterruptedException { | 86 | public void test100KActorsAnd1Messages5timesSingleThread() throws InterruptedException { |
79 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newSingleThreadExecutor()); | 87 | + executor = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName(getClass().getSimpleName())); |
88 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
80 | testActorsAndMessages(_100K, 1, 5); | 89 | testActorsAndMessages(_100K, 1, 5); |
81 | } | 90 | } |
82 | 91 | ||
83 | @Test | 92 | @Test |
84 | public void test100KActorsAnd1Messages5times() throws InterruptedException { | 93 | public void test100KActorsAnd1Messages5times() throws InterruptedException { |
85 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 94 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
95 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
86 | testActorsAndMessages(_100K, 1, 5); | 96 | testActorsAndMessages(_100K, 1, 5); |
87 | } | 97 | } |
88 | 98 | ||
89 | @Test | 99 | @Test |
90 | public void test100KActorsAnd10Messages() throws InterruptedException { | 100 | public void test100KActorsAnd10Messages() throws InterruptedException { |
91 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 101 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
102 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
92 | testActorsAndMessages(_100K, 10, 1); | 103 | testActorsAndMessages(_100K, 10, 1); |
93 | } | 104 | } |
94 | 105 | ||
95 | @Test | 106 | @Test |
96 | public void test1KActorsAnd1KMessages() throws InterruptedException { | 107 | public void test1KActorsAnd1KMessages() throws InterruptedException { |
97 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 108 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
109 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
98 | testActorsAndMessages(1000, 1000, 10); | 110 | testActorsAndMessages(1000, 1000, 10); |
99 | } | 111 | } |
100 | 112 | ||
101 | @Test | 113 | @Test |
102 | public void testNoMessagesAfterDestroy() throws InterruptedException { | 114 | public void testNoMessagesAfterDestroy() throws InterruptedException { |
103 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 115 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
116 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
104 | ActorTestCtx testCtx1 = getActorTestCtx(1); | 117 | ActorTestCtx testCtx1 = getActorTestCtx(1); |
105 | ActorTestCtx testCtx2 = getActorTestCtx(1); | 118 | ActorTestCtx testCtx2 = getActorTestCtx(1); |
106 | 119 | ||
@@ -119,7 +132,8 @@ public class ActorSystemTest { | @@ -119,7 +132,8 @@ public class ActorSystemTest { | ||
119 | 132 | ||
120 | @Test | 133 | @Test |
121 | public void testOneActorCreated() throws InterruptedException { | 134 | public void testOneActorCreated() throws InterruptedException { |
122 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 135 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
136 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
123 | ActorTestCtx testCtx1 = getActorTestCtx(1); | 137 | ActorTestCtx testCtx1 = getActorTestCtx(1); |
124 | ActorTestCtx testCtx2 = getActorTestCtx(1); | 138 | ActorTestCtx testCtx2 = getActorTestCtx(1); |
125 | TbActorId actorId = new TbEntityActorId(new DeviceId(UUID.randomUUID())); | 139 | TbActorId actorId = new TbEntityActorId(new DeviceId(UUID.randomUUID())); |
@@ -145,7 +159,8 @@ public class ActorSystemTest { | @@ -145,7 +159,8 @@ public class ActorSystemTest { | ||
145 | 159 | ||
146 | @Test | 160 | @Test |
147 | public void testActorCreatorCalledOnce() throws InterruptedException { | 161 | public void testActorCreatorCalledOnce() throws InterruptedException { |
148 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 162 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
163 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
149 | ActorTestCtx testCtx = getActorTestCtx(1); | 164 | ActorTestCtx testCtx = getActorTestCtx(1); |
150 | TbActorId actorId = new TbEntityActorId(new DeviceId(UUID.randomUUID())); | 165 | TbActorId actorId = new TbEntityActorId(new DeviceId(UUID.randomUUID())); |
151 | final int actorsCount = 1000; | 166 | final int actorsCount = 1000; |
@@ -169,7 +184,8 @@ public class ActorSystemTest { | @@ -169,7 +184,8 @@ public class ActorSystemTest { | ||
169 | 184 | ||
170 | @Test | 185 | @Test |
171 | public void testFailedInit() throws InterruptedException { | 186 | public void testFailedInit() throws InterruptedException { |
172 | - actorSystem.createDispatcher(ROOT_DISPATCHER, Executors.newWorkStealingPool(parallelism)); | 187 | + executor = ThingsBoardExecutors.newWorkStealingPool(parallelism, getClass()); |
188 | + actorSystem.createDispatcher(ROOT_DISPATCHER, executor); | ||
173 | ActorTestCtx testCtx1 = getActorTestCtx(1); | 189 | ActorTestCtx testCtx1 = getActorTestCtx(1); |
174 | ActorTestCtx testCtx2 = getActorTestCtx(1); | 190 | ActorTestCtx testCtx2 = getActorTestCtx(1); |
175 | 191 |
@@ -24,6 +24,7 @@ import org.eclipse.californium.scandium.DTLSConnector; | @@ -24,6 +24,7 @@ import org.eclipse.californium.scandium.DTLSConnector; | ||
24 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; | 24 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; |
25 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
26 | import org.springframework.stereotype.Component; | 26 | import org.springframework.stereotype.Component; |
27 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
27 | 28 | ||
28 | import javax.annotation.PostConstruct; | 29 | import javax.annotation.PostConstruct; |
29 | import javax.annotation.PreDestroy; | 30 | import javax.annotation.PreDestroy; |
@@ -118,7 +119,7 @@ public class DefaultCoapServerService implements CoapServerService { | @@ -118,7 +119,7 @@ public class DefaultCoapServerService implements CoapServerService { | ||
118 | CoapEndpoint dtlsCoapEndpoint = dtlsCoapEndpointBuilder.build(); | 119 | CoapEndpoint dtlsCoapEndpoint = dtlsCoapEndpointBuilder.build(); |
119 | server.addEndpoint(dtlsCoapEndpoint); | 120 | server.addEndpoint(dtlsCoapEndpoint); |
120 | tbDtlsCertificateVerifier = (TbCoapDtlsCertificateVerifier) dtlsConnectorConfig.getAdvancedCertificateVerifier(); | 121 | tbDtlsCertificateVerifier = (TbCoapDtlsCertificateVerifier) dtlsConnectorConfig.getAdvancedCertificateVerifier(); |
121 | - dtlsSessionsExecutor = Executors.newSingleThreadScheduledExecutor(); | 122 | + dtlsSessionsExecutor = Executors.newSingleThreadScheduledExecutor(ThingsBoardThreadFactory.forName(getClass().getSimpleName())); |
122 | dtlsSessionsExecutor.scheduleAtFixedRate(this::evictTimeoutSessions, new Random().nextInt((int) getDtlsSessionReportTimeout()), getDtlsSessionReportTimeout(), TimeUnit.MILLISECONDS); | 123 | dtlsSessionsExecutor.scheduleAtFixedRate(this::evictTimeoutSessions, new Random().nextInt((int) getDtlsSessionReportTimeout()), getDtlsSessionReportTimeout(), TimeUnit.MILLISECONDS); |
123 | } | 124 | } |
124 | Resource root = server.getRoot(); | 125 | Resource root = server.getRoot(); |
@@ -18,6 +18,7 @@ package org.thingsboard.server.queue.common; | @@ -18,6 +18,7 @@ package org.thingsboard.server.queue.common; | ||
18 | import com.google.common.util.concurrent.ListeningExecutorService; | 18 | import com.google.common.util.concurrent.ListeningExecutorService; |
19 | import com.google.common.util.concurrent.MoreExecutors; | 19 | import com.google.common.util.concurrent.MoreExecutors; |
20 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
21 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
21 | import org.thingsboard.server.queue.TbQueueMsg; | 22 | import org.thingsboard.server.queue.TbQueueMsg; |
22 | 23 | ||
23 | import java.util.concurrent.Executors; | 24 | import java.util.concurrent.Executors; |
@@ -41,7 +42,7 @@ public abstract class AbstractParallelTbQueueConsumerTemplate<R, T extends TbQue | @@ -41,7 +42,7 @@ public abstract class AbstractParallelTbQueueConsumerTemplate<R, T extends TbQue | ||
41 | log.trace("Interrupted while waiting for consumer executor to stop"); | 42 | log.trace("Interrupted while waiting for consumer executor to stop"); |
42 | } | 43 | } |
43 | } | 44 | } |
44 | - consumerExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(threadPoolSize)); | 45 | + consumerExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(threadPoolSize, ThingsBoardThreadFactory.forName(getClass().getSimpleName()))); |
45 | } | 46 | } |
46 | 47 | ||
47 | protected void shutdownExecutor() { | 48 | protected void shutdownExecutor() { |
@@ -21,6 +21,7 @@ import org.eclipse.californium.core.Utils; | @@ -21,6 +21,7 @@ import org.eclipse.californium.core.Utils; | ||
21 | import org.eclipse.californium.elements.DtlsEndpointContext; | 21 | import org.eclipse.californium.elements.DtlsEndpointContext; |
22 | import org.eclipse.californium.elements.EndpointContext; | 22 | import org.eclipse.californium.elements.EndpointContext; |
23 | import org.eclipse.californium.elements.exception.ConnectorException; | 23 | import org.eclipse.californium.elements.exception.ConnectorException; |
24 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
24 | 25 | ||
25 | import java.io.IOException; | 26 | import java.io.IOException; |
26 | import java.net.URI; | 27 | import java.net.URI; |
@@ -31,7 +32,7 @@ import java.util.concurrent.Executors; | @@ -31,7 +32,7 @@ import java.util.concurrent.Executors; | ||
31 | 32 | ||
32 | public class NoSecClient { | 33 | public class NoSecClient { |
33 | 34 | ||
34 | - private ExecutorService executor = Executors.newFixedThreadPool(1); | 35 | + private ExecutorService executor = Executors.newFixedThreadPool(1, ThingsBoardThreadFactory.forName(getClass().getSimpleName())); |
35 | private CoapClient coapClient; | 36 | private CoapClient coapClient; |
36 | 37 | ||
37 | public NoSecClient(String host, int port, String accessToken, String clientKeys, String sharedKeys) throws URISyntaxException { | 38 | public NoSecClient(String host, int port, String accessToken, String clientKeys, String sharedKeys) throws URISyntaxException { |
@@ -22,6 +22,7 @@ import org.eclipse.californium.core.CoapObserveRelation; | @@ -22,6 +22,7 @@ import org.eclipse.californium.core.CoapObserveRelation; | ||
22 | import org.eclipse.californium.core.CoapResponse; | 22 | import org.eclipse.californium.core.CoapResponse; |
23 | import org.eclipse.californium.core.coap.CoAP; | 23 | import org.eclipse.californium.core.coap.CoAP; |
24 | import org.eclipse.californium.core.coap.Request; | 24 | import org.eclipse.californium.core.coap.Request; |
25 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
25 | 26 | ||
26 | import java.net.URI; | 27 | import java.net.URI; |
27 | import java.net.URISyntaxException; | 28 | import java.net.URISyntaxException; |
@@ -36,7 +37,7 @@ public class NoSecObserveClient { | @@ -36,7 +37,7 @@ public class NoSecObserveClient { | ||
36 | 37 | ||
37 | private CoapClient coapClient; | 38 | private CoapClient coapClient; |
38 | private CoapObserveRelation observeRelation; | 39 | private CoapObserveRelation observeRelation; |
39 | - private ExecutorService executor = Executors.newFixedThreadPool(1); | 40 | + private ExecutorService executor = Executors.newFixedThreadPool(1, ThingsBoardThreadFactory.forName(getClass().getSimpleName())); |
40 | private CountDownLatch latch; | 41 | private CountDownLatch latch; |
41 | 42 | ||
42 | public NoSecObserveClient(String host, int port, String accessToken) throws URISyntaxException { | 43 | public NoSecObserveClient(String host, int port, String accessToken) throws URISyntaxException { |
@@ -27,6 +27,7 @@ import org.eclipse.californium.scandium.DTLSConnector; | @@ -27,6 +27,7 @@ import org.eclipse.californium.scandium.DTLSConnector; | ||
27 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; | 27 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; |
28 | import org.eclipse.californium.scandium.dtls.CertificateType; | 28 | import org.eclipse.californium.scandium.dtls.CertificateType; |
29 | import org.eclipse.californium.scandium.dtls.x509.StaticNewAdvancedCertificateVerifier; | 29 | import org.eclipse.californium.scandium.dtls.x509.StaticNewAdvancedCertificateVerifier; |
30 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
30 | 31 | ||
31 | import java.io.IOException; | 32 | import java.io.IOException; |
32 | import java.net.URI; | 33 | import java.net.URI; |
@@ -41,7 +42,7 @@ import java.util.concurrent.Executors; | @@ -41,7 +42,7 @@ import java.util.concurrent.Executors; | ||
41 | public class SecureClientNoAuth { | 42 | public class SecureClientNoAuth { |
42 | 43 | ||
43 | private final DTLSConnector dtlsConnector; | 44 | private final DTLSConnector dtlsConnector; |
44 | - private ExecutorService executor = Executors.newFixedThreadPool(1); | 45 | + private ExecutorService executor = Executors.newFixedThreadPool(1, ThingsBoardThreadFactory.forName(getClass().getSimpleName())); |
45 | private CoapClient coapClient; | 46 | private CoapClient coapClient; |
46 | 47 | ||
47 | public SecureClientNoAuth(DTLSConnector dtlsConnector, String host, int port, String accessToken, String clientKeys, String sharedKeys) throws URISyntaxException { | 48 | public SecureClientNoAuth(DTLSConnector dtlsConnector, String host, int port, String accessToken, String clientKeys, String sharedKeys) throws URISyntaxException { |
@@ -27,6 +27,7 @@ import org.eclipse.californium.scandium.DTLSConnector; | @@ -27,6 +27,7 @@ import org.eclipse.californium.scandium.DTLSConnector; | ||
27 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; | 27 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; |
28 | import org.eclipse.californium.scandium.dtls.CertificateType; | 28 | import org.eclipse.californium.scandium.dtls.CertificateType; |
29 | import org.eclipse.californium.scandium.dtls.x509.StaticNewAdvancedCertificateVerifier; | 29 | import org.eclipse.californium.scandium.dtls.x509.StaticNewAdvancedCertificateVerifier; |
30 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
30 | 31 | ||
31 | import java.io.IOException; | 32 | import java.io.IOException; |
32 | import java.net.URI; | 33 | import java.net.URI; |
@@ -41,7 +42,7 @@ import java.util.concurrent.Executors; | @@ -41,7 +42,7 @@ import java.util.concurrent.Executors; | ||
41 | public class SecureClientX509 { | 42 | public class SecureClientX509 { |
42 | 43 | ||
43 | private final DTLSConnector dtlsConnector; | 44 | private final DTLSConnector dtlsConnector; |
44 | - private ExecutorService executor = Executors.newFixedThreadPool(1); | 45 | + private ExecutorService executor = Executors.newFixedThreadPool(1, ThingsBoardThreadFactory.forName(getClass().getSimpleName())); |
45 | private CoapClient coapClient; | 46 | private CoapClient coapClient; |
46 | 47 | ||
47 | public SecureClientX509(DTLSConnector dtlsConnector, String host, int port, String clientKeys, String sharedKeys) throws URISyntaxException { | 48 | public SecureClientX509(DTLSConnector dtlsConnector, String host, int port, String clientKeys, String sharedKeys) throws URISyntaxException { |
@@ -34,6 +34,7 @@ import org.snmp4j.transport.DefaultTcpTransportMapping; | @@ -34,6 +34,7 @@ import org.snmp4j.transport.DefaultTcpTransportMapping; | ||
34 | import org.snmp4j.transport.DefaultUdpTransportMapping; | 34 | import org.snmp4j.transport.DefaultUdpTransportMapping; |
35 | import org.springframework.beans.factory.annotation.Value; | 35 | import org.springframework.beans.factory.annotation.Value; |
36 | import org.springframework.stereotype.Service; | 36 | import org.springframework.stereotype.Service; |
37 | +import org.thingsboard.common.util.ThingsBoardExecutors; | ||
37 | import org.thingsboard.common.util.ThingsBoardThreadFactory; | 38 | import org.thingsboard.common.util.ThingsBoardThreadFactory; |
38 | import org.thingsboard.server.common.data.DataConstants; | 39 | import org.thingsboard.server.common.data.DataConstants; |
39 | import org.thingsboard.server.common.data.TbTransportService; | 40 | import org.thingsboard.server.common.data.TbTransportService; |
@@ -90,7 +91,7 @@ public class SnmpTransportService implements TbTransportService { | @@ -90,7 +91,7 @@ public class SnmpTransportService implements TbTransportService { | ||
90 | @PostConstruct | 91 | @PostConstruct |
91 | private void init() throws IOException { | 92 | private void init() throws IOException { |
92 | queryingExecutor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), ThingsBoardThreadFactory.forName("snmp-querying")); | 93 | queryingExecutor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors(), ThingsBoardThreadFactory.forName("snmp-querying")); |
93 | - responseProcessingExecutor = Executors.newWorkStealingPool(responseProcessingParallelismLevel); | 94 | + responseProcessingExecutor = ThingsBoardExecutors.newWorkStealingPool(responseProcessingParallelismLevel, "snmp-response-processing"); |
94 | 95 | ||
95 | initializeSnmp(); | 96 | initializeSnmp(); |
96 | configureResponseDataMappers(); | 97 | configureResponseDataMappers(); |
@@ -99,6 +100,16 @@ public class SnmpTransportService implements TbTransportService { | @@ -99,6 +100,16 @@ public class SnmpTransportService implements TbTransportService { | ||
99 | log.info("SNMP transport service initialized"); | 100 | log.info("SNMP transport service initialized"); |
100 | } | 101 | } |
101 | 102 | ||
103 | + @PreDestroy | ||
104 | + public void stop() { | ||
105 | + if (queryingExecutor != null) { | ||
106 | + queryingExecutor.shutdownNow(); | ||
107 | + } | ||
108 | + if (responseProcessingExecutor != null) { | ||
109 | + responseProcessingExecutor.shutdownNow(); | ||
110 | + } | ||
111 | + } | ||
112 | + | ||
102 | private void initializeSnmp() throws IOException { | 113 | private void initializeSnmp() throws IOException { |
103 | TransportMapping<?> transportMapping; | 114 | TransportMapping<?> transportMapping; |
104 | switch (snmpUnderlyingProtocol) { | 115 | switch (snmpUnderlyingProtocol) { |
@@ -24,6 +24,7 @@ import org.junit.Assert; | @@ -24,6 +24,7 @@ import org.junit.Assert; | ||
24 | import org.junit.Before; | 24 | import org.junit.Before; |
25 | import org.junit.Ignore; | 25 | import org.junit.Ignore; |
26 | import org.junit.Test; | 26 | import org.junit.Test; |
27 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
27 | import org.thingsboard.server.common.data.Device; | 28 | import org.thingsboard.server.common.data.Device; |
28 | import org.thingsboard.server.common.data.DeviceProfile; | 29 | import org.thingsboard.server.common.data.DeviceProfile; |
29 | import org.thingsboard.server.common.data.DeviceProfileInfo; | 30 | import org.thingsboard.server.common.data.DeviceProfileInfo; |
@@ -158,7 +159,7 @@ public class BaseDeviceProfileServiceTest extends AbstractServiceTest { | @@ -158,7 +159,7 @@ public class BaseDeviceProfileServiceTest extends AbstractServiceTest { | ||
158 | 159 | ||
159 | @Test | 160 | @Test |
160 | public void testFindOrCreateDeviceProfile() throws ExecutionException, InterruptedException { | 161 | public void testFindOrCreateDeviceProfile() throws ExecutionException, InterruptedException { |
161 | - ListeningExecutorService testExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(100)); | 162 | + ListeningExecutorService testExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(100, ThingsBoardThreadFactory.forName(getClass().getSimpleName() + "-test-scope"))); |
162 | try { | 163 | try { |
163 | List<ListenableFuture<DeviceProfile>> futures = new ArrayList<>(); | 164 | List<ListenableFuture<DeviceProfile>> futures = new ArrayList<>(); |
164 | for (int i = 0; i < 50; i++) { | 165 | for (int i = 0; i < 50; i++) { |
@@ -19,8 +19,10 @@ import com.datastax.oss.driver.api.core.uuid.Uuids; | @@ -19,8 +19,10 @@ import com.datastax.oss.driver.api.core.uuid.Uuids; | ||
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | import com.google.common.util.concurrent.ListeningExecutorService; | 20 | import com.google.common.util.concurrent.ListeningExecutorService; |
21 | import com.google.common.util.concurrent.MoreExecutors; | 21 | import com.google.common.util.concurrent.MoreExecutors; |
22 | +import org.junit.After; | ||
22 | import org.junit.Test; | 23 | import org.junit.Test; |
23 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
25 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
24 | import org.thingsboard.server.common.data.Device; | 26 | import org.thingsboard.server.common.data.Device; |
25 | import org.thingsboard.server.common.data.id.CustomerId; | 27 | import org.thingsboard.server.common.data.id.CustomerId; |
26 | import org.thingsboard.server.common.data.id.DeviceId; | 28 | import org.thingsboard.server.common.data.id.DeviceId; |
@@ -47,6 +49,15 @@ public class JpaDeviceDaoTest extends AbstractJpaDaoTest { | @@ -47,6 +49,15 @@ public class JpaDeviceDaoTest extends AbstractJpaDaoTest { | ||
47 | @Autowired | 49 | @Autowired |
48 | private DeviceDao deviceDao; | 50 | private DeviceDao deviceDao; |
49 | 51 | ||
52 | + ListeningExecutorService executor; | ||
53 | + | ||
54 | + @After | ||
55 | + public void tearDown() throws Exception { | ||
56 | + if (executor != null) { | ||
57 | + executor.shutdownNow(); | ||
58 | + } | ||
59 | + } | ||
60 | + | ||
50 | @Test | 61 | @Test |
51 | public void testFindDevicesByTenantId() { | 62 | public void testFindDevicesByTenantId() { |
52 | UUID tenantId1 = Uuids.timeBased(); | 63 | UUID tenantId1 = Uuids.timeBased(); |
@@ -77,8 +88,8 @@ public class JpaDeviceDaoTest extends AbstractJpaDaoTest { | @@ -77,8 +88,8 @@ public class JpaDeviceDaoTest extends AbstractJpaDaoTest { | ||
77 | assertNotNull(entity); | 88 | assertNotNull(entity); |
78 | assertEquals(uuid, entity.getId().getId()); | 89 | assertEquals(uuid, entity.getId().getId()); |
79 | 90 | ||
80 | - ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); | ||
81 | - ListenableFuture<Device> future = service.submit(() -> deviceDao.findById(new TenantId(tenantId), uuid)); | 91 | + executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10, ThingsBoardThreadFactory.forName(getClass().getSimpleName() + "-test-scope"))); |
92 | + ListenableFuture<Device> future = executor.submit(() -> deviceDao.findById(new TenantId(tenantId), uuid)); | ||
82 | Device asyncDevice = future.get(); | 93 | Device asyncDevice = future.get(); |
83 | assertNotNull("Async device expected to be not null", asyncDevice); | 94 | assertNotNull("Async device expected to be not null", asyncDevice); |
84 | } | 95 | } |
@@ -34,6 +34,7 @@ import org.junit.runner.Description; | @@ -34,6 +34,7 @@ import org.junit.runner.Description; | ||
34 | import org.springframework.core.ParameterizedTypeReference; | 34 | import org.springframework.core.ParameterizedTypeReference; |
35 | import org.springframework.http.HttpMethod; | 35 | import org.springframework.http.HttpMethod; |
36 | import org.springframework.http.ResponseEntity; | 36 | import org.springframework.http.ResponseEntity; |
37 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
37 | import org.thingsboard.mqtt.MqttClient; | 38 | import org.thingsboard.mqtt.MqttClient; |
38 | import org.thingsboard.mqtt.MqttClientConfig; | 39 | import org.thingsboard.mqtt.MqttClientConfig; |
39 | import org.thingsboard.mqtt.MqttHandler; | 40 | import org.thingsboard.mqtt.MqttHandler; |
@@ -263,7 +264,7 @@ public class MqttClientTest extends AbstractContainerTest { | @@ -263,7 +264,7 @@ public class MqttClientTest extends AbstractContainerTest { | ||
263 | JsonObject serverRpcPayload = new JsonObject(); | 264 | JsonObject serverRpcPayload = new JsonObject(); |
264 | serverRpcPayload.addProperty("method", "getValue"); | 265 | serverRpcPayload.addProperty("method", "getValue"); |
265 | serverRpcPayload.addProperty("params", true); | 266 | serverRpcPayload.addProperty("params", true); |
266 | - ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); | 267 | + ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName(getClass().getSimpleName()))); |
267 | ListenableFuture<ResponseEntity> future = service.submit(() -> { | 268 | ListenableFuture<ResponseEntity> future = service.submit(() -> { |
268 | try { | 269 | try { |
269 | return restClient.getRestTemplate() | 270 | return restClient.getRestTemplate() |
@@ -287,6 +288,7 @@ public class MqttClientTest extends AbstractContainerTest { | @@ -287,6 +288,7 @@ public class MqttClientTest extends AbstractContainerTest { | ||
287 | mqttClient.publish("v1/devices/me/rpc/response/" + requestId, Unpooled.wrappedBuffer(clientResponse.toString().getBytes())).get(); | 288 | mqttClient.publish("v1/devices/me/rpc/response/" + requestId, Unpooled.wrappedBuffer(clientResponse.toString().getBytes())).get(); |
288 | 289 | ||
289 | ResponseEntity serverResponse = future.get(5, TimeUnit.SECONDS); | 290 | ResponseEntity serverResponse = future.get(5, TimeUnit.SECONDS); |
291 | + service.shutdownNow(); | ||
290 | Assert.assertTrue(serverResponse.getStatusCode().is2xxSuccessful()); | 292 | Assert.assertTrue(serverResponse.getStatusCode().is2xxSuccessful()); |
291 | Assert.assertEquals(clientResponse.toString(), serverResponse.getBody()); | 293 | Assert.assertEquals(clientResponse.toString(), serverResponse.getBody()); |
292 | 294 |
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttGatewayClientTest.java
@@ -33,6 +33,7 @@ import org.junit.Assert; | @@ -33,6 +33,7 @@ import org.junit.Assert; | ||
33 | import org.junit.Before; | 33 | import org.junit.Before; |
34 | import org.junit.Test; | 34 | import org.junit.Test; |
35 | import org.springframework.http.ResponseEntity; | 35 | import org.springframework.http.ResponseEntity; |
36 | +import org.thingsboard.common.util.ThingsBoardThreadFactory; | ||
36 | import org.thingsboard.mqtt.MqttClient; | 37 | import org.thingsboard.mqtt.MqttClient; |
37 | import org.thingsboard.mqtt.MqttClientConfig; | 38 | import org.thingsboard.mqtt.MqttClientConfig; |
38 | import org.thingsboard.mqtt.MqttHandler; | 39 | import org.thingsboard.mqtt.MqttHandler; |
@@ -259,7 +260,7 @@ public class MqttGatewayClientTest extends AbstractContainerTest { | @@ -259,7 +260,7 @@ public class MqttGatewayClientTest extends AbstractContainerTest { | ||
259 | JsonObject serverRpcPayload = new JsonObject(); | 260 | JsonObject serverRpcPayload = new JsonObject(); |
260 | serverRpcPayload.addProperty("method", "getValue"); | 261 | serverRpcPayload.addProperty("method", "getValue"); |
261 | serverRpcPayload.addProperty("params", true); | 262 | serverRpcPayload.addProperty("params", true); |
262 | - ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); | 263 | + ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName(getClass().getSimpleName()))); |
263 | ListenableFuture<ResponseEntity> future = service.submit(() -> { | 264 | ListenableFuture<ResponseEntity> future = service.submit(() -> { |
264 | try { | 265 | try { |
265 | return restClient.getRestTemplate() | 266 | return restClient.getRestTemplate() |
@@ -273,6 +274,7 @@ public class MqttGatewayClientTest extends AbstractContainerTest { | @@ -273,6 +274,7 @@ public class MqttGatewayClientTest extends AbstractContainerTest { | ||
273 | 274 | ||
274 | // Wait for RPC call from the server and send the response | 275 | // Wait for RPC call from the server and send the response |
275 | MqttEvent requestFromServer = listener.getEvents().poll(10, TimeUnit.SECONDS); | 276 | MqttEvent requestFromServer = listener.getEvents().poll(10, TimeUnit.SECONDS); |
277 | + service.shutdownNow(); | ||
276 | 278 | ||
277 | Assert.assertNotNull(requestFromServer); | 279 | Assert.assertNotNull(requestFromServer); |
278 | Assert.assertNotNull(requestFromServer.getMessage()); | 280 | Assert.assertNotNull(requestFromServer.getMessage()); |