Search in sources :

Example 86 with Collection

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!");
                }
            }
        }
    }
}
Also used : ExecutorDetails(org.apache.storm.scheduler.ExecutorDetails) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map)

Example 87 with Collection

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();
        }
    }
}
Also used : Query(javax.jdo.Query) MNotificationNextId(org.apache.hadoop.hive.metastore.model.MNotificationNextId) Collection(java.util.Collection) CurrentNotificationEventId(org.apache.hadoop.hive.metastore.api.CurrentNotificationEventId)

Example 88 with Collection

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;
}
Also used : Query(javax.jdo.Query) Iterator(java.util.Iterator) Collection(java.util.Collection)

Example 89 with Collection

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;
}
Also used : Query(javax.jdo.Query) Collection(java.util.Collection)

Example 90 with Collection

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;
}
Also used : Query(javax.jdo.Query) Iterator(java.util.Iterator) Collection(java.util.Collection)

Aggregations

Collection (java.util.Collection)2848 ArrayList (java.util.ArrayList)801 Map (java.util.Map)581 Test (org.junit.Test)537 HashMap (java.util.HashMap)479 List (java.util.List)387 Iterator (java.util.Iterator)325 HashSet (java.util.HashSet)279 IOException (java.io.IOException)258 Set (java.util.Set)250 File (java.io.File)114 Collectors (java.util.stream.Collectors)95 LinkedHashMap (java.util.LinkedHashMap)90 LinkedList (java.util.LinkedList)82 Test (org.testng.annotations.Test)78 NotNull (org.jetbrains.annotations.NotNull)75 Region (org.apache.geode.cache.Region)71 Collections (java.util.Collections)67 Field (java.lang.reflect.Field)65 Logger (org.slf4j.Logger)63