Search in sources :

Example 91 with LinkedHashMap

use of java.util.LinkedHashMap in project hazelcast by hazelcast.

the class QueueContainer method clear.

public Map<Long, Data> clear() {
    long current = Clock.currentTimeMillis();
    LinkedHashMap<Long, Data> map = new LinkedHashMap<Long, Data>(getItemQueue().size());
    for (QueueItem item : getItemQueue()) {
        map.put(item.getItemId(), item.getData());
        // For stats
        age(item, current);
    }
    if (store.isEnabled() && !map.isEmpty()) {
        try {
            store.deleteAll(map.keySet());
        } catch (Exception e) {
            throw new HazelcastException(e);
        }
    }
    getItemQueue().clear();
    dataMap.clear();
    scheduleEvictionIfEmpty();
    return map;
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Data(com.hazelcast.nio.serialization.Data) TxQueueItem(com.hazelcast.collection.impl.txnqueue.TxQueueItem) TransactionException(com.hazelcast.transaction.TransactionException) HazelcastException(com.hazelcast.core.HazelcastException) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap)

Example 92 with LinkedHashMap

use of java.util.LinkedHashMap in project hazelcast by hazelcast.

the class QueueContainer method drain.

/**
     * Removes items from the queue and the queue store (if configured), up to {@code maxSize} or the size of the queue,
     * whichever is smaller. Also schedules the queue for destruction if it is empty or destroys it immediately if it is
     * empty and {@link QueueConfig#getEmptyQueueTtl()} is 0.
     *
     * @param maxSize the maximum number of items to be removed
     * @return the map of IDs and removed (drained) items
     */
public Map<Long, Data> drain(int maxSize) {
    int maxSizeParam = maxSize;
    if (maxSizeParam < 0 || maxSizeParam > getItemQueue().size()) {
        maxSizeParam = getItemQueue().size();
    }
    final LinkedHashMap<Long, Data> map = new LinkedHashMap<Long, Data>(maxSizeParam);
    mapDrainIterator(maxSizeParam, map);
    if (store.isEnabled() && maxSizeParam != 0) {
        try {
            store.deleteAll(map.keySet());
        } catch (Exception e) {
            throw new HazelcastException(e);
        }
    }
    long current = Clock.currentTimeMillis();
    for (int i = 0; i < maxSizeParam; i++) {
        final QueueItem item = getItemQueue().poll();
        //For Stats
        age(item, current);
    }
    if (maxSizeParam != 0) {
        scheduleEvictionIfEmpty();
    }
    return map;
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Data(com.hazelcast.nio.serialization.Data) TxQueueItem(com.hazelcast.collection.impl.txnqueue.TxQueueItem) TransactionException(com.hazelcast.transaction.TransactionException) HazelcastException(com.hazelcast.core.HazelcastException) IOException(java.io.IOException) LinkedHashMap(java.util.LinkedHashMap)

Example 93 with LinkedHashMap

use of java.util.LinkedHashMap in project Gaffer by gchq.

the class MapGeneratorTest method shouldGenerateAnEmptyMap.

@Test
public void shouldGenerateAnEmptyMap() {
    // Given
    final Object vertex = "source vertex";
    final String prop1 = "property 1";
    final int count = 10;
    final Element element = new Entity.Builder().group(TestGroups.ENTITY).vertex(vertex).property(TestPropertyNames.PROP_1, prop1).property(TestPropertyNames.COUNT, count).build();
    final MapGenerator generator = new MapGenerator();
    // When
    final Map<String, Object> map = generator.getObject(element);
    // Then
    final Map<String, Object> expectedMap = new LinkedHashMap<>();
    assertEquals(expectedMap, map);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) MapGenerator(uk.gov.gchq.gaffer.data.generator.MapGenerator) Element(uk.gov.gchq.gaffer.data.element.Element) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 94 with LinkedHashMap

use of java.util.LinkedHashMap in project hazelcast by hazelcast.

the class ClientClusterServiceImpl method handleInitialMembershipEvent.

void handleInitialMembershipEvent(InitialMembershipEvent event) {
    synchronized (initialMembershipListenerMutex) {
        Set<Member> initialMembers = event.getMembers();
        LinkedHashMap<Address, Member> newMap = new LinkedHashMap<Address, Member>();
        for (Member initialMember : initialMembers) {
            newMap.put(initialMember.getAddress(), initialMember);
        }
        members.set(Collections.unmodifiableMap(newMap));
        fireInitialMembershipEvent(event);
    }
}
Also used : Address(com.hazelcast.nio.Address) InetSocketAddress(java.net.InetSocketAddress) Member(com.hazelcast.core.Member) LinkedHashMap(java.util.LinkedHashMap)

Example 95 with LinkedHashMap

use of java.util.LinkedHashMap in project Lifecycle-Sorter by armandAkop.

the class Lifecycle method sort.

/**
     * Sorts the lifecycle methods provided
     * @return A Map of the method names and entire method definitions, respecting the
     * sort order of mLifecycleOrdering
     */
public Map<String, PsiMethod> sort() {
    // LinkedHashMap because we must respect the ordering in which we insert
    Map<String, PsiMethod> sortedMethods = new LinkedHashMap<String, PsiMethod>();
    for (int i = 0; i < mLifecycleOrdering.size(); i++) {
        String methodName = mLifecycleOrdering.get(i);
        PsiMethod method = mAllMethods.get(methodName);
        if (method != null) {
            sortedMethods.put(methodName, method);
        }
    }
    return sortedMethods;
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2398 Map (java.util.Map)691 ArrayList (java.util.ArrayList)675 HashMap (java.util.HashMap)439 Test (org.junit.Test)317 List (java.util.List)298 IOException (java.io.IOException)152 HashSet (java.util.HashSet)128 Set (java.util.Set)110 LinkedHashSet (java.util.LinkedHashSet)100 File (java.io.File)93 LinkedList (java.util.LinkedList)75 TreeMap (java.util.TreeMap)72 Node (org.apache.hadoop.hive.ql.lib.Node)70 NodeProcessor (org.apache.hadoop.hive.ql.lib.NodeProcessor)68 Rule (org.apache.hadoop.hive.ql.lib.Rule)68 GraphWalker (org.apache.hadoop.hive.ql.lib.GraphWalker)66 Dispatcher (org.apache.hadoop.hive.ql.lib.Dispatcher)65 Iterator (java.util.Iterator)64 DefaultRuleDispatcher (org.apache.hadoop.hive.ql.lib.DefaultRuleDispatcher)64