-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
310 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
web/src/main/java/com/navercorp/pinpoint/web/dao/hbase/AgentEventFilterBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.navercorp.pinpoint.web.dao.hbase; | ||
|
||
import com.navercorp.pinpoint.common.server.util.AgentEventType; | ||
import com.navercorp.pinpoint.common.util.CollectionUtils; | ||
import com.navercorp.pinpoint.web.service.component.AgentEventQuery; | ||
import org.apache.hadoop.hbase.CompareOperator; | ||
import org.apache.hadoop.hbase.filter.BinaryComparator; | ||
import org.apache.hadoop.hbase.filter.Filter; | ||
import org.apache.hadoop.hbase.filter.FilterList; | ||
import org.apache.hadoop.hbase.filter.QualifierFilter; | ||
import org.apache.hadoop.hbase.util.Bytes; | ||
|
||
import java.util.Set; | ||
|
||
public class AgentEventFilterBuilder { | ||
|
||
public AgentEventFilterBuilder() { | ||
|
||
} | ||
|
||
public Filter queryToFilter(AgentEventQuery query) { | ||
return switch (query.getQueryType()) { | ||
case INCLUDE -> includeFilter(query.getEventTypes()); | ||
case EXCLUDE -> excludeFilter(query.getEventTypes()); | ||
case ALL -> null; | ||
}; | ||
} | ||
|
||
public Filter excludeFilter(Set<AgentEventType> excludeEventTypes) { | ||
if (CollectionUtils.isEmpty(excludeEventTypes)) { | ||
return null; | ||
} | ||
if (excludeEventTypes.size() == 1) { | ||
AgentEventType event = excludeEventTypes.iterator().next(); | ||
return excludeQualifierFilter(event); | ||
} | ||
|
||
final FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL); | ||
for (AgentEventType excludeEventType : excludeEventTypes) { | ||
Filter filter = excludeQualifierFilter(excludeEventType); | ||
filterList.addFilter(filter); | ||
} | ||
return filterList; | ||
} | ||
|
||
private Filter excludeQualifierFilter(AgentEventType excludeEventType) { | ||
byte[] excludeQualifier = Bytes.toBytes(excludeEventType.getCode()); | ||
return new QualifierFilter(CompareOperator.NOT_EQUAL, new BinaryComparator(excludeQualifier)); | ||
} | ||
|
||
public Filter includeFilter(Set<AgentEventType> includeEventTypes) { | ||
if (CollectionUtils.isEmpty(includeEventTypes)) { | ||
return null; | ||
} | ||
if (includeEventTypes.size() == 1) { | ||
AgentEventType event = includeEventTypes.iterator().next(); | ||
return includeFilter(event); | ||
} | ||
|
||
final FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE); | ||
for (AgentEventType excludeEventType : includeEventTypes) { | ||
Filter filter = includeFilter(excludeEventType); | ||
filterList.addFilter(filter); | ||
} | ||
return filterList; | ||
} | ||
|
||
private Filter includeFilter(AgentEventType excludeEventType) { | ||
byte[] excludeQualifier = Bytes.toBytes(excludeEventType.getCode()); | ||
return new QualifierFilter(CompareOperator.EQUAL, new BinaryComparator(excludeQualifier)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.