LuceneDocumentIndexService extends StatelessService { public static void setExpiredDocumentSearchThreshold(int count) { expiredDocumentSearchThreshold = count; } LuceneDocumentIndexService();  LuceneDocumentIndexService(String indexDirectory); static void setImplicitQueryResultLimit(int limit); static int getImplicitQueryResultLimit(); static void setImplicitQueryProcessingPageSize(int limit); static int getImplicitQueryProcessingPageSize(); static void setIndexFileCountThresholdForWriterRefresh(int count); static int getIndexFileCountThresholdForWriterRefresh(); static void setExpiredDocumentSearchThreshold(int count); static int getExpiredDocumentSearchThreshold(); static void setVersionRetentionBulkCleanupThreshold(int count); static int getVersionRetentionBulkCleanupThreshold(); static void setVersionRetentionServiceThreshold(int count); static int getVersionRetentionServiceThreshold(); static long getSearcherRefreshIntervalMicros(); static void setSearcherRefreshIntervalMicros(long interval); static void setMetadataUpdateMaxQueueDepth(int depth); static int getMetadataUpdateMaxQueueDepth(); @Override void handleStart(final Operation post); IndexWriter createWriter(File directory, boolean doUpgrade); @Override void authorizeRequest(Operation op); @Override void handleRequest(Operation op); void handleGetImpl(Operation get); void handleDeleteImpl(Operation delete); @Override URI getUri(); @Override void handleMaintenance(Operation post); static final String SELF_LINK; static final int QUERY_THREAD_COUNT; static final int UPDATE_THREAD_COUNT; static final int QUERY_QUEUE_DEPTH; static final int UPDATE_QUEUE_DEPTH; static final String FILE_PATH_LUCENE; static final int DEFAULT_INDEX_FILE_COUNT_THRESHOLD_FOR_WRITER_REFRESH; static final int DEFAULT_INDEX_SEARCHER_COUNT_THRESHOLD; static final int MIN_QUERY_RESULT_LIMIT; static final int DEFAULT_QUERY_RESULT_LIMIT; static final int DEFAULT_QUERY_PAGE_RESULT_LIMIT; static final int DEFAULT_EXPIRED_DOCUMENT_SEARCH_THRESHOLD; static final int DEFAULT_METADATA_UPDATE_MAX_QUEUE_DEPTH; static final long DEFAULT_PAGINATED_SEARCHER_EXPIRATION_DELAY; static final String STAT_NAME_ACTIVE_QUERY_FILTERS; static final String STAT_NAME_ACTIVE_PAGINATED_QUERIES; static final String STAT_NAME_COMMIT_COUNT; static final String STAT_NAME_INDEX_LOAD_RETRY_COUNT; static final String STAT_NAME_COMMIT_DURATION_MICROS; static final String STAT_NAME_GROUP_QUERY_COUNT; static final String STAT_NAME_QUERY_DURATION_MICROS; static final String STAT_NAME_GROUP_QUERY_DURATION_MICROS; static final String STAT_NAME_QUERY_SINGLE_DURATION_MICROS; static final String STAT_NAME_QUERY_ALL_VERSIONS_DURATION_MICROS; static final String STAT_NAME_RESULT_PROCESSING_DURATION_MICROS; static final String STAT_NAME_INDEXED_FIELD_COUNT; static final String STAT_NAME_INDEXED_DOCUMENT_COUNT; static final String STAT_NAME_FORCED_UPDATE_DOCUMENT_DELETE_COUNT; static final String STAT_NAME_FIELD_COUNT_PER_DOCUMENT; static final String STAT_NAME_INDEXING_DURATION_MICROS; static final String STAT_NAME_SEARCHER_UPDATE_COUNT; static final String STAT_NAME_SEARCHER_REUSE_BY_DOCUMENT_KIND_COUNT; static final String STAT_NAME_PAGINATED_SEARCHER_UPDATE_COUNT; static final String STAT_NAME_PAGINATED_SEARCHER_FORCE_DELETION_COUNT; static final String STAT_NAME_WRITER_ALREADY_CLOSED_EXCEPTION_COUNT; static final String STAT_NAME_READER_ALREADY_CLOSED_EXCEPTION_COUNT; static final String STAT_NAME_SERVICE_DELETE_COUNT; static final String STAT_NAME_DOCUMENT_EXPIRATION_COUNT; static final String STAT_NAME_DOCUMENT_EXPIRATION_FORCED_MAINTENANCE_COUNT; static final String STAT_NAME_METADATA_INDEXING_UPDATE_COUNT; static final String STAT_NAME_VERSION_CACHE_LOOKUP_COUNT; static final String STAT_NAME_VERSION_CACHE_MISS_COUNT; static final String STAT_NAME_VERSION_CACHE_ENTRY_COUNT; static final String STAT_NAME_MAINTENANCE_SEARCHER_REFRESH_DURATION_MICROS; static final String STAT_NAME_MAINTENANCE_DOCUMENT_EXPIRATION_DURATION_MICROS; static final String STAT_NAME_MAINTENANCE_VERSION_RETENTION_DURATION_MICROS; static final String STAT_NAME_MAINTENANCE_METADATA_INDEXING_DURATION_MICROS; static final String STAT_NAME_DOCUMENT_KIND_QUERY_COUNT_FORMAT; static final String STAT_NAME_NON_DOCUMENT_KIND_QUERY_COUNT; static final String STAT_NAME_SINGLE_QUERY_BY_FACTORY_COUNT_FORMAT; static final String STAT_NAME_PREFIX_UPDATE_QUEUE_DEPTH; static final String STAT_NAME_FORMAT_UPDATE_QUEUE_DEPTH; static final String STAT_NAME_PREFIX_QUERY_QUEUE_DEPTH; static final String STAT_NAME_FORMAT_QUERY_QUEUE_DEPTH; }
@Test public void throughputPostWithExpirationLongRunning() throws Throwable { if (this.serviceCacheClearIntervalSeconds == 0) { this.serviceCacheClearIntervalSeconds = TimeUnit.MICROSECONDS.toSeconds( ServiceHostState.DEFAULT_OPERATION_TIMEOUT_MICROS); } QueryTask queryTask = QueryTask.Builder.createDirectTask() .setQuery(QueryTask.Query.Builder.create() .addKindFieldClause(ExampleServiceState.class) .build()) .build(); setUpHost(false); LuceneDocumentIndexService.setExpiredDocumentSearchThreshold(10); URI factoryUri = createImmutableFactoryService(this.host); this.indexService.toggleOption(ServiceOption.INSTRUMENTATION, true); this.host.log("Starting throughout POST, expiration: %d", this.expirationSeconds); Long expirationMicros = null; if (this.expirationSeconds != null) { expirationMicros = TimeUnit.SECONDS.toMicros(this.expirationSeconds); } long testExpiration = Utils.getSystemNowMicrosUtc() + TimeUnit.SECONDS.toMicros(this.testDurationSeconds); do { this.host.log("Starting POST test to %s, count:%d", factoryUri, this.serviceCount); doThroughputPost(true, factoryUri, expirationMicros, queryTask); Map<String, ServiceStat> stats = this.host.getServiceStats( this.host.getDocumentIndexServiceUri()); ServiceStat expiredDocumentStat = stats.get( LuceneDocumentIndexService.STAT_NAME_DOCUMENT_EXPIRATION_COUNT + ServiceStats.STAT_NAME_SUFFIX_PER_DAY); if (expiredDocumentStat != null) { this.host.log("Expired documents: %f", expiredDocumentStat.latestValue); } } while (this.testDurationSeconds > 0 && Utils.getSystemNowMicrosUtc() < testExpiration); Map<String, ServiceStat> indexServiceStats = this.host.getServiceStats( this.host.getDocumentIndexServiceUri()); logServiceStatHistogram(indexServiceStats, LuceneDocumentIndexService.STAT_NAME_COMMIT_DURATION_MICROS); logServiceStatHistogram(indexServiceStats, LuceneDocumentIndexService.STAT_NAME_MAINTENANCE_DOCUMENT_EXPIRATION_DURATION_MICROS); logServiceStatHistogram(indexServiceStats, LuceneDocumentIndexService.STAT_NAME_QUERY_DURATION_MICROS); logServiceStatHistogram(indexServiceStats, LuceneDocumentIndexService.STAT_NAME_RESULT_PROCESSING_DURATION_MICROS); }