Граф коммитов

21 Коммитов

Автор SHA1 Сообщение Дата
Devis Lucato 0ced724464 Add support for storing data in Azure Tables (#327) 2018-12-10 14:59:37 -08:00
Devis Lucato 8fa180f715
Reliability improvements
**Major:**
1. Backoff in case of d2c messaging throttling, stopping telemetry and twin operations
2. Improve perf reducing load on garbage collector and disposing IoT SDK resources
3. Improve device twin management, e.g. try to avoid twin writes when data is not changed, handle more error scenarios
4. Add "development" feature flag to enable/disable expensive runtime checks
5. Change partitions size from 1000 to 5000 devices to reduce the load on storage

**Minor:**
1. Backoff in case of device count throttling (e.g. when reaching 8000 devices in the free SKU)
2. Remove unused daily counter for telemetry
3. Improve perf reducing the number of no-op async tasks
4. Update IoT SDK and other dependencies
5. Clean up logging code, reimplement log filtering (removed in past PRs)
6. Print SDK version at startup
7. Add some scripts for development, see /scripts/development (create/delete simulation, start storage adapter)

**Bug fixes:**
1. Handle and recover from exceptions in the partitioning agent
2. Fix some swallowed errors/exceptions and unnecessary try/catch
3. Share script interpreter between methods and state to ensure device state consistency
4. Fix logged throughput in case of no traffic, i.e. show 0.0 msg/sec, and round value to 3 decimals
5. Fix logging from ConfigData
6. Change the dev endpoint used to delete simulations: don't delete devices (the endpoint was not working) - no user impact, dev only
2018-11-29 17:29:58 -08:00
Devis Lucato d1a986f1dd bugfix: use correct Device IDs (#274) 2018-10-09 17:59:19 -07:00
Devis Lucato 792fdfd345
Add agent for creating and partitioning devices (#251)
Add agent for creating and partitioning devices

1. Add a new agent to the solution, which will be responsible for creating
the devices in IoT hub and for partitioning the list of devices, so
that multiple VMs can each simulate a different set of devices.
The agent is not started yet because the new storage library is not
ready.
2. Refactor concurrency settings and add clustering settings
3. Temporary add retry logic to a couple of flaky tests
2018-09-12 15:37:56 -07:00
Hugh Xiong b8dab0315e Add device model scripts endpoint (#231)
* Add device model scripts endpoint
2018-08-27 12:49:05 -07:00
Isaac 341f3020e9 Fix for circular depedency [hold merge till other repos are ready] (#190)
* deviceProperties

* Json format

* comments

* Fix for Review comments

* GetPropertyNames

* GetPropertyNames

* nits

* Merge with master

** Resolve conflict
** Add tests

* Sort using

* Fix typo in file name

* Update DevicePropertyNames API

Change response from hashset to list

* Add API specs doc

* Fix indentation

* Fix typo

* Add test

* Add Comments

* deviceModelProperties

* api specs for device model Properties

* api spec update in sln

* Removing Comments

* DeviceModelPropertiesController Json change

* caps

* update API Spec

* reverting env var

* deviceModelProperties

* PREFIX moved to service model

* review comments some exception

* Revert "review comments some exception"

This reverts commit 6220a93d44.

* adding comments

* Update SomeException.cs

* Update SomeException.cs

* fix typo

* nit
2018-06-20 15:56:58 -07:00
Jill Bender b211cb7805 Merge azure-iot-pcs-simulation into master (#197)
* Rewrite to use fewer threads and increase throughput
* Expose simulation metrics in the status endpoint
* When available, return a URL to the Azure Portal metrics of the pre-provisioned IoT Hub
* Allow to run a simulation against a custom IoT Hub, passing the connection string
* Allow to schedule a simulation, defining start and end time
* Improve security by running the service as a non-root user
* Support multiple behavior scripts in a device model
* Support custom device with custom sensors, behavior and frequency
* Allow to override the initial device state when creating a simulation
* When a simulation starts, create all the devices in batches
* When a simulation is deleted, delete also the devices
* Refactor timers to start sending telemetry as soon as possible
* Refactor and improve how simulation scripts access state and properties
* Change stock models to use AMQP (#189)
* Overall improvements to exceptions handling
* Disable SDK retry, and change timeout from default (4 minutes) to 10 seconds
* Do not retry sending telemetry on failure, skip message
* Use IoT Hub S2 SKU limits by default
* Upgrade to .NET Core 2.0.3
* Upgrade Azure IoT SDK: Devices 1.4.1 to 1.6.0, Devices Client 1.5.2 to 1.7.0
* Run simulation engine in the same process used for the web service
* Move docs, move wiki, new API specs, fix scripts for Windows Bash
* Fix the spelling of “ETag” and allow ETag=*
* Add internal scripts for increasing/decreasing/random telemetry
* Add env vars documentation ENVIRONMENT_VARIABLES.md
* Add more optional logging by device and by actor
* Use logging level and other logging settings from configuration
* Adjust unit test precision to mitigate flaky test
* Add system properties to telemetry messages
* Removing the squash flag from Docker scripts
* Use env vars in launchSettings.json
2018-04-12 17:42:46 -07:00
Devis Lucato d9d5a54e25 Remove duplicate code from IFactory implementation (#74)
* Remove duplicate code from IFactory implementation
* Update GitHub templates
2017-10-09 20:28:58 -07:00
Devis Lucato 4c1511a0f4 Add Auth to webservice (#61)
* Add Auth and refactor CORS (sync with other services)
* Revisit configuration format, sync with other services
2017-09-26 11:51:27 -07:00
Tim Laverty c33241a5cd Methods and docs (#40)
This PR provides method support for chillers in the default simulation: reboot, firmware update, increase pressure, and decrease pressure.  It also keeps reported properties in sync with desired properties (by polling for value changes).

* DeviceMethod implmentation class

* First round of methods, added: 1) infra for registering methods for devices, 2) walking avail. methods for each device.  Main functionality missing is allowing specifation and then running the method script.

* remove todo from actor

* nits to code style

* Move methods ownership from devicebootstrap to deviceclient.

* error handling and todos.

* retry method registration, minor fixes.

* nits, logging, removed exception handling for registering methods (it's handled by the parent method)

* bumped version

* code style nits

* Methods use scripts.

Desired properties are polled in UpdateDeviceState and delta is copied into Reported property values.

Telemetry is not sent if the device is marked other than online == "True"

* code style/cleanup changes.

change get query for simulations to linq query rather than iterating the list.

* update version

* Exception handling for updatedevicestate

nit for rename method execution endpoint to include Async suffix.

* nit fix comment code style

* Inject scriptinterpreter. refactoring.

* nits

* state update bug

* no need for scriptengine null check

* Bootstrap individual methods, implement decreasepressure aka EMergencyValveRelease

* remove connection string :(

* fixed threading problem w/ methods, implemented & tested first four methods

* Implement switch to turn random telemetry off; e.g. when increasepressure is called, wait until decreasepressure is called to turn it back on.

* remove clearing of DeviceMethodStatus

* Code style changes + fix some jslint errors

* Fix js methods files

* DeviceMethods code style changes

* Devices.cs code style

* JavascriptInterpreter.cs code style

* script changes for messages, docs

* Cleanup up Javascript functions, create Issue to track implementing functions not yet done.

* Halve the amount of telemetry sent

* Address PR comments.

* issue for script interpreter todo

* todos, nits, pr feedback
2017-09-07 15:08:26 -07:00
Devis Lucato 570645bf2e Simulation seed data (#33)
* Complete seed data, complete all the device models as per specs
* Rename “device type” to “device model”
* Clean JS syntax, check with JS Lint
* Generate device IDs from device model ID, instead of device model Name
* Complete health check endpoint
2017-08-16 12:37:56 -07:00
Devis Lucato abbd305492 Implement device bootstrap scenario and decouple from IoT Hub manager (#30)
* When a new device is created, mark it as a simulated device and 
* When a device connects report some properties like device type, messages schema, and initial location. Use MQTT for twin operations
* Remove dependency on IoT Hub manager and access IoT Hub directly
* Refactor state machine to reduce complexity and reuse code
* Add launch settings for Visual Studio
* Remove env var used for the web service TCP port
* Improve logging of exceptions to avoid log flooding
* Fix messages format, to always use the “_unit” convention
* Bump version to 0.1.4
2017-08-08 18:10:43 -07:00
Devis Lucato 454ffe86ae Allow to inject custom device types (#24)
* Allow to inject custom device models
* Improve parsing of Jint response to support dictionaries and objects
* Sync scripts with template
* Change Truck geolocation format
* Update docker scripts
2017-07-21 12:20:25 -07:00
Devis Lucato 360ec08524 Remove Akka and update to new template (#21)
Remove Akka and use .NET Thread Pool to manage multiple threads sending telemetry. The lack of Akka means some extra work that we'll need in order to distribute the simulation over multiple servers. For the time being, we assume that the simulation runs in one instance only. If Akka's move to .NET Core is ready we can move back to Akka, otherwise we need some partitioning logic to distribute the load over multiple machines.

Upgrade the project to the latest template, e.g. scripts and documentations. Minor fixes for cross-platform development (VS2017 and Rider).

Complete the /status endpoint to check if IoT Hub Manager is available. In order to run the simulation, IoT Hub Manager is required. Without this check, it was too difficult to debug whether the service could connect to IoT Hub Manager or not, particularly when using Docker Compose.

Added Docker Compose file, to bootstrap this service and IoT Hub Manager containers. Add script to publish to Docker Hub. Move Docker image version/tag to a version file, so that the version is not hard coded in multiple places.

Fix an issue with the logger using too much memory when serializing exceptions.

Improve handling of exceptions caused by unreachable external dependencies when using the HTTP client.
2017-07-07 13:49:03 -07:00
Devis Lucato 541e5cff8e Minor cleanups left over after .NET Core migration (#10)
* remove unused dependency
* minor changes, cleaning up
2017-06-22 16:59:18 -07:00
Devis Lucato 8a4e79cf00 Migrate to .NET Core (#9)
Upgrade source code, project files and scripts to use .NET Core. Mono is not required anymore, and also the Docker image will now use only .NET Core.
The configuration format has changed to be in line with ASP.NET Core configuration providers.
The simulation runner is temporarily disabled, because Akka.NET is not ready for .NET Core, and I'm in the middle of removing Akka from the project as well.
Due to the move from .NET Core, some internal APIs are different, for instance you might notice changes in the web service exception filter, in the Autofac dependency injection setup, in the use of Kestrel as a HTTP server.
Since the microservice is now built and packaged with the `dotnet` command, some paths have changed, and scripts have been updated accordingly. I tested the scripts in Windows and MacOS, hopefully catching all the edge cases. The scripts are now actually simpler, which is a nice and unexpected result of the migration.
2017-06-20 18:52:50 -07:00
Devis Lucato 2302587b1b Synchronize env vars and scripts with template (#8)
* Remove Akka HOCON from web service, use app.confg for settings - use HOCON only when using Akka
* Improve config parsing
* Add Moq to all test projects
* Add env var for IoTHubMan web service
* Update env vars management and correlated scripts
2017-06-07 18:01:19 -07:00
Devis Lucato f545d74e79 Start/stop simulation actors based on simulation status + Dockerize microservice (#6)
* implement simulation agent using Akka actors
* update Docker scripts to package the web service and the simulation agent
* some DI refactoring to align web service and simulation agent
* detect and manage content negotiation errors
* Change ERRORLEVEL code in Windows scripts
* Change windows scripts error redirection
* Fix compilation warnings and convert some *nix scripts to ISO
* Document the exceptions and apply filters on controllers (rather than globally)
2017-06-01 12:56:19 -07:00
Devis Lucato 1e2ef4051c Add device types and simulations endpoints
* Add new endpoint to list all the supported device types. Device types are configured via JSON files external to the assembly, so that users can add custom types without rebuilding the service. The files include a README describing the format of these files.
* Add simulations storage and endpoint with input validation and error handling. Supports creating a default simulation.
* Improve performance by using singletons
* Add missing property in the Status endpoint
* Make sure the temporary storage is usable when working in an IDE
2017-05-30 20:05:48 -07:00
Devis Lucato 15c6855f62 Initialize project with files from template 2017-05-25 18:22:07 -07:00
Devis Lucato da56943aae Initial commit 2017-04-30 19:08:53 -07:00