@Test public void statsKeyOrder() { ExampleServiceState state = new ExampleServiceState(); state.name = "foo"; Operation post = Operation.createPost(this.host, ExampleService.FACTORY_LINK) .setBody(state); state = this.sender.sendAndWait(post, ExampleServiceState.class); ServiceStats stats = new ServiceStats(); ServiceStat stat = new ServiceStat(); stat.name = "keyBBB"; stat.latestValue = 10; stats.entries.put(stat.name, stat); stat = new ServiceStat(); stat.name = "keyCCC"; stat.latestValue = 10; stats.entries.put(stat.name, stat); stat = new ServiceStat(); stat.name = "keyAAA"; stat.latestValue = 10; stats.entries.put(stat.name, stat); URI exampleStatsUri = UriUtils.buildStatsUri(this.host, state.documentSelfLink); this.sender.sendAndWait(Operation.createPut(exampleStatsUri).setBody(stats)); String odataFilterValue = String.format("%s eq %s*", ServiceStat.FIELD_NAME_NAME, "key"); URI filteredStats = UriUtils.extendUriWithQuery(exampleStatsUri, UriUtils.URI_PARAM_ODATA_FILTER, odataFilterValue); ServiceStats result = getStats(filteredStats); assertEquals(3, result.entries.size()); List<String> statList = new ArrayList<>(result.entries.keySet()); assertEquals("stat index 0", "keyAAA", statList.get(0)); assertEquals("stat index 1", "keyBBB", statList.get(1)); assertEquals("stat index 2", "keyCCC", statList.get(2)); }
@Override public ServiceStats getStats() { if (this.stats == null) { return null; } synchronized (this.stats) { return Utils.clone(this.stats); } }
UtilityService implements Service { @Override public ServiceStats getStats() { if (this.stats == null) { return null; } synchronized (this.stats) { return Utils.clone(this.stats); } } }
UtilityService implements Service { @Override public ServiceStats getStats() { if (this.stats == null) { return null; } synchronized (this.stats) { return Utils.clone(this.stats); } } UtilityService(); }
UtilityService implements Service { @Override public ServiceStats getStats() { if (this.stats == null) { return null; } synchronized (this.stats) { return Utils.clone(this.stats); } } UtilityService(); UtilityService setParent(Service parent); @Override void authorizeRequest(Operation op); @Override void handleRequest(Operation op); @Override void handleCreate(Operation post); @Override void handleStart(Operation startPost); @Override void handleStop(Operation op); @Override void handleRequest(Operation op, OperationProcessingStage opProcessingStage); boolean hasSubscribers(); boolean hasStats(); void notifySubscribers(Operation op); void redirectGetToHtmlUiResource(Operation op, String htmlResourcePath); @Override void handleConfigurationRequest(Operation op); void handlePatchConfiguration(Operation op, ServiceConfigUpdateRequest updateBody); @Override void setStat(ServiceStat stat, double newValue); @Override void adjustStat(ServiceStat stat, double delta); @Override ServiceStat getStat(String name); @Override ServiceStats getStats(); ServiceStat getStat(String name, boolean create); @Override ServiceHost getHost(); @Override String getSelfLink(); @Override URI getUri(); @Override OperationProcessingChain getOperationProcessingChain(); @Override ProcessingStage getProcessingStage(); @Override EnumSet<ServiceOption> getOptions(); @Override boolean hasOption(ServiceOption cap); @Override void toggleOption(ServiceOption cap, boolean enable); @Override void adjustStat(String name, double delta); @Override void setStat(String name, double newValue); @Override void handleMaintenance(Operation post); @Override void setHost(ServiceHost serviceHost); @Override void setSelfLink(String path); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage initialized); @Override ServiceDocument setInitialState(Object state, Long initialVersion); @Override Service getUtilityService(String uriPath, boolean allocate); @Override boolean queueRequest(Operation op); @Override void sendRequest(Operation op); @Override ServiceDocument getDocumentTemplate(); @Override void setPeerNodeSelectorPath(String uriPath); @Override String getPeerNodeSelectorPath(); @Override void setDocumentIndexPath(String uriPath); @Override String getDocumentIndexPath(); @Override void setState(Operation op, ServiceDocument newState); @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 final void setAuthorizationContext(Operation op, AuthorizationContext ctx); @Override final AuthorizationContext getSystemAuthorizationContext(); }
UtilityService implements Service { @Override public ServiceStats getStats() { if (this.stats == null) { return null; } synchronized (this.stats) { return Utils.clone(this.stats); } } UtilityService(); UtilityService setParent(Service parent); @Override void authorizeRequest(Operation op); @Override void handleRequest(Operation op); @Override void handleCreate(Operation post); @Override void handleStart(Operation startPost); @Override void handleStop(Operation op); @Override void handleRequest(Operation op, OperationProcessingStage opProcessingStage); boolean hasSubscribers(); boolean hasStats(); void notifySubscribers(Operation op); void redirectGetToHtmlUiResource(Operation op, String htmlResourcePath); @Override void handleConfigurationRequest(Operation op); void handlePatchConfiguration(Operation op, ServiceConfigUpdateRequest updateBody); @Override void setStat(ServiceStat stat, double newValue); @Override void adjustStat(ServiceStat stat, double delta); @Override ServiceStat getStat(String name); @Override ServiceStats getStats(); ServiceStat getStat(String name, boolean create); @Override ServiceHost getHost(); @Override String getSelfLink(); @Override URI getUri(); @Override OperationProcessingChain getOperationProcessingChain(); @Override ProcessingStage getProcessingStage(); @Override EnumSet<ServiceOption> getOptions(); @Override boolean hasOption(ServiceOption cap); @Override void toggleOption(ServiceOption cap, boolean enable); @Override void adjustStat(String name, double delta); @Override void setStat(String name, double newValue); @Override void handleMaintenance(Operation post); @Override void setHost(ServiceHost serviceHost); @Override void setSelfLink(String path); @Override void setOperationProcessingChain(OperationProcessingChain opProcessingChain); @Override void setProcessingStage(ProcessingStage initialized); @Override ServiceDocument setInitialState(Object state, Long initialVersion); @Override Service getUtilityService(String uriPath, boolean allocate); @Override boolean queueRequest(Operation op); @Override void sendRequest(Operation op); @Override ServiceDocument getDocumentTemplate(); @Override void setPeerNodeSelectorPath(String uriPath); @Override String getPeerNodeSelectorPath(); @Override void setDocumentIndexPath(String uriPath); @Override String getDocumentIndexPath(); @Override void setState(Operation op, ServiceDocument newState); @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 final void setAuthorizationContext(Operation op, AuthorizationContext ctx); @Override final AuthorizationContext getSystemAuthorizationContext();  }