@Test public void getStats() throws Throwable { StatelessService service = new StatelessTestService(); service.setMaintenanceIntervalMicros(1000); service.options.add(Service.ServiceOption.INSTRUMENTATION); service.options.add(Service.ServiceOption.PERIODIC_MAINTENANCE); this.host.startServiceAndWait(service, "some/service", null); this.host.waitFor("missing stats", () -> { ServiceStats stats = service.getStats(); if (stats == null || stats.entries.isEmpty()) { return false; } ServiceStat maintSt = stats.entries.get(Service.STAT_NAME_MAINTENANCE_COUNT); if (maintSt == null || maintSt.version < 1) { return false; } return true; }); }
@Override public ServiceStats getStats() { Service s = this.getUtilityService(ServiceHost.SERVICE_URI_SUFFIX_STATS, false); if (s == null) { return null; } return s.getStats(); }
StatelessService implements Service { @Override public ServiceStats getStats() { Service s = this.getUtilityService(ServiceHost.SERVICE_URI_SUFFIX_STATS, false); if (s == null) { return null; } return s.getStats(); } }
StatelessService implements Service { @Override public ServiceStats getStats() { Service s = this.getUtilityService(ServiceHost.SERVICE_URI_SUFFIX_STATS, false); if (s == null) { return null; } return s.getStats(); } StatelessService(Class<? extends ServiceDocument> stateType);  StatelessService(); }
StatelessService implements Service { @Override public ServiceStats getStats() { Service s = this.getUtilityService(ServiceHost.SERVICE_URI_SUFFIX_STATS, false); if (s == null) { return null; } return s.getStats(); } StatelessService(Class<? extends ServiceDocument> stateType);  StatelessService(); @Override void handleCreate(Operation post); @Override void handleStart(Operation startPost); @Override void authorizeRequest(Operation op); @Override boolean queueRequest(Operation op); @Override void sendRequest(Operation op); @Override void handleRequest(Operation op); @Override void handleRequest(Operation op, OperationProcessingStage opProcessingStage); void handlePut(Operation put); void handlePatch(Operation patch); void handleOptions(Operation options); void handlePost(Operation post); void handleGet(Operation get); void handleDelete(Operation delete); @Override void handleStop(Operation delete); @Override void handleMaintenance(Operation post); void handlePeriodicMaintenance(Operation post); void handleNodeGroupMaintenance(Operation post); @Override ServiceHost getHost(); @Override String getSelfLink(); @Override URI getUri(); @Override OperationProcessingChain getOperationProcessingChain(); @Override ProcessingStage getProcessingStage(); @Override boolean hasOption(ServiceOption cap); @Override void toggleOption(ServiceOption option, boolean enable); @Override void setStat(String name, double newValue); @Override void setStat(ServiceStat s, double newValue); @Override void adjustStat(ServiceStat s, double delta); @Override void adjustStat(String name, double delta); @Override ServiceStats getStats(); @Override ServiceStat getStat(String name); void setAvailable(boolean isAvailable); boolean isAvailable(); @Override void setHost(ServiceHost serviceHost); @Override void setSelfLink(String path); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage stage); @Override ServiceDocument setInitialState(Object state, Long version); @Override Service getUtilityService(String uriPath, boolean allocate); @Override ServiceDocument getDocumentTemplate(); void logSevere(Throwable e); void logSevere(String fmt, Object... args); void logSevere(Supplier<String> messageSupplier); void logInfo(String fmt, Object... args); void logInfo(Supplier<String> messageSupplier); void logFine(String fmt, Object... args); void logFine(Supplier<String> messageSupplier); void logWarning(String fmt, Object... args); void logWarning(Supplier<String> messageSupplier); void log(Level level, String fmt, Object... args); void log(Level level, Supplier<String> messageSupplier); @Override void setPeerNodeSelectorPath(String uriPath); @Override String getPeerNodeSelectorPath(); @Override void setDocumentIndexPath(String uriPath); @Override String getDocumentIndexPath(); @Override EnumSet<ServiceOption> getOptions(); void publish(Operation op); @Override void setState(Operation op, ServiceDocument state); @SuppressWarnings("unchecked") @Override T getState(Operation op); @Override void setMaintenanceIntervalMicros(long micros); @Override void setCacheClearDelayMicros(long micros); @Override long getMaintenanceIntervalMicros(); @Override long getCacheClearDelayMicros(); @Override Operation dequeueRequest(); @Override Class<? extends ServiceDocument> getStateType(); @Override void handleConfigurationRequest(Operation request); @Override final void setAuthorizationContext(Operation op, AuthorizationContext ctx); final Signer getTokenSigner(); final Verifier getTokenVerifier(); @Override final AuthorizationContext getSystemAuthorizationContext(); final AuthorizationContext getAuthorizationContextForSubject(String subject); void setOperationHandlerInvokeTimeStat(Operation request); void setOperationDurationStat(Operation request); }
StatelessService implements Service { @Override public ServiceStats getStats() { Service s = this.getUtilityService(ServiceHost.SERVICE_URI_SUFFIX_STATS, false); if (s == null) { return null; } return s.getStats(); } StatelessService(Class<? extends ServiceDocument> stateType);  StatelessService(); @Override void handleCreate(Operation post); @Override void handleStart(Operation startPost); @Override void authorizeRequest(Operation op); @Override boolean queueRequest(Operation op); @Override void sendRequest(Operation op); @Override void handleRequest(Operation op); @Override void handleRequest(Operation op, OperationProcessingStage opProcessingStage); void handlePut(Operation put); void handlePatch(Operation patch); void handleOptions(Operation options); void handlePost(Operation post); void handleGet(Operation get); void handleDelete(Operation delete); @Override void handleStop(Operation delete); @Override void handleMaintenance(Operation post); void handlePeriodicMaintenance(Operation post); void handleNodeGroupMaintenance(Operation post); @Override ServiceHost getHost(); @Override String getSelfLink(); @Override URI getUri(); @Override OperationProcessingChain getOperationProcessingChain(); @Override ProcessingStage getProcessingStage(); @Override boolean hasOption(ServiceOption cap); @Override void toggleOption(ServiceOption option, boolean enable); @Override void setStat(String name, double newValue); @Override void setStat(ServiceStat s, double newValue); @Override void adjustStat(ServiceStat s, double delta); @Override void adjustStat(String name, double delta); @Override ServiceStats getStats(); @Override ServiceStat getStat(String name); void setAvailable(boolean isAvailable); boolean isAvailable(); @Override void setHost(ServiceHost serviceHost); @Override void setSelfLink(String path); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage stage); @Override ServiceDocument setInitialState(Object state, Long version); @Override Service getUtilityService(String uriPath, boolean allocate); @Override ServiceDocument getDocumentTemplate(); void logSevere(Throwable e); void logSevere(String fmt, Object... args); void logSevere(Supplier<String> messageSupplier); void logInfo(String fmt, Object... args); void logInfo(Supplier<String> messageSupplier); void logFine(String fmt, Object... args); void logFine(Supplier<String> messageSupplier); void logWarning(String fmt, Object... args); void logWarning(Supplier<String> messageSupplier); void log(Level level, String fmt, Object... args); void log(Level level, Supplier<String> messageSupplier); @Override void setPeerNodeSelectorPath(String uriPath); @Override String getPeerNodeSelectorPath(); @Override void setDocumentIndexPath(String uriPath); @Override String getDocumentIndexPath(); @Override EnumSet<ServiceOption> getOptions(); void publish(Operation op); @Override void setState(Operation op, ServiceDocument state); @SuppressWarnings("unchecked") @Override T getState(Operation op); @Override void setMaintenanceIntervalMicros(long micros); @Override void setCacheClearDelayMicros(long micros); @Override long getMaintenanceIntervalMicros(); @Override long getCacheClearDelayMicros(); @Override Operation dequeueRequest(); @Override Class<? extends ServiceDocument> getStateType(); @Override void handleConfigurationRequest(Operation request); @Override final void setAuthorizationContext(Operation op, AuthorizationContext ctx); final Signer getTokenSigner(); final Verifier getTokenVerifier(); @Override final AuthorizationContext getSystemAuthorizationContext(); final AuthorizationContext getAuthorizationContextForSubject(String subject); void setOperationHandlerInvokeTimeStat(Operation request); void setOperationDurationStat(Operation request);  }