您现在的位置是:主页 > news > 网站备案要啥/自媒体是如何赚钱的
网站备案要啥/自媒体是如何赚钱的
admin2025/5/11 3:31:21【news】
简介网站备案要啥,自媒体是如何赚钱的,北京做网站的好公司,如何做网站二维码本文整理匯總了Java中org.elasticsearch.common.transport.TransportAddress類的典型用法代碼示例。如果您正苦於以下問題:Java TransportAddress類的具體用法?Java TransportAddress怎麽用?Java TransportAddress使用的例子?那麽…
本文整理匯總了Java中org.elasticsearch.common.transport.TransportAddress類的典型用法代碼示例。如果您正苦於以下問題:Java TransportAddress類的具體用法?Java TransportAddress怎麽用?Java TransportAddress使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。
TransportAddress類屬於org.elasticsearch.common.transport包,在下文中一共展示了TransportAddress類的38個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: testThatNettyHttpServerDoesNotSupportPipelining
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testThatNettyHttpServerDoesNotSupportPipelining() throws Exception {
ensureGreen();
String[] requests = new String[] {"/", "/_nodes/stats", "/", "/_cluster/state", "/", "/_nodes", "/"};
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
TransportAddress[] boundAddresses = httpServerTransport.boundAddress().boundAddresses();
TransportAddress transportAddress = (TransportAddress) randomFrom(boundAddresses);
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
Collection responses = nettyHttpClient.get(transportAddress.address(), requests);
assertThat(responses, hasSize(requests.length));
List opaqueIds = new ArrayList<>(Netty4HttpClient.returnOpaqueIds(responses));
assertResponsesOutOfOrder(opaqueIds);
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,
示例2: testThatHttpPipeliningWorksWhenEnabled
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testThatHttpPipeliningWorksWhenEnabled() throws Exception {
final Settings settings = Settings.builder()
.put("http.pipelining", true)
.put("http.port", "0")
.build();
try (HttpServerTransport httpServerTransport = new CustomNettyHttpServerTransport(settings)) {
httpServerTransport.start();
final TransportAddress transportAddress = randomFrom(httpServerTransport.boundAddress().boundAddresses());
final int numberOfRequests = randomIntBetween(4, 16);
final List requests = new ArrayList<>(numberOfRequests);
for (int i = 0; i < numberOfRequests; i++) {
if (rarely()) {
requests.add("/slow/" + i);
} else {
requests.add("/" + i);
}
}
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
Collection responses = nettyHttpClient.get(transportAddress.address(), requests.toArray(new String[]{}));
Collection responseBodies = Netty4HttpClient.returnHttpResponseBodies(responses);
assertThat(responseBodies, contains(requests.toArray()));
}
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,
示例3: testDoesNotLimitExcludedRequests
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testDoesNotLimitExcludedRequests() throws Exception {
ensureGreen();
@SuppressWarnings("unchecked")
Tuple[] requestUris = new Tuple[1500];
for (int i = 0; i < requestUris.length; i++) {
requestUris[i] = Tuple.tuple("/_cluster/settings",
"{ \"transient\": {\"search.default_search_timeout\": \"40s\" } }");
}
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
TransportAddress transportAddress = (TransportAddress) randomFrom(httpServerTransport.boundAddress
().boundAddresses());
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
Collection responses = nettyHttpClient.put(transportAddress.address(), requestUris);
assertThat(responses, hasSize(requestUris.length));
assertAllInExpectedStatus(responses, HttpResponseStatus.OK);
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,
示例4: testThatTransportClientCanConnect
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testThatTransportClientCanConnect() throws Exception {
Settings settings = Settings.builder()
.put("cluster.name", internalCluster().getClusterName())
.put(NetworkModule.TRANSPORT_TYPE_KEY, Netty4Plugin.NETTY_TRANSPORT_NAME)
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.build();
try (TransportClient transportClient = new MockTransportClient(settings, Netty4Plugin.class)) {
transportClient.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), randomPort));
ClusterHealthResponse response = transportClient.admin().cluster().prepareHealth().get();
assertThat(response.getStatus(), is(ClusterHealthStatus.GREEN));
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,
示例5: testEnforceLimitsWhenBoundToNonLocalAddress
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testEnforceLimitsWhenBoundToNonLocalAddress() {
final List transportAddresses = new ArrayList<>();
final TransportAddress nonLocalTransportAddress = buildNewFakeTransportAddress();
transportAddresses.add(nonLocalTransportAddress);
for (int i = 0; i < randomIntBetween(0, 7); i++) {
final TransportAddress randomTransportAddress = randomBoolean() ? buildNewFakeTransportAddress() :
new TransportAddress(InetAddress.getLoopbackAddress(), i);
transportAddresses.add(randomTransportAddress);
}
final TransportAddress publishAddress = randomBoolean() ? buildNewFakeTransportAddress() :
new TransportAddress(InetAddress.getLoopbackAddress(), 0);
final BoundTransportAddress boundTransportAddress = mock(BoundTransportAddress.class);
Collections.shuffle(transportAddresses, random());
when(boundTransportAddress.boundAddresses()).thenReturn(transportAddresses.toArray(new TransportAddress[0]));
when(boundTransportAddress.publishAddress()).thenReturn(publishAddress);
assertTrue(BootstrapChecks.enforceLimits(boundTransportAddress));
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,
示例6: startClient
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
private static Client startClient(Path tempDir, TransportAddress... transportAddresses) {
Settings.Builder builder = Settings.builder()
.put("node.name", "qa_smoke_client_" + counter.getAndIncrement())
.put("client.transport.ignore_cluster_name", true)
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir);
final Collection> plugins;
if (random().nextBoolean()) {
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
plugins = Collections.singleton(MockTcpTransportPlugin.class);
} else {
plugins = Collections.emptyList();
}
TransportClient client = new PreBuiltTransportClient(builder.build(), plugins).addTransportAddresses(transportAddresses);
logger.info("--> Elasticsearch Java TransportClient started");
Exception clientException = null;
try {
ClusterHealthResponse health = client.admin().cluster().prepareHealth().get();
logger.info("--> connected to [{}] cluster which is running [{}] node(s).",
health.getClusterName(), health.getNumberOfNodes());
} catch (Exception e) {
clientException = e;
}
assumeNoException("Sounds like your cluster is not running at " + clusterAddresses, clientException);
return client;
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:30,
示例7: testTcpHandshakeTimeout
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testTcpHandshakeTimeout() throws IOException {
try (ServerSocket socket = new MockServerSocket()) {
socket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0), 1);
socket.setReuseAddress(true);
DiscoveryNode dummy = new DiscoveryNode("TEST", new TransportAddress(socket.getInetAddress(),
socket.getLocalPort()), emptyMap(),
emptySet(), version0);
ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
builder.addConnections(1,
TransportRequestOptions.Type.BULK,
TransportRequestOptions.Type.PING,
TransportRequestOptions.Type.RECOVERY,
TransportRequestOptions.Type.REG,
TransportRequestOptions.Type.STATE);
builder.setHandshakeTimeout(TimeValue.timeValueMillis(1));
ConnectTransportException ex = expectThrows(ConnectTransportException.class,
() -> serviceA.connectToNode(dummy, builder.build()));
assertEquals("[][" + dummy.getAddress() + "] handshake_timeout[1ms]", ex.getMessage());
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,
示例8: addFailToSendNoConnectRule
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Adds a rule that will cause every send request to fail, and each new connect since the rule
* is added to fail as well.
*/
public void addFailToSendNoConnectRule(TransportAddress transportAddress) {
addDelegate(transportAddress, new DelegateTransport(original) {
@Override
public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile,
CheckedBiConsumer connectionValidator)
throws ConnectTransportException {
if (original.nodeConnected(node) == false) {
// connecting to an already connected node is a no-op
throw new ConnectTransportException(node, "DISCONNECT: simulated");
}
}
@Override
protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request,
TransportRequestOptions options) throws IOException {
simulateDisconnect(connection, original, "DISCONNECT: simulated");
}
});
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,
示例9: addUnresponsiveRule
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Adds a rule that will cause ignores each send request, simulating an unresponsive node
* and failing to connect once the rule was added.
*/
public void addUnresponsiveRule(TransportAddress transportAddress) {
addDelegate(transportAddress, new DelegateTransport(original) {
@Override
public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile,
CheckedBiConsumer connectionValidator)
throws ConnectTransportException {
if (original.nodeConnected(node) == false) {
// connecting to an already connected node is a no-op
throw new ConnectTransportException(node, "UNRESPONSIVE: simulated");
}
}
@Override
protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request,
TransportRequestOptions options) throws IOException {
// don't send anything, the receiving node is unresponsive
}
});
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,
示例10: testPublicIp
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testPublicIp() throws InterruptedException {
int nodes = randomInt(10);
for (int i = 0; i < nodes; i++) {
poorMansDNS.put(AmazonEC2Mock.PREFIX_PUBLIC_IP + (i+1), buildNewFakeTransportAddress());
}
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "public_ip")
.build();
List discoveryNodes = buildDynamicNodes(nodeSettings, nodes);
assertThat(discoveryNodes, hasSize(nodes));
// We check that we are using here expected address
int node = 1;
for (DiscoveryNode discoveryNode : discoveryNodes) {
TransportAddress address = discoveryNode.getAddress();
TransportAddress expected = poorMansDNS.get(AmazonEC2Mock.PREFIX_PUBLIC_IP + node++);
assertEquals(address, expected);
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,
示例11: doStart
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
@Override
protected void doStart() {
add(localNodeMasterListeners);
add(taskManager);
this.clusterState = ClusterState.builder(clusterState).blocks(initialBlocks).build();
this.updateTasksExecutor = EsExecutors.newSinglePrioritizing(UPDATE_THREAD_NAME, daemonThreadFactory(settings, UPDATE_THREAD_NAME));
this.reconnectToNodes = threadPool.schedule(reconnectInterval, ThreadPool.Names.GENERIC, new ReconnectToNodes());
Map nodeAttributes = discoveryNodeService.buildAttributes();
// note, we rely on the fact that its a new id each time we start, see FD and "kill -9" handling
final String nodeId = DiscoveryService.generateNodeId(settings);
final TransportAddress publishAddress = transportService.boundAddress().publishAddress();
DiscoveryNode localNode = new DiscoveryNode(settings.get("name"), nodeId, publishAddress, nodeAttributes, version);
DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder().put(localNode).localNodeId(localNode.id());
this.clusterState = ClusterState.builder(clusterState).nodes(nodeBuilder).blocks(initialBlocks).build();
this.transportService.setLocalNode(localNode);
}
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,
示例12: testBuiltRemoteClustersSeeds
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testBuiltRemoteClustersSeeds() throws Exception {
Map> map = RemoteClusterService.buildRemoteClustersSeeds(
Settings.builder().put("search.remote.foo.seeds", "192.168.0.1:8080").put("search.remote.bar.seeds", "[::1]:9090").build());
assertEquals(2, map.size());
assertTrue(map.containsKey("foo"));
assertTrue(map.containsKey("bar"));
assertEquals(1, map.get("foo").size());
assertEquals(1, map.get("bar").size());
DiscoveryNode foo = map.get("foo").get(0);
assertEquals(foo.getAddress(), new TransportAddress(new InetSocketAddress(InetAddress.getByName("192.168.0.1"), 8080)));
assertEquals(foo.getId(), "foo#192.168.0.1:8080");
assertEquals(foo.getVersion(), Version.CURRENT.minimumCompatibilityVersion());
DiscoveryNode bar = map.get("bar").get(0);
assertEquals(bar.getAddress(), new TransportAddress(new InetSocketAddress(InetAddress.getByName("[::1]"), 9090)));
assertEquals(bar.getId(), "bar#[::1]:9090");
assertEquals(bar.getVersion(), Version.CURRENT.minimumCompatibilityVersion());
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:21,
示例13: sendErrorResponse
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Sends back an error response to the caller via the given channel
* @param nodeVersion the caller node version
* @param channel the channel to send the response to
* @param error the error to return
* @param requestId the request ID this response replies to
* @param action the action this response replies to
*/
public void sendErrorResponse(Version nodeVersion, Channel channel, final Exception error, final long requestId,
final String action) throws IOException {
try (BytesStreamOutput stream = new BytesStreamOutput()) {
stream.setVersion(nodeVersion);
RemoteTransportException tx = new RemoteTransportException(
nodeName(), new TransportAddress(getLocalAddress(channel)), action, error);
threadPool.getThreadContext().writeTo(stream);
stream.writeException(tx);
byte status = 0;
status = TransportStatus.setResponse(status);
status = TransportStatus.setError(status);
final BytesReference bytes = stream.bytes();
final BytesReference header = buildHeader(requestId, status, nodeVersion, bytes.length());
Runnable onRequestSent = () -> transportServiceAdapter.onResponseSent(requestId, action, error);
sendMessage(channel, new CompositeBytesReference(header, bytes), onRequestSent);
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:26,
示例14: buildMessage
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
private static String buildMessage(String name, TransportAddress address, String action, String msg) {
StringBuilder sb = new StringBuilder();
if (name != null) {
sb.append('[').append(name).append(']');
}
if (address != null) {
sb.append('[').append(address).append(']');
}
if (action != null) {
sb.append('[').append(action).append(']');
}
if (msg != null) {
sb.append(" ").append(msg);
}
return sb.toString();
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,
示例15: buildRemoteClustersSeeds
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
static Map> buildRemoteClustersSeeds(Settings settings) {
Stream>> allConcreteSettings = REMOTE_CLUSTERS_SEEDS.getAllConcreteSettings(settings);
return allConcreteSettings.collect(
Collectors.toMap(REMOTE_CLUSTERS_SEEDS::getNamespace, concreteSetting -> {
String clusterName = REMOTE_CLUSTERS_SEEDS.getNamespace(concreteSetting);
List nodes = new ArrayList<>();
for (InetSocketAddress address : concreteSetting.get(settings)) {
TransportAddress transportAddress = new TransportAddress(address);
DiscoveryNode node = new DiscoveryNode(clusterName + "#" + transportAddress.toString(),
transportAddress,
Version.CURRENT.minimumCompatibilityVersion());
nodes.add(node);
}
return nodes;
}));
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,
示例16: checkRemoveAddress
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
private void checkRemoveAddress(boolean sniff) {
Object[] extraSettings = {TransportClient.CLIENT_TRANSPORT_SNIFF.getKey(), sniff};
try(TestIteration iteration = new TestIteration(extraSettings)) {
final TransportClientNodesService service = iteration.transportClientNodesService;
assertEquals(iteration.listNodesCount + iteration.sniffNodesCount, service.connectedNodes().size());
final TransportAddress addressToRemove = randomFrom(iteration.listNodeAddresses);
service.removeTransportAddress(addressToRemove);
assertThat(service.connectedNodes(), everyItem(not(new CustomMatcher("removed address") {
@Override
public boolean matches(Object item) {
return item instanceof DiscoveryNode && ((DiscoveryNode)item).getAddress().equals(addressToRemove);
}
})));
assertEquals(iteration.listNodesCount + iteration.sniffNodesCount - 1, service.connectedNodes().size());
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,
示例17: testDiscoveryNodeSerializationKeepsHost
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testDiscoveryNodeSerializationKeepsHost() throws Exception {
InetAddress inetAddress = InetAddress.getByAddress("name1", new byte[] { (byte) 192, (byte) 168, (byte) 0, (byte) 1});
TransportAddress transportAddress = new TransportAddress(inetAddress, randomIntBetween(0, 65535));
DiscoveryNode node = new DiscoveryNode("name1", "id1", transportAddress, emptyMap(), emptySet(), Version.CURRENT);
BytesStreamOutput streamOutput = new BytesStreamOutput();
streamOutput.setVersion(Version.CURRENT);
node.writeTo(streamOutput);
StreamInput in = StreamInput.wrap(streamOutput.bytes().toBytesRef().bytes);
DiscoveryNode serialized = new DiscoveryNode(in);
assertEquals(transportAddress.address().getHostString(), serialized.getHostName());
assertEquals(transportAddress.address().getHostString(), serialized.getAddress().address().getHostString());
assertEquals(transportAddress.getAddress(), serialized.getHostAddress());
assertEquals(transportAddress.getAddress(), serialized.getAddress().getAddress());
assertEquals(transportAddress.getPort(), serialized.getAddress().getPort());
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,
示例18: removeTransportAddress
點讚 3
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public TransportClientNodesService removeTransportAddress(TransportAddress transportAddress) {
synchronized (mutex) {
if (closed) {
throw new IllegalStateException("transport client is closed, can't remove an address");
}
List builder = new ArrayList<>();
for (DiscoveryNode otherNode : listedNodes) {
if (!otherNode.address().equals(transportAddress)) {
builder.add(otherNode);
} else {
logger.debug("removing address [{}]", otherNode);
}
}
listedNodes = Collections.unmodifiableList(builder);
nodesSampler.sample();
}
return this;
}
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:19,
示例19: testBindUnavailableAddress
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testBindUnavailableAddress() {
try (Netty4HttpServerTransport transport = new Netty4HttpServerTransport(Settings.EMPTY, networkService, bigArrays, threadPool,
xContentRegistry(), new NullDispatcher())) {
transport.start();
TransportAddress remoteAddress = randomFrom(transport.boundAddress().boundAddresses());
Settings settings = Settings.builder().put("http.port", remoteAddress.getPort()).build();
try (Netty4HttpServerTransport otherTransport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool,
xContentRegistry(), new NullDispatcher())) {
BindHttpException bindHttpException = expectThrows(BindHttpException.class, () -> otherTransport.start());
assertEquals("Failed to bind to [" + remoteAddress.getPort() + "]", bindHttpException.getMessage());
}
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,
示例20: createTransportService
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
@Before
public void createTransportService() {
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
final Transport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList()),
Version.CURRENT) {
@Override
public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws UnknownHostException {
// we just need to ensure we don't resolve DNS here
return new TransportAddress[] {poorMansDNS.getOrDefault(address, buildNewFakeTransportAddress())};
}
};
transportService = new MockTransportService(Settings.EMPTY, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR,
null);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,
示例21: randomAddresses
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
private List randomAddresses() throws UnknownHostException {
List addresses = new ArrayList<>();
for (int i = 0; i < randomIntBetween(1, 5); i++) {
addresses.add(randomAddress());
}
return addresses;
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,
示例22: testLimitsInFlightRequests
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testLimitsInFlightRequests() throws Exception {
ensureGreen();
// we use the limit size as a (very) rough indication on how many requests we should sent to hit the limit
int numRequests = LIMIT.bytesAsInt() / 100;
StringBuilder bulkRequest = new StringBuilder();
for (int i = 0; i < numRequests; i++) {
bulkRequest.append("{\"index\": {}}");
bulkRequest.append(System.lineSeparator());
bulkRequest.append("{ \"field\" : \"value\" }");
bulkRequest.append(System.lineSeparator());
}
@SuppressWarnings("unchecked")
Tuple[] requests = new Tuple[150];
for (int i = 0; i < requests.length; i++) {
requests[i] = Tuple.tuple("/index/type/_bulk", bulkRequest);
}
HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
TransportAddress transportAddress = (TransportAddress) randomFrom(httpServerTransport.boundAddress
().boundAddresses());
try (Netty4HttpClient nettyHttpClient = new Netty4HttpClient()) {
Collection singleResponse = nettyHttpClient.post(transportAddress.address(), requests[0]);
assertThat(singleResponse, hasSize(1));
assertAtLeastOnceExpectedStatus(singleResponse, HttpResponseStatus.OK);
Collection multipleResponses = nettyHttpClient.post(transportAddress.address(), requests);
assertThat(multipleResponses, hasSize(requests.length));
assertAtLeastOnceExpectedStatus(multipleResponses, HttpResponseStatus.SERVICE_UNAVAILABLE);
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:35,
示例23: testDifferentPorts
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testDifferentPorts() throws Exception {
if (!NetworkUtils.SUPPORTS_V6) {
return;
}
logger.info("--> starting a node on ipv4 only");
Settings ipv4Settings = Settings.builder().put("network.host", "127.0.0.1").build();
String ipv4OnlyNode = internalCluster().startNode(ipv4Settings); // should bind 127.0.0.1:XYZ
logger.info("--> starting a node on ipv4 and ipv6");
Settings bothSettings = Settings.builder().put("network.host", "_local_").build();
internalCluster().startNode(bothSettings); // should bind [::1]:XYZ and 127.0.0.1:XYZ+1
logger.info("--> waiting for the cluster to declare itself stable");
ensureStableCluster(2); // fails if port of publish address does not match corresponding bound address
logger.info("--> checking if boundAddress matching publishAddress has same port");
NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get();
for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) {
BoundTransportAddress boundTransportAddress = nodeInfo.getTransport().getAddress();
if (nodeInfo.getNode().getName().equals(ipv4OnlyNode)) {
assertThat(boundTransportAddress.boundAddresses().length, equalTo(1));
assertThat(boundTransportAddress.boundAddresses()[0].getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
} else {
assertThat(boundTransportAddress.boundAddresses().length, greaterThan(1));
for (TransportAddress boundAddress : boundTransportAddress.boundAddresses()) {
assertThat(boundAddress, instanceOf(TransportAddress.class));
TransportAddress inetBoundAddress = (TransportAddress) boundAddress;
if (inetBoundAddress.address().getAddress() instanceof Inet4Address) {
// IPv4 address is preferred publish address for _local_
assertThat(inetBoundAddress.getPort(), equalTo(boundTransportAddress.publishAddress().getPort()));
}
}
}
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:36,
示例24: testReindexFromRemote
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testReindexFromRemote() throws Exception {
NodeInfo nodeInfo = client().admin().cluster().prepareNodesInfo().get().getNodes().get(0);
TransportAddress address = nodeInfo.getHttp().getAddress().publishAddress();
RemoteInfo remote = new RemoteInfo("http", address.getAddress(), address.getPort(), new BytesArray("{\"match_all\":{}}"), null,
null, emptyMap(), RemoteInfo.DEFAULT_SOCKET_TIMEOUT, RemoteInfo.DEFAULT_CONNECT_TIMEOUT);
ReindexRequestBuilder request = ReindexAction.INSTANCE.newRequestBuilder(client()).source("source").destination("dest")
.setRemoteInfo(remote);
testCase(ReindexAction.NAME, request, matcher().created(DOC_COUNT));
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,
示例25: testTcpHandshakeConnectionReset
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testTcpHandshakeConnectionReset() throws IOException, InterruptedException {
try (ServerSocket socket = new MockServerSocket()) {
socket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0), 1);
socket.setReuseAddress(true);
DiscoveryNode dummy = new DiscoveryNode("TEST", new TransportAddress(socket.getInetAddress(),
socket.getLocalPort()), emptyMap(),
emptySet(), version0);
Thread t = new Thread() {
@Override
public void run() {
try (Socket accept = socket.accept()) {
if (randomBoolean()) { // sometimes wait until the other side sends the message
accept.getInputStream().read();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
};
t.start();
ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
builder.addConnections(1,
TransportRequestOptions.Type.BULK,
TransportRequestOptions.Type.PING,
TransportRequestOptions.Type.RECOVERY,
TransportRequestOptions.Type.REG,
TransportRequestOptions.Type.STATE);
builder.setHandshakeTimeout(TimeValue.timeValueHours(1));
ConnectTransportException ex = expectThrows(ConnectTransportException.class,
() -> serviceA.connectToNode(dummy, builder.build()));
assertEquals(ex.getMessage(), "[][" + dummy.getAddress() + "] general node connection failure");
assertThat(ex.getCause().getMessage(), startsWith("handshake failed"));
t.join();
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:36,
示例26: buildExternalCluster
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
private ExternalTestCluster buildExternalCluster(String clusterAddresses) throws IOException {
String[] stringAddresses = clusterAddresses.split(",");
TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length];
int i = 0;
for (String stringAddress : stringAddresses) {
URL url = new URL("http://" + stringAddress);
InetAddress inetAddress = InetAddress.getByName(url.getHost());
transportAddresses[i++] = new TransportAddress(new InetSocketAddress(inetAddress, url.getPort()));
}
return new ExternalTestCluster(createTempDir(), externalClusterClientSettings(), transportClientPlugins(), transportAddresses);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,
示例27: extractTransportAddresses
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public static TransportAddress[] extractTransportAddresses(TransportService transportService) {
HashSet transportAddresses = new HashSet<>();
BoundTransportAddress boundTransportAddress = transportService.boundAddress();
transportAddresses.addAll(Arrays.asList(boundTransportAddress.boundAddresses()));
transportAddresses.add(boundTransportAddress.publishAddress());
return transportAddresses.toArray(new TransportAddress[transportAddresses.size()]);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,
示例28: clearRule
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Clears the rule associated with the provided transport address.
*/
public void clearRule(TransportAddress transportAddress) {
Transport transport = transport().transports.remove(transportAddress);
if (transport instanceof ClearableTransport) {
((ClearableTransport) transport).clearRule();
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,
示例29: transportAddresses
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public List transportAddresses() {
List lstBuilder = new ArrayList<>();
for (DiscoveryNode listedNode : listedNodes) {
lstBuilder.add(listedNode.address());
}
return Collections.unmodifiableList(lstBuilder);
}
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:8,
示例30: addDelegate
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Adds a new delegate transport that is used for communication with the given transport service.
*
* @return true iff no other delegate was registered for any of the addresses bound by transport service.
*/
public boolean addDelegate(TransportService transportService, DelegateTransport transport) {
boolean noRegistered = true;
for (TransportAddress transportAddress : extractTransportAddresses(transportService)) {
noRegistered &= addDelegate(transportAddress, transport);
}
return noRegistered;
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,
示例31: transportAddresses
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public List transportAddresses() {
List lstBuilder = new ArrayList<>();
for (DiscoveryNode listedNode : listedNodes) {
lstBuilder.add(listedNode.getAddress());
}
return Collections.unmodifiableList(lstBuilder);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,
示例32: createBoundTransportAddress
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
private BoundTransportAddress createBoundTransportAddress(String name, Settings profileSettings,
List boundAddresses) {
String[] boundAddressesHostStrings = new String[boundAddresses.size()];
TransportAddress[] transportBoundAddresses = new TransportAddress[boundAddresses.size()];
for (int i = 0; i < boundAddresses.size(); i++) {
InetSocketAddress boundAddress = boundAddresses.get(i);
boundAddressesHostStrings[i] = boundAddress.getHostString();
transportBoundAddresses[i] = new TransportAddress(boundAddress);
}
final String[] publishHosts;
if (TransportSettings.DEFAULT_PROFILE.equals(name)) {
publishHosts = TransportSettings.PUBLISH_HOST.get(settings).toArray(Strings.EMPTY_ARRAY);
} else {
publishHosts = profileSettings.getAsArray("publish_host", boundAddressesHostStrings);
}
final InetAddress publishInetAddress;
try {
publishInetAddress = networkService.resolvePublishHostAddresses(publishHosts);
} catch (Exception e) {
throw new BindTransportException("Failed to resolve publish address", e);
}
final int publishPort = resolvePublishPort(name, settings, profileSettings, boundAddresses, publishInetAddress);
final TransportAddress publishAddress = new TransportAddress(new InetSocketAddress(publishInetAddress, publishPort));
return new BoundTransportAddress(transportBoundAddresses, publishAddress);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:29,
示例33: addressesFromString
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
@Override
public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws Exception {
return parse(address, settings.get("transport.profiles.default.port",
settings.get("transport.netty.port",
settings.get("transport.tcp.port",
DEFAULT_PORT_RANGE))), perAddressLimit);
}
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:8,
示例34: testReadHostFromTag
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
public void testReadHostFromTag() throws InterruptedException, UnknownHostException {
int nodes = randomIntBetween(5, 10);
String[] addresses = new String[nodes];
for (int node = 0; node < nodes; node++) {
addresses[node] = "192.168.0." + (node + 1);
poorMansDNS.put("node" + (node + 1), new TransportAddress(InetAddress.getByName(addresses[node]), 9300));
}
Settings nodeSettings = Settings.builder()
.put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "tag:foo")
.build();
List> tagsList = new ArrayList<>();
for (int node = 0; node < nodes; node++) {
List tags = new ArrayList<>();
tags.add(new Tag("foo", "node" + (node + 1)));
tagsList.add(tags);
}
logger.info("started [{}] instances", nodes);
List discoveryNodes = buildDynamicNodes(nodeSettings, nodes, tagsList);
assertThat(discoveryNodes, hasSize(nodes));
for (DiscoveryNode discoveryNode : discoveryNodes) {
TransportAddress address = discoveryNode.getAddress();
TransportAddress expected = poorMansDNS.get(discoveryNode.getName());
assertEquals(address, expected);
}
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:32,
示例35: findByAddress
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Get a node by its address
*
* @param address {@link TransportAddress} of the wanted node
* @return node identified by the given address or null
if no such node exists
*/
public DiscoveryNode findByAddress(TransportAddress address) {
for (ObjectCursor cursor : nodes.values()) {
DiscoveryNode node = cursor.value;
if (node.getAddress().equals(address)) {
return node;
}
}
return null;
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,
示例36: DiscoveryNode
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/**
* Creates a new {@link DiscoveryNode}.
*
* Note: if the version of the node is unknown {@link Version#minimumCompatibilityVersion()} should be used for the current
* version. it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used
* the node might not be able to communicate with the remove node. After initial handshakes node versions will be discovered
* and updated.
*
*
* @param nodeName the nodes name
* @param nodeId the nodes unique persistent id
* @param ephemeralId the nodes unique ephemeral id
* @param hostAddress the nodes host address
* @param address the nodes transport address
* @param attributes node attributes
* @param roles node roles
* @param version the version of the node
*/
public DiscoveryNode(String nodeName, String nodeId, String ephemeralId, String hostName, String hostAddress,
TransportAddress address, Map attributes, Set roles, Version version) {
if (nodeName != null) {
this.nodeName = nodeName.intern();
} else {
this.nodeName = "";
}
this.nodeId = nodeId.intern();
this.ephemeralId = ephemeralId.intern();
this.hostName = hostName.intern();
this.hostAddress = hostAddress.intern();
this.address = address;
if (version == null) {
this.version = Version.CURRENT;
} else {
this.version = version;
}
this.attributes = Collections.unmodifiableMap(attributes);
//verify that no node roles are being provided as attributes
Predicate> predicate = (attrs) -> {
for (Role role : Role.values()) {
assert attrs.containsKey(role.getRoleName()) == false;
}
return true;
};
assert predicate.test(attributes);
Set rolesSet = EnumSet.noneOf(Role.class);
rolesSet.addAll(roles);
this.roles = Collections.unmodifiableSet(rolesSet);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:49,
示例37: createLocal
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
/** Creates a DiscoveryNode representing the local node. */
public static DiscoveryNode createLocal(Settings settings, TransportAddress publishAddress, String nodeId) {
Map attributes = new HashMap<>(Node.NODE_ATTRIBUTES.get(settings).getAsMap());
Set roles = getRolesFromSettings(settings);
return new DiscoveryNode(Node.NODE_NAME_SETTING.get(settings), nodeId, publishAddress, attributes, roles, Version.CURRENT);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,
示例38: ClusterStatsNodes
點讚 2
import org.elasticsearch.common.transport.TransportAddress; //導入依賴的package包/類
ClusterStatsNodes(List nodeResponses) {
this.versions = new HashSet<>();
this.fs = new FsInfo.Path();
this.plugins = new HashSet<>();
Set seenAddresses = new HashSet<>(nodeResponses.size());
List nodeInfos = new ArrayList<>();
List nodeStats = new ArrayList<>();
for (ClusterStatsNodeResponse nodeResponse : nodeResponses) {
nodeInfos.add(nodeResponse.nodeInfo());
nodeStats.add(nodeResponse.nodeStats());
this.versions.add(nodeResponse.nodeInfo().getVersion());
this.plugins.addAll(nodeResponse.nodeInfo().getPlugins().getPluginInfos());
// now do the stats that should be deduped by hardware (implemented by ip deduping)
TransportAddress publishAddress = nodeResponse.nodeInfo().getTransport().address().publishAddress();
final InetAddress inetAddress = publishAddress.address().getAddress();
if (!seenAddresses.add(inetAddress)) {
continue;
}
if (nodeResponse.nodeStats().getFs() != null) {
this.fs.add(nodeResponse.nodeStats().getFs().getTotal());
}
}
this.counts = new Counts(nodeInfos);
this.os = new OsStats(nodeInfos, nodeStats);
this.process = new ProcessStats(nodeStats);
this.jvm = new JvmStats(nodeInfos, nodeStats);
this.networkTypes = new NetworkTypes(nodeInfos);
}
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:31,
注:本文中的org.elasticsearch.common.transport.TransportAddress類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。