Skip to content

Commit fe82911

Browse files
authored
Merge pull request #7 from IBA-Group-IT/feature-4
Feature 4
2 parents 5e29b15 + 04278fe commit fe82911

File tree

15 files changed

+220
-58
lines changed

15 files changed

+220
-58
lines changed

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ services:
3939
- 61613:61613
4040
services:
4141
build: ./services
42-
image: ibagroup/iot-data-simulator-services:1.0.1
42+
image: ibagroup/iot-data-simulator-services:1.1.0
4343
container_name: iot-ds-services
4444
depends_on:
4545
- mongodb
@@ -64,7 +64,7 @@ services:
6464
- 8083:8083
6565
ui:
6666
build: ./ui
67-
image: ibagroup/iot-data-simulator-ui:1.0.1
67+
image: ibagroup/iot-data-simulator-ui:1.1.0
6868
container_name: iot-ds-ui
6969
depends_on:
7070
- services
@@ -79,7 +79,7 @@ services:
7979
command: ["npm", "start"]
8080
data-sender:
8181
build: ./data-sender
82-
image: ibagroup/iot-data-simulator-sender:1.0.1
82+
image: ibagroup/iot-data-simulator-sender:1.1.0
8383
container_name: iot-ds-data-sender
8484
depends_on:
8585
- rabbitmq

services/src/main/java/com/iba/iot/datasimulator/session/factory/session/SessionFactoryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public Session buildFromCreateUpdateRequest(SessionCreateUpdateRequest sessionCr
4747
session.setTimer(sessionCreateUpdateRequest.getTimer());
4848
session.setDatasetFilter(sessionCreateUpdateRequest.getDatasetFilter());
4949
session.setTicksNumber(sessionCreateUpdateRequest.getTicksNumber());
50+
session.setReplayLooped(sessionCreateUpdateRequest.isReplayLooped());
5051

5152
String definitionId = sessionCreateUpdateRequest.getDataDefinitionId();
5253
if (StringUtils.isNotBlank(definitionId)) {

services/src/main/java/com/iba/iot/datasimulator/session/model/Session.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public class Session implements ModelEntity {
6464
@JsonView(SessionViews.Short.class)
6565
private int ticksNumber;
6666

67+
@JsonView(SessionViews.Short.class)
68+
private boolean isReplayLooped;
69+
6770
@JsonView(SessionViews.Short.class)
6871
@Embedded
6972
@Valid

services/src/main/java/com/iba/iot/datasimulator/session/model/SessionCreateUpdateRequest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.iba.iot.datasimulator.session.model;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import com.iba.iot.datasimulator.session.model.active.filter.DatasetFilter;
45
import com.iba.iot.datasimulator.session.model.active.generator.Generator;
56
import com.iba.iot.datasimulator.session.model.active.injector.DeviceInjector;
@@ -29,6 +30,9 @@ public class SessionCreateUpdateRequest {
2930
/** **/
3031
private int ticksNumber;
3132

33+
@JsonProperty(value="isReplayLooped")
34+
private boolean isReplayLooped;
35+
3236
@Valid
3337
private DatasetFilter datasetFilter;
3438

services/src/main/java/com/iba/iot/datasimulator/session/model/active/ActiveSessionState.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public enum ActiveSessionState {
1111

1212
COMPLETED("completed"),
1313

14+
STOPPED("stopped"),
15+
1416
FAILED("failed");
1517

1618
/** **/

services/src/main/java/com/iba/iot/datasimulator/session/model/active/command/ActiveSessionManagementCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.iba.iot.datasimulator.session.model.active.command;
22

3+
import lombok.AllArgsConstructor;
34
import lombok.Data;
5+
import lombok.NoArgsConstructor;
46
import lombok.ToString;
57

68
import javax.validation.constraints.NotNull;
79

810
@Data
911
@ToString
12+
@AllArgsConstructor
13+
@NoArgsConstructor
1014
public class ActiveSessionManagementCommand {
1115

1216
@NotNull

services/src/main/java/com/iba/iot/datasimulator/session/service/active/entity/ActiveSession.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,52 @@
22

33
import com.iba.iot.datasimulator.session.model.active.ActiveSessionStatus;
44

5+
/**
6+
*
7+
*/
58
public interface ActiveSession {
69

10+
/**
11+
*
12+
*/
713
void start();
814

15+
/**
16+
*
17+
*/
918
void pause();
1019

20+
/**
21+
*
22+
*/
1123
void resume();
1224

25+
/**
26+
*
27+
*/
1328
void stop();
1429

30+
/**
31+
*
32+
* @param error
33+
*/
1534
void registerError(String error);
1635

36+
/**
37+
*
38+
* @return
39+
*/
1740
ActiveSessionStatus getStatus();
41+
42+
/**
43+
*
44+
* @return
45+
*/
46+
boolean isReplayLooped();
47+
48+
/**
49+
*
50+
* @return
51+
*/
52+
boolean isStopped();
1853
}

services/src/main/java/com/iba/iot/datasimulator/session/service/active/entity/ActiveSessionEntity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public class ActiveSessionEntity implements ActiveSession {
6161
/** **/
6262
private Collection<String> errors = new ArrayList<>();
6363

64+
/** **/
65+
private boolean isStopped;
66+
6467
/**
6568
*
6669
* @param session
@@ -114,6 +117,7 @@ public void resume() {
114117
public void stop() {
115118

116119
logger.info(">>> Session {} has been stopped", sessionId);
120+
isStopped = true;
117121
dataProducer.stop();
118122
}
119123

@@ -222,4 +226,14 @@ private void sendSessionFailedPayload() {
222226
private void sendSessionCompletedPayload() {
223227
payloadSender.send(sessionId, new ActiveSessionPayload(ActiveSessionState.COMPLETED), session.getTargetSystem());
224228
}
229+
230+
@Override
231+
public boolean isReplayLooped() {
232+
return session.isReplayLooped();
233+
}
234+
235+
@Override
236+
public boolean isStopped() {
237+
return isStopped;
238+
}
225239
}

services/src/main/java/com/iba/iot/datasimulator/session/service/active/entity/DummyActiveSession.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,14 @@ private void sendAnalyticsMessage(ActiveSessionAnalyticTag tag, String messagePo
141141

142142
messagingTemplate.convertAndSend(StompUtil.getSessionAnalyticsTopic(sessionId), activeSessionAnalyticsMessage);
143143
}
144+
145+
@Override
146+
public boolean isReplayLooped() {
147+
return false;
148+
}
149+
150+
@Override
151+
public boolean isStopped() {
152+
return false;
153+
}
144154
}

services/src/main/java/com/iba/iot/datasimulator/session/service/active/processing/timer/IntervalTimerProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public IntervalTimerProcessor(Timer timer) {
3737
public long getWaitInterval(String previousEntry, String nextEntry) {
3838

3939
if (StringUtils.isEmpty(previousEntry) && StringUtils.isNotEmpty(nextEntry)) {
40-
return 0;
40+
return 500;
4141
}
4242

4343
Long value = this.timer.getValue();

0 commit comments

Comments
 (0)