5 Replies Latest reply: Jan 2, 2013 1:23 PM by User738616-Oracle RSS

    Backing Map Insert Error

    AntonZ
      Hi.

      I'm trying to make an insert into the backing map of another cache inside the EntryProcessor, but get the following error: An entry was inserted into the backing map for the partitioned cache "another-cache" that is not owned by this member; the entry will be removed.

      So, EP is invoked against one cache, but the insert inside it occurs to a different cache.

      Here is the code for it, please let me know what can fix the error above:

           public Object process(InvocableMap.Entry entry)
           {
           ..

           BackingMapManagerContext ctx = ((BinaryEntry) entry).getContext();
           BackingMapManagerContext ctx2 = ctx.getBackingMapContext("another-cache").getManagerContext();
           
      Map childCache = ctx.getBackingMapContext("another-cache").getBackingMap();
      childCache.put(ctx2.getKeyToInternalConverter().convert(KeyObject), ctx2.getValueToInternalConverter().convert(ValueObject));

           ..
           }
        • 1. Re: Backing Map Insert Error
          User738616-Oracle
          Hi,
          I'm trying to make an insert into the backing map of another cache inside the EntryProcessor, but get the following error: An entry was inserted into the backing map for the partitioned cache "another-cache" that is not owned by this member; the entry will be removed.

          So, EP is invoked against one cache, but the insert inside it occurs to a different cache.

          Here is the code for it, please let me know what can fix the error above:

               public Object process(InvocableMap.Entry entry)
               {
               ..

               BackingMapManagerContext ctx = ((BinaryEntry) entry).getContext();
               BackingMapManagerContext ctx2 = ctx.getBackingMapContext("another-cache").getManagerContext();
               
          Map childCache = ctx.getBackingMapContext("another-cache").getBackingMap();
          childCache.put(ctx2.getKeyToInternalConverter().convert(KeyObject), ctx2.getValueToInternalConverter().convert(ValueObject));

               ..
               }
          The reason for the error is that the owner of the key "KeyObject" is not the same node as the owner of the entry "entry". If you want to implement it then you need to define the "DataAffinity" between the objects of both your caches so they are collocated on the same node.

          HTH

          Cheers,
          _NJ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
          • 2. Re: Backing Map Insert Error
            AntonZ
            I'm inserting a new object entry into the map, meaning KeyObject is not present in any node yet.

            Also, I would think, if I make all inserts into cache1 through entry processor which in turn will make inserts into the backing map of cache2, I will in end achieve data affinity between cache1 and cache2 objects. Isn't that right?
            • 3. Re: Backing Map Insert Error
              User738616-Oracle
              Hi,
              I'm inserting a new object entry into the map, meaning KeyObject is not present in any node yet.

              Also, I would think, if I make all inserts into cache1 through entry processor which in turn will make inserts into the backing map of cache2, I will in end achieve data affinity between cache1 and cache2 objects. Isn't that right?
              No that is not correct since Coherence decides the owner of the "key" based on the hashcode of the "key" and a complex algorithm. Coherence would not allow to put an entry into the backingMap if the algo+hashcode does not evaluate the owner of the key to be same backingMap and that is why you are getting this error. If you run a single Coherence node, you should be able to run your code.

              HTH

              Cheers,
              NJ
              • 4. Re: Backing Map Insert Error
                AntonZ
                Ah, ok. Thanks. So I suppose, re-using the key that entry processor is executed against will guarantee I don't get the error above?
                • 5. Re: Backing Map Insert Error
                  User738616-Oracle
                  Yes you need to guarantee that the key owner is the same node as the node where you are trying to execute backingMap APIs.

                  Cheers,
                  _NJ