Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap$Entry


    private String queuePrefix = "queue.";
    private String topicPrefix = "topic.";

    public Context getInitialContext(Hashtable environment) throws NamingException {
        // lets create a factory
        Map data = new ConcurrentHashMap();
        Broker broker = null;
       
        String[] names = getConnectionFactoryNames(environment);
        for (int i = 0; i < names.length; i++) {
           
            String name = names[i];
            ActiveMQConnectionFactory factory = createConnectionFactory(name, environment);
           
            if( broker==null ) {
                try {
                    broker = factory.getEmbeddedBroker();
                }
                catch (JMSException e) {
                    log.warn("Failed to get embedded broker", e);
                }
            }
            data.put(name,factory);
        }
               
        createQueues(data, environment);
        createTopics(data, environment);
        if (broker != null) {
            data.put("destinations", broker.getDestinationContext(environment));
        }

        data.put("dynamicQueues", new LazyCreateContext() {
            protected Object createEntry(String name) {
                return new ActiveMQQueue(name);
            }
        });
        data.put("dynamicTopics", new LazyCreateContext() {
            protected Object createEntry(String name) {
                return new ActiveMQTopic(name);
            }
        });
View Full Code Here


        String ProdSequenceNo = null;
        String mapKey = null;
        int expectedNoOfMessages = ConsumerSysTest.noOfMessages;
        int consumerCount = ConsumerSysTest.ConsumerCount;
        boolean dowhile = true;
        Map consumerMap = new ConcurrentHashMap();
        Map prodNameMap = new TreeMap();
        Map prodMsgMap = new TreeMap();

        while (dowhile) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            ConsumerSysTest consumer = new ConsumerSysTest();
            currentProducerMap = Collections.synchronizedMap(consumer.resetProducerMap());
//System.out.println("CURR MAP = " + currentProducerMap);           
//            ConsumerSysTest.ProducerMap.clear();

            if (currentProducerMap.size() == 0) {
                dowhile = false;
            }

            // Put the map values to another map for parsing.
            for (int i = 1; i <= currentProducerMap.size(); i++) {
                String ProdMsg = (String) currentProducerMap.get(String.valueOf(i));
//System.out.println("");
                ProducerName = ProdMsg.substring(0, ProdMsg.indexOf("#"));
                MsgBody = ProdMsg.substring(ProdMsg.indexOf("#")+1,  ProdMsg.indexOf("#", ProdMsg.indexOf("#")+1));
                ProdSequenceNo = ProdMsg.substring(ProdMsg.indexOf("#", ProdMsg.indexOf("#", ProdMsg.indexOf("#")+1)) + 1, ProdMsg.lastIndexOf("#"));
                ConsumerName = ProdMsg.substring(ProdMsg.lastIndexOf("#") +1, ProdMsg.length());

                if (ConsumerSysTest.destination) {
                    mapKey = ConsumerName + ProducerName;
                } else {
                    mapKey = ProducerName;
                }

                if (ProducerTextMap.containsKey(mapKey)) {
                    // Increment the counter value
                    Integer value = (Integer) ProducerTextMap.get(mapKey);

                    ProducerTextMap.put(mapKey, new Integer(value.intValue()+1));
                } else {
                    // Put the Producer Name in the map
                    ProducerTextMap.put(mapKey, new Integer(1));
                }

                Integer ConsumerSeqID = (Integer) ProducerTextMap.get(mapKey);
                Integer ProducerSeqID = Integer.valueOf(ProdSequenceNo);

                if (ConsumerSysTest.destination) {
                    // Check for duplicate message.
                    if (ConsumerSeqID.intValue() > expectedNoOfMessages) {
                        messageField.setText(JMeterUtils.getResString("duplicate_message"));
                    } else if (MsgBody.equals(ProducerSysTest.LAST_MESSAGE)) {
                        // Check for message order.
                        if (ConsumerSeqID.intValue() != expectedNoOfMessages) {
                            messageField.setText(JMeterUtils.getResString("not_in_order_message"));
                        } else if (currentProducerMap.size() == i) {
                            if (messageField.getText().length() == 0) {
                                messageField.setText(JMeterUtils.getResString("system_test_pass"));
                            }
                        }
                    }
                } else {
                    //Create map for each consumer
                    for (int j = 0 ; j < consumerCount ; j++) {
                        if (!consumerMap.containsKey(new String(ConsumerName))) {
                            consumerMap.put(new String(ConsumerName), new LinkedHashMap());
                        }
                    }

                    //create Producer Name Map
                    if (!prodNameMap.containsKey(ProducerName)) {
                        prodNameMap.put(ProducerName, (null));
                    }

                    //Get the current size of consumer
                    int seqVal = 0;
                    Object[] cObj = consumerMap.keySet().toArray();
                    for (int k = 0; k < cObj.length; k++) {
                        String cMapKey = (String)cObj[k];
                        Map cMapVal = (Map)consumerMap.get(cObj[k]);
                        if (cMapKey.equals(ConsumerName)) {
                            seqVal = cMapVal.size();
                            break;
                        }
                    }

                    //Put object to its designated consumer map
                    Object[] consumerObj = consumerMap.keySet().toArray();
                    for (int j = 0; j < consumerObj.length; j++) {
                        String cMapKey = (String)consumerObj[j];
                        Map cMapVal = (LinkedHashMap)consumerMap.get(consumerObj[j]);
                        if (cMapKey.equals(ConsumerName)) {
                            cMapVal.put(new Integer(seqVal), (ProducerName + "/" + ProducerSeqID));
                        }
                    }
                }
View Full Code Here

    /**
     *
     * @return Resets the Producer map.
     */
    public synchronized  Map resetProducerMap() {
        Map copy = Collections.synchronizedMap(new ConcurrentHashMap(ProducerMap));
        ProducerMap.clear();
        msgCounter = 0;
        return copy;
    }
View Full Code Here

    boolean transactional = this instanceof XAConnection;
    factoryStats = factory.getFactoryStats();
    factoryStats.addConnection(this);
    stats = new JMSConnectionStatsImpl(sessions, transactional);
    this.transientConsumedRedeliverCache = new CopyOnWriteArrayList();
    this.tempDestinationMap = new ConcurrentHashMap();
    this.validDestinationsMap = new ConcurrentHashMap();
    factory.onConnectionCreate(this);
  }
View Full Code Here

            log.trace(this + " sending ping to server. Currently managing lease " +
               "for following clients:\n" + sb.toString());
         }

         Map clientsClone = new ConcurrentHashMap(clients);
         Map requestClients = new ConcurrentHashMap();
         requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone);

         InvocationRequest ir =
            new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null);

         invoker.invoke(ir);
View Full Code Here

    private String queuePrefix = "queue.";
    private String topicPrefix = "topic.";

    public Context getInitialContext(Hashtable environment) throws NamingException {
        // lets create a factory
        Map data = new ConcurrentHashMap();
        ActiveMQConnectionFactory factory = createConnectionFactory(environment);

        String[] names = getConnectionFactoryNames(environment);
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            data.put(name, factory);
        }
       
        // Bind jms/DURABLE_SUB_CONNECTION_FACTORY to be a ConnectionFactory that can be used for durable subscriptions.
        ActiveMQConnectionFactory durableFactory = createDurableConnectionFactory(environment);
        Map jmsContext = new ConcurrentHashMap();
        jmsContext.put("DURABLE_SUB_CONNECTION_FACTORY", durableFactory);
        data.put("jms", new ReadOnlyContext(environment, jmsContext));

        createQueues(data, environment);
        createTopics(data, environment);
View Full Code Here

      synchronized (replicatedData)
      {
         copy = copyReplicatedData(replicatedData);
      }

      SharedState state = new SharedState(list, copy, new ConcurrentHashMap(nodeIDAddressMap));

      return StreamUtils.toBytes(state);
   }
View Full Code Here

     
      nameMaps = new HashMap();
     
      channelIDMap = new HashMap();
     
      nodeIDAddressMap = new ConcurrentHashMap();          
     
      if (clustered)
      {
        replicatedData = new HashMap();

         failoverMap = new ConcurrentHashMap();

         leftSet = new ConcurrentHashSet();
      }
     
      //NOTE, MUST be a QueuedExecutor so we ensure that responses arrive back in order
View Full Code Here

    
     Map ids = (Map)recoveryArea.get(nid);
    
     if (ids == null)
     {
       ids = new ConcurrentHashMap();
      
       recoveryArea.put(nid, ids);
     }
    
     ids.put(new Long(messageID), sessionID);
View Full Code Here

    
     Integer nid = new Integer(nodeID);
            
     if (!(ids instanceof ConcurrentHashMap))
     {
       ids = new ConcurrentHashMap(ids);
     }
    
     if (trace) { log.trace("Adding " + ids.size() + " ids to recovery area for node " + nodeID); }
    
     recoveryArea.put(nid, ids);
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap$Entry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.