private Map<URI, Double> getMaintStats(List<URI> targetServices) { Map<URI, Double> results = new HashMap<>(); for (URI targetService : targetServices) { URI statsUri = UriUtils.buildStatsUri(targetService); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, statsUri); ServiceStat maintStat = stats == null ? null : stats.entries.get(Service.STAT_NAME_MAINTENANCE_COUNT); Double maintStatValue = maintStat == null ? 0.0 : maintStat.latestValue; results.put(targetService, maintStatValue); } return results; }
public int getStat(URI uri, String name) throws Throwable { URI statsURI = UriUtils.buildStatsUri(uri); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, statsURI); double startCount = stats.entries.get(name).latestValue; return (int) startCount; }
private ServiceStats getStats(ExampleServiceState exampleServiceState) { return this.host.getServiceState(null, ServiceStats.class, UriUtils.buildStatsUri( this.host, exampleServiceState.documentSelfLink)); }
public int getStat(URI uri, String name) throws Throwable { URI statsURI = UriUtils.buildStatsUri(uri); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, statsURI); double startCount = stats.entries.get(name).latestValue; return (int) startCount; }
private Map<URI, Double> getMaintStats(List<URI> targetServices) { Map<URI, Double> results = new HashMap<>(); for (URI targetService : targetServices) { URI statsUri = UriUtils.buildStatsUri(targetService); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, statsUri); ServiceStat maintStat = stats == null ? null : stats.entries.get(Service.STAT_NAME_MAINTENANCE_COUNT); Double maintStatValue = maintStat == null ? 0.0 : maintStat.latestValue; results.put(targetService, maintStatValue); } return results; }
private ServiceStats getStats(ExampleServiceState exampleServiceState) { return this.host.getServiceState(null, ServiceStats.class, UriUtils.buildStatsUri( this.host, exampleServiceState.documentSelfLink)); }
private void waitForSynchRetries(SynchronizationTaskService.State state, String statName, Function<ServiceStats.ServiceStat, Boolean> check) { this.host.waitFor("Expected retries not completed", () -> { URI statsURI = UriUtils.buildStatsUri(this.host, state.documentSelfLink); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, statsURI); ServiceStats.ServiceStat synchRetryCount = stats.entries .get(statName); return synchRetryCount != null && check.apply(synchRetryCount); }); }
private void verifyNoPaginatedIndexSearchers() throws Throwable { // verify that paginated index searchers did not get created URI indexStatsUri = UriUtils.buildStatsUri(this.host.getDocumentIndexServiceUri()); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, indexStatsUri); ServiceStat pgqStat = stats.entries .get(LuceneDocumentIndexService.STAT_NAME_ACTIVE_PAGINATED_QUERIES); if (pgqStat != null && pgqStat.latestValue > 0) { throw new IllegalStateException("Found paginated index searchers, not expected"); } }
private void waitForSynchRetries(String statName, Function<ServiceStats.ServiceStat, Boolean> check) { this.host.waitFor("Expected retries not completed", () -> { URI statsURI = UriUtils.buildStatsUri(this.host, ExampleService.FACTORY_LINK); ServiceStats factoryStats = this.host.getServiceState(null, ServiceStats.class, statsURI); ServiceStats.ServiceStat synchRetryCount = factoryStats.entries .get(statName); return synchRetryCount != null && check.apply(synchRetryCount); }); }
private void waitForSynchRetries(String statName, Function<ServiceStats.ServiceStat, Boolean> check) { this.host.waitFor("Expected retries not completed", () -> { URI statsURI = UriUtils.buildStatsUri(this.host, ExampleService.FACTORY_LINK); ServiceStats factoryStats = this.host.getServiceState(null, ServiceStats.class, statsURI); ServiceStats.ServiceStat synchRetryCount = factoryStats.entries .get(statName); return synchRetryCount != null && check.apply(synchRetryCount); }); }
private void verifyNoPaginatedIndexSearchers() throws Throwable { // verify that paginated index searchers did not get created URI indexStatsUri = UriUtils.buildStatsUri(this.host.getDocumentIndexServiceUri()); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, indexStatsUri); ServiceStat pgqStat = stats.entries .get(LuceneDocumentIndexService.STAT_NAME_ACTIVE_PAGINATED_QUERIES); if (pgqStat != null && pgqStat.latestValue > 0) { throw new IllegalStateException("Found paginated index searchers, not expected"); } }
private void waitForSynchRetries(SynchronizationTaskService.State state, String statName, Function<ServiceStats.ServiceStat, Boolean> check) { this.host.waitFor("Expected retries not completed", () -> { URI statsURI = UriUtils.buildStatsUri(this.host, state.documentSelfLink); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, statsURI); ServiceStats.ServiceStat synchRetryCount = stats.entries .get(statName); return synchRetryCount != null && check.apply(synchRetryCount); }); }
private Long getPaginatedSearcherRefreshCount() { URI luceneStatsUri = UriUtils.buildStatsUri(this.host.getDocumentIndexServiceUri()); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, luceneStatsUri); ServiceStat paginatedSearcherRefreshCountStat = stats.entries.get( LuceneDocumentIndexService.STAT_NAME_PAGINATED_SEARCHER_UPDATE_COUNT + ServiceStats.STAT_NAME_SUFFIX_PER_DAY); if (paginatedSearcherRefreshCountStat == null) { return null; } return (long) paginatedSearcherRefreshCountStat.latestValue; }
private Long getPaginatedSearcherRefreshCount() { URI luceneStatsUri = UriUtils.buildStatsUri(this.host.getDocumentIndexServiceUri()); ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, luceneStatsUri); ServiceStat paginatedSearcherRefreshCountStat = stats.entries.get( LuceneDocumentIndexService.STAT_NAME_PAGINATED_SEARCHER_UPDATE_COUNT + ServiceStats.STAT_NAME_SUFFIX_PER_DAY); if (paginatedSearcherRefreshCountStat == null) { return null; } return (long) paginatedSearcherRefreshCountStat.latestValue; }
/** * Synchronously retrieve service statistics from service/stats suffix */ public ServiceStats sendStatsGetAndWait(URI uri) { return sendAndWait(Operation.createGet(UriUtils.buildStatsUri(uri)), ServiceStats.class); }
/** * Synchronously retrieve service statistics from service/stats suffix */ public ServiceStats sendStatsGetAndWait(URI uri) { return sendAndWait(Operation.createGet(UriUtils.buildStatsUri(uri)), ServiceStats.class); }
private void waitForContiniousQueryActivation(VerificationHost host, double numberActiveQueries) { // Since the continuous query is not direct, it becomes active in the index asynchronously // with respect to the completion of the initial POST operation. Poll the index stats until // they indicate that the continuous query filter is active. host.waitFor("task never activated", () -> { ServiceStats indexStats = host.getServiceState(null, ServiceStats.class, UriUtils.buildStatsUri(host.getDocumentIndexServiceUri())); ServiceStat activeQueryStat = indexStats.entries.get( LuceneDocumentIndexService.STAT_NAME_ACTIVE_QUERY_FILTERS + ServiceStats.STAT_NAME_SUFFIX_PER_HOUR); return activeQueryStat != null && activeQueryStat.latestValue >= numberActiveQueries; }); }
public void scheduleSynchronizationIfAutoSyncDisabled(String selectorPath) { if (this.isPeerSynchronizationEnabled()) { return; } for (VerificationHost peerHost : getInProcessHostMap().values()) { peerHost.scheduleNodeGroupChangeMaintenance(selectorPath); ServiceStats selectorStats = getServiceState(null, ServiceStats.class, UriUtils.buildStatsUri(peerHost, selectorPath)); ServiceStat synchStat = selectorStats.entries .get(ConsistentHashingNodeSelectorService.STAT_NAME_SYNCHRONIZATION_COUNT); if (synchStat != null && synchStat.latestValue > 0) { throw new IllegalStateException("Automatic synchronization was triggered"); } } }
private void verifyPaginatedIndexSearcherExpiration() throws Throwable { this.host.waitFor("Paginated index searchers never expired", () -> { URI indexStatsUri = UriUtils.buildStatsUri(this.host.getDocumentIndexServiceUri()); // check the index statistic tracking paginated queries ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, indexStatsUri); ServiceStat pgqStat = stats.entries .get(LuceneDocumentIndexService.STAT_NAME_ACTIVE_PAGINATED_QUERIES); if (pgqStat != null && pgqStat.latestValue != 0) { return false; } return true; }); }
private void verifyPaginatedIndexSearcherExpiration() throws Throwable { this.host.waitFor("Paginated index searchers never expired", () -> { URI indexStatsUri = UriUtils.buildStatsUri(this.host.getDocumentIndexServiceUri()); // check the index statistic tracking paginated queries ServiceStats stats = this.host.getServiceState(null, ServiceStats.class, indexStatsUri); ServiceStat pgqStat = stats.entries .get(LuceneDocumentIndexService.STAT_NAME_ACTIVE_PAGINATED_QUERIES); if (pgqStat != null && pgqStat.latestValue != 0) { return false; } return true; }); }