Get Datafeed APIedit

The Get Datafeed API provides the ability to get machine learning datafeeds in the cluster. It accepts a GetDatafeedRequest object and responds with a GetDatafeedResponse object.

Get Datafeed Requestedit

A GetDatafeedRequest object gets can have any number of datafeedId entries. However, they all must be non-null. An empty list is the same as requesting for all datafeeds.

GetDatafeedRequest request = new GetDatafeedRequest(datafeedId); 
request.setAllowNoDatafeeds(true); 

Constructing a new request referencing existing datafeedIds, can contain wildcards

Whether to ignore if a wildcard expression matches no datafeeds. (This includes _all string or when no datafeeds have been specified)

Get Datafeed Responseedit

long numberOfDatafeeds = response.count(); 
List<DatafeedConfig> datafeeds = response.datafeeds(); 

The count of retrieved datafeeds

The retrieved datafeeds

Synchronous Executionedit

When executing a GetDatafeedRequest in the following manner, the client waits for the GetDatafeedResponse to be returned before continuing with code execution:

GetDatafeedResponse response = client.machineLearning().getDatafeed(request, RequestOptions.DEFAULT);

Asynchronous Executionedit

Executing a GetDatafeedRequest can also be done in an asynchronous fashion so that the client can return directly. Users need to specify how the response or potential failures will be handled by passing the request and a listener to the asynchronous get-datafeed method:

client.machineLearning().getDatafeedAsync(request, RequestOptions.DEFAULT, listener); 

The GetDatafeedRequest to execute and the ActionListener to use when the execution completes

The asynchronous method does not block and returns immediately. Once it is completed the ActionListener is called back using the onResponse method if the execution successfully completed or using the onFailure method if it failed.

A typical listener for get-datafeed looks like:

ActionListener<GetDatafeedResponse> listener = new ActionListener<GetDatafeedResponse>() {
    @Override
    public void onResponse(GetDatafeedResponse response) {
        
    }

    @Override
    public void onFailure(Exception e) {
        
    }
};

Called when the execution is successfully completed.

Called when the whole GetDatafeedRequest fails.