Skip to content

Instantly share code, notes, and snippets.

View pavolloffay's full-sized avatar
🚀
Let's build something together!

Pavol Loffay pavolloffay

🚀
Let's build something together!
View GitHub Profile
@pavolloffay
pavolloffay / Bus context classloader.java
Created December 10, 2015 11:58
Bus context classloader
public static <T extends BasicMessage> BasicMessageWithExtraData<T> fromJSON(InputStream in, Class<T> clazz) {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(AbstractMessage.class.getClassLoader());
final T obj;
final byte[] remainder;
try (JsonParser parser = new JsonFactory().configure(Feature.AUTO_CLOSE_SOURCE, false).createParser(in)) {
Method buildObjectMapperForDeserializationMethod = findBuildObjectMapperForDeserializationMethod(clazz);
@pavolloffay
pavolloffay / BusTest.java
Created December 8, 2015 21:18
Hawkular Bus serialization test
@Test
public void testA() throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
InventoryJacksonConfig.configure(objectMapper);
Query relationships = Query.filter().with(RelationWith.name("__inPrediction")).with(RelationWith.sourceOfType
(Tenant.class)).with(RelationWith.targetOfType(Metric.class)).get();
String json = serialize(relationships, objectMapper);
@pavolloffay
pavolloffay / Hawkular Alerts
Last active November 27, 2015 15:36
Hawkular Alerts
# Plugins are for example email, sms, irc, snmp... Needs to be deployd as war in the Alerts.
# Actions are instancies of action Plugins. This actions can be assigned to Triggers. Examples of actions - send email to admin, send sms to CEO,
# Trigger has multiple Conditions, based on this condition Action is carried out (send email, create file)
# Alert is created when conditions are met.
# Standalone mode
mvn clean install -Pstandalone
hawkular-alerts-rest-tests/target/wildfly-9.0.1.Final/bin/standalone.sh --debug -Dhawkular.backend=embedded_cassandra
-H 'Hawkular-Tenant: xmen'
Root
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/'
Tenant
curl -ivX GET -H "Content-Type: application/json" 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'
curl -ivX DELETE -H "Content-Type: application/json" 'http://jdoe:password@localhost:8080/hawkular/inventory/tenant'
Metric types
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/metricTypes?feedless=false'
curl -ivX POST -H "Content-Type: application/json" -d '{"id": "test", "type":"COUNTER", "properties": {"p1": "a"}}' 'http://jdoe:password@localhost:8080/hawkular/inventory/metricTypes'
@pavolloffay
pavolloffay / install
Last active November 7, 2015 14:30
Fedora install
sudo dnf grouplist
Xfce
sudo dnf install xfce4-weather-plugin.x86_64 xfce4-cpugraph-plugin.x86_64 xfce4-sensors-plugin.x86_64 xfce4-xkb-plugin xfce4-whiskermenu-plugin.x86_64 xfce4-mixer
Utils
sudo dnf install gvim vim mc xchat gitk figlet
Latex
sudo dnf install texlive texlive-upquote.noarch texlive-blindtext.noarch texlive-bibtex.noarch texlive-babel.noarch texlive-babel-slovak
@pavolloffay
pavolloffay / R
Last active October 23, 2015 13:27
R
install.packages('rjson')
install.packages('RCurl')
install.packages('fpp')
install.packages('xts')
library(rjson)
library(RCurl)
library(fpp)
library(xts)
By default data are deleted after 7 days
-H "Hawkular-Tenant:28026b36-8fe4-4332-84c8-524e173a68bf"
Metrics module info
curl -ivX GET http://localhost:8080/hawkular/metrics
curl -ivX GET -H "Hawkular-Tenant:28026b36-8fe4-4332-84c8-524e173a68bf" 'http://localhost:8080/hawkular/metrics/metrics?type=gauge'
curl -ivX GET -H "Hawkular-Tenant:id1" 'localhost:8080/hawkular/metrics/metrics?type=availability'
Tenants
curl -ivX GET 'http://localhost:8080/hawkular/metrics/tenants'
public class Pair {
public String first;
public JavaDStream<MetricData> second;
public Pair(String first, JavaDStream<MetricData> second) {
this.first = first;
this.second = second;
}
}
@pavolloffay
pavolloffay / Hawkular_ui_devel.sh
Last active August 29, 2015 14:28
hawkular_UI_devel
In hawkular-ui-services root
bower link
In hawkular root
mvn clean install -Pdev,link -Dbower.link.package=hawkular-ui-services
In hawkular/console/target/gulp-build
gulp watch-server
Compile hawkular-ui-services
@pavolloffay
pavolloffay / Inventory Resource configuration + validation
Last active August 29, 2015 14:27
Inventory Resource configuration + validation
ResourceType
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/resourceTypes/fooType/data?dataType=configurationSchema'
curl -ivX GET 'http://jdoe:password@localhost:8080/hawkular/inventory/resourceTypes/fooType/data?dataType=connectionConfigurationSchema'
curl -ivX POST -H 'Content-Type:application/json' -d '{"id": "fooType" }' http://jdoe:password@localhost:8080/hawkular/inventory/resourceTypes
curl -ivX POST -H "Content-Type:application/json" -d '{"role": "configurationSchema", "value": {"title": "Foo resource configuration schema", "type": "object"}}' 'http://jdoe:password@localhost:8080/hawkular/inventory/resourceTypes/fooType/data'
curl -ivX PUT -H "Content-Type:application/json" -d '{"value": {"title": "Foo resource configuration schema", "type": "object", "required": ["man"],"properties": {"man": {"type": "integer"}}}}' 'http://jdoe:password@localhost:8080/hawkular/inventory/resourceTypes/fooType/data?dataType=configurationSchema'
curl -ivX PUT -H "Content-Type:application/json" -d