Search in sources :

Example 1 with ProfileNodeResponse

use of org.opensearch.ad.transport.ProfileNodeResponse in project anomaly-detection by opensearch-project.

the class AnomalyDetectorProfileRunnerTests method setUpClientExecuteProfileAction.

@SuppressWarnings("unchecked")
private void setUpClientExecuteProfileAction() {
    doAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        ActionListener<ProfileResponse> listener = (ActionListener<ProfileResponse>) args[2];
        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);
        modelSize = 4456448L;
        model1Id = "Pl536HEBnXkDrah03glg_model_rcf_1";
        model0Id = "Pl536HEBnXkDrah03glg_model_rcf_0";
        shingleSize = 6;
        String clusterName = "test-cluster-name";
        Map<String, Long> modelSizeMap1 = new HashMap<String, Long>() {

            {
                put(model1Id, modelSize);
            }
        };
        Map<String, Long> modelSizeMap2 = new HashMap<String, Long>() {

            {
                put(model0Id, modelSize);
            }
        };
        ProfileNodeResponse profileNodeResponse1 = new ProfileNodeResponse(discoveryNode1, modelSizeMap1, shingleSize, 0L, 0L, new ArrayList<>(), modelSizeMap1.size());
        ProfileNodeResponse profileNodeResponse2 = new ProfileNodeResponse(discoveryNode2, modelSizeMap2, -1, 0L, 0L, new ArrayList<>(), modelSizeMap2.size());
        List<ProfileNodeResponse> profileNodeResponses = Arrays.asList(profileNodeResponse1, profileNodeResponse2);
        List<FailedNodeException> failures = Collections.emptyList();
        ProfileResponse profileResponse = new ProfileResponse(new ClusterName(clusterName), profileNodeResponses, failures);
        listener.onResponse(profileResponse);
        return null;
    }).when(client).execute(any(ProfileAction.class), any(), any());
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) HashMap(java.util.HashMap) TransportAddress(org.opensearch.common.transport.TransportAddress) ProfileNodeResponse(org.opensearch.ad.transport.ProfileNodeResponse) ProfileAction(org.opensearch.ad.transport.ProfileAction) ProfileResponse(org.opensearch.ad.transport.ProfileResponse) ActionListener(org.opensearch.action.ActionListener) ClusterName(org.opensearch.cluster.ClusterName) FailedNodeException(org.opensearch.action.FailedNodeException)

Example 2 with ProfileNodeResponse

use of org.opensearch.ad.transport.ProfileNodeResponse in project anomaly-detection by opensearch-project.

the class MultiEntityProfileRunnerTests method setUpClientExecuteProfileAction.

@SuppressWarnings("unchecked")
private void setUpClientExecuteProfileAction(InittedEverResultStatus initted) {
    doAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        ActionListener<ProfileResponse> listener = (ActionListener<ProfileResponse>) args[2];
        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);
        modelSize = 712480L;
        model1Id = "A69pa3UBHuCbh-emo9oR_entity_host1";
        model0Id = "A69pa3UBHuCbh-emo9oR_entity_host0";
        shingleSize = -1;
        String clusterName = "test-cluster-name";
        Map<String, Long> modelSizeMap1 = new HashMap<String, Long>() {

            {
                put(model1Id, modelSize);
            }
        };
        Map<String, Long> modelSizeMap2 = new HashMap<String, Long>() {

            {
                put(model0Id, modelSize);
            }
        };
        // one model in each node; all fully initialized
        long updates = requiredSamples - 1;
        if (InittedEverResultStatus.INITTED == initted) {
            updates = requiredSamples + 1;
        }
        ProfileNodeResponse profileNodeResponse1 = new ProfileNodeResponse(discoveryNode1, modelSizeMap1, shingleSize, 1L, updates, new ArrayList<>(), modelSizeMap1.size());
        ProfileNodeResponse profileNodeResponse2 = new ProfileNodeResponse(discoveryNode2, modelSizeMap2, shingleSize, 1L, updates, new ArrayList<>(), modelSizeMap2.size());
        List<ProfileNodeResponse> profileNodeResponses = Arrays.asList(profileNodeResponse1, profileNodeResponse2);
        List<FailedNodeException> failures = Collections.emptyList();
        ProfileResponse profileResponse = new ProfileResponse(new ClusterName(clusterName), profileNodeResponses, failures);
        listener.onResponse(profileResponse);
        return null;
    }).when(client).execute(any(ProfileAction.class), any(), any());
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) HashMap(java.util.HashMap) TransportAddress(org.opensearch.common.transport.TransportAddress) ProfileNodeResponse(org.opensearch.ad.transport.ProfileNodeResponse) ProfileAction(org.opensearch.ad.transport.ProfileAction) ProfileResponse(org.opensearch.ad.transport.ProfileResponse) ActionListener(org.opensearch.action.ActionListener) ClusterName(org.opensearch.cluster.ClusterName) FailedNodeException(org.opensearch.action.FailedNodeException)

Example 3 with ProfileNodeResponse

use of org.opensearch.ad.transport.ProfileNodeResponse in project anomaly-detection by opensearch-project.

the class BwcTests method setUpProfileResponse.

@SuppressWarnings("serial")
private void setUpProfileResponse() {
    String node1 = "node1";
    String nodeName1 = "nodename1";
    DiscoveryNode discoveryNode1_1 = new DiscoveryNode(nodeName1, node1, new TransportAddress(TransportAddress.META_ADDRESS, 9300), emptyMap(), emptySet(), V_1_1_0);
    String node2 = "node2";
    String nodeName2 = "nodename2";
    DiscoveryNode discoveryNode2 = new DiscoveryNode(nodeName2, node2, new TransportAddress(TransportAddress.META_ADDRESS, 9301), emptyMap(), emptySet(), V_1_1_0);
    String model1Id = "model1";
    String model2Id = "model2";
    Map<String, Long> modelSizeMap1 = new HashMap<String, Long>() {

        {
            put(model1Id, modelSize);
            put(model2Id, modelSize2);
        }
    };
    Map<String, Long> modelSizeMap2 = new HashMap<String, Long>();
    int shingleSize = 8;
    ModelProfile modelProfile = new ModelProfile(model1Id, entity, modelSize);
    ModelProfile modelProfile2 = new ModelProfile(model2Id, entity2, modelSize2);
    ProfileNodeResponse profileNodeResponse1 = new ProfileNodeResponse(discoveryNode1_1, modelSizeMap1, shingleSize, 0, 0, Arrays.asList(modelProfile, modelProfile2), modelSizeMap1.size());
    ProfileNodeResponse profileNodeResponse2 = new ProfileNodeResponse(discoveryNode2, modelSizeMap2, -1, 0, 0, new ArrayList<>(), modelSizeMap2.size());
    List<ProfileNodeResponse> profileNodeResponses = Arrays.asList(profileNodeResponse1, profileNodeResponse2);
    List<FailedNodeException> failures = Collections.emptyList();
    ClusterName clusterName = new ClusterName("test-cluster-name");
    profileResponse1_1 = new ProfileResponse(clusterName, profileNodeResponses, failures);
    ProfileNodeResponse1_0 profileNodeResponse1_1_0 = new ProfileNodeResponse1_0(discoveryNode1_1, modelSizeMap1, shingleSize, 0, 0);
    ProfileNodeResponse1_0 profileNodeResponse2_1_0 = new ProfileNodeResponse1_0(discoveryNode2, modelSizeMap2, -1, 0, 0);
    List<ProfileNodeResponse1_0> profileNodeResponses1_0 = Arrays.asList(profileNodeResponse1_1_0, profileNodeResponse2_1_0);
    profileResponse1_0 = new ProfileResponse1_0(clusterName, profileNodeResponses1_0, failures);
    convertedModelProfileOnNodeArray = new ModelProfileOnNode[2];
    ModelProfile convertedModelProfile1 = new ModelProfile(model1Id, null, modelSize);
    convertedModelProfileOnNodeArray[0] = new ModelProfileOnNode(CommonName.EMPTY_FIELD, convertedModelProfile1);
    ModelProfile convertedModelProfile2 = new ModelProfile(model2Id, null, modelSize2);
    convertedModelProfileOnNodeArray[1] = new ModelProfileOnNode(CommonName.EMPTY_FIELD, convertedModelProfile2);
    convertedModelProfile = new ModelProfile1_0[2];
    convertedModelProfile[0] = new ModelProfile1_0(model1Id, modelSize, CommonName.EMPTY_FIELD);
    convertedModelProfile[1] = new ModelProfile1_0(model2Id, modelSize2, CommonName.EMPTY_FIELD);
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) HashMap(java.util.HashMap) TransportAddress(org.opensearch.common.transport.TransportAddress) ModelProfileOnNode(org.opensearch.ad.model.ModelProfileOnNode) ProfileNodeResponse(org.opensearch.ad.transport.ProfileNodeResponse) EntityProfileResponse(org.opensearch.ad.transport.EntityProfileResponse) ProfileResponse(org.opensearch.ad.transport.ProfileResponse) ModelProfile(org.opensearch.ad.model.ModelProfile) ClusterName(org.opensearch.cluster.ClusterName) FailedNodeException(org.opensearch.action.FailedNodeException)

Example 4 with ProfileNodeResponse

use of org.opensearch.ad.transport.ProfileNodeResponse in project anomaly-detection by opensearch-project.

the class CardinalityProfileTests method setUpProfileAction.

@SuppressWarnings("unchecked")
private void setUpProfileAction() {
    doAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        ActionListener<ProfileResponse> listener = (ActionListener<ProfileResponse>) args[2];
        ProfileNodeResponse profileNodeResponse1 = new ProfileNodeResponse(discoveryNode1, new HashMap<>(), shingleSize, 0, 0, new ArrayList<>(), 0);
        List<ProfileNodeResponse> profileNodeResponses = Arrays.asList(profileNodeResponse1);
        listener.onResponse(new ProfileResponse(new ClusterName(clusterName), profileNodeResponses, Collections.emptyList()));
        return null;
    }).when(client).execute(eq(ProfileAction.INSTANCE), any(), any());
}
Also used : ActionListener(org.opensearch.action.ActionListener) ClusterName(org.opensearch.cluster.ClusterName) ProfileNodeResponse(org.opensearch.ad.transport.ProfileNodeResponse) ProfileResponse(org.opensearch.ad.transport.ProfileResponse)

Aggregations

ProfileNodeResponse (org.opensearch.ad.transport.ProfileNodeResponse)4 ProfileResponse (org.opensearch.ad.transport.ProfileResponse)4 ClusterName (org.opensearch.cluster.ClusterName)4 HashMap (java.util.HashMap)3 ActionListener (org.opensearch.action.ActionListener)3 FailedNodeException (org.opensearch.action.FailedNodeException)3 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)3 TransportAddress (org.opensearch.common.transport.TransportAddress)3 ProfileAction (org.opensearch.ad.transport.ProfileAction)2 ModelProfile (org.opensearch.ad.model.ModelProfile)1 ModelProfileOnNode (org.opensearch.ad.model.ModelProfileOnNode)1 EntityProfileResponse (org.opensearch.ad.transport.EntityProfileResponse)1