Remove swagger and minor feature extensions and bug fixes
- Various Bug fixes and improvements - Management API extended - Swagger removed - Guava Upgraded to 19
This commit is contained in:
0
examples/hawkbit-device-simulator/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-device-simulator/.gitignore
vendored
Executable file → Normal file
23
examples/hawkbit-device-simulator/README.md
Executable file → Normal file
23
examples/hawkbit-device-simulator/README.md
Executable file → Normal file
@@ -11,8 +11,29 @@ Or:
|
||||
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
The simulator has user authentication enabled by default. Default credentials:
|
||||
* username : admin
|
||||
* passwd : admin
|
||||
|
||||
This can be configured/disabled by spring boot properties
|
||||
|
||||
## Usage
|
||||
The device simulator exposes an REST-API which can be used to trigger device creation.
|
||||
|
||||
Optional parameters:
|
||||
* name : name prefix simulated devices (default: "dmfSimulated"), followed by counter
|
||||
* amount : number of simulated devices (default: 20, capped at: 4000)
|
||||
* tenant : in a multi-tenenat ready hawkBit installation (default: "DEFAULT")
|
||||
|
||||
|
||||
Example: for 20 simulated devices (default)
|
||||
```
|
||||
http://localhost:8083/start?amount=10
|
||||
http://localhost:8083/start
|
||||
```
|
||||
|
||||
Example: for 10 simulated devices that start with the name prefix "activeSim":
|
||||
```
|
||||
http://localhost:8083/start?amount=10&name=activeSim
|
||||
```
|
||||
|
||||
118
examples/hawkbit-device-simulator/pom.xml
Executable file → Normal file
118
examples/hawkbit-device-simulator/pom.xml
Executable file → Normal file
@@ -9,53 +9,81 @@
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
</parent>
|
||||
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
</parent>
|
||||
<artifactId>hawkbit-device-simulator</artifactId>
|
||||
<name>hawkBit :: Device Simulator</name>
|
||||
<description>Device Management Federation API based simulator</description>
|
||||
|
||||
<artifactId>hawkbit-device-simulator</artifactId>
|
||||
<name>hawkBit :: Device Simulator</name>
|
||||
<description>Device Management Federation API based simulator</description>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${baseDir}</outputDirectory>
|
||||
<addResources>false</addResources>
|
||||
<mainClass>org.eclipse.hawkbit.simulator.DeviceSimulator</mainClass>
|
||||
<layout>JAR</layout>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-dmf-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-dmf-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java
Executable file → Normal file
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java
Executable file → Normal file
@@ -20,6 +20,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class DeviceSimulator {
|
||||
|
||||
private DeviceSimulator() {
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Spring Boot Application.
|
||||
*
|
||||
|
||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java
Executable file → Normal file
18
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java
Executable file → Normal file
18
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java
Executable file → Normal file
@@ -48,7 +48,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create jackson message converter bean.
|
||||
*
|
||||
*
|
||||
* @return the jackson message converter
|
||||
*/
|
||||
@Bean
|
||||
@@ -60,7 +60,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the receiver queue from sp. Receive messages from sp.
|
||||
*
|
||||
*
|
||||
* @return the queue
|
||||
*/
|
||||
@Bean
|
||||
@@ -71,7 +71,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the recevier exchange. Sp send messages to this exchange.
|
||||
*
|
||||
*
|
||||
* @return the exchange
|
||||
*/
|
||||
@Bean
|
||||
@@ -83,7 +83,7 @@ public class AmqpConfiguration {
|
||||
* Create the Binding
|
||||
* {@link AmqpConfiguration#receiverConnectorQueueFromSp()} to
|
||||
* {@link AmqpConfiguration#exchangeQueueToConnector()}.
|
||||
*
|
||||
*
|
||||
* @return the binding and create the queue and exchange
|
||||
*/
|
||||
@Bean
|
||||
@@ -93,7 +93,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create dead letter queue.
|
||||
*
|
||||
*
|
||||
* @return the queue
|
||||
*/
|
||||
@Bean
|
||||
@@ -103,7 +103,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the dead letter fanout exchange.
|
||||
*
|
||||
*
|
||||
* @return the fanout exchange
|
||||
*/
|
||||
@Bean
|
||||
@@ -113,7 +113,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the Binding deadLetterQueue to exchangeDeadLetter.
|
||||
*
|
||||
*
|
||||
* @return the binding
|
||||
*/
|
||||
@Bean
|
||||
@@ -123,7 +123,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Returns the Listener factory.
|
||||
*
|
||||
*
|
||||
* @return the {@link SimpleMessageListenerContainer} that gets used receive
|
||||
* AMQP messages
|
||||
*/
|
||||
@@ -136,7 +136,7 @@ public class AmqpConfiguration {
|
||||
}
|
||||
|
||||
private Map<String, Object> getDeadLetterExchangeArgs() {
|
||||
final Map<String, Object> args = new HashMap<String, Object>();
|
||||
final Map<String, Object> args = new HashMap<>();
|
||||
args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
|
||||
return args;
|
||||
}
|
||||
|
||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java
Executable file → Normal file
2
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java
Executable file → Normal file
2
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java
Executable file → Normal file
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.simulator.amqp;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,7 @@ public abstract class SenderService extends MessageService {
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
message.getMessageProperties().getHeaders().remove(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME);
|
||||
rabbitTemplate.setExchange(adress);
|
||||
rabbitTemplate.send(message);
|
||||
}
|
||||
|
||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java
Executable file → Normal file
12
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java
Executable file → Normal file
12
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java
Executable file → Normal file
@@ -131,11 +131,23 @@ public class SpReceiverService extends ReceiverService {
|
||||
DownloadAndUpdateRequest.class);
|
||||
final Long actionId = downloadAndUpdateRequest.getActionId();
|
||||
|
||||
try {
|
||||
Thread.sleep(1_000);
|
||||
} catch (final InterruptedException e) {
|
||||
LOGGER.error("Sleep interrupted", e);
|
||||
}
|
||||
|
||||
spSenderService.sendActionStatusMessage(tenant, ActionStatus.RUNNING,
|
||||
"device Simulator retrieved update request. proceeding with simulation.", actionId);
|
||||
|
||||
final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId);
|
||||
|
||||
try {
|
||||
Thread.sleep(1_000);
|
||||
} catch (final InterruptedException e) {
|
||||
LOGGER.error("Sleep interrupted", e);
|
||||
}
|
||||
|
||||
spSenderService.finishUpdateProcess(update, "Simulation complete!");
|
||||
}
|
||||
|
||||
|
||||
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java
Executable file → Normal file
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java
Executable file → Normal file
@@ -216,9 +216,7 @@ public class SpSenderService extends SenderService {
|
||||
|
||||
private Message createActionStatusMessage(final SimulatedUpdate update, final String messageDescription,
|
||||
final ActionStatus status) {
|
||||
final Message sendMessage = createActionStatusMessage(update.getTenant(), status, messageDescription,
|
||||
update.getActionId());
|
||||
return sendMessage;
|
||||
return createActionStatusMessage(update.getTenant(), status, messageDescription, update.getActionId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
56
examples/hawkbit-device-simulator/src/main/resources/application.properties
Executable file → Normal file
56
examples/hawkbit-device-simulator/src/main/resources/application.properties
Executable file → Normal file
@@ -12,7 +12,7 @@
|
||||
# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here)
|
||||
#########################################################################################
|
||||
## Configuration for RabbitMQ communication
|
||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=sp_connector_receiver
|
||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver
|
||||
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
||||
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
||||
hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo
|
||||
@@ -27,58 +27,6 @@ spring.rabbitmq.port=5672
|
||||
spring.rabbitmq.dynamic=true
|
||||
|
||||
|
||||
#disable expose jmx beans
|
||||
spring.jmx.enabled=false
|
||||
# the context path of the monitor spring actuator which offers following endpoints
|
||||
# /autoconfig, /beans, /configprops, /dump, /env, /health, /info, /metrics, /mappings, /trace
|
||||
management.context-path=/system
|
||||
management.security.enabled=true
|
||||
management.security.sessions=stateless
|
||||
# ENDPOINTS
|
||||
endpoints.autoconfig.id=autoconfig
|
||||
endpoints.autoconfig.sensitive=true
|
||||
endpoints.autoconfig.enabled=false
|
||||
endpoints.beans.id=beans
|
||||
endpoints.beans.sensitive=true
|
||||
endpoints.beans.enabled=false
|
||||
endpoints.configprops.id=configprops
|
||||
endpoints.configprops.sensitive=true
|
||||
endpoints.configprops.enabled=true
|
||||
#endpoints.configprops.keys-to-sanitize=password,secret,key # suffix or regex
|
||||
endpoints.dump.id=dump
|
||||
endpoints.dump.sensitive=true
|
||||
endpoints.dump.enabled=false
|
||||
endpoints.env.id=env
|
||||
endpoints.env.sensitive=true
|
||||
endpoints.env.enabled=true
|
||||
#endpoints.env.keys-to-sanitize=password,secret,key # suffix or regex
|
||||
endpoints.health.id=health
|
||||
endpoints.health.sensitive=true
|
||||
endpoints.health.enabled=true
|
||||
endpoints.info.id=info
|
||||
endpoints.info.sensitive=true
|
||||
endpoints.info.enabled=true
|
||||
endpoints.metrics.id=metrics
|
||||
endpoints.metrics.sensitive=true
|
||||
endpoints.metrics.enabled=true
|
||||
endpoints.shutdown.id=shutdown
|
||||
endpoints.shutdown.sensitive=true
|
||||
endpoints.shutdown.enabled=false
|
||||
endpoints.trace.id=trace
|
||||
endpoints.trace.sensitive=true
|
||||
endpoints.trace.enabled=true
|
||||
|
||||
# HEALTH INDICATORS (previously health.*)
|
||||
management.health.db.enabled=true
|
||||
management.health.diskspace.enabled=true
|
||||
management.health.mongo.enabled=true
|
||||
management.health.rabbit.enabled=true
|
||||
management.health.redis.enabled=false
|
||||
management.health.solr.enabled=false
|
||||
management.health.diskspace.path=.
|
||||
management.health.diskspace.threshold=10485760
|
||||
management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, UP
|
||||
|
||||
# SECURITY (SecurityProperties)
|
||||
security.user.name=${BASIC_USERNAME:admin}
|
||||
security.user.password=${BASIC_PASSWORD:admin}
|
||||
@@ -87,7 +35,7 @@ security.require-ssl=false
|
||||
security.enable-csrf=false
|
||||
security.basic.enabled=true
|
||||
security.basic.realm=DeviceSimulator
|
||||
security.basic.path= /system/**
|
||||
security.basic.path= /**
|
||||
security.basic.authorize-mode=ROLE
|
||||
security.filter-order=0
|
||||
security.headers.xss=false
|
||||
|
||||
Reference in New Issue
Block a user