use of org.apache.hadoop.hbase.hbtop.field.Field in project hbase by apache.
the class FieldScreenPresenter method arrowDown.
public void arrowDown() {
if (currentPosition < fields.size() - 1) {
currentPosition += 1;
if (moveMode) {
Field tmp = fields.remove(currentPosition - 1);
fields.add(currentPosition, tmp);
}
showField(currentPosition);
showField(currentPosition - 1);
fieldScreenView.refreshTerminal();
}
}
use of org.apache.hadoop.hbase.hbtop.field.Field in project hbase by apache.
the class RegionServerModeStrategy method getRecords.
@Override
public List<Record> getRecords(ClusterMetrics clusterMetrics, List<RecordFilter> pushDownFilters) {
// Get records from RegionModeStrategy and add REGION_COUNT field
List<Record> records = regionModeStrategy.selectModeFieldsAndAddCountField(fieldInfos, regionModeStrategy.getRecords(clusterMetrics, pushDownFilters), Field.REGION_COUNT);
// Aggregation by LONG_REGION_SERVER field
Map<String, Record> retMap = ModeStrategyUtils.aggregateRecords(records, Field.LONG_REGION_SERVER).stream().collect(Collectors.toMap(r -> r.get(Field.LONG_REGION_SERVER).asString(), r -> r));
// Add USED_HEAP_SIZE field and MAX_HEAP_SIZE field
for (ServerMetrics sm : clusterMetrics.getLiveServerMetrics().values()) {
Record record = retMap.get(sm.getServerName().getServerName());
if (record == null) {
continue;
}
Record newRecord = Record.builder().putAll(record).put(Field.USED_HEAP_SIZE, sm.getUsedHeapSize()).put(Field.MAX_HEAP_SIZE, sm.getMaxHeapSize()).build();
retMap.put(sm.getServerName().getServerName(), newRecord);
}
return new ArrayList<>(retMap.values());
}
use of org.apache.hadoop.hbase.hbtop.field.Field in project hbase by apache.
the class FieldScreenView method showFieldScreen.
public void showFieldScreen(String sortFieldHeader, List<Field> fields, EnumMap<Field, Boolean> fieldDisplayMap, int currentPosition, int headerMaxLength, int descriptionMaxLength, boolean moveMode) {
showScreenDescription(sortFieldHeader);
for (int i = 0; i < fields.size(); i++) {
Field field = fields.get(i);
showField(i, field, fieldDisplayMap.get(field), i == currentPosition, headerMaxLength, descriptionMaxLength, moveMode);
}
}
use of org.apache.hadoop.hbase.hbtop.field.Field in project hbase by apache.
the class ClientModeStrategy method aggregateRecordsAndAddDistinct.
/**
* Aggregate the records and count the unique values for the given distinctField
*
* @param records records to be processed
* @param groupBy Field on which group by needs to be done
* @param distinctField Field whose unique values needs to be counted
* @param uniqueCountAssignedTo a target field to which the unique count is assigned to
* @return aggregated records
*/
List<Record> aggregateRecordsAndAddDistinct(List<Record> records, Field groupBy, Field distinctField, Field uniqueCountAssignedTo) {
List<Record> result = new ArrayList<>();
records.stream().collect(Collectors.groupingBy(r -> r.get(groupBy))).values().forEach(val -> {
Set<FieldValue> distinctValues = new HashSet<>();
Map<Field, FieldValue> map = new HashMap<>();
for (Record record : val) {
for (Map.Entry<Field, FieldValue> field : record.entrySet()) {
if (distinctField.equals(field.getKey())) {
// We will not be adding the field in the new record whose distinct count is required
distinctValues.add(record.get(distinctField));
} else {
if (field.getKey().getFieldValueType() == FieldValueType.STRING) {
map.put(field.getKey(), field.getValue());
} else {
if (map.get(field.getKey()) == null) {
map.put(field.getKey(), field.getValue());
} else {
map.put(field.getKey(), map.get(field.getKey()).plus(field.getValue()));
}
}
}
}
}
// Add unique count field
map.put(uniqueCountAssignedTo, uniqueCountAssignedTo.newValue(distinctValues.size()));
result.add(Record.ofEntries(map.entrySet().stream().map(k -> Record.entry(k.getKey(), k.getValue()))));
});
return result;
}
use of org.apache.hadoop.hbase.hbtop.field.Field in project hbase by apache.
the class RecordFilter method parse.
/*
* Parse a filter string and build a RecordFilter instance.
*/
public static RecordFilter parse(String filterString, List<Field> fields, boolean ignoreCase) {
int index = 0;
boolean not = isNot(filterString);
if (not) {
index += 1;
}
StringBuilder fieldString = new StringBuilder();
while (filterString.length() > index && filterString.charAt(index) != '<' && filterString.charAt(index) != '>' && filterString.charAt(index) != '=') {
fieldString.append(filterString.charAt(index++));
}
if (fieldString.length() == 0 || filterString.length() == index) {
return null;
}
Field field = getField(fields, fieldString.toString());
if (field == null) {
return null;
}
StringBuilder operatorString = new StringBuilder();
while (filterString.length() > index && (filterString.charAt(index) == '<' || filterString.charAt(index) == '>' || filterString.charAt(index) == '=')) {
operatorString.append(filterString.charAt(index++));
}
Operator operator = getOperator(operatorString.toString());
if (operator == null) {
return null;
}
String value = filterString.substring(index);
FieldValue fieldValue = getFieldValue(field, value);
if (fieldValue == null) {
return null;
}
return new RecordFilter(ignoreCase, not, field, operator, fieldValue);
}
Aggregations