GoldenGate Conflicts Resolution
When the cache is updated via the GoldenGate and GridGain cache API, you can choose to proceed with the update, retain the old value, or generate some other value by merging old and new values. To achieve this, GridGain offers Conflicts Resolution.
For using conflicts resolution for cache operations and Data Streamer
, you need to use the GridGain.cache(String cacheName, byte dataCenterId)
and GridGain.dataStreamer(String cacheName, byte dataCenterId)
methods. It is expected that the data center ID will be unique for all topologies participating in data center replication, and same for all nodes that belong to the given topology.
// Get GridGain plugin.
GridGain gridGain = ignite.plugin(GridGain.PLUGIN_NAME);
// Get "Person" cache with given data center id.
IgniteCache cache = gridGain.cache("Person", 31);
...
/**
* Conflict resolver for Person entity. In conflicts always used an entry
* with data center id equals 31.
*/
public class PersonConflictResolver implements CacheConflictResolver<Integer, Person> {
/** {@inheritDoc} */
@Override public void resolve(CacheConflictContext<Integer, Person> ctx) {
// If we
if (oldEntry.dataCenterId() == 31)
ctx.useOld();
else if (newEntry.dataCenterId() == 31)
ctx.useNew();
}
}
// Get GridGain plugin.
GridGain gridGain = ignite.plugin(GridGain.PLUGIN_NAME);
// Get Data Streamer for cache with given data center id.
IgniteDataStreamer cache = gridGain.dataStreamer("Person", 31);
...
/**
* Conflict resolver for Person entity. In conflicts always used an entry
* with data center id equals 31.
*/
public class PersonConflictResolver implements CacheConflictResolver<Integer, Person> {
/** {@inheritDoc} */
@Override public void resolve(CacheConflictContext<Integer, Person> ctx) {
// If we
if (oldEntry.dataCenterId() == 31)
ctx.useOld();
else if (newEntry.dataCenterId() == 31)
ctx.useNew();
}
}
© 2024 GridGain Systems, Inc. All Rights Reserved. Privacy Policy | Legal Notices. GridGain® is a registered trademark of GridGain Systems, Inc.
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.