use of org.smartdata.metastore.dao.AccessCountTable in project SSM by Intel-bigdata.
the class RuleExecutor method getAccessCountTablesDuringLast.
/**
* @param lastInterval
* @return
*/
private List<String> getAccessCountTablesDuringLast(long lastInterval) {
List<String> tableNames = new ArrayList<>();
if (ruleManager == null || ruleManager.getStatesManager() == null) {
return tableNames;
}
List<AccessCountTable> accTables = null;
try {
accTables = ruleManager.getStatesManager().getTablesInLast(lastInterval);
} catch (MetaStoreException e) {
LOG.error("Rule " + ctx.getRuleId() + " get access info tables exception", e);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Rule " + ctx.getRuleId() + " got " + accTables.size() + " tables:");
int idx = 1;
for (AccessCountTable t : accTables) {
LOG.debug(idx + ". " + (t.isEphemeral() ? " [TABLE] " : " ") + t.getTableName() + " ");
}
}
if (accTables == null || accTables.size() == 0) {
return tableNames;
}
for (AccessCountTable t : accTables) {
tableNames.add(t.getTableName());
if (t.isEphemeral()) {
dynamicCleanups.push("DROP TABLE IF EXISTS " + t.getTableName() + ";");
}
}
return tableNames;
}
use of org.smartdata.metastore.dao.AccessCountTable in project SSM by Intel-bigdata.
the class MetaStore method getHotFiles.
public List<FileAccessInfo> getHotFiles(List<AccessCountTable> tables, int topNum) throws MetaStoreException {
Iterator<AccessCountTable> tableIterator = tables.iterator();
if (tableIterator.hasNext()) {
try {
Map<Long, Integer> accessCounts = accessCountDao.getHotFiles(tables, topNum);
if (accessCounts.size() == 0) {
return new ArrayList<>();
}
Map<Long, String> idToPath = getFilePaths(accessCounts.keySet());
List<FileAccessInfo> result = new ArrayList<>();
for (Map.Entry<Long, Integer> entry : accessCounts.entrySet()) {
Long fid = entry.getKey();
if (idToPath.containsKey(fid) && entry.getValue() > 0) {
result.add(new FileAccessInfo(fid, idToPath.get(fid), entry.getValue()));
}
}
return result;
} catch (EmptyResultDataAccessException e) {
return new ArrayList<>();
} catch (Exception e) {
throw new MetaStoreException(e);
} finally {
for (AccessCountTable accessCountTable : tables) {
if (accessCountTable.isEphemeral()) {
this.dropTable(accessCountTable.getTableName());
}
}
}
} else {
return new ArrayList<>();
}
}
Aggregations