use of java.util.Collection in project storm by apache.
the class RAS_Node method intializeResources.
/**
* initializes resource usages on node
*/
private void intializeResources() {
for (Entry<String, Map<String, Collection<ExecutorDetails>>> entry : _topIdToUsedSlots.entrySet()) {
String topoId = entry.getKey();
Map<String, Collection<ExecutorDetails>> assignment = entry.getValue();
Map<ExecutorDetails, Double> topoMemoryResourceList = _topologies.getById(topoId).getTotalMemoryResourceList();
for (Collection<ExecutorDetails> execs : assignment.values()) {
for (ExecutorDetails exec : execs) {
if (!_isAlive) {
continue;
// We do not free the assigned slots (the orphaned slots) on the inactive supervisors
// The inactive node will be treated as a 0-resource node and not available for other unassigned workers
}
if (topoMemoryResourceList.containsKey(exec)) {
consumeResourcesforTask(exec, _topologies.getById(topoId));
} else {
throw new IllegalStateException("Executor " + exec + "not found!");
}
}
}
}
}
use of java.util.Collection in project hive by apache.
the class ObjectStore method getCurrentNotificationEventId.
@Override
public CurrentNotificationEventId getCurrentNotificationEventId() {
boolean commited = false;
Query query = null;
try {
openTransaction();
query = pm.newQuery(MNotificationNextId.class);
Collection<MNotificationNextId> ids = (Collection) query.execute();
long id = 0;
if (ids != null && ids.size() > 0) {
id = ids.iterator().next().getNextEventId() - 1;
}
commited = commitTransaction();
return new CurrentNotificationEventId(id);
} finally {
if (!commited) {
rollbackTransaction();
}
if (query != null) {
query.closeAll();
}
}
}
use of java.util.Collection in project hive by apache.
the class ObjectStore method getDatabases.
@Override
public List<String> getDatabases(String pattern) throws MetaException {
if (pattern == null || pattern.equals("*")) {
return getAllDatabases();
}
boolean commited = false;
List<String> databases = null;
Query query = null;
try {
openTransaction();
// Take the pattern and split it on the | to get all the composing
// patterns
String[] subpatterns = pattern.trim().split("\\|");
String queryStr = "select name from org.apache.hadoop.hive.metastore.model.MDatabase where (";
boolean first = true;
for (String subpattern : subpatterns) {
subpattern = "(?i)" + subpattern.replaceAll("\\*", ".*");
if (!first) {
queryStr = queryStr + " || ";
}
queryStr = queryStr + " name.matches(\"" + subpattern + "\")";
first = false;
}
queryStr = queryStr + ")";
query = pm.newQuery(queryStr);
query.setResult("name");
query.setOrdering("name ascending");
Collection names = (Collection) query.execute();
databases = new ArrayList<String>();
for (Iterator i = names.iterator(); i.hasNext(); ) {
databases.add((String) i.next());
}
commited = commitTransaction();
} finally {
if (!commited) {
rollbackTransaction();
}
if (query != null) {
query.closeAll();
}
}
return databases;
}
use of java.util.Collection in project hive by apache.
the class ObjectStore method getAllDatabases.
@Override
public List<String> getAllDatabases() throws MetaException {
boolean commited = false;
List<String> databases = null;
String queryStr = "select name from org.apache.hadoop.hive.metastore.model.MDatabase";
Query query = null;
openTransaction();
try {
query = pm.newQuery(queryStr);
query.setResult("name");
databases = new ArrayList<String>((Collection<String>) query.execute());
commited = commitTransaction();
} finally {
if (!commited) {
rollbackTransaction();
}
if (query != null) {
query.closeAll();
}
}
Collections.sort(databases);
return databases;
}
use of java.util.Collection in project hive by apache.
the class ObjectStore method getTables.
@Override
public List<String> getTables(String dbName, String pattern, TableType tableType) throws MetaException {
boolean commited = false;
Query query = null;
List<String> tbls = null;
try {
openTransaction();
dbName = HiveStringUtils.normalizeIdentifier(dbName);
// Take the pattern and split it on the | to get all the composing
// patterns
String[] subpatterns = pattern.trim().split("\\|");
String queryStr = "select tableName from org.apache.hadoop.hive.metastore.model.MTable " + "where database.name == dbName && (";
boolean first = true;
for (String subpattern : subpatterns) {
subpattern = "(?i)" + subpattern.replaceAll("\\*", ".*");
if (!first) {
queryStr = queryStr + " || ";
}
queryStr = queryStr + " tableName.matches(\"" + subpattern + "\")";
first = false;
}
queryStr = queryStr + ")";
if (tableType != null) {
queryStr = queryStr + " && tableType.matches(\"" + tableType.toString() + "\")";
}
query = pm.newQuery(queryStr);
query.declareParameters("java.lang.String dbName");
query.setResult("tableName");
query.setOrdering("tableName ascending");
Collection names = (Collection) query.execute(dbName);
tbls = new ArrayList<String>();
for (Iterator i = names.iterator(); i.hasNext(); ) {
tbls.add((String) i.next());
}
commited = commitTransaction();
} finally {
if (!commited) {
rollbackTransaction();
}
if (query != null) {
query.closeAll();
}
}
return tbls;
}
Aggregations