本文整理汇总了Java中org.elasticsearch.common.StopWatch.start方法的典型用法代码示例。如果您正苦于以下问题:Java StopWatch.start方法的具体用法?Java StopWatch.start怎么用?Java StopWatch.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.StopWatch
的用法示例。
在下文中一共展示了StopWatch.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.elasticsearch.common.StopWatch; //导入方法依赖的package包/类
protected OpenNlpService start() {
StopWatch sw = new StopWatch("models-loading");
Map<String, String> settingsMap = IngestOpenNlpPlugin.MODEL_FILE_SETTINGS.getAsMap(settings);
for (Map.Entry<String, String> entry : settingsMap.entrySet()) {
String name = entry.getKey();
sw.start(name);
Path path = configDirectory.resolve(entry.getValue());
try (InputStream is = Files.newInputStream(path)) {
nameFinderModels.put(name, new TokenNameFinderModel(is));
} catch (IOException e) {
logger.error((Supplier<?>) () -> new ParameterizedMessage("Could not load model [{}] with path [{}]", name, path), e);
}
sw.stop();
}
if (settingsMap.keySet().size() == 0) {
logger.error("Did not load any models for ingest-opennlp plugin, none configured");
} else {
logger.info("Read models in [{}] for {}", sw.totalTime(), settingsMap.keySet());
}
return this;
}
示例2: check
import org.elasticsearch.common.StopWatch; //导入方法依赖的package包/类
private void check(Traversal traversal) {
StopWatch sw = new StopWatch();
int count = 0;
sw.start();
System.out.println("pre-strategy:" + traversal);
traversal.hasNext();
System.out.println("post-strategy:" + traversal);
//traversal.profile().cap(TraversalMetrics.METRICS_KEY);
while(traversal.hasNext()) {
count ++;
System.out.println(traversal.next());
}
sw.stop();
System.out.println(sw.toString());
System.out.println(count);
}
示例3: testSameAlias
import org.elasticsearch.common.StopWatch; //导入方法依赖的package包/类
public void testSameAlias() throws Exception {
logger.info("--> creating index [test]");
assertAcked(prepareCreate("test").addMapping("type", "name", "type=text"));
ensureGreen();
logger.info("--> creating alias1 ");
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1")));
TimeValue timeout = TimeValue.timeValueSeconds(2);
logger.info("--> recreating alias1 ");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1").setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> modifying alias1 to have a filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "foo")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> recreating alias1 with the same filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "foo")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> recreating alias1 with a different filter");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().addAlias("test", "alias1", termQuery("name", "bar")).setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
logger.info("--> verify that filter was updated");
AliasMetaData aliasMetaData = ((AliasOrIndex.Alias) internalCluster().clusterService().state().metaData().getAliasAndIndexLookup().get("alias1")).getFirstAliasMetaData();
assertThat(aliasMetaData.getFilter().toString(), equalTo("{\"term\":{\"name\":{\"value\":\"bar\",\"boost\":1.0}}}"));
logger.info("--> deleting alias1");
stopWatch.start();
assertAcked((admin().indices().prepareAliases().removeAlias("test", "alias1").setTimeout(timeout)));
assertThat(stopWatch.stop().lastTaskTime().millis(), lessThan(timeout.millis()));
}
示例4: measureCollectTime
import org.elasticsearch.common.StopWatch; //导入方法依赖的package包/类
private void measureCollectTime() {
final StopWatch stopWatch = new StopWatch(collectPhase.executionPhaseId() + ": " + collectPhase.name());
stopWatch.start("starting collectors");
listenableRowReceiver.finishFuture().addListener(new Runnable() {
@Override
public void run() {
stopWatch.stop();
logger.trace("Collectors finished: {}", stopWatch.shortSummary());
}
}, MoreExecutors.directExecutor());
}
示例5: setupIndex
import org.elasticsearch.common.StopWatch; //导入方法依赖的package包/类
public void setupIndex() {
log("==== INDEX SETUP ====");
try {
client.admin().indices().create(createIndexRequest(PARENT_INDEX).mapping(PARENT_TYPE,
"id", "type=string,index=not_analyzed,doc_values=true",
"num", "type=integer,doc_values=true")).actionGet();
client.admin().indices().create(createIndexRequest(CHILD_INDEX).mapping(CHILD_TYPE,
"id", "type=string,index=not_analyzed,doc_values=true",
"pid", "type=string,index=not_analyzed,doc_values=true",
"num", "type=integer,doc_values=true")).actionGet();
Thread.sleep(5000);
StopWatch stopWatch = new StopWatch().start();
log("Indexing [" + NUM_PARENTS + "] parent documents into [" + PARENT_INDEX + "]");
log("Indexing [" + (NUM_PARENTS * NUM_CHILDREN_PER_PARENT) + "] child documents into [" + CHILD_INDEX + "]");
int ITERS = NUM_PARENTS / BATCH_SIZE;
int i = 1;
int counter = 0;
for (; i <= ITERS; i++) {
BulkRequestBuilder request = client.prepareBulk();
for (int j = 0; j < BATCH_SIZE; j++) {
String parentId = Integer.toString(counter);
counter++;
request.add(Requests.indexRequest(PARENT_INDEX)
.type(PARENT_TYPE)
.id(parentId)
.source(parentSource(counter, "test" + counter)));
for (int k = 0; k < NUM_CHILDREN_PER_PARENT; k++) {
String childId = parentId + "_" + k;
request.add(Requests.indexRequest(CHILD_INDEX)
.type(CHILD_TYPE)
.id(childId)
.source(childSource(childId, counter, "tag" + k)));
}
}
BulkResponse response = request.execute().actionGet();
if (response.hasFailures()) {
log("Index Failures...");
}
if (((i * BATCH_SIZE) % 10000) == 0) {
log("Indexed [" + (i * BATCH_SIZE) * (1 + NUM_CHILDREN_PER_PARENT) + "] took [" + stopWatch.stop().lastTaskTime() + "]");
stopWatch.start();
}
}
log("Indexing took [" + stopWatch.totalTime() + "]");
log("TPS [" + (((double) (NUM_PARENTS * (1 + NUM_CHILDREN_PER_PARENT))) / stopWatch.totalTime().secondsFrac()) + "]");
} catch (Exception e) {
log("Indices exist, wait for green");
waitForGreen();
}
client.admin().indices().prepareRefresh().execute().actionGet();
log("Number of docs in index: " + client.prepareCount(PARENT_INDEX, CHILD_INDEX).setQuery(matchAllQuery()).execute().actionGet().getCount());
log("");
}
示例6: setupIndex
import org.elasticsearch.common.StopWatch; //导入方法依赖的package包/类
public void setupIndex() {
log("==== INDEX SETUP ====");
try {
client.admin().indices().create(createIndexRequest(PARENT_INDEX)).actionGet();
client.admin().indices().create(createIndexRequest(CHILD_INDEX)).actionGet();
Thread.sleep(5000);
StopWatch stopWatch = new StopWatch().start();
log("Indexing [" + NUM_PARENTS + "] parent documents into [" + PARENT_INDEX + "]");
log("Indexing [" + (NUM_PARENTS * NUM_CHILDREN_PER_PARENT) + "] child documents into [" + CHILD_INDEX + "]");
int ITERS = NUM_PARENTS / BATCH_SIZE;
int i = 1;
int counter = 0;
for (; i <= ITERS; i++) {
BulkRequestBuilder request = client.prepareBulk();
for (int j = 0; j < BATCH_SIZE; j++) {
String parentId = Integer.toString(counter);
counter++;
request.add(Requests.indexRequest(PARENT_INDEX)
.type(PARENT_TYPE)
.id(parentId)
.source(parentSource(counter, "test" + counter)));
for (int k = 0; k < NUM_CHILDREN_PER_PARENT; k++) {
String childId = parentId + "_" + k;
request.add(Requests.indexRequest(CHILD_INDEX)
.type(CHILD_TYPE)
.id(childId)
.source(childSource(childId, counter, "tag" + k)));
}
}
BulkResponse response = request.execute().actionGet();
if (response.hasFailures()) {
log("Index Failures...");
}
if (((i * BATCH_SIZE) % 10000) == 0) {
log("Indexed [" + (i * BATCH_SIZE) * (1 + NUM_CHILDREN_PER_PARENT) + "] took [" + stopWatch.stop().lastTaskTime() + "]");
stopWatch.start();
}
}
log("Indexing took [" + stopWatch.totalTime() + "]");
log("TPS [" + (((double) (NUM_PARENTS * (1 + NUM_CHILDREN_PER_PARENT))) / stopWatch.totalTime().secondsFrac()) + "]");
} catch (Exception e) {
log("Indices exist, wait for green");
waitForGreen();
}
client.admin().indices().prepareRefresh().execute().actionGet();
log("Number of docs in index: " + client.prepareCount(PARENT_INDEX, CHILD_INDEX).setQuery(matchAllQuery()).execute().actionGet().getCount());
log("");
}