Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
feat(log): Request /response analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
brasseld committed May 11, 2017
1 parent 76839c0 commit e8de616
Show file tree
Hide file tree
Showing 6 changed files with 461 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.gravitee.repository.analytics.query.count.CountQueryBuilder;
import io.gravitee.repository.analytics.query.groupby.GroupByQueryBuilder;
import io.gravitee.repository.analytics.query.tabular.TabularQueryBuilder;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
Expand All @@ -35,4 +36,8 @@ public static GroupByQueryBuilder groupBy() {
public static CountQueryBuilder count() {
return CountQueryBuilder.query();
}

public static TabularQueryBuilder tabular() {
return TabularQueryBuilder.query();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.analytics.query.tabular;

import io.gravitee.repository.analytics.query.AbstractQuery;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
*/
public class TabularQuery extends AbstractQuery<TabularResponse> {

private int size = 20;

private int page = 0;

@Override
public Class<TabularResponse> responseType() {
return TabularResponse.class;
}

public int size() {
return size;
}

void size(int size) {
this.size = size;
}

public int page() {
return page;
}

void page(int page) {
this.page = page;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.analytics.query.tabular;

import io.gravitee.repository.analytics.query.AbstractQueryBuilder;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
*/
public class TabularQueryBuilder extends AbstractQueryBuilder<TabularQueryBuilder, TabularQuery> {

protected TabularQueryBuilder(TabularQuery query) {
super(query);
}

public static TabularQueryBuilder query() {
return new TabularQueryBuilder(new TabularQuery());
}

public TabularQueryBuilder page(int page) {
query.page(page);
return this;
}

public TabularQueryBuilder size(int size) {
query.size(size);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.analytics.query.tabular;

import io.gravitee.repository.log.model.Request;
import io.gravitee.repository.analytics.query.response.Response;

import java.util.List;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
*/
public class TabularResponse implements Response {

private final long total;

public TabularResponse(long total) {
this.total = total;
}

private List<Request> requests;

public List<Request> getRequests() {
return requests;
}

public void setRequests(List<Request> requests) {
this.requests = requests;
}

public long getSize() {
return total;
}
}
32 changes: 32 additions & 0 deletions src/main/java/io/gravitee/repository/log/api/LogRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.log.api;

import io.gravitee.repository.analytics.AnalyticsException;
import io.gravitee.repository.analytics.query.tabular.TabularQuery;
import io.gravitee.repository.analytics.query.tabular.TabularResponse;
import io.gravitee.repository.log.model.Request;

/**
* @author David BRASSELY (david.brassely at graviteesource.com)
* @author GraviteeSource Team
*/
public interface LogRepository {

TabularResponse query(TabularQuery query) throws AnalyticsException;

Request findById(String requestId) throws AnalyticsException;
}
Loading

0 comments on commit e8de616

Please sign in to comment.