use of org.elasticsearch.cluster.node.DiscoveryNode in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnParticipatingNodeDisconnectedKillsJob.
@Test
public void testOnParticipatingNodeDisconnectedKillsJob() throws Exception {
JobContextService jobContextService = jobContextService();
DiscoveryNode coordinator_node = new DiscoveryNode("coordinator_node_id", DummyTransportAddress.INSTANCE, Version.CURRENT);
DiscoveryNode data_node = new DiscoveryNode("data_node_id", DummyTransportAddress.INSTANCE, Version.CURRENT);
DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().localNodeId("coordinator_node_id").put(coordinator_node).put(data_node).build();
JobExecutionContext.Builder builder = jobContextService.newBuilder(UUID.randomUUID(), coordinator_node.getId(), Arrays.asList(coordinator_node.getId(), data_node.getId()));
builder.addSubContext(new DummySubContext());
jobContextService.createContext(builder);
TransportKillJobsNodeAction killAction = mock(TransportKillJobsNodeAction.class);
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(Settings.EMPTY, mock(ThreadPool.class), jobContextService, mock(TransportService.class), killAction);
monitorService.onNodeDisconnected(discoveryNodes.get("data_node_id"));
verify(killAction, times(1)).broadcast(any(KillJobsRequest.class), any(ActionListener.class), eq(Arrays.asList(discoveryNodes.get("data_node_id").getId())));
}
use of org.elasticsearch.cluster.node.DiscoveryNode in project crate by crate.
the class CreateAlterTableStatementAnalyzerTest method init.
@Before
public void init() throws Exception {
String analyzerSettings = FulltextAnalyzerResolver.encodeSettings(Settings.builder().put("search", "foobar").build()).toUtf8();
MetaData metaData = MetaData.builder().persistentSettings(Settings.builder().put("crate.analysis.custom.analyzer.ft_search", analyzerSettings).build()).build();
ClusterState state = ClusterState.builder(ClusterName.DEFAULT).nodes(DiscoveryNodes.builder().put(new DiscoveryNode("n1", DummyTransportAddress.INSTANCE, org.elasticsearch.Version.CURRENT)).put(new DiscoveryNode("n2", DummyTransportAddress.INSTANCE, org.elasticsearch.Version.CURRENT)).put(new DiscoveryNode("n3", DummyTransportAddress.INSTANCE, org.elasticsearch.Version.CURRENT)).localNodeId("n1")).metaData(metaData).build();
e = SQLExecutor.builder(new NoopClusterService(state)).enableDefaultTables().build();
}
use of org.elasticsearch.cluster.node.DiscoveryNode in project crate by crate.
the class NodeStatsContextFieldResolverTest method setup.
@Before
public void setup() {
DiscoveryNode discoveryNode = mock(DiscoveryNode.class);
when(discoveryNode.getId()).thenReturn("node_id");
when(discoveryNode.name()).thenReturn("node_name");
when(clusterService.localNode()).thenReturn(discoveryNode);
resolver = new NodeStatsContextFieldResolver(clusterService, osService, nodeService, jvmService, threadPool, extendedNodeInfo, postgresNetty);
}
use of org.elasticsearch.cluster.node.DiscoveryNode in project crate by crate.
the class NodeStatsCollectSourceTest method filterNodes.
private List<DiscoveryNode> filterNodes(String where) throws NoSuchFieldException, IllegalAccessException {
// build where clause with id = ?
SysNodesTableInfo tableInfo = mock(SysNodesTableInfo.class);
when(tableInfo.ident()).thenReturn(new TableIdent("sys", "nodes"));
when(tableInfo.getReference(new ColumnIdent("id"))).thenReturn(new Reference(new ReferenceIdent(new TableIdent("sys", "nodes"), "id"), RowGranularity.DOC, DataTypes.STRING));
when(tableInfo.getReference(SysNodesTableInfo.Columns.NAME)).thenReturn(new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.NAME), RowGranularity.DOC, DataTypes.STRING));
when(tableInfo.getReference(SysNodesTableInfo.Columns.HOSTNAME)).thenReturn(new Reference(new ReferenceIdent(SysNodesTableInfo.IDENT, SysNodesTableInfo.Columns.HOSTNAME), RowGranularity.DOC, DataTypes.STRING));
TableRelation tableRelation = new TableRelation(tableInfo);
Map<QualifiedName, AnalyzedRelation> tableSources = ImmutableMap.<QualifiedName, AnalyzedRelation>of(new QualifiedName("sys.nodes"), tableRelation);
SqlExpressions sqlExpressions = new SqlExpressions(tableSources, tableRelation);
WhereClause whereClause = new WhereClause(sqlExpressions.normalize(sqlExpressions.asSymbol(where)));
List<DiscoveryNode> nodes = Lists.newArrayList(NodeStatsCollectSource.nodeIds(whereClause, discoveryNodes, getFunctions()));
Collections.sort(nodes, new Comparator<DiscoveryNode>() {
@Override
public int compare(DiscoveryNode o1, DiscoveryNode o2) {
return o1.getId().compareTo(o2.getId());
}
});
return nodes;
}
use of org.elasticsearch.cluster.node.DiscoveryNode in project crate by crate.
the class Transports method sendRequest.
public <TRequest extends TransportRequest, TResponse extends TransportResponse> void sendRequest(String action, String node, TRequest request, ActionListener<TResponse> listener, TransportResponseHandler<TResponse> handler, TransportRequestOptions options) {
DiscoveryNode discoveryNode = clusterService.state().nodes().get(node);
if (discoveryNode == null) {
listener.onFailure(new IllegalArgumentException(String.format(Locale.ENGLISH, "node \"%s\" not found in cluster state!", node)));
return;
}
transportService.sendRequest(discoveryNode, action, request, options, handler);
}
Aggregations