method2testcases
stringlengths
118
3.08k
### Question: MicrometerHttpRequestExecutor extends HttpRequestExecutor { public static Builder builder(MeterRegistry registry) { return new Builder(registry); } private MicrometerHttpRequestExecutor(int waitForContinue, MeterRegistry registry, ...
### Question: KafkaConsumerMetrics implements MeterBinder, AutoCloseable { int kafkaMajorVersion(Tags tags) { if (kafkaMajorVersion == null || kafkaMajorVersion == -1) { kafkaMajorVersion = tags.stream().filter(t -> "client.id".equals(t.getKey())).findAny() .map(clientId -> { try { String version = (String) mBeanServer...
### Question: DatabaseTableMetrics implements MeterBinder { public static void monitor(MeterRegistry registry, String tableName, String dataSourceName, DataSource dataSource, String... tags) { monitor(registry, dataSource, dataSourceName, tableName, Tags.of(tags)); } DatabaseTableMetrics(DataSource dataSource, String d...
### Question: LogbackMetrics implements MeterBinder, AutoCloseable { @Override public void bindTo(MeterRegistry registry) { MetricsTurboFilter filter = new MetricsTurboFilter(registry, tags); synchronized (metricsTurboFilters) { metricsTurboFilters.put(registry, filter); loggerContext.addTurboFilter(filter); } } Logbac...
### Question: LogbackMetrics implements MeterBinder, AutoCloseable { public static void ignoreMetrics(Runnable r) { ignoreMetrics.set(true); try { r.run(); } finally { ignoreMetrics.remove(); } } LogbackMetrics(); LogbackMetrics(Iterable<Tag> tags); LogbackMetrics(Iterable<Tag> tags, LoggerContext context); @Override...
### Question: FileDescriptorMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { if (openFilesMethod != null) { Gauge.builder("process.files.open", osBean, x -> invoke(openFilesMethod)) .tags(tags) .description("The open file descriptor count") .baseUnit(BaseUnits.FILES) .register(reg...
### Question: UptimeMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { TimeGauge.builder("process.uptime", runtimeMXBean, TimeUnit.MILLISECONDS, RuntimeMXBean::getUptime) .tags(tags) .description("The uptime of the Java virtual machine") .register(registry); TimeGauge.builder("proce...
### Question: ElasticMeterRegistry extends StepMeterRegistry { protected String indexName() { ZonedDateTime dt = ZonedDateTime.ofInstant(new Date(config().clock().wallTime()).toInstant(), ZoneOffset.UTC); return config.index() + config.indexDateSeparator() + indexDateFormatter.format(dt); } @SuppressWarnings("deprecati...
### Question: SignalFxNamingConvention implements NamingConvention { @Override public String tagKey(String key) { String conventionKey = delegate.tagKey(key); conventionKey = START_UNDERSCORE_PATTERN.matcher(conventionKey).replaceAll(""); conventionKey = SF_PATTERN.matcher(conventionKey).replaceAll(""); conventionKey =...
### Question: JvmMemory { static Optional<MemoryPoolMXBean> getOldGen() { return ManagementFactory .getPlatformMXBeans(MemoryPoolMXBean.class) .stream() .filter(JvmMemory::isHeap) .filter(mem -> isOldGenPool(mem.getName())) .findAny(); } private JvmMemory(); }### Answer: @Test void assertJvmMemoryGetOldGen() { Optio...
### Question: JvmThreadMetrics implements MeterBinder { static long getThreadStateCount(ThreadMXBean threadBean, Thread.State state) { return Arrays.stream(threadBean.getThreadInfo(threadBean.getAllThreadIds())) .filter(threadInfo -> threadInfo != null && threadInfo.getThreadState() == state) .count(); } JvmThreadMetri...
### Question: ClassLoaderMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean(); Gauge.builder("jvm.classes.loaded", classLoadingBean, ClassLoadingMXBean::getLoadedClassCount) .tags(tags) .description("The n...
### Question: DiskSpaceMetrics implements MeterBinder { public DiskSpaceMetrics(File path) { this(path, emptyList()); } DiskSpaceMetrics(File path); DiskSpaceMetrics(File path, Iterable<Tag> tags); @Override void bindTo(MeterRegistry registry); }### Answer: @Test void diskSpaceMetrics() { new DiskSpaceMetrics(new Fil...
### Question: DiskSpaceMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { Iterable<Tag> tagsWithPath = Tags.concat(tags, "path", absolutePath); Gauge.builder("disk.free", path, File::getUsableSpace) .tags(tagsWithPath) .description("Usable space for path") .baseUnit(BaseUnits.BYTES)...
### Question: JvmCompilationMetrics implements MeterBinder { @Override public void bindTo(MeterRegistry registry) { CompilationMXBean compilationBean = ManagementFactory.getCompilationMXBean(); if (compilationBean != null && compilationBean.isCompilationTimeMonitoringSupported()) { FunctionCounter.builder("jvm.compilat...
### Question: EhCache2Metrics extends CacheMeterBinder { public static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags) { return monitor(registry, cache, Tags.of(tags)); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... ta...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected Long size() { return stats.getSize(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, Iterable<T...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected Long evictionCount() { return stats.cacheEvictedCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcach...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected long hitCount() { return stats.cacheHitCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, ...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected Long missCount() { return stats.cacheMissCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache...
### Question: EhCache2Metrics extends CacheMeterBinder { @Override protected long putCount() { return stats.cachePutCount(); } EhCache2Metrics(Ehcache cache, Iterable<Tag> tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, String... tags); static Ehcache monitor(MeterRegistry registry, Ehcache cache, ...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { public static Object monitor(MeterRegistry registry, Object cache, String... tags) { return monitor(registry, cache, Tags.of(tags)); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, Strin...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return cache.getLocalMapStats().getOwnedEntryCount(); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegist...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return null; } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegistry registry, Object cache, Iterable<...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Nullable @Override protected Long evictionCount() { return null; } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegistry registry, Object ca...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return cache.getLocalMapStats().getHits(); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(MeterRegistry regi...
### Question: HazelcastCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return cache.getLocalMapStats().getPutOperationCount(); } HazelcastCacheMetrics(Object cache, Iterable<Tag> tags); static Object monitor(MeterRegistry registry, Object cache, String... tags); static Object monitor(Meter...
### Question: GuavaCacheMetrics extends CacheMeterBinder { public static <C extends Cache<?, ?>> C monitor(MeterRegistry registry, C cache, String cacheName, String... tags) { return monitor(registry, cache, cacheName, Tags.of(tags)); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static ...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return cache.size(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegistry registry, C ...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return cache.stats().hitCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegis...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return cache.stats().missCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterReg...
### Question: ElasticNamingConvention implements NamingConvention { @Override public String tagKey(String key) { if (key.equals("name")) { key = "name.tag"; } else if (key.equals("type")) { key = "type.tag"; } else if (key.startsWith("_")) { key = FIRST_UNDERSCORE_PATTERN.matcher(key).replaceFirst(""); } return delegat...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected Long evictionCount() { return cache.stats().evictionCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(...
### Question: GuavaCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return cache.stats().loadCount(); } GuavaCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegi...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { public static <C extends Cache<?, ?>> C monitor(MeterRegistry registry, C cache, String cacheName, String... tags) { return monitor(registry, cache, cacheName, Tags.of(tags)); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); s...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return cache.estimatedSize(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(MeterRegist...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return cache.stats().hitCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(Mete...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return cache.stats().missCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(Me...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected Long evictionCount() { return cache.stats().evictionCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C mo...
### Question: CaffeineCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return cache.stats().loadCount(); } CaffeineCacheMetrics(Cache<?, ?> cache, String cacheName, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String cacheName, String... tags); static C monitor(Met...
### Question: JCacheMetrics extends CacheMeterBinder { public static <K, V, C extends Cache<K, V>> C monitor(MeterRegistry registry, C cache, String... tags) { return monitor(registry, cache, Tags.of(tags)); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected Long size() { return null; } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> tags); }### Answer: @Test void...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected Long missCount() { return lookupStatistic("CacheMisses"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> ...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected Long evictionCount() { return lookupStatistic("CacheEvictions"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterabl...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected long hitCount() { return lookupStatistic("CacheHits"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> tag...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected long putCount() { return lookupStatistic("CachePuts"); } JCacheMetrics(Cache<?, ?> cache, Iterable<Tag> tags); static C monitor(MeterRegistry registry, C cache, String... tags); static C monitor(MeterRegistry registry, C cache, Iterable<Tag> tag...
### Question: JCacheMetrics extends CacheMeterBinder { @Override protected void bindImplementationSpecificMetrics(MeterRegistry registry) { if (objectName != null) { Gauge.builder("cache.removals", objectName, objectName -> lookupStatistic("CacheRemovals")) .tags(getTagsWithCacheName()) .description("Cache removals") ....
### Question: TimedHandler extends HandlerWrapper implements Graceful { @Override public Future<Void> shutdown() { return shutdown.shutdown(); } TimedHandler(MeterRegistry registry, Iterable<Tag> tags); TimedHandler(MeterRegistry registry, Iterable<Tag> tags, HttpServletRequestTagsProvider tagsProvider); @Override voi...
### Question: JettySslHandshakeMetrics implements SslHandshakeListener { @Override public void handshakeFailed(Event event, Throwable failure) { handshakesFailed.increment(); } JettySslHandshakeMetrics(MeterRegistry registry); JettySslHandshakeMetrics(MeterRegistry registry, Iterable<Tag> tags); @Override void handsha...
### Question: JettySslHandshakeMetrics implements SslHandshakeListener { @Override public void handshakeSucceeded(Event event) { SSLSession session = event.getSSLEngine().getSession(); Counter.builder(METER_NAME) .baseUnit(BaseUnits.EVENTS) .description(DESCRIPTION) .tag(TAG_RESULT, "succeeded") .tag(TAG_PROTOCOL, sess...
### Question: HibernateMetrics implements MeterBinder { public static void monitor(MeterRegistry registry, SessionFactory sessionFactory, String sessionFactoryName, String... tags) { monitor(registry, sessionFactory, sessionFactoryName, Tags.of(tags)); } HibernateMetrics(SessionFactory sessionFactory, String sessionFac...
### Question: PushMeterRegistry extends MeterRegistry { @Deprecated public final void start() { start(Executors.defaultThreadFactory()); } protected PushMeterRegistry(PushRegistryConfig config, Clock clock); @Deprecated final void start(); void start(ThreadFactory threadFactory); void stop(); @Override void close(); ...
### Question: PushMeterRegistry extends MeterRegistry { @Override public void close() { if (config.enabled()) { publishSafely(); } stop(); super.close(); } protected PushMeterRegistry(PushRegistryConfig config, Clock clock); @Deprecated final void start(); void start(ThreadFactory threadFactory); void stop(); @Overrid...
### Question: StepFunctionTimer implements FunctionTimer { public double totalTime(TimeUnit unit) { accumulateCountAndTotal(); return TimeUtils.convert(countTotal.poll2(), baseTimeUnit(), unit); } StepFunctionTimer(Id id, Clock clock, long stepMillis, T obj, ToLongFunction<T> countFunction, ...
### Question: StepFunctionTimer implements FunctionTimer { public double count() { accumulateCountAndTotal(); return countTotal.poll1(); } StepFunctionTimer(Id id, Clock clock, long stepMillis, T obj, ToLongFunction<T> countFunction, ToDoubleFunction<T> totalTimeFunction, TimeUnit totalTime...
### Question: StepValue { public V poll() { rollCount(clock.wallTime()); return previous; } StepValue(final Clock clock, final long stepMillis); V poll(); }### Answer: @Test void poll() { final AtomicLong aLong = new AtomicLong(42); final long stepTime = 60; final StepValue<Long> stepValue = new StepValue<Long>(clock,...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { Optional<String> writeGauge(Gauge gauge) { double value = gauge.value(); if (!Double.isFinite(value)) { return Optional.empty(); } return Optional.of(write(gauge.getId(), "gauge", Fields.Value.tag(), decimal(value))); } @SuppressWarnings("deprecation") A...
### Question: StepFunctionCounter extends AbstractMeter implements FunctionCounter { @Override public double count() { T obj2 = ref.get(); if (obj2 != null) { double prevLast = last; last = f.applyAsDouble(obj2); count.getCurrent().add(last - prevLast); } return count.poll(); } StepFunctionCounter(Id id, Clock clock, l...
### Question: MultiGauge { private MultiGauge(MeterRegistry registry, Meter.Id commonId) { this.registry = registry; this.commonId = commonId; } private MultiGauge(MeterRegistry registry, Meter.Id commonId); static Builder builder(String name); void register(Iterable<Row<?>> rows); @SuppressWarnings("unchecked") void ...
### Question: MultiGauge { public void register(Iterable<Row<?>> rows) { register(rows, false); } private MultiGauge(MeterRegistry registry, Meter.Id commonId); static Builder builder(String name); void register(Iterable<Row<?>> rows); @SuppressWarnings("unchecked") void register(Iterable<Row<?>> rows, boolean overwri...
### Question: FixedBoundaryVictoriaMetricsHistogram implements Histogram { public static String getRangeTagValue(double value) { IdxOffset idxOffset = getBucketIdxAndOffset(value); return VMRANGES[getRangeIndex(idxOffset.bucketIdx, idxOffset.offset)]; } FixedBoundaryVictoriaMetricsHistogram(); @Override void recordLong...
### Question: TimeWindowFixedBoundaryHistogram extends AbstractTimeWindowHistogram<TimeWindowFixedBoundaryHistogram.FixedBoundaryHistogram, Void> { @Override final void recordDouble(FixedBoundaryHistogram bucket, double value) { recordLong(bucket, (long) Math.ceil(value)); } TimeWindowFixedBoundaryHistogram(Clock clock...
### Question: DefaultJerseyTagsProvider implements JerseyTagsProvider { @Override public Iterable<Tag> httpLongRequestTags(RequestEvent event) { return Tags.of(JerseyTags.method(event.getContainerRequest()), JerseyTags.uri(event)); } @Override Iterable<Tag> httpRequestTags(RequestEvent event); @Override Iterable<Tag> ...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { Optional<String> writeFunctionCounter(FunctionCounter counter) { double count = counter.count(); if (Double.isFinite(count) && count > 0) { return Optional.of(write(counter.getId(), "functionCounter", Fields.Value.tag(), decimal(count))); } return Optiona...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { @Override protected void publish() { try { String bodyMeasurementsPrefix = getBodyMeasurementsPrefix(); for (List<Meter> batch : MeterPartition.partition(this, config.batchSize())) { final List<String> meters = batch.stream() .map(meter -> meter.match( th...
### Question: AppOpticsMeterRegistry extends StepMeterRegistry { String getBodyMeasurementsPrefix() { long stepSeconds = config.step().getSeconds(); long wallTimeInSeconds = TimeUnit.MILLISECONDS.toSeconds(clock.wallTime()); if (config.floorTimes()) { wallTimeInSeconds -= wallTimeInSeconds % stepSeconds; } return Strin...
### Question: AtlasMeterRegistry extends MeterRegistry { @Override public void close() { stop(); super.close(); } AtlasMeterRegistry(AtlasConfig config, Clock clock); AtlasMeterRegistry(AtlasConfig config); void start(); void stop(); @Override void close(); Registry getSpectatorRegistry(); }### Answer: @Issue("#484")...
### Question: AtlasMeterRegistry extends MeterRegistry { public Registry getSpectatorRegistry() { return registry; } AtlasMeterRegistry(AtlasConfig config, Clock clock); AtlasMeterRegistry(AtlasConfig config); void start(); void stop(); @Override void close(); Registry getSpectatorRegistry(); }### Answer: @Issue("#20...
### Question: AtlasNamingConvention implements NamingConvention { @Override public String tagKey(String key) { if (key.equals("name")) { key = "name.tag"; } else if (key.equals("statistic")) { key = "statistic.tag"; } return NamingConvention.camelCase.tagKey(key); } @Override String name(String name, Meter.Type type, ...
### Question: SpectatorTimer extends AbstractTimer { @Override public double max(TimeUnit unit) { for (Measurement measurement : timer.measure()) { if (stream(measurement.id().tags().spliterator(), false) .anyMatch(tag -> tag.key().equals("statistic") && tag.value().equals(Statistic.max.toString()))) { return TimeUtils...
### Question: DynatraceMeterRegistry extends StepMeterRegistry { void putCustomMetric(final DynatraceMetricDefinition customMetric) { try { httpClient.put(customMetricEndpointTemplate + customMetric.getMetricId() + "?api-token=" + config.apiToken()) .withJsonContent(customMetric.asJson()) .send() .onSuccess(response ->...
### Question: DynatraceNamingConvention implements NamingConvention { @Override public String name(String name, Meter.Type type, @Nullable String baseUnit) { return "custom:" + sanitizeName(delegate.name(name, type, baseUnit)); } DynatraceNamingConvention(NamingConvention delegate); DynatraceNamingConvention(); @Overr...
### Question: DynatraceNamingConvention implements NamingConvention { @Override public String tagKey(String key) { return KEY_CLEANUP_PATTERN.matcher(delegate.tagKey(key)).replaceAll("_"); } DynatraceNamingConvention(NamingConvention delegate); DynatraceNamingConvention(); @Override String name(String name, Meter.Type...
### Question: DynatraceTimeSeries { String asJson() { String body = "{\"timeseriesId\":\"" + metricId + "\"" + ",\"dataPoints\":[[" + time + "," + DoubleFormat.wholeOrDecimal(value) + "]]"; if (dimensions != null && !dimensions.isEmpty()) { body += ",\"dimensions\":{" + dimensions.entrySet().stream() .map(t -> "\"" + t...
### Question: PrometheusRenameFilter implements MeterFilter { @Override public Meter.Id map(Meter.Id id) { String convertedName = MICROMETER_TO_PROMETHEUS_NAMES.get(id.getName()); return convertedName == null ? id : id.withName(convertedName); } @Override Meter.Id map(Meter.Id id); }### Answer: @Test void doesNotChan...
### Question: PrometheusMeterRegistry extends MeterRegistry { public PrometheusMeterRegistry throwExceptionOnRegistrationFailure() { config().onMeterRegistrationFailed((id, reason) -> { throw new IllegalArgumentException(reason); }); return this; } PrometheusMeterRegistry(PrometheusConfig config); PrometheusMeterRegis...
### Question: PrometheusMeterRegistry extends MeterRegistry { public CollectorRegistry getPrometheusRegistry() { return registry; } PrometheusMeterRegistry(PrometheusConfig config); PrometheusMeterRegistry(PrometheusConfig config, CollectorRegistry registry, Clock clock); String scrape(); void scrape(Writer writer); @...
### Question: CacheController { public ClientConnection getConnection(String deviceName){ synchronized (clientCache) { List<ClientConnection> clientConnections = clientCache.get(deviceName); if (clientConnections != null && !clientConnections.isEmpty()){ for (ClientConnection c : clientConnections){ if (!isConnectionEx...
### Question: Notify extends Message { public static Notify fromJSON(JSONObject json) throws JSONException { Notify e = new Notify(); Message.fromJSON(e, json); e.setEventKey(json.optString("eventKey",null)); e.setDriver(json.optString("driver",null)); e.setInstanceId(json.optString("instanceId",null)); if(json.has("pa...
### Question: DriverDao { public void insert(DriverModel driver) { DriverModel found = retrieve(driver.id(), driver.device()); if (found != null){ removeFromMap(found); } insertOnMap(driver); } DriverDao(InitialProperties bundle); void insert(DriverModel driver); List<DriverModel> list(); List<DriverModel> list(String ...
### Question: DriverManager { public List<UosDriver> listDrivers(){ List<DriverModel> list = driverDao.list(null,currentDevice.getName()); if (list.isEmpty()) return new ArrayList<UosDriver>(); List<UosDriver> ret = new ArrayList<UosDriver>(); for (DriverModel m : list){ ret.add(instances.get(m.rowid())); } return ret;...
### Question: DriverManager { public void initDrivers(Gateway gateway, InitialProperties properties){ try { if (driverDao.list("uos.DeviceDriver").isEmpty()){ DeviceDriver deviceDriver = new DeviceDriver(); deployDriver(deviceDriver.getDriver(), deviceDriver); } } catch (Exception e) { throw new RuntimeException(e); } ...
### Question: DriverManager { public void tearDown(){ for (DriverModel d : driverDao.list()){ undeployDriver(d.id()); } dCount = 0; } DriverManager(UpDevice currentDevice, DriverDao driverDao, DeviceDao deviceDao, ReflectionServiceCaller serviceCaller); Response handleServiceCall(Call serviceCall, CallContext messageC...
### Question: DriverData { public boolean equals(Object obj) { if (obj != null && obj instanceof DriverData){ DriverData temp = (DriverData)obj; if (temp.driver != null && temp.device != null && temp.instanceID != null){ return temp.driver.equals(this.driver) && temp.device.equals(this.device) && temp.instanceID.equals...
### Question: ApplicationManager { public void add(UosApplication app) { add(app, assignAName(app, null)); } ApplicationManager(InitialProperties properties, Gateway gateway, ConnectionManagerControlCenter connectionManagerControlCenter); void add(UosApplication app); void add(UosApplication app, String id); void st...
### Question: ApplicationManager { public void deploy(UosApplication app) { deploy(app, null); } ApplicationManager(InitialProperties properties, Gateway gateway, ConnectionManagerControlCenter connectionManagerControlCenter); void add(UosApplication app); void add(UosApplication app, String id); void startApplicati...
### Question: EventManager implements NotifyHandler { public void notify(Notify notify, UpDevice device) throws NotifyException{ try { if(device == null){ handleNofify(notify, device); }else{ messageEngine.notify(notify, device); } } catch (MessageEngineException e) { throw new NotifyException(e); } } EventManager(Mess...
### Question: EventManager implements NotifyHandler { public void unregister(UosEventListener listener, UpDevice device, String driver, String instanceId, String eventKey) throws NotifyException{ List<ListenerInfo> listeners = findListeners( device, driver, instanceId, eventKey); if (listeners == null){ return; } Notif...
### Question: SmartSpaceGateway implements Gateway { public void notify(Notify notify, UpDevice device) throws NotifyException { adaptabilityEngine.notify(notify, device); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityM...
### Question: SmartSpaceGateway implements Gateway { public void unregister(UosEventListener listener) throws NotifyException { adaptabilityEngine.unregister(listener); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityMana...
### Question: SmartSpaceGateway implements Gateway { public List<DriverData> listDrivers(String driverName) { return driverManager.listDrivers(driverName, null); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityManager, ...
### Question: SmartSpaceGateway implements Gateway { public List<UpDevice> listDevices() { return deviceManager.listDevices(); } void init(AdaptabilityEngine adaptabilityEngine, UpDevice currentDevice, SecurityManager securityManager, ConnectivityManager connectivityManager, DeviceManager deviceManager, Drive...
### Question: DeviceDriver implements UosDriver { @Override public UpDriver getDriver() { return driver; } DeviceDriver(); @Override UpDriver getDriver(); @Override void init(Gateway gateway, InitialProperties properties, String instanceId); @Override void destroy(); @Override List<UpDriver> getParent(); @SuppressWarni...
### Question: UpDriver { @Override public boolean equals(Object obj) { if (obj == null || ! (obj instanceof UpDriver) ) return false; UpDriver d = (UpDriver) obj; if(!compare(this.name,d.name)) return false; if(!compare(this.services,d.services)) return false; if(!compare(this.events,d.events)) return false; return tru...
### Question: UpDriver { @Override public int hashCode() { if(name != null){ return name.hashCode(); } return super.hashCode(); } UpDriver(); UpDriver(String name); String getName(); void setName(String name); List<UpService> getServices(); void setServices(List<UpService> services); UpService addService(UpService ser...
### Question: UpDriver { public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put("name", this.getName()); addServices(json, "services", this.services); addServices(json, "events", this.events); addStrings(json, "equivalent_drivers", equivalentDrivers); return json; } UpDriver(); ...
### Question: UpDriver { public static UpDriver fromJSON(JSONObject json) throws JSONException { UpDriver d = new UpDriver(json.optString("name",null)); d.services = addServices(json, "services"); d.events = addServices(json, "events"); d.equivalentDrivers = addStrings(json, "equivalent_drivers"); return d; } UpDriver(...
### Question: UpDevice { @Override public boolean equals(Object obj) { if (obj == null || ! (obj instanceof UpDevice) ){ return false; } UpDevice d = (UpDevice) obj; if(!compare(this.name,d.name)) return false; if(!compare(this.networks,d.networks)) return false; if(!compare(this.meta,d.meta)) return false; return true...
### Question: UpDevice { @Override public int hashCode() { if(name != null){ return name.hashCode(); } return super.hashCode(); } UpDevice(); UpDevice(String name); UpDevice addNetworkInterface(String networkAdress, String networkType); String getName(); void setName(String name); List<UpNetworkInterface> getNetworks(...
### Question: UpDevice { public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); json.put("name", this.name); addNetworks(json, "networks"); addMeta(json); return json; } UpDevice(); UpDevice(String name); UpDevice addNetworkInterface(String networkAdress, String networkType); String getN...