Exemple #1
0
  /** @param keyMap Key map to register. */
  void addKeyMapping(Map<GridRichNode, Collection<K>> keyMap) {
    for (Map.Entry<GridRichNode, Collection<K>> mapping : keyMap.entrySet()) {
      GridRichNode n = mapping.getKey();

      for (K key : mapping.getValue()) {
        GridCacheTxEntry<K, V> txEntry = txMap.get(key);

        assert txEntry != null;

        GridDistributedTxMapping<K, V> m = mappings.get(n.id());

        if (m == null) mappings.put(n.id(), m = new GridDistributedTxMapping<K, V>(n));

        txEntry.nodeId(n.id());

        m.add(txEntry);
      }
    }

    if (log.isDebugEnabled())
      log.debug(
          "Added mappings to transaction [locId="
              + cctx.nodeId()
              + ", mappings="
              + keyMap
              + ", tx="
              + this
              + ']');
  }
  /**
   * @param entry Transaction entry.
   * @param nodes Nodes.
   */
  private void map(GridCacheTxEntry<K, V> entry, Collection<GridRichNode> nodes) {
    GridRichNode primary = CU.primary0(cctx.affinity(entry.key(), nodes));

    GridDistributedTxMapping<K, V> t = mappings.get(primary.id());

    if (t == null) mappings.put(primary.id(), t = new GridDistributedTxMapping<K, V>(primary));

    t.add(entry);
  }