Search in sources :

Example 1 with PlatformAffinityFunction

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);
}
Also used : PlatformAffinityFunction(org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) PlatformAffinityFunction(org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction) PlatformDotNetAffinityFunction(org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction)

Example 2 with PlatformAffinityFunction

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);
    }
}
Also used : PlatformAffinityFunction(org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction) PlatformDotNetAffinityFunction(org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) PlatformAffinityFunction(org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction) PlatformDotNetAffinityFunction(org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction)

Aggregations

AffinityFunction (org.apache.ignite.cache.affinity.AffinityFunction)2 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)2 PlatformAffinityFunction (org.apache.ignite.internal.processors.platform.cache.affinity.PlatformAffinityFunction)2 PlatformDotNetAffinityFunction (org.apache.ignite.platform.dotnet.PlatformDotNetAffinityFunction)2