use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridDhtAtomicUpdateRequest method addNearWriteValue.
/**
* {@inheritDoc}
*/
@Override
public void addNearWriteValue(KeyCacheObject key, @Nullable CacheObject val, EntryProcessor<Object, Object, Object> entryProcessor, long ttl, long expireTime) {
assert key.partition() >= 0 : key;
if (hasKey(key)) {
if (obsoleteIndexes == null)
obsoleteIndexes = new GridIntList();
obsoleteIndexes.add(keys.indexOf(key));
return;
}
if (nearKeys == null) {
nearKeys = new ArrayList<>();
if (forceTransformBackups) {
nearEntryProcessors = new ArrayList<>();
nearEntryProcessorsBytes = new ArrayList<>();
} else
nearVals = new ArrayList<>();
}
nearKeys.add(key);
if (forceTransformBackups) {
assert entryProcessor != null;
nearEntryProcessors.add(entryProcessor);
} else
nearVals.add(val);
if (ttl >= 0) {
if (nearTtls == null) {
nearTtls = new GridLongList(nearKeys.size());
for (int i = 0; i < nearKeys.size() - 1; i++) nearTtls.add(CU.TTL_NOT_CHANGED);
}
}
if (nearTtls != null)
nearTtls.add(ttl);
if (expireTime >= 0) {
if (nearExpireTimes == null) {
nearExpireTimes = new GridLongList(nearKeys.size());
for (int i = 0; i < nearKeys.size() - 1; i++) nearExpireTimes.add(CU.EXPIRE_TIME_CALCULATE);
}
}
if (nearExpireTimes != null)
nearExpireTimes.add(expireTime);
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridDhtAtomicUpdateRequest method addWriteValue.
/**
* {@inheritDoc}
*/
@Override
public void addWriteValue(KeyCacheObject key, @Nullable CacheObject val, EntryProcessor<Object, Object, Object> entryProcessor, long ttl, long conflictExpireTime, @Nullable GridCacheVersion conflictVer, boolean addPrevVal, @Nullable CacheObject prevVal, long updateCntr, GridCacheOperation cacheOp) {
assert key.partition() >= 0 : key;
keys.add(key);
if (forceTransformBackups) {
assert entryProcessor != null;
entryProcessors.add(entryProcessor);
} else
vals.add(val);
if (addPrevVal) {
if (prevVals == null)
prevVals = new ArrayList<>();
prevVals.add(prevVal);
}
if (updateCntrs == null)
updateCntrs = new GridLongList();
updateCntrs.add(updateCntr);
// In case there is no conflict, do not create the list.
if (conflictVer != null) {
if (conflictVers == null) {
conflictVers = new ArrayList<>();
for (int i = 0; i < keys.size() - 1; i++) conflictVers.add(null);
}
conflictVers.add(conflictVer);
} else if (conflictVers != null)
conflictVers.add(null);
if (ttl >= 0) {
if (ttls == null) {
ttls = new GridLongList(keys.size());
for (int i = 0; i < keys.size() - 1; i++) ttls.add(CU.TTL_NOT_CHANGED);
}
}
if (ttls != null)
ttls.add(ttl);
if (conflictExpireTime >= 0) {
if (conflictExpireTimes == null) {
conflictExpireTimes = new GridLongList(keys.size());
for (int i = 0; i < keys.size() - 1; i++) conflictExpireTimes.add(CU.EXPIRE_TIME_CALCULATE);
}
}
if (conflictExpireTimes != null)
conflictExpireTimes.add(conflictExpireTime);
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class PagesList method putReuseBag.
/**
* @param pageId Page ID.
* @param page Page pointer.
* @param pageAddr Page address.
* @param io IO.
* @param bag Reuse bag.
* @param bucket Bucket.
* @param statHolder Statistics holder to track IO operations.
* @return {@code true} If succeeded.
* @throws IgniteCheckedException if failed.
*/
private boolean putReuseBag(final long pageId, final long page, final long pageAddr, PagesListNodeIO io, ReuseBag bag, int bucket, IoStatisticsHolder statHolder) throws IgniteCheckedException {
assert bag != null : "bag is null";
assert !bag.isEmpty() : "bag is empty";
if (io.getNextId(pageAddr) != 0L)
// Splitted.
return false;
long nextId;
long prevId = pageId;
long prevPage = page;
long prevAddr = pageAddr;
Boolean walPlc = null;
// TODO may be unlock right away and do not keep all these pages locked?
GridLongList locked = null;
try {
while ((nextId = bag.pollFreePage()) != 0L) {
assert PageIdUtils.itemId(nextId) > 0 && PageIdUtils.itemId(nextId) <= MAX_ITEMID_NUM : U.hexLong(nextId);
int idx = io.addPage(prevAddr, nextId, pageSize());
if (idx == -1) {
// Attempt to add page failed: the node page is full.
final long nextPage = acquirePage(nextId, statHolder);
try {
// Page from reuse bag can't be concurrently recycled.
long nextPageAddr = writeLock(nextId, nextPage);
assert nextPageAddr != 0L;
if (locked == null)
locked = new GridLongList(6);
locked.add(nextId);
locked.add(nextPage);
locked.add(nextPageAddr);
setupNextPage(io, prevId, prevAddr, nextId, nextPageAddr);
if (needWalDeltaRecord(prevId, prevPage, walPlc))
wal.log(new PagesListSetNextRecord(grpId, prevId, nextId));
// Here we should never write full page, because it is known to be new.
if (needWalDeltaRecord(nextId, nextPage, FALSE))
wal.log(new PagesListInitNewPageRecord(grpId, nextId, io.getType(), io.getVersion(), nextId, prevId, 0L));
// In reuse bucket the page itself can be used as a free page.
if (isReuseBucket(bucket))
incrementBucketSize(bucket);
// Switch to this new page, which is now a part of our list
// to add the rest of the bag to the new page.
prevAddr = nextPageAddr;
prevId = nextId;
prevPage = nextPage;
// Starting from tis point all wal records are written for reused pages from the bag.
// This mean that we use delta records only.
walPlc = FALSE;
} finally {
releasePage(nextId, nextPage);
}
} else {
// TODO: use single WAL record for bag?
if (needWalDeltaRecord(prevId, prevPage, walPlc))
wal.log(new PagesListAddPageRecord(grpId, prevId, nextId));
incrementBucketSize(bucket);
}
}
} finally {
if (locked != null) {
// We have to update our bucket with the new tail.
updateTail(bucket, pageId, prevId);
// Release write.
for (int i = 0; i < locked.size(); i += 3) writeUnlock(locked.get(i), locked.get(i + 1), locked.get(i + 2), FALSE, true);
}
}
return true;
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class PartitionUpdateCounterTrackingImpl method finalizeUpdateCounters.
/**
* {@inheritDoc}
*/
@Override
public synchronized GridLongList finalizeUpdateCounters() {
Map.Entry<Long, Item> item = queue.pollFirstEntry();
GridLongList gaps = null;
while (item != null) {
if (gaps == null)
gaps = new GridLongList((queue.size() + 1) * 2);
long start = cntr.get() + 1;
long end = item.getValue().start;
gaps.add(start);
gaps.add(end);
// Close pending ranges.
cntr.set(item.getValue().absolute());
item = queue.pollFirstEntry();
}
reserveCntr.set(get());
return gaps;
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class MvccProcessorImpl method processActiveQueriesMessage.
/**
* @param nodeId Node ID.
* @param msg Message.
*/
private void processActiveQueriesMessage(UUID nodeId, MvccActiveQueriesMessage msg) {
GridLongList queryIds = msg.activeQueries();
assert queryIds != null;
prevQueries.addActiveQueries(nodeId, queryIds);
}
Aggregations