This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how we did async in the dark ages | |
Futures.addCallback(session.executeAsync(boundStatement), new FutureCallback<ResultSet>() { | |
@Override | |
public void onSuccess(ResultSet rows) { | |
rows.forEach(row -> mappings.put(row.getString(0), row.getString(1))); | |
} | |
@Override | |
public void onFailure(Throwable throwable) { | |
// handle failure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Map<String,String> getMappingTable() { | |
// You only want to prepare the query once. Best to do it when you initialize the session. | |
PreparedStatement findMappings = session.prepare( | |
"SELECT project_id, project_name " + | |
"FROM openshift_metrics.metrics_mappings " + | |
"WHERE token(project_id) > ? AND token(project_id) <= ?"); | |
Map<String,String> mappings = new HashMap<>(); | |
if (hasMappingTable()) { | |
for (TokenRange tokenRange : getTokenRanges()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void start() throws Exception { | |
ObjectMapper mapper = createMapper(); | |
Router router = Router.router(vertx); | |
router.route(HttpMethod.POST, BASE_URL + "gauges/raw").handler(context -> | |
RxHelper.toObservable(context.request()) | |
.map(buffer -> { | |
try { | |
TypeReference<List<Metric<Double>>> typeRef = new TypeReference<List<Metric<Double>>>() {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable<Row> findEntityByCanonicalPath(String cp) { | |
// return session.executeAndFetch(findEntityByCanonicalPath.bind(cp)); | |
return session.execute(findEntityByCanonicalPath.bind(cp)).flatMap(Observable::from); | |
} | |
Observable<Row> findRelationshipByCanonicalPath(String cp) { | |
// return session.executeAndFetch(findRelationshipByCanonicalPath.bind(cp)); | |
return session.execute(findRelationshipByCanonicalPath.bind(cp)).flatMap(Observable::from); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I put this class in the rest-tests-jaxrs module. | |
class NullStringITest extends RESTTest { | |
@Test | |
void nullStrings() { | |
String tenantId = nextTenantId() | |
def response = hawkularMetrics.post( | |
path: 'strings', | |
body: [ | |
id: 'NULL-STRING', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cache-container name="hawkular-metrics" | |
default-cache="locks" | |
module="org.wildfly.clustering.server" | |
statistics-enabled="true"> | |
<transport lock-timeout="60000"/> | |
<replicated-cache name="locks" mode="SYNC"> | |
<transaction mode="NON_XA" locking="PESSIMISTIC"/> | |
</replicated-cache> | |
</cache-container |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initSchema() { | |
doWithLock("cassalog", () -> { | |
SchemaService schemaService = new SchemaService(); | |
schemaService.run(session, keyspace, Boolean.parseBoolean(resetDb)); | |
session.execute("USE " + keyspace); | |
}); | |
} | |
private void doWithLock(String key, Runnable runnable) { | |
AdvancedCache<String, String> cache = locksCache.getAdvancedCache(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Listener | |
public class DistributedLock { | |
private static Logger log = Logger.getLogger(DistributedLock.class); | |
private static final String KEY = "cassalog"; | |
private AdvancedCache<String, String> locksCache; | |
public DistributedLock(AdvancedCache<String, String> locksCache) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void initSchema() { | |
doWithLock("cassalog", () -> { | |
SchemaService schemaService = new SchemaService(); | |
schemaService.run(session, keyspace, Boolean.parseBoolean(resetDb)); | |
session.execute("USE " + keyspace); | |
}); | |
} | |
private void doWithLock(String key, Runnable runnable) { | |
AdvancedCache<String, String> cache = locksCache.getAdvancedCache(); | |
TransactionManager transactionManager = cache.getTransactionManager(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean enableAll(MetricRegistry registry) | |
{ | |
boolean enabled = false; | |
if (console != null) | |
{ | |
if (enableConsole(registry)) | |
{ | |
enabled = true; | |
} | |
} |