use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition in project ignite by apache.
the class GridDhtPartitionDemander method createDemandMessage.
/**
* @param old Old message.
* @param parts Partitions to demand.
* @return New demand message.
*/
private GridDhtPartitionDemandMessage createDemandMessage(GridDhtPartitionDemandMessage old, Collection<Integer> parts) {
Map<Integer, Long> partCntrs = null;
for (Integer part : parts) {
try {
if (cctx.shared().database().persistenceEnabled()) {
if (partCntrs == null)
partCntrs = new HashMap<>(parts.size(), 1.0f);
GridDhtLocalPartition p = cctx.topology().localPartition(part, old.topologyVersion(), false);
partCntrs.put(part, p.initialUpdateCounter());
}
} catch (GridDhtInvalidPartitionException ignore) {
// Skip this partition.
}
}
return new GridDhtPartitionDemandMessage(old, parts, partCntrs);
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition in project ignite by apache.
the class IgniteCacheOffheapManagerImpl method read.
/** {@inheritDoc} */
@Nullable
@Override
public CacheDataRow read(KeyCacheObject key) throws IgniteCheckedException {
CacheDataRow row;
if (cctx.isLocal())
row = locCacheDataStore.find(key);
else {
GridDhtLocalPartition part = cctx.topology().localPartition(cctx.affinity().partition(key), null, false);
row = part != null ? dataStore(part).find(key) : null;
}
assert row == null || row.value() != null : row;
return row;
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition in project ignite by apache.
the class GridDistributedCacheAdapter method localSizeLong.
/** {@inheritDoc} */
@Override
public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
PeekModes modes = parsePeekModes(peekModes, true);
long size = 0;
if (modes.near)
size += nearSize();
// Swap and offheap are disabled for near cache.
if (modes.primary || modes.backup) {
AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
IgniteCacheOffheapManager offheap = ctx.offheap();
if (modes.offheap)
size += offheap.entriesCount(modes.primary, modes.backup, topVer);
else if (modes.heap) {
for (GridDhtLocalPartition locPart : ctx.topology().currentLocalPartitions()) {
if ((modes.primary && locPart.primary(topVer)) || (modes.backup && locPart.backup(topVer)))
size += locPart.publicSize();
}
}
}
return size;
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method getOrganizationCountFromPartitionMap.
/**
* @param ignite Ignite.
* @param orgId Organization id.
* @return Count of found Person object with specified orgId
* @throws Exception If failed.
*/
private static int getOrganizationCountFromPartitionMap(final IgniteEx ignite, int orgId) throws Exception {
int part = ignite.affinity(Organization.class.getSimpleName()).partition(orgId);
GridCacheAdapter<?, ?> cacheAdapterOrg = ignite.context().cache().internalCache(Organization.class.getSimpleName());
GridDhtLocalPartition pOrgs = cacheAdapterOrg.context().topology().localPartition(part, AffinityTopologyVersion.NONE, false);
int cnt = 0;
GridCursor<? extends CacheDataRow> c = pOrgs.dataStore().cursor();
CacheObjectContext ctx = cacheAdapterOrg.context().cacheObjectContext();
while (c.next()) {
CacheDataRow e = c.get();
Integer k = e.key().value(ctx, false);
Organization org = e.value().value(ctx, false);
if (org != null && org.getId() == orgId)
++cnt;
}
return cnt;
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition in project ignite by apache.
the class IgniteCacheLockPartitionOnAffinityRunTest method getPersonsCountFromPartitionMap.
/**
* @param ignite Ignite.
* @param orgId Organization id.
* @return Count of found Person object with specified orgId
* @throws Exception If failed.
*/
private static int getPersonsCountFromPartitionMap(final IgniteEx ignite, int orgId) throws Exception {
int part = ignite.affinity(Organization.class.getSimpleName()).partition(orgId);
GridCacheAdapter<?, ?> cacheAdapterPers = ignite.context().cache().internalCache(Person.class.getSimpleName());
GridDhtLocalPartition pPers = cacheAdapterPers.context().topology().localPartition(part, AffinityTopologyVersion.NONE, false);
int cnt = 0;
GridCursor<? extends CacheDataRow> c = pPers.dataStore().cursor();
CacheObjectContext ctx = cacheAdapterPers.context().cacheObjectContext();
while (c.next()) {
CacheDataRow e = c.get();
Person.Key k = e.key().value(ctx, false);
Person p = e.value().value(ctx, false);
if (p != null && p.getOrgId() == orgId && k.orgId == orgId)
++cnt;
}
return cnt;
}
Aggregations