-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexey Goncharuk <alexey.goncharuk@gmail.com>
- Loading branch information
1 parent
d5432c0
commit a232b88
Showing
8 changed files
with
427 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
.../internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.processors.cache.distributed.dht.preloader; | ||
|
||
import java.nio.ByteBuffer; | ||
import org.apache.ignite.IgniteCheckedException; | ||
import org.apache.ignite.internal.GridDirectTransient; | ||
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; | ||
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; | ||
import org.apache.ignite.internal.util.typedef.internal.U; | ||
import org.apache.ignite.lang.IgniteProductVersion; | ||
import org.apache.ignite.plugin.extensions.communication.MessageReader; | ||
import org.apache.ignite.plugin.extensions.communication.MessageWriter; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Supply message with supplier error transfer support. | ||
*/ | ||
public class GridDhtPartitionSupplyMessageV2 extends GridDhtPartitionSupplyMessage { | ||
/** */ | ||
private static final long serialVersionUID = 0L; | ||
|
||
/** Available since. */ | ||
public static final IgniteProductVersion AVAILABLE_SINCE = IgniteProductVersion.fromString("2.7.0"); | ||
|
||
/** Supplying process error. */ | ||
@GridDirectTransient | ||
private Throwable err; | ||
|
||
/** Supplying process error bytes. */ | ||
private byte[] errBytes; | ||
|
||
/** | ||
* Default constructor. | ||
*/ | ||
public GridDhtPartitionSupplyMessageV2() { | ||
} | ||
|
||
/** | ||
* @param rebalanceId Rebalance id. | ||
* @param grpId Group id. | ||
* @param topVer Topology version. | ||
* @param addDepInfo Add dep info. | ||
* @param err Supply process error. | ||
*/ | ||
public GridDhtPartitionSupplyMessageV2( | ||
long rebalanceId, | ||
int grpId, | ||
AffinityTopologyVersion topVer, | ||
boolean addDepInfo, | ||
Throwable err | ||
) { | ||
super(rebalanceId, grpId, topVer, addDepInfo); | ||
|
||
this.err = err; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@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 { | ||
super.finishUnmarshal(ctx, ldr); | ||
|
||
if (errBytes != null && err == null) | ||
err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig())); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { | ||
writer.setBuffer(buf); | ||
|
||
if (!super.writeTo(buf, writer)) | ||
return false; | ||
|
||
if (!writer.isHeaderWritten()) { | ||
if (!writer.writeHeader(directType(), fieldsCount())) | ||
return false; | ||
|
||
writer.onHeaderWritten(); | ||
} | ||
|
||
switch (writer.state()) { | ||
case 12: | ||
if (!writer.writeByteArray("errBytes", errBytes)) | ||
return false; | ||
|
||
writer.incrementState(); | ||
|
||
} | ||
|
||
return true; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { | ||
reader.setBuffer(buf); | ||
|
||
if (!reader.beforeMessageRead()) | ||
return false; | ||
|
||
if (!super.readFrom(buf, reader)) | ||
return false; | ||
|
||
switch (reader.state()) { | ||
case 12: | ||
errBytes = reader.readByteArray("errBytes"); | ||
|
||
if (!reader.isLastRead()) | ||
return false; | ||
|
||
reader.incrementState(); | ||
|
||
} | ||
|
||
return reader.afterMessageRead(GridDhtPartitionSupplyMessageV2.class); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Nullable @Override public Throwable error() { | ||
return err; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public short directType() { | ||
return 120; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public byte fieldsCount() { | ||
return 13; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.