本文整理汇总了Java中org.elasticsearch.client.Client.close方法的典型用法代码示例。如果您正苦于以下问题:Java Client.close方法的具体用法?Java Client.close怎么用?Java Client.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.client.Client
的用法示例。
在下文中一共展示了Client.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.elasticsearch.client.Client; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
Log4jESLoggerFactory.getRootLogger().setLevel("ERROR");
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "ciphergateway").build();
//Use one and only one Client in your JVM. It's threadsafe.
Client client = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
Long start = System.currentTimeMillis();
// exportES(client);
// deleteES(client);
// importES(client);
// searchES(client);
exportAndDeleteES(client);
client.close();
Long end = System.currentTimeMillis();
System.out.println("用时: " + (end - start) + " ms");
}
示例2: testBulkProcessorConcurrentRequestsNoNodeAvailableException
import org.elasticsearch.client.Client; //导入方法依赖的package包/类
public void testBulkProcessorConcurrentRequestsNoNodeAvailableException() throws Exception {
//we create a transport client with no nodes to make sure it throws NoNodeAvailableException
Settings settings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.build();
Client transportClient = new MockTransportClient(settings);
int bulkActions = randomIntBetween(10, 100);
int numDocs = randomIntBetween(bulkActions, bulkActions + 100);
int concurrentRequests = randomIntBetween(0, 10);
int expectedBulkActions = numDocs / bulkActions;
final CountDownLatch latch = new CountDownLatch(expectedBulkActions);
int totalExpectedBulkActions = numDocs % bulkActions == 0 ? expectedBulkActions : expectedBulkActions + 1;
final CountDownLatch closeLatch = new CountDownLatch(totalExpectedBulkActions);
BulkProcessorTestListener listener = new BulkProcessorTestListener(latch, closeLatch);
try (BulkProcessor processor = BulkProcessor.builder(transportClient, listener)
.setConcurrentRequests(concurrentRequests).setBulkActions(bulkActions)
//set interval and size to high values
.setFlushInterval(TimeValue.timeValueHours(24)).setBulkSize(new ByteSizeValue(1, ByteSizeUnit.GB)).build()) {
indexDocs(transportClient, processor, numDocs);
latch.await();
assertThat(listener.beforeCounts.get(), equalTo(expectedBulkActions));
assertThat(listener.afterCounts.get(), equalTo(expectedBulkActions));
assertThat(listener.bulkFailures.size(), equalTo(expectedBulkActions));
assertThat(listener.bulkItems.size(), equalTo(0));
}
closeLatch.await();
assertThat(listener.bulkFailures.size(), equalTo(totalExpectedBulkActions));
assertThat(listener.bulkItems.size(), equalTo(0));
transportClient.close();
}
示例3: main
import org.elasticsearch.client.Client; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {
Client client = EsClient.getClient();
// CreateIndex(client);
// GetResponse(client);
// DeleteResponse(client);
// UpdateRequest(client);
client.close();
// MultiGet(client);
// BulkIndex(client);
// SearchIndex(client);
}