public EagleServiceQueryBuilder addReturnField(String field) throws EagleServiceClientException { if (field == null) { throw new EagleServiceClientException("field can't be null"); } List<String> returnFields = request.getReturnFields(); if (returnFields == null) { returnFields = new ArrayList<String>(); request.setReturnFields(returnFields); } if (!returnFields.contains(field)) { returnFields.add(field); } return this; }
public EagleServiceQueryBuilder setEndTime(long endTime) { request.setEndTime(endTime); return this; }
public EagleServiceQueryBuilder setStartTime(long startTime) { request.setStartTime(startTime); return this; }
public EagleServiceQueryBuilder addReturnTag(String tagKey) throws EagleServiceClientException { if (tagKey == null) { throw new EagleServiceClientException("tagKey can't be null"); } List<String> returnTags = request.getReturnTags(); if (returnTags == null) { returnTags = new ArrayList<String>(); request.setReturnTags(returnTags); } if (!returnTags.contains(tagKey)) { returnTags.add(tagKey); } return this; }
public EagleServiceQueryBuilder addSearchTag(String tagKey, String tagValue) throws EagleServiceClientException { if (tagKey == null || tagValue == null) { throw new EagleServiceClientException("tagKey or tagValue is null, tagKey: " + tagKey + ", tagValue: " + tagValue); } List<EagleServiceQueryRequest.Tag> searchTags = request.getSearchTags(); if (searchTags == null) { searchTags = new ArrayList<EagleServiceQueryRequest.Tag>(); request.setSearchTags(searchTags); } if (!containsTag(tagKey, tagValue)) { final EagleServiceQueryRequest.Tag tag = new EagleServiceQueryRequest.Tag(); tag.setKey(tagKey); tag.setValue(tagValue); searchTags.add(tag); } return this; }
public EagleServiceQueryBuilder setPageSize(int pageSize) throws EagleServiceClientException { if (pageSize <= 0) { throw new EagleServiceClientException("pageSize can't be less than 1"); } request.setPageSize(pageSize); return this; }
private boolean containsTag(String tagKey, String tagValue) { for (EagleServiceQueryRequest.Tag tag : request.getSearchTags()) { if (tag.getKey().equals(tagKey) && tag.getValue().equals(tagValue)) { return true; } } return false; } }
@Test public void testEagleQuery() throws Exception { EagleServiceQueryBuilder builder = new EagleServiceQueryBuilder(); builder.setStartTime(0).setEndTime(DateUtils.MILLIS_PER_DAY).setPageSize(Integer.MAX_VALUE).addReturnField("field1").addReturnField("field2") .addReturnTag("tag1").addSearchTag("tagKey", "tagValue"); EagleServiceQueryRequest request = builder.buildRequest(); Assert.assertEquals("pageSize=2147483647&startTime=1970-01-01%2000:00:00&endTime=1970-01-02%2000:00:00&tagNameValue=tagKey%3DtagValue&outputTag=tag1&outputField=field1&outputField=field2", request.getQueryParameterString()); }
public EagleServiceQueryBuilder addReturnTag(String tagKey) throws EagleServiceClientException { if (tagKey == null) { throw new EagleServiceClientException("tagKey can't be null"); } List<String> returnTags = request.getReturnTags(); if (returnTags == null) { returnTags = new ArrayList<String>(); request.setReturnTags(returnTags); } if (!returnTags.contains(tagKey)) { returnTags.add(tagKey); } return this; }
public EagleServiceQueryBuilder addSearchTag(String tagKey, String tagValue) throws EagleServiceClientException { if (tagKey == null || tagValue == null) { throw new EagleServiceClientException("tagKey or tagValue is null, tagKey: " + tagKey + ", tagValue: " + tagValue); } List<EagleServiceQueryRequest.Tag> searchTags = request.getSearchTags(); if (searchTags == null) { searchTags = new ArrayList<EagleServiceQueryRequest.Tag>(); request.setSearchTags(searchTags); } if (!containsTag(tagKey, tagValue)) { final EagleServiceQueryRequest.Tag tag = new EagleServiceQueryRequest.Tag(); tag.setKey(tagKey); tag.setValue(tagValue); searchTags.add(tag); } return this; }
public EagleServiceQueryBuilder setPageSize(int pageSize) throws EagleServiceClientException { if (pageSize <= 0) { throw new EagleServiceClientException("pageSize can't be less than 1"); } request.setPageSize(pageSize); return this; }
private boolean containsTag(String tagKey, String tagValue) { for (EagleServiceQueryRequest.Tag tag : request.getSearchTags()) { if (tag.getKey().equals(tagKey) && tag.getValue().equals(tagValue)) { return true; } } return false; } }
public EagleServiceQueryBuilder addReturnField(String field) throws EagleServiceClientException { if (field == null) { throw new EagleServiceClientException("field can't be null"); } List<String> returnFields = request.getReturnFields(); if (returnFields == null) { returnFields = new ArrayList<String>(); request.setReturnFields(returnFields); } if (!returnFields.contains(field)) { returnFields.add(field); } return this; }
public EagleServiceQueryBuilder setStartTime(long startTime) { request.setStartTime(startTime); return this; }
public EagleServiceQueryBuilder setEndTime(long endTime) { request.setEndTime(endTime); return this; }