All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.internal.cluster.impl.ClusterDataSerializerHook Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed 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 com.hazelcast.internal.cluster.impl;

import com.hazelcast.cluster.Address;
import com.hazelcast.cluster.impl.MemberImpl;
import com.hazelcast.cluster.impl.VectorClock;
import com.hazelcast.instance.EndpointQualifier;
import com.hazelcast.internal.serialization.DataSerializerHook;
import com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory;
import com.hazelcast.nio.serialization.DataSerializableFactory;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.version.MemberVersion;
import com.hazelcast.version.Version;

import java.util.function.Supplier;

public final class ClusterDataSerializerHook
        implements DataSerializerHook {

    public static final int F_ID = 0;

    // never reassign numbers, in case of deletion leave a number gap.
    public static final int ADDRESS = 1;
    public static final int MEMBER = 2;
    public static final int ENDPOINT_QUALIFIER = 17;
    public static final int MEMBER_INFO = 25;
    public static final int MEMBER_VERSION = 29;
    public static final int VERSION = 32;
    public static final int VECTOR_CLOCK = 40;
    public static final int MEMBERS_VIEW_RESPONSE = 42;


    static final int LEN = MEMBERS_VIEW_RESPONSE + 1;

    @Override
    public int getFactoryId() {
        return F_ID;
    }

    @Override
    public DataSerializableFactory createFactory() {
        Supplier[] constructors = new Supplier[LEN];

        constructors[ADDRESS] = Address::new;
        constructors[VERSION] = Version::new;
        constructors[MEMBER_VERSION] = MemberVersion::new;
        constructors[MEMBER] = MemberImpl::new;
        constructors[ENDPOINT_QUALIFIER] = EndpointQualifier::new;
        constructors[VECTOR_CLOCK] = VectorClock::new;
        return new ArrayDataSerializableFactory(constructors);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy