Package org.apache.commons.collections.map

Examples of org.apache.commons.collections.map.MultiValueMap


                // First, create the HashMap,
                avas = new ArrayList<Ava>();

                // and store the existing Ava into it.
                avas.add( ava );
                avaTypes = new MultiValueMap();
                avaTypes.put( avaType, ava );

                this.ava = null;

                // Now, fall down to the commmon case
View Full Code Here


                    rdn.avaTypes = avaTypes;
                    break;

                default:
                    // We must duplicate the treeSet and the hashMap
                    rdn.avaTypes = new MultiValueMap();
                    rdn.avas = new ArrayList<Ava>();

                    for ( Ava currentAva : this.avas )
                    {
                        rdn.avas.add( (Ava) currentAva.clone() );
View Full Code Here

                break;

            default:
                avas = new ArrayList<Ava>();

                avaTypes = new MultiValueMap();

                for ( int i = 0; i < nbAvas; i++ )
                {
                    Ava ava = new Ava( schemaManager );
                    ava.readExternal( in );
View Full Code Here

  MultiValueMap multipleHits;
  HashMap<String, Node> children;

  Node() {
    uniqueHits = new HashMap<String, DNSServer>();
    multipleHits = new MultiValueMap();
    children = new HashMap<String, Node>();
  }
View Full Code Here

        //If a query is not supported, then skip it
        if (!this.allQueries[queryIndex].isSupportedByLibrary(this.DNS_LIB)) {
          continue;
        }

        MultiValueMap nodeChildrenGroupedByResponse = new MultiValueMap();
        for (Object server : serverList) {
          String rsp = ((DNSServer) server).responses[queryIndex];

          rsp = QueryTree.normalizeResponseString(rsp);

          nodeChildrenGroupedByResponse.put(rsp, server);
        }
        //If query can split the group of servers, set up a new child node using the query
        //TODO: Instead of using the first query that can split the servers, use the best ?
        if (nodeChildrenGroupedByResponse.keySet().size() > 1) {
          //System.out.println("Query "+queryIndex+" splits response "+response+" of query "+cur.query+ " into "+nodeChildrenGroupedByResponse.keySet().size() + " parts");

          Node childNode = new Node();
          childNode.query = queryIndex;
          for (Object childResponse : nodeChildrenGroupedByResponse.keySet()) {
            List childServerList = (List) nodeChildrenGroupedByResponse.get(childResponse);
            if (childServerList.size() == 1) {
              childNode.uniqueHits.put((String) childResponse, (DNSServer) childServerList.get(0));
            }
          }

          //Remove the unique-hits from the list of all hits and what remains is multiple hits
          for (Object r : childNode.uniqueHits.keySet()) {
            nodeChildrenGroupedByResponse.remove(r);
          }

          childNode.multipleHits = nodeChildrenGroupedByResponse;
          //cur.multipleHits.remove(response);
          cur.children.put((String) response, childNode);
View Full Code Here

   * @return an array of queries that will return unique responses
   */
  static int[] getUniqueQueries(int numServers, DNSServer servers[]) {
    int queries[];
    //Group identical rows together
    MultiValueMap groupedMatrixRows = new MultiValueMap();
    StringBuilder sb = null;
    for (int i = 0; i < NUM_RESPONSES; i++) {
      sb = new StringBuilder(servers[0].responses[i]);
      for (int j = 1; j < numServers; j++) {
        sb.append(servers[j].responses[i]);
      }
      groupedMatrixRows.put(sb.toString(), i);
    }

    //Get the unique row indexes.
    Set matrixRows = groupedMatrixRows.keySet();
    queries = new int[matrixRows.size()];
    int curQ = 0;
    for (Object matrixRow : matrixRows) {
      queries[curQ] = (Integer) ((List) groupedMatrixRows.get((String) matrixRow)).get(0);
      curQ++;
    }

    return queries;
  }
View Full Code Here

  }

  void replayLog(List<File> logs) throws IOException {
    int total = 0;
    int count = 0;
    MultiMap transactionMap = new MultiValueMap();
    LOG.info("Starting replay of " + logs);
    for (File log : logs) {
      LOG.info("Replaying " + log);
      LogFile.SequentialReader reader = null;
      try {
        reader = new LogFile.SequentialReader(log);
        Pair<Integer, TransactionEventRecord> entry;
        FlumeEventPointer ptr;
        // for puts the fileId is the fileID of the file they exist in
        // for takes the fileId and offset are pointers to a put
        int fileId = reader.getLogFileID();
        while ((entry = reader.next()) != null) {
          int offset = entry.getLeft();
          TransactionEventRecord record = entry.getRight();
          short type = record.getRecordType();
          long trans = record.getTransactionID();
          if (LOG.isDebugEnabled()) {
            LOG.debug("record.getTimestamp() = " + record.getTimestamp()
                + ", lastCheckpoint = " + lastCheckpoint + ", fileId = "
                + fileId + ", offset = " + offset + ", type = "
                + TransactionEventRecord.getName(type) + ", transaction "
                + trans);
          }
          if (record.getTimestamp() > lastCheckpoint) {
            if (type == TransactionEventRecord.Type.PUT.get()) {
              ptr = new FlumeEventPointer(fileId, offset);
              transactionMap.put(trans, ptr);
            } else if (type == TransactionEventRecord.Type.TAKE.get()) {
              Take take = (Take) record;
              ptr = new FlumeEventPointer(take.getFileID(), take.getOffset());
              transactionMap.put(trans, ptr);
            } else if (type == TransactionEventRecord.Type.ROLLBACK.get()) {
              transactionMap.remove(trans);
            } else if (type == TransactionEventRecord.Type.COMMIT.get()) {
              @SuppressWarnings("unchecked")
              Collection<FlumeEventPointer> pointers =
                (Collection<FlumeEventPointer>) transactionMap.remove(trans);
              if (pointers != null && pointers.size() > 0) {
                processCommit(((Commit) record).getType(), pointers);
                count += pointers.size();
              }
            } else {
View Full Code Here

                will(returnValue(mockClientResponse));

                one(mockClientResponse).setReturnType(String.class);
                allowing(mockClientResponse);

                final MultiValueMap result = new MultiValueMap();
                result.put("Content-Type", "application/json");
                allowing(mockClientResponse).getMetadata();
                will(returnValue(result));
            }

        });
View Full Code Here

    @Test
    public void testOverridePreferred() throws Exception
    {
        DefaultAppBloodhound bh = new DefaultAppBloodhound();
        MultiMap overrides = new MultiValueMap();
        overrides.put("properties", new TestDescriptorParserDefault());

        // test with default annotation values
        bh.mergeParserOverrides(overrides);
        assertEquals(1, bh.parserRegistry.size());
        DescriptorParser result = bh.parserRegistry.get("properties");
View Full Code Here

    @Test
    public void testBothPreferredWithWeight() throws Exception
    {
        DefaultAppBloodhound bh = new DefaultAppBloodhound();
        MultiMap overrides = new MultiValueMap();
        overrides.put("properties", new TestDescriptorParserDefault());
        overrides.put("properties", new TestDescriptorParserPreferred());

        // test with weigh attribute (we have 3 candidates now)
        bh.mergeParserOverrides(overrides);
        assertEquals(1, bh.parserRegistry.size());
        DescriptorParser result = bh.parserRegistry.get("properties");
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.map.MultiValueMap

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.