Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perfana/test-events-hello-world
Example implementation of the event-scheduler Event and EventGenerator interfaces.
https://github.com/perfana/test-events-hello-world
Last synced: 2 days ago
JSON representation
Example implementation of the event-scheduler Event and EventGenerator interfaces.
- Host: GitHub
- URL: https://github.com/perfana/test-events-hello-world
- Owner: perfana
- License: apache-2.0
- Created: 2018-12-21T10:51:03.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-07-05T15:54:05.000Z (over 1 year ago)
- Last Synced: 2023-07-28T10:15:18.231Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# test-events-hello-world
This project shows an example implementation of the `Event` interface
and the `EventGenerator` interface.The `HelloWorldEvent` shows when events are called in `System.out`.
It also prints out some system information at the start.The `HelloWorldEventGenerator` shows how to create a custom list of events from
a generator class with properties.This event is an `isReadyForStartParticipant`. Only when this event reports
back a `Go!` message, the event-scheduler is allowed to start.
This plugin will sent a `Go!` message after waiting `helloInitialSleepSeconds` seconds.## to try it out
If you just want to experiment with the `event-scheduler-maven-plugin` and
sub-plugins `test-events-hello-world` and `perfana-java-client`,
just add the `test-events-hello-world` and `perfana-java-client` plugin to the dependencies
of the `event-scheduler-maven-plugin`.For instance add the following:
```xml
io.perfana
event-scheduler-maven-plugin
true
true
true
true
PT5S|restart|{ server:'myserver' replicas:2 tags: [ 'first', 'second' ] }
PT10S|scale-down
PT30S|heapdump|server=myserver.example.com;port=1567
PT1M|scale-up|{ replicas:2 }
${systemUnderTest}
${version}
${workload}
${testEnvironment}
${testRunId}
${buildResultsUrl}
${rampupTimeInSeconds}
${constantLoadTimeInSeconds}
${annotations}
${tags}
HelloWorldEvent1
40
https://my-rest-api
${ENV.SECRET}
PerfanaEvent1
http://localhost:8888
false
my_value
io.perfana
test-events-hello-world
${test-events-hello-world.version}
io.perfana
perfana-java-client
${perfana-java-client.version}
```
See also:
* https://github.com/perfana/event-scheduler-maven-plugin
* https://github.com/perfana/event-scheduler
* https://github.com/perfana/perfana-java-client## create your own plugin
Add a dependency to the `event-scheduler` jar, just for compile so you can use the api interfaces
and classes.Example:
```xml
io.perfana
event-scheduler
3.0.2
compile
```
Then you can create your own implementations of the `Event` and the `EventFactory` interface.
The same goes for the `EventGenerator` and the `EventGeneratorFactory` interface.For convenience, you can use the `EventAdapter` abstract class
to implementing `Event` interface. Only implement the method you want to override.Create an `*EventConfig` calls for the configuration with only setters.
Create an immutable `*EventContext` class with only getter.
In the `EventConfig` class override the 2 `toContext` methods.## add services files
The magic happens when you add the appropriate file
in `META-INF/services`. See the sample in this project.You need to specify the fully qualified name of your implementation
(e.g. `io.perfana.helloworld.event.HelloWorldEventFactory`)
in a file called `io.perfana.eventscheduler.api.EventFactory`.And for the event schedule generators use
(e.g. `io.perfana.helloworld.event.HelloWorldEventGeneratorFactory`)
a file called `io.perfana.eventscheduler.api.EventGeneratorFactory`.Note that both can contain multiple lines with different implementations.