use of org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction in project ignite by apache.
the class PlatformConfigurationUtils method readAffinityFunction.
/**
* Reads the eviction policy.
*
* @param in Stream.
* @return Affinity function.
*/
public static PlatformAffinityFunction readAffinityFunction(BinaryRawReaderEx in) {
byte plcTyp = in.readByte();
if (plcTyp == 0)
return null;
int partitions = in.readInt();
boolean exclNeighbours = in.readBoolean();
byte overrideFlags = in.readByte();
Object userFunc = in.readObjectDetached();
AffinityFunction baseFunc = null;
switch(plcTyp) {
case 1:
{
throw new IllegalStateException("FairAffinityFunction");
}
case 2:
{
RendezvousAffinityFunction f = new RendezvousAffinityFunction();
f.setPartitions(partitions);
f.setExcludeNeighbors(exclNeighbours);
baseFunc = f;
break;
}
default:
assert plcTyp == 3;
}
return new PlatformAffinityFunction(userFunc, partitions, overrideFlags, baseFunc);
}
use of org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction in project ignite by apache.
the class PlatformConfigurationUtils method writeAffinityFunction.
/**
* Writes the affinity functions.
*
* @param out Stream.
* @param f Affinity.
*/
private static void writeAffinityFunction(BinaryRawWriter out, AffinityFunction f) {
if (f instanceof PlatformDotNetAffinityFunction)
f = ((PlatformDotNetAffinityFunction) f).getFunc();
if (f instanceof RendezvousAffinityFunction) {
out.writeByte((byte) 2);
RendezvousAffinityFunction f0 = (RendezvousAffinityFunction) f;
out.writeInt(f0.getPartitions());
out.writeBoolean(f0.isExcludeNeighbors());
// override flags
out.writeByte((byte) 0);
// user func
out.writeObject(null);
} else if (f instanceof PlatformAffinityFunction) {
PlatformAffinityFunction f0 = (PlatformAffinityFunction) f;
AffinityFunction baseFunc = f0.getBaseFunc();
if (baseFunc instanceof RendezvousAffinityFunction) {
out.writeByte((byte) 2);
out.writeInt(f0.partitions());
out.writeBoolean(((RendezvousAffinityFunction) baseFunc).isExcludeNeighbors());
out.writeByte(f0.getOverrideFlags());
out.writeObject(f0.getUserFunc());
} else {
out.writeByte((byte) 3);
out.writeInt(f0.partitions());
// exclude neighbors
out.writeBoolean(false);
out.writeByte(f0.getOverrideFlags());
out.writeObject(f0.getUserFunc());
}
} else {
out.writeByte((byte) 0);
}
}
Aggregations