use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class GridDhtAtomicCache method processDhtAtomicDeferredUpdateResponse.
/**
* @param nodeId Sender node ID.
* @param res Deferred atomic update response.
*/
private void processDhtAtomicDeferredUpdateResponse(UUID nodeId, GridDhtAtomicDeferredUpdateResponse res) {
GridLongList futIds = res.futureIds();
assert futIds != null && !futIds.isEmpty() : futIds;
for (int i = 0; i < futIds.size(); i++) {
long id = futIds.get(i);
GridDhtAtomicAbstractUpdateFuture updateFut = (GridDhtAtomicAbstractUpdateFuture) ctx.mvcc().atomicFuture(id);
if (updateFut != null) {
if (msgLog.isDebugEnabled()) {
msgLog.debug("Received DHT atomic deferred update response [futId=" + id + ", writeVer=" + res + ", node=" + nodeId + ']');
}
updateFut.onDeferredResponse(nodeId);
} else {
U.warn(msgLog, "Failed to find DHT update future for deferred update response [futId=" + id + ", nodeId=" + nodeId + ", res=" + res + ']');
}
}
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class PagesList method flushBucketsCache.
/**
* Flush onheap cached pages lists to page memory.
*
* @param statHolder Statistic holder.
* @throws IgniteCheckedException If failed to write a page.
*/
private void flushBucketsCache(IoStatisticsHolder statHolder) throws IgniteCheckedException {
if (!isCachingApplicable() || !pageCacheChanged)
return;
pageCacheChanged = false;
onheapListCachingEnabled = false;
int lockedPages = 0;
try {
for (int bucket = 0; bucket < buckets; bucket++) {
PagesCache pagesCache = getBucketCache(bucket, false);
if (pagesCache == null)
continue;
GridLongList pages = pagesCache.flush();
if (pages != null) {
if (log.isDebugEnabled()) {
log.debug("Move pages from heap to PageMemory [list=" + name() + ", bucket=" + bucket + ", pages=" + pages + ']');
}
for (int i = 0; i < pages.size(); i++) {
long pageId = pages.get(i);
if (log.isDebugEnabled()) {
log.debug("Move page from heap to PageMemory [list=" + name() + ", bucket=" + bucket + ", pageId=" + pageId + ']');
}
Boolean res = write(pageId, putBucket, bucket, null, statHolder);
if (res == null) {
// Return page to onheap pages list if can't lock it.
pagesCache.add(pageId);
lockedPages++;
}
}
}
}
} finally {
onheapListCachingEnabled = true;
}
if (lockedPages != 0) {
if (log.isInfoEnabled())
log.info("Several pages were locked and weren't flushed on disk [grp=" + grpName + ", lockedPages=" + lockedPages + ']');
pageCacheChanged = true;
}
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class PagesList method init.
/**
* @param metaPageId Metadata page ID.
* @param initNew {@code True} if new list if created, {@code false} if should be initialized from metadata.
* @throws IgniteCheckedException If failed.
*/
protected final void init(long metaPageId, boolean initNew) throws IgniteCheckedException {
if (metaPageId != 0L) {
if (initNew)
init(metaPageId, PagesListMetaIO.VERSIONS.latest());
else {
Map<Integer, GridLongList> bucketsData = new HashMap<>();
long nextId = metaPageId;
while (nextId != 0) {
final long pageId = nextId;
final long page = acquirePage(pageId, IoStatisticsHolderNoOp.INSTANCE);
try {
// No concurrent recycling on init.
long pageAddr = readLock(pageId, page);
assert pageAddr != 0L;
try {
PagesListMetaIO io = PagesListMetaIO.VERSIONS.forPage(pageAddr);
io.getBucketsData(pageAddr, bucketsData);
nextId = io.getNextMetaPageId(pageAddr);
assert nextId != pageId : "Loop detected [next=" + U.hexLong(nextId) + ", cur=" + U.hexLong(pageId) + ']';
} finally {
readUnlock(pageId, page, pageAddr);
}
} finally {
releasePage(pageId, page);
}
}
for (Map.Entry<Integer, GridLongList> e : bucketsData.entrySet()) {
int bucket = e.getKey();
long bucketSize = 0;
Stripe[] old = getBucket(bucket);
assert old == null;
long[] upd = e.getValue().array();
Stripe[] tails = new Stripe[upd.length];
for (int i = 0; i < upd.length; i++) {
long tailId = upd[i];
long prevId = tailId;
int cnt = 0;
while (prevId != 0L) {
final long pageId = prevId;
final long page = acquirePage(pageId, IoStatisticsHolderNoOp.INSTANCE);
try {
long pageAddr = readLock(pageId, page);
assert pageAddr != 0L;
try {
PagesListNodeIO io = PagesListNodeIO.VERSIONS.forPage(pageAddr);
cnt += io.getCount(pageAddr);
prevId = io.getPreviousId(pageAddr);
// In reuse bucket the page itself can be used as a free page.
if (isReuseBucket(bucket) && prevId != 0L)
cnt++;
} finally {
readUnlock(pageId, page, pageAddr);
}
} finally {
releasePage(pageId, page);
}
}
Stripe stripe = new Stripe(tailId, cnt == 0);
tails[i] = stripe;
bucketSize += cnt;
}
boolean ok = casBucket(bucket, null, tails);
assert ok;
bucketsSize.set(bucket, bucketSize);
}
}
}
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class PagesListMetaIO method getBucketsData.
/**
* @param pageAddr Page address.
* @param res Results map.
*/
public void getBucketsData(long pageAddr, Map<Integer, GridLongList> res) {
int cnt = getCount(pageAddr);
assert cnt >= 0 && cnt <= Short.MAX_VALUE : cnt;
if (cnt == 0)
return;
int off = offset(0);
for (int i = 0; i < cnt; i++) {
int bucket = (int) PageUtils.getShort(pageAddr, off);
assert bucket >= 0 && bucket <= Short.MAX_VALUE : bucket;
long tailId = PageUtils.getLong(pageAddr, off + 2);
assert tailId != 0;
GridLongList list = res.get(bucket);
if (list == null)
res.put(bucket, list = new GridLongList());
list.add(tailId);
off += ITEM_SIZE;
}
}
use of org.apache.ignite.internal.util.GridLongList in project ignite by apache.
the class FullPageIdTable method removeIf.
/**
* {@inheritDoc}
*/
@Override
public GridLongList removeIf(int startIdxToClear, int endIdxToClear, KeyPredicate keyPred) {
assert endIdxToClear > startIdxToClear : "Start and end indexes are not consistent: {" + startIdxToClear + ", " + endIdxToClear + "}";
int sz = endIdxToClear - startIdxToClear;
GridLongList list = new GridLongList(sz);
for (int idx = startIdxToClear; idx < endIdxToClear; idx++) {
long base = entryBase(idx);
int grpId = GridUnsafe.getInt(base);
long pageId = GridUnsafe.getLong(base + PAGE_ID_OFFSET);
if (isRemoved(grpId, pageId) || isEmpty(grpId, pageId))
continue;
if (!keyPred.test(grpId, pageId))
continue;
long res = valueAt(idx);
setRemoved(idx);
list.add(res);
}
return list;
}
Aggregations