Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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.