use of org.opensearch.common.transport.TransportAddress in project anomaly-detection by opensearch-project.
the class AbstractProfileRunnerTests method setUpOnce.
@BeforeClass
public static void setUpOnce() {
stateOnly = new HashSet<DetectorProfileName>();
stateOnly.add(DetectorProfileName.STATE);
stateNError = new HashSet<DetectorProfileName>();
stateNError.add(DetectorProfileName.ERROR);
stateNError.add(DetectorProfileName.STATE);
stateInitProgress = new HashSet<DetectorProfileName>();
stateInitProgress.add(DetectorProfileName.INIT_PROGRESS);
stateInitProgress.add(DetectorProfileName.STATE);
modelProfile = new HashSet<DetectorProfileName>(Arrays.asList(DetectorProfileName.SHINGLE_SIZE, DetectorProfileName.MODELS, DetectorProfileName.COORDINATING_NODE, DetectorProfileName.TOTAL_SIZE_IN_BYTES));
totalInitProgress = new HashSet<DetectorProfileName>(Arrays.asList(DetectorProfileName.TOTAL_ENTITIES, DetectorProfileName.INIT_PROGRESS));
initProgressErrorProfile = new HashSet<DetectorProfileName>(Arrays.asList(DetectorProfileName.INIT_PROGRESS, DetectorProfileName.ERROR));
clusterName = "test-cluster-name";
discoveryNode1 = new DiscoveryNode("nodeName1", "node1", new TransportAddress(TransportAddress.META_ADDRESS, 9300), emptyMap(), emptySet(), Version.CURRENT);
}
use of org.opensearch.common.transport.TransportAddress in project anomaly-detection by opensearch-project.
the class ProfileTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
clusterName = "test-cluster-name";
node1 = "node1";
nodeName1 = "nodename1";
discoveryNode1 = new DiscoveryNode(nodeName1, node1, new TransportAddress(TransportAddress.META_ADDRESS, 9300), emptyMap(), emptySet(), Version.CURRENT);
node2 = "node2";
nodeName2 = "nodename2";
discoveryNode2 = new DiscoveryNode(nodeName2, node2, new TransportAddress(TransportAddress.META_ADDRESS, 9301), emptyMap(), emptySet(), Version.CURRENT);
clusterStats = new HashMap<>();
modelSize = 4456448L;
model1Id = "Pl536HEBnXkDrah03glg_model_rcf_1";
model0Id = "Pl536HEBnXkDrah03glg_model_rcf_0";
detectorId = "123";
shingleSize = 6;
modelSizeMap1 = new HashMap<String, Long>() {
{
put(model1Id, modelSize);
}
};
modelSizeMap2 = new HashMap<String, Long>() {
{
put(model0Id, modelSize);
}
};
}
use of org.opensearch.common.transport.TransportAddress in project anomaly-detection by opensearch-project.
the class RCFPollingTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
clusterService = mock(ClusterService.class);
hashRing = mock(HashRing.class);
transportAddress1 = new TransportAddress(new InetSocketAddress(InetAddress.getByName("1.2.3.4"), 9300));
manager = mock(ModelManager.class);
transportService = new TransportService(Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet());
future = new PlainActionFuture<>();
request = new RCFPollingRequest(detectorId);
model0Id = SingleStreamModelIdMapper.getRcfModelId(detectorId, 0);
doAnswer(invocation -> {
Object[] args = invocation.getArguments();
@SuppressWarnings("unchecked") ActionListener<Long> listener = (ActionListener<Long>) args[2];
listener.onResponse(totalUpdates);
return null;
}).when(manager).getTotalUpdates(any(String.class), any(String.class), any());
normalTransportInterceptor = new TransportInterceptor() {
@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) {
if (RCFPollingAction.NAME.equals(action)) {
sender.sendRequest(connection, action, request, options, rcfRollingHandler(handler));
} else {
sender.sendRequest(connection, action, request, options, handler);
}
}
};
}
};
failureTransportInterceptor = new TransportInterceptor() {
@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) {
if (RCFPollingAction.NAME.equals(action)) {
sender.sendRequest(connection, action, request, options, rcfFailureRollingHandler(handler));
} else {
sender.sendRequest(connection, action, request, options, handler);
}
}
};
}
};
}
use of org.opensearch.common.transport.TransportAddress in project anomaly-detection by opensearch-project.
the class DeleteTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
node1 = "node1";
node2 = "node2";
nodename1 = "nodename1";
nodename2 = "nodename2";
DiscoveryNode discoveryNode1 = new DiscoveryNode(nodename1, node1, new TransportAddress(TransportAddress.META_ADDRESS, 9300), emptyMap(), emptySet(), Version.CURRENT);
DiscoveryNode discoveryNode2 = new DiscoveryNode(nodename2, node2, new TransportAddress(TransportAddress.META_ADDRESS, 9301), emptyMap(), emptySet(), Version.CURRENT);
List<DiscoveryNode> discoveryNodes = new ArrayList<DiscoveryNode>(2);
discoveryNodes.add(discoveryNode1);
discoveryNodes.add(discoveryNode2);
DeleteModelNodeResponse nodeResponse1 = new DeleteModelNodeResponse(discoveryNode1);
DeleteModelNodeResponse nodeResponse2 = new DeleteModelNodeResponse(discoveryNode2);
deleteModelResponse = new ArrayList<>();
deleteModelResponse.add(nodeResponse1);
deleteModelResponse.add(nodeResponse2);
failures = new ArrayList<>();
failures.add(new FailedNodeException("node3", "blah", new OpenSearchException("foo")));
response = new DeleteModelResponse(new ClusterName("Cluster"), deleteModelResponse, failures);
clusterService = mock(ClusterService.class);
when(clusterService.localNode()).thenReturn(discoveryNode1);
when(clusterService.state()).thenReturn(ClusterCreation.state(new ClusterName("test"), discoveryNode2, discoveryNode1, discoveryNodes));
transportService = mock(TransportService.class);
threadPool = mock(ThreadPool.class);
actionFilters = mock(ActionFilters.class);
Settings settings = Settings.builder().put("plugins.anomaly_detection.request_timeout", TimeValue.timeValueSeconds(10)).build();
task = mock(Task.class);
when(task.getId()).thenReturn(1000L);
client = mock(Client.class);
when(client.settings()).thenReturn(settings);
when(client.threadPool()).thenReturn(threadPool);
}
use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.
the class ClusterFormationFailureHelperTests method testDescriptionOnMasterIneligibleNodes.
public void testDescriptionOnMasterIneligibleNodes() {
final DiscoveryNode localNode = new DiscoveryNode("local", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).version(12L).metadata(Metadata.builder().coordinationMetadata(CoordinationMetadata.builder().term(4L).build())).nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId())).build();
assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), emptyList(), 15L, electionStrategy, new StatusInfo(HEALTHY, "healthy-info")).getDescription(), is("master not discovered yet: have discovered []; discovery will continue using [] from hosts providers " + "and [] from last-known cluster state; node term 15, last-accepted version 12 in term 4"));
final TransportAddress otherAddress = buildNewFakeTransportAddress();
assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, singletonList(otherAddress), emptyList(), 16L, electionStrategy, new StatusInfo(HEALTHY, "healthy-info")).getDescription(), is("master not discovered yet: have discovered []; discovery will continue using [" + otherAddress + "] from hosts providers and [] from last-known cluster state; node term 16, last-accepted version 12 in term 4"));
final DiscoveryNode otherNode = new DiscoveryNode("other", buildNewFakeTransportAddress(), Version.CURRENT);
assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), singletonList(otherNode), 17L, electionStrategy, new StatusInfo(HEALTHY, "healthy-info")).getDescription(), is("master not discovered yet: have discovered [" + otherNode + "]; discovery will continue using [] from hosts providers " + "and [] from last-known cluster state; node term 17, last-accepted version 12 in term 4"));
}
Aggregations