Skip to content

Instantly share code, notes, and snippets.

View jotak's full-sized avatar

Joel Takvorian jotak

View GitHub Profile
public class Person {
private final String firstname;
private final String lastname;
private final String address;
private final String zipCode;
private final Gender gender;
public Person(final String firstname, final String lastname, final String address, final String zipCode, final Gender gender) {
this.firstname = Preconditions.nonNull(firstname);
this.lastname = Preconditions.nonNull(lastname);
@jotak
jotak / CassandraBackend.java
Created November 29, 2016 15:22
Inventory with Javaslang
@Override
public <T> Page<T> query(Query query, Pager pager, Function<Row, T> conversion, Function<T, Boolean> filter) {
for (QueryFragment qf : query.getFragments()) {
Clause clause = Match(qf.getFilter()).of(
Case(instanceOf(With.Ids.class), FilterApplicators::withIds),
Case(instanceOf(With.Names.class), FilterApplicators::withNames),
// etc.
Case($(), o -> { throw new IllegalArgumentException("Unsupported filter type " + o.getClass()); }));
@jotak
jotak / CassandraBackend.java
Created November 29, 2016 17:12
getTransitiveClosureOver
@Override
public Iterator<Row> getTransitiveClosureOver(Row startingPoint, Relationships.Direction direction,
String... relationshipNames) {
String table;
switch (direction) {
case incoming:
table = RELATIONSHIP_IN;
break;
case outgoing:
@jotak
jotak / dashboard.json
Created March 3, 2017 09:30
Grafana dashboard variable for Hawkular 0.18.x
{
"__inputs": [
{
"name": "DS_HAWKULAR-DEV",
"label": "Hawkular-dev",
"description": "",
"type": "datasource",
"pluginId": "hawkular-datasource",
"pluginName": "Hawkular"
}
@jotak
jotak / docker-compose.yml
Created March 24, 2017 08:40
docker-compose for local hawkular-services
hawkular:
image: "jotak/hawkular-services:latest"
ports:
- "8080:8080"
- "8443:8443"
- "9990:9990"
links:
- myCassandra
volumes:
- /home/jotak/hservices/opt/data:/opt/data:Z
@jotak
jotak / WithReporter.java
Created May 23, 2017 07:02
Vertx metrics => Hawkular
Vertx vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(
new DropwizardMetricsOptions().setEnabled(true).setRegistryName("reg")));
HawkularReporter hawkularReporter = HawkularReporter
.builder(SharedMetricRegistries.getOrCreate("reg"), "sample-tenant")
.build();
hawkularReporter.start(1, TimeUnit.SECONDS);
vertx.deployVerticle(/*...*/);
@jotak
jotak / ExpressionTagQueryITest.groovy
Last active May 23, 2017 09:43
Tag expression "not A" doesn't work with non-indexed metrics
/*
* Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@jotak
jotak / grafaprom.yml
Created September 1, 2017 07:48
grafaprom templates
apiVersion: v1
kind: Template
metadata:
name: grafaprom
objects:
- apiVersion: v1
kind: DeploymentConfig
metadata:
generation: 1
labels:
@jotak
jotak / sample.json
Last active October 10, 2017 15:11
Inventory sample JSON for import
{
"resources":[
{
"id":"EAP-1",
"name":"EAP-1",
"typeId":"EAP",
"parentId":null,
"metrics":[
{
"name":"memory1",
public class PrometheusNamesProvider implements MetricNamesProvider {
private static final String CONNECTIONS = "connections";
private static final String BYTES_RECEIVED = "bytes_received";
private static final String BYTES_SENT = "bytes_sent";
private static final String ERROR_COUNT = "error_count";
private static final String REQUESTS = "requests";
private static final String REQUEST_COUNT = "request_count";
private static final String WS_CONNECTIONS = "ws_connections";
private static final String RESPONSE_TIME = "response_time";