org.apache.calcite.avatica.metrics.MetricsSystem Java Examples
The following examples show how to use
org.apache.calcite.avatica.metrics.MetricsSystem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicAvaticaJsonHandler.java From kareldb with Apache License 2.0 | 6 votes |
public DynamicAvaticaJsonHandler(KarelDbConfig config, AvaticaHandler localHandler, UrlProvider urlProvider, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.config = config; this.localHandler = Objects.requireNonNull(localHandler); this.urlProvider = Objects.requireNonNull(urlProvider); this.metrics = Objects.requireNonNull(metrics); // Metrics this.requestTimer = this.metrics.getTimer( concat(AvaticaJsonHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.threadLocalBuffer = ThreadLocal.withInitial(UnsynchronizedBuffer::new); this.serverConfig = serverConfig; }
Example #2
Source File: HandlerFactory.java From calcite-avatica with Apache License 2.0 | 6 votes |
/** * Constructs the desired implementation for the given serialization method and server * configuration with metrics. * * @param service The underlying {@link Service} * @param serialization The serializatio mechanism to use * @param metricsConfig Configuration for the {@link MetricsSystem}. * @param serverConfig Avatica server configuration or null * @return An {@link AvaticaHandler} */ public AvaticaHandler getHandler(Service service, Driver.Serialization serialization, MetricsSystemConfiguration<?> metricsConfig, AvaticaServerConfiguration serverConfig) { if (null == metricsConfig) { metricsConfig = NoopMetricsSystemConfiguration.getInstance(); } MetricsSystem metrics = MetricsSystemLoader.load(metricsConfig); switch (serialization) { case JSON: return new AvaticaJsonHandler(service, metrics, serverConfig); case PROTOBUF: return new AvaticaProtobufHandler(service, metrics, serverConfig); default: throw new IllegalArgumentException("Unknown Avatica handler for " + serialization.name()); } }
Example #3
Source File: AvaticaJsonHandler.java From calcite-avatica with Apache License 2.0 | 6 votes |
public AvaticaJsonHandler(Service service, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.service = Objects.requireNonNull(service); this.metrics = Objects.requireNonNull(metrics); // Avatica doesn't have a Guava dependency this.jsonHandler = new JsonHandler(service, this.metrics); // Metrics this.requestTimer = this.metrics.getTimer( concat(AvaticaJsonHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.threadLocalBuffer = new ThreadLocal<UnsynchronizedBuffer>() { @Override public UnsynchronizedBuffer initialValue() { return new UnsynchronizedBuffer(); } }; this.serverConfig = serverConfig; }
Example #4
Source File: AvaticaProtobufHandler.java From calcite-avatica with Apache License 2.0 | 6 votes |
public AvaticaProtobufHandler(Service service, MetricsSystem metrics, AvaticaServerConfiguration serverConfig) { this.service = Objects.requireNonNull(service); this.metrics = Objects.requireNonNull(metrics); this.requestTimer = this.metrics.getTimer( MetricsHelper.concat(AvaticaProtobufHandler.class, MetricsAwareAvaticaHandler.REQUEST_TIMER_NAME)); this.protobufTranslation = new ProtobufTranslationImpl(); this.pbHandler = new ProtobufHandler(service, protobufTranslation, metrics); this.threadLocalBuffer = new ThreadLocal<UnsynchronizedBuffer>() { @Override public UnsynchronizedBuffer initialValue() { return new UnsynchronizedBuffer(); } }; this.serverConfig = serverConfig; }
Example #5
Source File: LocalService.java From calcite-avatica with Apache License 2.0 | 5 votes |
public LocalService(Meta meta, MetricsSystem metrics) { this.meta = meta; this.metrics = Objects.requireNonNull(metrics); this.executeTimer = this.metrics.getTimer(name("Execute")); this.commitTimer = this.metrics.getTimer(name("Commit")); this.prepareTimer = this.metrics.getTimer(name("Prepare")); this.prepareAndExecuteTimer = this.metrics.getTimer(name("PrepareAndExecute")); this.connectionSyncTimer = this.metrics.getTimer(name("ConnectionSync")); }
Example #6
Source File: NoopMetricsSystemTest.java From calcite-avatica with Apache License 2.0 | 5 votes |
@Test public void testNoNulls() { // The NOOP implementation should act as a real implementation, no "nulls" allowed. MetricsSystem metrics = NoopMetricsSystem.getInstance(); Counter counter = metrics.getCounter("counter"); counter.decrement(); counter.increment(); counter.decrement(1L); counter.increment(1L); Histogram histogram = metrics.getHistogram("histogram"); histogram.update(1); histogram.update(1L); Timer timer = metrics.getTimer("timer"); Context context = timer.start(); context.close(); Context contextTwo = timer.start(); assertTrue("Timer's context should be a singleton", context == contextTwo); Meter meter = metrics.getMeter("meter"); meter.mark(); meter.mark(5L); metrics.register("gauge", new Gauge<Long>() { @Override public Long getValue() { return 42L; } }); }
Example #7
Source File: ProtobufHandler.java From calcite-avatica with Apache License 2.0 | 5 votes |
public ProtobufHandler(Service service, ProtobufTranslation translation, MetricsSystem metrics) { super(service); this.translation = translation; this.metrics = metrics; this.serializationTimer = this.metrics.getTimer( MetricsHelper.concat(ProtobufHandler.class, HANDLER_SERIALIZATION_METRICS_NAME)); }
Example #8
Source File: JsonHandler.java From calcite-avatica with Apache License 2.0 | 4 votes |
public JsonHandler(Service service, MetricsSystem metrics) { super(service); this.metrics = metrics; this.serializationTimer = this.metrics.getTimer( MetricsHelper.concat(JsonHandler.class, HANDLER_SERIALIZATION_METRICS_NAME)); }
Example #9
Source File: DynamicAvaticaJsonHandler.java From kareldb with Apache License 2.0 | 4 votes |
public DynamicAvaticaJsonHandler(KarelDbConfig config, AvaticaHandler localHandler, UrlProvider urlProvider, MetricsSystem metrics) { this(config, localHandler, urlProvider, metrics, null); }
Example #10
Source File: AvaticaJsonHandler.java From calcite-avatica with Apache License 2.0 | 4 votes |
@Override public MetricsSystem getMetrics() { return metrics; }
Example #11
Source File: AvaticaJsonHandler.java From calcite-avatica with Apache License 2.0 | 4 votes |
public AvaticaJsonHandler(Service service, MetricsSystem metrics) { this(service, metrics, null); }
Example #12
Source File: AvaticaProtobufHandler.java From calcite-avatica with Apache License 2.0 | 4 votes |
@Override public MetricsSystem getMetrics() { return this.metrics; }
Example #13
Source File: AvaticaProtobufHandler.java From calcite-avatica with Apache License 2.0 | 4 votes |
public AvaticaProtobufHandler(Service service, MetricsSystem metrics) { this(service, metrics, null); }
Example #14
Source File: JdbcMeta.java From calcite-avatica with Apache License 2.0 | 4 votes |
/** * Creates a JdbcMeta. * * @param url a database url of the form * <code> jdbc:<em>subprotocol</em>:<em>subname</em></code> * @param info a list of arbitrary string tag/value pairs as * connection arguments; normally at least a "user" and * "password" property should be included */ public JdbcMeta(String url, Properties info, MetricsSystem metrics) throws SQLException { this.url = url; this.info = info; this.metrics = Objects.requireNonNull(metrics); int concurrencyLevel = Integer.parseInt( info.getProperty(ConnectionCacheSettings.CONCURRENCY_LEVEL.key(), ConnectionCacheSettings.CONCURRENCY_LEVEL.defaultValue())); int initialCapacity = Integer.parseInt( info.getProperty(ConnectionCacheSettings.INITIAL_CAPACITY.key(), ConnectionCacheSettings.INITIAL_CAPACITY.defaultValue())); long maxCapacity = Long.parseLong( info.getProperty(ConnectionCacheSettings.MAX_CAPACITY.key(), ConnectionCacheSettings.MAX_CAPACITY.defaultValue())); long connectionExpiryDuration = Long.parseLong( info.getProperty(ConnectionCacheSettings.EXPIRY_DURATION.key(), ConnectionCacheSettings.EXPIRY_DURATION.defaultValue())); TimeUnit connectionExpiryUnit = TimeUnit.valueOf( info.getProperty(ConnectionCacheSettings.EXPIRY_UNIT.key(), ConnectionCacheSettings.EXPIRY_UNIT.defaultValue())); this.connectionCache = CacheBuilder.newBuilder() .concurrencyLevel(concurrencyLevel) .initialCapacity(initialCapacity) .maximumSize(maxCapacity) .expireAfterAccess(connectionExpiryDuration, connectionExpiryUnit) .removalListener(new ConnectionExpiryHandler()) .build(); LOG.debug("instantiated connection cache: {}", connectionCache.stats()); concurrencyLevel = Integer.parseInt( info.getProperty(StatementCacheSettings.CONCURRENCY_LEVEL.key(), StatementCacheSettings.CONCURRENCY_LEVEL.defaultValue())); initialCapacity = Integer.parseInt( info.getProperty(StatementCacheSettings.INITIAL_CAPACITY.key(), StatementCacheSettings.INITIAL_CAPACITY.defaultValue())); maxCapacity = Long.parseLong( info.getProperty(StatementCacheSettings.MAX_CAPACITY.key(), StatementCacheSettings.MAX_CAPACITY.defaultValue())); connectionExpiryDuration = Long.parseLong( info.getProperty(StatementCacheSettings.EXPIRY_DURATION.key(), StatementCacheSettings.EXPIRY_DURATION.defaultValue())); connectionExpiryUnit = TimeUnit.valueOf( info.getProperty(StatementCacheSettings.EXPIRY_UNIT.key(), StatementCacheSettings.EXPIRY_UNIT.defaultValue())); this.statementCache = CacheBuilder.newBuilder() .concurrencyLevel(concurrencyLevel) .initialCapacity(initialCapacity) .maximumSize(maxCapacity) .expireAfterAccess(connectionExpiryDuration, connectionExpiryUnit) .removalListener(new StatementExpiryHandler()) .build(); LOG.debug("instantiated statement cache: {}", statementCache.stats()); // Register some metrics this.metrics.register(concat(JdbcMeta.class, "ConnectionCacheSize"), new Gauge<Long>() { @Override public Long getValue() { return connectionCache.size(); } }); this.metrics.register(concat(JdbcMeta.class, "StatementCacheSize"), new Gauge<Long>() { @Override public Long getValue() { return statementCache.size(); } }); }
Example #15
Source File: QuicksqlServerMeta.java From Quicksql with MIT License | 4 votes |
/** * Creates a QuicksqlServerMeta. * * @param url a database url of the form * <code> jdbc:<em>subprotocol</em>:<em>subname</em></code> * @param info a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and * "password" property should be included */ public QuicksqlServerMeta(String url, Properties info, MetricsSystem metrics) throws SQLException { this.url = url; this.info = info; this.metrics = Objects.requireNonNull(metrics); int concurrencyLevel = Integer.parseInt( info.getProperty(ConnectionCacheSettings.CONCURRENCY_LEVEL.key(), ConnectionCacheSettings.CONCURRENCY_LEVEL.defaultValue())); int initialCapacity = Integer.parseInt( info.getProperty(ConnectionCacheSettings.INITIAL_CAPACITY.key(), ConnectionCacheSettings.INITIAL_CAPACITY.defaultValue())); long maxCapacity = Long.parseLong( info.getProperty(ConnectionCacheSettings.MAX_CAPACITY.key(), ConnectionCacheSettings.MAX_CAPACITY.defaultValue())); long connectionExpiryDuration = Long.parseLong( info.getProperty(ConnectionCacheSettings.EXPIRY_DURATION.key(), ConnectionCacheSettings.EXPIRY_DURATION.defaultValue())); TimeUnit connectionExpiryUnit = TimeUnit.valueOf( info.getProperty(ConnectionCacheSettings.EXPIRY_UNIT.key(), ConnectionCacheSettings.EXPIRY_UNIT.defaultValue())); this.connectionCache = CacheBuilder.newBuilder() .concurrencyLevel(concurrencyLevel) .initialCapacity(initialCapacity) .maximumSize(maxCapacity) .expireAfterAccess(connectionExpiryDuration, connectionExpiryUnit) .removalListener(new ConnectionExpiryHandler()) .build(); LOGGER.debug("instantiated connection cache: {}", connectionCache.stats()); concurrencyLevel = Integer.parseInt( info.getProperty(StatementCacheSettings.CONCURRENCY_LEVEL.key(), StatementCacheSettings.CONCURRENCY_LEVEL.defaultValue())); initialCapacity = Integer.parseInt( info.getProperty(StatementCacheSettings.INITIAL_CAPACITY.key(), StatementCacheSettings.INITIAL_CAPACITY.defaultValue())); maxCapacity = Long.parseLong( info.getProperty(StatementCacheSettings.MAX_CAPACITY.key(), StatementCacheSettings.MAX_CAPACITY.defaultValue())); connectionExpiryDuration = Long.parseLong( info.getProperty(StatementCacheSettings.EXPIRY_DURATION.key(), StatementCacheSettings.EXPIRY_DURATION.defaultValue())); connectionExpiryUnit = TimeUnit.valueOf( info.getProperty(StatementCacheSettings.EXPIRY_UNIT.key(), StatementCacheSettings.EXPIRY_UNIT.defaultValue())); this.statementCache = CacheBuilder.newBuilder() .concurrencyLevel(concurrencyLevel) .initialCapacity(initialCapacity) .maximumSize(maxCapacity) .expireAfterAccess(connectionExpiryDuration, connectionExpiryUnit) .removalListener(new StatementExpiryHandler()) .build(); LOGGER.debug("instantiated statement cache: {}", statementCache.stats()); // Register some metrics this.metrics.register(concat( QuicksqlServerMeta.class, "ConnectionCacheSize"), new Gauge<Long>() { @Override public Long getValue() { return connectionCache.size(); } }); this.metrics.register(concat(QuicksqlServerMeta.class, "StatementCacheSize"), new Gauge<Long>() { @Override public Long getValue() { return statementCache.size(); } }); }
Example #16
Source File: DynamicAvaticaJsonHandler.java From kareldb with Apache License 2.0 | 4 votes |
@Override public MetricsSystem getMetrics() { return metrics; }
Example #17
Source File: MetricsAwareAvaticaHandler.java From calcite-avatica with Apache License 2.0 | 2 votes |
/** * @return An instance of the {@link MetricsSystem} for this AvaticaHandler. */ MetricsSystem getMetrics();