Skip to content

Commit 9863243

Browse files
committed
IGNITE-12069 (minor) Code cleanup. Removed some todo from off-heap manager and other cleanups.
1 parent ecd216a commit 9863243

10 files changed

Lines changed: 35 additions & 55 deletions

File tree

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridPartitionFilePreloader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ public Runnable addNodeAssignments(
250250
}
251251

252252
if (fut0.isCancelled()) {
253-
log.info("File rebalance canceled [topVer=" + topVer + "]");
253+
if (log.isInfoEnabled())
254+
log.info("File rebalance canceled [topVer=" + topVer + "]");
254255

255256
return;
256257
}

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
6565
import org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo;
6666
import org.apache.ignite.internal.processors.cache.GridCacheTtlManager;
67+
import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager.CacheDataStore;
6768
import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl;
6869
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
6970
import org.apache.ignite.internal.processors.cache.PartitionAtomicUpdateCounterImpl;
@@ -1012,8 +1013,6 @@ private Metas getOrAllocateCacheMetas() throws IgniteCheckedException {
10121013
int p = partCntrs.partitionAt(i);
10131014
long initCntr = partCntrs.initialUpdateCounterAt(i);
10141015

1015-
// todo For file rebalancing we starting searching from reserved pointer.
1016-
// For historical rebalancing it may be more effective to search pointer in checkpoint hostory
10171016
FileWALPointer startPtr = database.reservedWALPointer(grp.groupId(), p, initCntr);
10181017

10191018
if (startPtr == null)
@@ -1100,7 +1099,7 @@ long freeSpace() {
11001099
for (CacheDataStore store : partDataStores.values()) {
11011100
assert store instanceof GridCacheDataStore;
11021101

1103-
AbstractFreeList freeList = ((GridCacheDataStore)(store)).freeList;
1102+
AbstractFreeList freeList = ((GridCacheDataStore)store).freeList;
11041103

11051104
if (freeList == null)
11061105
continue;
@@ -1122,7 +1121,7 @@ long emptyDataPages() {
11221121
for (CacheDataStore store : partDataStores.values()) {
11231122
assert store instanceof GridCacheDataStore;
11241123

1125-
AbstractFreeList freeList = ((GridCacheDataStore)(store)).freeList;
1124+
AbstractFreeList freeList = ((GridCacheDataStore)store).freeList;
11261125

11271126
if (freeList == null)
11281127
continue;
@@ -1342,7 +1341,7 @@ private void releasePartitions() {
13421341
GridDhtLocalPartition part = grp.topology().localPartition(p);
13431342

13441343
assert part != null && part.state() == OWNING && part.reservations() > 0
1345-
: "Partition should in OWNING state and has at least 1 reservation, state=" + part.state();
1344+
: "Partition should in OWNING state and has at least 1 reservation [state=" + part.state() + "]";
13461345

13471346
part.release();
13481347
}
@@ -1423,7 +1422,7 @@ else if (rec.get2() instanceof RollbackRecord) {
14231422
}
14241423

14251424
assert entryIt != null || doneParts.size() == partMap.size() :
1426-
"Reached end of WAL but not all partitions are done ; done=" + doneParts + ", required=" + partMap;
1425+
"Reached end of WAL but not all partitions are done [done=" + doneParts + ", all=" + partMap + "]";
14271426
}
14281427
}
14291428
}
@@ -1614,12 +1613,15 @@ public class GridCacheDataStore implements CacheDataStore {
16141613
/** */
16151614
private final boolean exists;
16161615

1617-
/** */
1616+
/** Lock to protect the initialization phase. */
16181617
private final Lock initLock = new ReentrantLock();
16191618

16201619
/** Currently used data storage state. */
16211620
private final AtomicBoolean readOnlyMode = new AtomicBoolean();
16221621

1622+
/** Update counter for read-only mode. */
1623+
private volatile PartitionUpdateCounter readModeCntr;
1624+
16231625
/**
16241626
* @param partId Partition.
16251627
* @param exists {@code True} if store exists.
@@ -2503,10 +2505,6 @@ public PartitionUpdateCounter readOnlyPartUpdateCounter() {
25032505
/** {@inheritDoc} */
25042506
@Override public int cleanup(GridCacheContext cctx,
25052507
@Nullable List<MvccLinkAwareSearchRow> cleanupRows) throws IgniteCheckedException {
2506-
// todo can be removed?
2507-
if (readOnly())
2508-
return 0;
2509-
25102508
CacheDataStore delegate = init0(false);
25112509

25122510
return delegate.cleanup(cctx, cleanupRows);
@@ -2555,10 +2553,6 @@ public PartitionUpdateCounter readOnlyPartUpdateCounter() {
25552553

25562554
/** {@inheritDoc} */
25572555
@Override public CacheDataRow find(GridCacheContext cctx, KeyCacheObject key) throws IgniteCheckedException {
2558-
// todo remove this
2559-
if (readOnly())
2560-
return null;
2561-
25622556
CacheDataStore delegate = init0(true);
25632557

25642558
if (delegate != null)
@@ -2702,9 +2696,7 @@ public PartitionUpdateCounter readOnlyPartUpdateCounter() {
27022696

27032697
/** {@inheritDoc} */
27042698
@Override public void clear(int cacheId) throws IgniteCheckedException {
2705-
// todo remove this
2706-
if (readOnlyMode.get())
2707-
return;
2699+
assert !readOnlyMode.get() : "grp=" + grp.cacheOrGroupName() + ", p=" + partId;
27082700

27092701
CacheDataStore delegate0 = init0(true);
27102702

@@ -2926,8 +2918,9 @@ private int purgeExpiredInternal(
29262918
return readOnlyMode.get();
29272919
}
29282920

2929-
private volatile PartitionUpdateCounter readModeCntr;
2930-
2921+
/**
2922+
* Initialize partition update counter for read-only mode.
2923+
*/
29312924
private void initReadModeCounter() {
29322925
PartitionUpdateCounter readCntr0;
29332926

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStore.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,6 @@ public void init() throws StorageException {
539539

540540
try {
541541
if (!inited) {
542-
// U.dumpStack("Init page store: " + getFileAbsolutePath());
543-
544542
FileIO fileIO = null;
545543

546544
StorageException err = null;
@@ -783,10 +781,6 @@ private static int calcCrc32(ByteBuffer pageBuf, int pageSize) {
783781
lock.writeLock().lock();
784782

785783
try {
786-
// // todo why checkpointer syncs read-only partition?
787-
// if (!inited)
788-
// return;
789-
790784
init();
791785

792786
FileIO fileIO = this.fileIO;

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/PageMemoryImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ private DataRegionConfiguration getDataRegionConfiguration() {
787787
}
788788
}
789789
else if (relPtr == OUTDATED_REL_PTR) {
790-
assert PageIdUtils.pageIndex(pageId) == 0 : fullId + " p=" + PageIdUtils.partId(pageId);
790+
assert PageIdUtils.pageIndex(pageId) == 0 : fullId;
791791

792792
relPtr = refreshOutdatedPage(seg, grpId, pageId, false);
793793

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,8 +2830,8 @@ private void init() throws IgniteCheckedException {
28302830
try {
28312831
fd = segmentRouter.findSegment(curWalSegmIdx);
28322832

2833-
if (log.isInfoEnabled())
2834-
log.info("Reading next file [absIdx=" + curWalSegmIdx + ", file=" + fd.file.getAbsolutePath() + ']');
2833+
if (log.isDebugEnabled())
2834+
log.debug("Reading next file [absIdx=" + curWalSegmIdx + ", file=" + fd.file.getAbsolutePath() + ']');
28352835

28362836
nextHandle = initReadHandle(fd, start != null && curWalSegmIdx == start.index() ? start : null);
28372837
}

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/verify/IdleVerifyUtility.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,8 @@ public static boolean isCheckpointNow(@Nullable IgniteCacheDatabaseSharedManager
104104
if (!(db instanceof GridCacheDatabaseSharedManager))
105105
return false;
106106

107-
GridCacheDatabaseSharedManager.Checkpointer cp = ((GridCacheDatabaseSharedManager)db).getCheckpointer();
108-
109-
if (cp == null)
110-
return false;
111-
112107
GridCacheDatabaseSharedManager.CheckpointProgress progress =
113-
cp.currentProgress();
108+
((GridCacheDatabaseSharedManager)db).getCheckpointer().currentProgress();
114109

115110
if (progress == null)
116111
return false;

modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,11 +1779,9 @@ private void registerCache0(
17791779
QueryTypeIdKey altTypeId = cand.alternativeTypeId();
17801780
QueryTypeDescriptorImpl desc = cand.descriptor();
17811781

1782-
typesByName.put(new QueryTypeNameKey(cacheName, desc.name()), desc);
1783-
1784-
// if (typesByName.put(new QueryTypeNameKey(cacheName, desc.name()), desc) != null)
1785-
// throw new IgniteCheckedException("Type with name '" + desc.name() + "' already indexed " +
1786-
// "in cache '" + cacheName + "'.");
1782+
if (typesByName.putIfAbsent(new QueryTypeNameKey(cacheName, desc.name()), desc) != null)
1783+
throw new IgniteCheckedException("Type with name '" + desc.name() + "' already indexed " +
1784+
"in cache '" + cacheName + "'.");
17871785

17881786
types.put(typeId, desc);
17891787

@@ -1793,16 +1791,14 @@ private void registerCache0(
17931791
for (QueryIndexDescriptorImpl idx : desc.indexes0()) {
17941792
QueryIndexKey idxKey = new QueryIndexKey(schemaName, idx.name());
17951793

1796-
idxs.put(idxKey, idx);
1794+
QueryIndexDescriptorImpl oldIdx = idxs.putIfAbsent(idxKey, idx);
17971795

1798-
// QueryIndexDescriptorImpl oldIdx = idxs.put(idxKey, idx);
1799-
//
1800-
// if (oldIdx != null) {
1801-
// throw new IgniteException("Duplicate index name [cache=" + cacheName +
1802-
// ", schemaName=" + schemaName + ", idxName=" + idx.name() +
1803-
// ", existingTable=" + oldIdx.typeDescriptor().tableName() +
1804-
// ", table=" + desc.tableName() + ']');
1805-
// }
1796+
if (oldIdx != null) {
1797+
throw new IgniteException("Duplicate index name [cache=" + cacheName +
1798+
", schemaName=" + schemaName + ", idxName=" + idx.name() +
1799+
", existingTable=" + oldIdx.typeDescriptor().tableName() +
1800+
", table=" + desc.tableName() + ']');
1801+
}
18061802
}
18071803

18081804
if (idx != null)
@@ -1812,8 +1808,6 @@ private void registerCache0(
18121808
cacheNames.add(CU.mask(cacheName));
18131809
}
18141810
catch (IgniteCheckedException | RuntimeException e) {
1815-
e.printStackTrace();
1816-
18171811
onCacheStop0(cacheInfo, true);
18181812

18191813
throw e;

modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4401,8 +4401,11 @@ assert nodeSupports(remote, CHANNEL_COMMUNICATION) : "Node doesn't support direc
44014401
/** */
44024402
private final long endTime = U.currentTimeMillis() + connTimeout;
44034403

4404+
/** */
4405+
private final IgniteUuid id = IgniteUuid.randomUuid();
4406+
44044407
@Override public IgniteUuid id() {
4405-
return IgniteUuid.randomUuid();
4408+
return id;
44064409
}
44074410

44084411
@Override public long endTime() {

modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/FutureTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public abstract class FutureTask<T> extends GridFutureAdapter<T> implements Runn
2727
/**
2828
*
2929
*/
30-
protected abstract T body() throws Exception;
30+
protected abstract T body();
3131

3232
/** {@inheritDoc} */
3333
@Override public void run() {

modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheFileRebalancingAbstractTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ public void testContinuousBaselineChangeWithLoad() throws Exception {
429429
* @throws Exception If failed.
430430
*/
431431
@Test
432-
public void testIndexedCacheStartStopLastNodeWithLoad() throws Exception {
432+
public void test3nodesRestartLastNodeWithLoad() throws Exception {
433433
List<ClusterNode> blt = new ArrayList<>();
434434

435435
boolean checkRemoves = false;

0 commit comments

Comments
 (0)