move initialize index
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e88167d3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e88167d3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e88167d3 Branch: refs/heads/USERGRID-347 Commit: e88167d3592afaed1964bd3605f1813399be1c01 Parents: f69bceb a40fb8d Author: Shawn Feldman <[email protected]> Authored: Fri Mar 20 17:29:16 2015 -0600 Committer: Shawn Feldman <[email protected]> Committed: Fri Mar 20 17:29:16 2015 -0600 ---------------------------------------------------------------------- stack/corepersistence/queryindex/pom.xml | 57 +-- .../persistence/index/EntityIndexBatch.java | 5 + .../index/impl/EsEntityIndexBatchImpl.java | 32 +- .../usergrid/persistence/index/query/Query.java | 6 +- .../persistence/index/guice/IndexTestFig.java | 7 +- .../index/impl/IndexLoadTestsIT.java | 344 ++++++++++++++++--- 6 files changed, 352 insertions(+), 99 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e88167d3/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java ---------------------------------------------------------------------- diff --cc stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java index 44a9743,bfd713e..0275e53 --- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java +++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java @@@ -71,13 -104,67 +104,83 @@@ public class IndexLoadTestsIT extends B public EntityIndexFactory entityIndexFactory; @Inject - public EntityIndex index; + public EntityIndex entityIndex; + + @Inject + public MetricsFactory metricsFactory; + + private Meter batchWriteTPS; + private Timer batchWriteTimer; + + private Meter queryTps; + private Timer queryTimer; + + private Slf4jReporter reporter; + + + @Before + public void setupIndexAndMeters() { ++ final String userAppId = indexTestFig.getApplicationId(); + - entityIndex.initializeIndex(); ++ ++ //if it's unset, generate one ++ final String uniqueIdentifier = UUIDGenerator.newTimeUUID().toString(); ++ ++ //use the appId supplied, or generate one ++ final UUID applicationUUID = UUID.fromString( userAppId ); ++ ++ final Id applicationId = new SimpleId( applicationUUID, "application" ); ++ final ApplicationScope scope = new ApplicationScopeImpl( applicationId ); ++ ++ ++ final IndexScope indexScope = new IndexScopeImpl( applicationId, "test" ); + ++ final ApplicationEntityIndex appEntityIndex = entityIndexFactory.createApplicationEntityIndex( scope ); + ++ appEntityIndex.initializeIndex(); + + batchWriteTPS = metricsFactory.getMeter( IndexLoadTestsIT.class, "write.tps" ); + + batchWriteTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "write.timer" ); + + queryTps = metricsFactory.getMeter( IndexLoadTestsIT.class, "query.tps" ); + + queryTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "query.timer" ); + + reporter = + Slf4jReporter.forRegistry( metricsFactory.getRegistry() ).outputTo( log ).convertRatesTo( TimeUnit.SECONDS ) + .convertDurationsTo( TimeUnit.MILLISECONDS ).build(); + + reporter.start( 30, TimeUnit.SECONDS ); + } + + + @After + public void printMetricsBeforeShutdown() { + //stop the log reporter and print the last report + reporter.stop(); + reporter.report(); + } + + + /** + * Perform the following 1, spin up the specified number of workers For each worker, insert the specified number of + * elements + * + * Wait the wait time after buffer execution before beginning validate + * + * Validate every entity inserted is returned by a search. + */ @Test - public void testHeavyLoad() { + public void testHeavyLoadValidate() { + final String userAppId = indexTestFig.getApplicationId(); + + + //if it's unset, generate one + final String uniqueIdentifier = UUIDGenerator.newTimeUUID().toString(); - final UUID applicationUUID = UUID.fromString( indexTestFig.getApplicationId() ); + //use the appId supplied, or generate one + final UUID applicationUUID = UUID.fromString( userAppId ); final Id applicationId = new SimpleId( applicationUUID, "application" ); final ApplicationScope scope = new ApplicationScopeImpl( applicationId );
