Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-22790 Cleanup of Grid*Request and Grid*Response classes #11457

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public GridDeploymentInfo deployInfo() {
* @param ctx Cache context.
* @throws IgniteCheckedException If failed.
*/
public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws IgniteCheckedException {
// No-op.
}

Expand All @@ -298,7 +298,7 @@ public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedExcep
* @param ldr Class loader.
* @throws IgniteCheckedException If failed.
*/
public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
// No-op.
}

Expand Down Expand Up @@ -657,7 +657,7 @@ protected final void finishUnmarshalCacheObjects(@Nullable Collection<? extends
* @param ctx Context.
* @return Logger.
*/
public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.messageLogger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static boolean cheatCache(int id) {
private static final CacheEntryPredicate[] ALWAYS_FALSE0_ARR = new CacheEntryPredicate[] {ALWAYS_FALSE0};

/** Read filter. */
public static final IgnitePredicate READ_FILTER = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> READ_FILTER = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.op() == READ;
}
Expand All @@ -267,7 +267,7 @@ public static boolean cheatCache(int id) {
};

/** Read filter. */
public static final IgnitePredicate READ_FILTER_NEAR = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> READ_FILTER_NEAR = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.op() == READ && e.context().isNear();
}
Expand All @@ -278,7 +278,7 @@ public static boolean cheatCache(int id) {
};

/** Read filter. */
public static final IgnitePredicate READ_FILTER_COLOCATED = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> READ_FILTER_COLOCATED = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.op() == READ && !e.context().isNear();
}
Expand All @@ -289,7 +289,7 @@ public static boolean cheatCache(int id) {
};

/** Write filter. */
public static final IgnitePredicate WRITE_FILTER = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> WRITE_FILTER = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.op() != READ;
}
Expand All @@ -300,7 +300,7 @@ public static boolean cheatCache(int id) {
};

/** Write filter. */
public static final IgnitePredicate WRITE_FILTER_NEAR = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> WRITE_FILTER_NEAR = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.op() != READ && e.context().isNear();
}
Expand All @@ -311,7 +311,7 @@ public static boolean cheatCache(int id) {
};

/** Write filter. */
public static final IgnitePredicate WRITE_FILTER_COLOCATED = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> WRITE_FILTER_COLOCATED = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.op() != READ && !e.context().isNear();
}
Expand All @@ -322,7 +322,7 @@ public static boolean cheatCache(int id) {
};

/** Write filter. */
public static final IgnitePredicate FILTER_NEAR_CACHE_ENTRY = new P1<IgniteTxEntry>() {
public static final IgnitePredicate<IgniteTxEntry> FILTER_NEAR_CACHE_ENTRY = new P1<IgniteTxEntry>() {
@Override public boolean apply(IgniteTxEntry e) {
return e.context().isNear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public boolean system() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txRecoveryMessageLogger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public boolean success() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txRecoveryMessageLogger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public boolean storeUsed() {
*/
public void storeUsed(boolean storeUsed) {
if (storeUsed)
flags = (byte)(flags | STORE_USED_FLAG_MASK);
flags |= STORE_USED_FLAG_MASK;
else
flags &= ~STORE_USED_FLAG_MASK;
}
Expand All @@ -290,14 +290,8 @@ public int txSize() {
*
* @param key Key.
* @param retVal Flag indicating whether value should be returned.
* @param ctx Context.
* @throws IgniteCheckedException If failed.
*/
public void addKeyBytes(
KeyCacheObject key,
boolean retVal,
GridCacheContext ctx
) throws IgniteCheckedException {
public void addKeyBytes(KeyCacheObject key, boolean retVal) {
if (keys == null)
keys = new ArrayList<>(keysCount());

Expand Down Expand Up @@ -328,25 +322,25 @@ public long timeout() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txLockMessageLogger();
}

/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
@Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);

GridCacheContext cctx = ctx.cacheContext(cacheId);
GridCacheContext<?, ?> cctx = ctx.cacheContext(cacheId);

prepareMarshalCacheObjects(keys, cctx);
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
@Override public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);

GridCacheContext cctx = ctx.cacheContext(cacheId);
GridCacheContext<?, ?> cctx = ctx.cacheContext(cacheId);

finishUnmarshalCacheObjects(keys, cctx, ldr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ protected int valuesSize() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txLockMessageLogger();
}

/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
@Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);

prepareMarshalCacheObjects(vals, ctx.cacheContext(cacheId));
Expand All @@ -197,7 +197,7 @@ protected int valuesSize() {
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
@Override public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);

finishUnmarshalCacheObjects(vals, ctx.cacheContext(cacheId), ldr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public boolean replyRequired() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txFinishMessageLogger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public IgniteUuid futureId() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txFinishMessageLogger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.ignite.internal.processors.cache.distributed;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
Expand Down Expand Up @@ -234,7 +233,7 @@ public boolean removeEntry(IgniteTxEntry entry) {
* @param keys Keys to evict readers for.
*/
public void evictReaders(@Nullable Collection<IgniteTxKey> keys) {
if (keys == null || keys.isEmpty())
if (F.isEmpty(keys))
return;

evictReaders(keys, entries);
Expand All @@ -245,15 +244,10 @@ public void evictReaders(@Nullable Collection<IgniteTxKey> keys) {
* @param entries Entries to check.
*/
private void evictReaders(Collection<IgniteTxKey> keys, @Nullable Collection<IgniteTxEntry> entries) {
if (entries == null || entries.isEmpty())
if (F.isEmpty(entries))
return;

for (Iterator<IgniteTxEntry> it = entries.iterator(); it.hasNext();) {
IgniteTxEntry entry = it.next();

if (keys.contains(entry.txKey()))
it.remove();
}
entries.removeIf(entry -> keys.contains(entry.txKey()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,10 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
public static final int STORE_WRITE_THROUGH_FLAG_MASK = 0x20;

/** Collection to message converter. */
private static final C1<Collection<UUID>, UUIDCollectionMessage> COL_TO_MSG = new C1<Collection<UUID>, UUIDCollectionMessage>() {
@Override public UUIDCollectionMessage apply(Collection<UUID> uuids) {
return new UUIDCollectionMessage(uuids);
}
};
private static final C1<Collection<UUID>, UUIDCollectionMessage> COL_TO_MSG = UUIDCollectionMessage::new;

/** Message to collection converter. */
private static final C1<UUIDCollectionMessage, Collection<UUID>> MSG_TO_COL = new C1<UUIDCollectionMessage, Collection<UUID>>() {
@Override public Collection<UUID> apply(UUIDCollectionMessage msg) {
return msg.uuids();
}
};
private static final C1<UUIDCollectionMessage, Collection<UUID>> MSG_TO_COL = UUIDCollectionMessage::uuids;

/** Thread ID. */
@GridToStringInclude
Expand Down Expand Up @@ -247,7 +239,7 @@ public boolean storeWriteThrough() {
*/
public void storeWriteThrough(boolean storeWriteThrough) {
if (storeWriteThrough)
flags = (byte)(flags | STORE_WRITE_THROUGH_FLAG_MASK);
flags |= STORE_WRITE_THROUGH_FLAG_MASK;
else
flags &= ~STORE_WRITE_THROUGH_FLAG_MASK;
}
Expand Down Expand Up @@ -276,7 +268,7 @@ public void addDhtVersion(IgniteTxKey key, @Nullable GridCacheVersion dhtVer) {
* @return Map of versions to be verified.
*/
public Map<IgniteTxKey, GridCacheVersion> dhtVersions() {
return dhtVers == null ? Collections.<IgniteTxKey, GridCacheVersion>emptyMap() : dhtVers;
return dhtVers == null ? Collections.emptyMap() : dhtVers;
}

/**
Expand Down Expand Up @@ -382,7 +374,7 @@ public boolean last() {

/** {@inheritDoc}
* @param ctx*/
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
@Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);

if (writes != null)
Expand All @@ -393,7 +385,7 @@ public boolean last() {

if (dhtVers != null && dhtVerKeys == null) {
for (IgniteTxKey key : dhtVers.keySet()) {
GridCacheContext cctx = ctx.cacheContext(key.cacheId());
GridCacheContext<?, ?> cctx = ctx.cacheContext(key.cacheId());

key.prepareMarshal(cctx);
}
Expand All @@ -407,7 +399,7 @@ public boolean last() {
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
@Override public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);

if (writes != null)
Expand Down Expand Up @@ -444,7 +436,7 @@ public boolean last() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txPrepareMessageLogger();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,20 @@ public boolean isRollback() {
}

/** {@inheritDoc} */
@Override public IgniteLogger messageLogger(GridCacheSharedContext ctx) {
@Override public IgniteLogger messageLogger(GridCacheSharedContext<?, ?> ctx) {
return ctx.txPrepareMessageLogger();
}

/** {@inheritDoc} */
@Override public void prepareMarshal(GridCacheSharedContext ctx) throws IgniteCheckedException {
@Override public void prepareMarshal(GridCacheSharedContext<?, ?> ctx) throws IgniteCheckedException {
super.prepareMarshal(ctx);

if (err != null && errBytes == null)
errBytes = U.marshal(ctx, err);
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
@Override public void finishUnmarshal(GridCacheSharedContext<?, ?> ctx, ClassLoader ldr) throws IgniteCheckedException {
super.finishUnmarshal(ctx, ldr);

if (errBytes != null && err == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected GridDistributedTxRemoteAdapter(
}

/** {@inheritDoc} */
@Override public void addActiveCache(GridCacheContext cacheCtx, boolean recovery) throws IgniteCheckedException {
@Override public void addActiveCache(GridCacheContext<?, ?> cacheCtx, boolean recovery) throws IgniteCheckedException {
txState.addActiveCache(cacheCtx, recovery, this);
}

Expand Down
Loading