本文整理匯總了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);
}