当前位置: 首页>>代码示例>>Java>>正文


Java TransportRequest类代码示例

本文整理汇总了Java中org.elasticsearch.transport.TransportRequest的典型用法代码示例。如果您正苦于以下问题:Java TransportRequest类的具体用法?Java TransportRequest怎么用?Java TransportRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransportRequest类属于org.elasticsearch.transport包,在下文中一共展示了TransportRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: register

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public Task register(String type, String action, TransportRequest request) {
    Task task = super.register(type, action, request);
    if (task != null) {
        for (MockTaskManagerListener listener : listeners) {
            try {
                listener.onTaskRegistered(task);
            } catch (Exception e) {
                logger.warn(
                    (Supplier<?>) () -> new ParameterizedMessage(
                        "failed to notify task manager listener about unregistering the task with id {}",
                        task.getId()),
                    e);
            }
        }
    }
    return task;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:MockTaskManager.java

示例2: addFailToSendNoConnectRule

import org.elasticsearch.transport.TransportRequest; //导入依赖的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<Connection, ConnectionProfile, IOException> 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,代码来源:MockTransportService.java

示例3: addUnresponsiveRule

import org.elasticsearch.transport.TransportRequest; //导入依赖的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<Connection, ConnectionProfile, IOException> 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,代码来源:MockTransportService.java

示例4: openConnection

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public Connection openConnection(DiscoveryNode node, ConnectionProfile profile) throws IOException {
    return new Connection() {
        @Override
        public DiscoveryNode getNode() {
            return node;
        }

        @Override
        public void sendRequest(long requestId, String action, TransportRequest request, TransportRequestOptions options)
            throws IOException, TransportException {
            requests.put(requestId, Tuple.tuple(node, action));
            capturedRequests.add(new CapturedRequest(node, requestId, action, request));
        }

        @Override
        public void close() throws IOException {

        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:CapturingTransport.java

示例5: register

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
/**
 * Registers a task without parent task
 * <p>
 * Returns the task manager tracked task or null if the task doesn't support the task manager
 */
public Task register(String type, String action, TransportRequest request) {
    Task task = request.createTask(taskIdGenerator.incrementAndGet(), type, action, request.getParentTask());
    if (task == null) {
        return null;
    }
    assert task.getParentTaskId().equals(request.getParentTask()) : "Request [ " + request + "] didn't preserve it parentTaskId";
    if (logger.isTraceEnabled()) {
        logger.trace("register {} [{}] [{}] [{}]", task.getId(), type, action, task.getDescription());
    }

    if (task instanceof CancellableTask) {
        registerCancellableTask(task);
    } else {
        Task previousTask = tasks.put(task.getId(), task);
        assert previousTask == null;
    }
    return task;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:TaskManager.java

示例6: getTransportInterceptors

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public List<TransportInterceptor> getTransportInterceptors(NamedWriteableRegistry namedWriteableRegistry,
                                                           ThreadContext threadContext) {
    return Collections.singletonList(new TransportInterceptor() {
        @Override
        public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler(String action, String executor,
                                                                                    boolean forceExecution,
                                                                                    TransportRequestHandler<T> actualHandler) {
            return instance.interceptHandler(action, executor, forceExecution, actualHandler);
        }

        @Override
        public AsyncSender interceptSender(AsyncSender sender) {
            return instance.interceptSender(sender);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:TransportClientHeadersTests.java

示例7: getConnection

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public Connection getConnection(DiscoveryNode node) {
    return new Connection() {
        @Override
        public DiscoveryNode getNode() {
            return node;
        }

        @Override
        public void sendRequest(long requestId, String action, TransportRequest request, TransportRequestOptions options)
            throws IOException, TransportException {

        }

        @Override
        public void close() throws IOException {

        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:NodeConnectionsServiceTests.java

示例8: messageReceived

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public void messageReceived(T request, TransportChannel channel, Task task) throws Exception {
    synchronized (InterceptingTransportService.this) {
        if (actions.contains(action)) {
            List<TransportRequest> requestList = requests.get(action);
            if (requestList == null) {
                requestList = new ArrayList<>();
                requestList.add(request);
                requests.put(action, requestList);
            } else {
                requestList.add(request);
            }
        }
    }
    requestHandler.messageReceived(request, channel, task);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:IndicesRequestIT.java

示例9: sendRequest

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException {
    if (action.equals(PeerRecoveryTargetService.Actions.FILE_CHUNK)) {
        RecoveryFileChunkRequest chunkRequest = (RecoveryFileChunkRequest) request;
        if (chunkRequest.name().startsWith(IndexFileNames.SEGMENTS)) {
            // corrupting the segments_N files in order to make sure future recovery re-send files
            logger.debug("corrupting [{}] to {}. file name: [{}]", action, connection.getNode(), chunkRequest.name());
            assert chunkRequest.content().toBytesRef().bytes == chunkRequest.content().toBytesRef().bytes : "no internal reference!!";
            byte[] array = chunkRequest.content().toBytesRef().bytes;
            array[0] = (byte) ~array[0]; // flip one byte in the content
            corruptionCount.countDown();
        }
        super.sendRequest(connection, requestId, action, request, options);
    } else {
        super.sendRequest(connection, requestId, action, request, options);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RelocationIT.java

示例10: logError

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public void logError(Throwable t, TransportRequest request, String action, Task task, int type) {
    switch (type) {
    case 0:
        if(t instanceof ElasticsearchException) {
            auditLog.logMissingPrivileges(action, request, task);
        } else {
            auditLog.logSSLException(request, t, action, task);
        }
        break;
    case 1:
        auditLog.logBadHeaders(request, action, task);
        break;
    default:
        break;
    }
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:18,代码来源:AuditLogSslExceptionHandler.java

示例11: getConnection

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public Connection getConnection(DiscoveryNode node) {
    return new FilteredConnection(transport.getConnection(node)) {
        @Override
        public void sendRequest(long requestId, String action, TransportRequest request, TransportRequestOptions options)
            throws IOException, TransportException {
            DelegateTransport.this.sendRequest(connection, requestId, action, request, options);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:MockTransportService.java

示例12: openConnection

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public Connection openConnection(DiscoveryNode node, ConnectionProfile profile) throws IOException {
    return new FilteredConnection(transport.openConnection(node, profile)) {
        @Override
        public void sendRequest(long requestId, String action, TransportRequest request, TransportRequestOptions options)
            throws IOException, TransportException {
            DelegateTransport.this.sendRequest(connection, requestId, action, request, options);
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:MockTransportService.java

示例13: interceptHandler

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler(String action, String executor,
                                                                                boolean forceExecution,
                                                                                TransportRequestHandler<T> actualHandler) {
    for (TransportInterceptor interceptor : this.transportInterceptors) {
        actualHandler = interceptor.interceptHandler(action, executor, forceExecution, actualHandler);
    }
    return actualHandler;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:NetworkModule.java

示例14: sendRequest

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request,
                           TransportRequestOptions options) throws IOException {
    if (recoveryActionToBlock.equals(action) || requestBlocked.getCount() == 0) {
        logger.info("--> preventing {} request", action);
        requestBlocked.countDown();
        if (dropRequests) {
            return;
        }
        throw new ConnectTransportException(connection.getNode(), "DISCONNECT: prevented " + action + " request");
    }
    super.sendRequest(connection, requestId, action, request, options);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:IndexRecoveryIT.java

示例15: interceptSender

import org.elasticsearch.transport.TransportRequest; //导入依赖的package包/类
@Override
public AsyncSender interceptSender(AsyncSender sender) {
    return new AsyncSender() {
        @Override
        public <T extends TransportResponse> void sendRequest(Transport.Connection connection, String action,
                                                              TransportRequest request,
                                                              TransportRequestOptions options,
                                                              TransportResponseHandler<T> handler) {
            final ClusterName clusterName = new ClusterName("cluster1");
            if (TransportLivenessAction.NAME.equals(action)) {
                assertHeaders(threadPool);
                ((TransportResponseHandler<LivenessResponse>) handler).handleResponse(
                    new LivenessResponse(clusterName, connection.getNode()));
            } else if (ClusterStateAction.NAME.equals(action)) {
                assertHeaders(threadPool);
                ClusterName cluster1 = clusterName;
                ClusterState.Builder builder = ClusterState.builder(cluster1);
                //the sniffer detects only data nodes
                builder.nodes(DiscoveryNodes.builder().add(new DiscoveryNode("node_id", "someId", "some_ephemeralId_id",
                    address.address().getHostString(), address.getAddress(), address, Collections.emptyMap(),
                        Collections.singleton(DiscoveryNode.Role.DATA), Version.CURRENT)));
                ((TransportResponseHandler<ClusterStateResponse>) handler)
                        .handleResponse(new ClusterStateResponse(cluster1, builder.build(), 0L));
                clusterStateLatch.countDown();
            } else if (TransportService.HANDSHAKE_ACTION_NAME .equals(action)) {
                ((TransportResponseHandler<TransportService.HandshakeResponse>) handler).handleResponse(
                    new TransportService.HandshakeResponse(connection.getNode(), clusterName, connection.getNode().getVersion()));
            } else {
                handler.handleException(new TransportException("", new InternalException(action)));
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:TransportClientHeadersTests.java


注:本文中的org.elasticsearch.transport.TransportRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。