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

Alachisoft.NCache.Common.Monitoring.ClientNode Maven / Gradle / Ivy

package Alachisoft.NCache.Common.Monitoring;

import Alachisoft.NCache.Common.Common;
import Alachisoft.NCache.Common.Enum.RtContextValue;
import com.alachisoft.ncache.serialization.core.io.InternalCompactSerializable;
import com.alachisoft.ncache.serialization.standard.io.CompactReader;
import com.alachisoft.ncache.serialization.standard.io.CompactWriter;

import java.io.IOException;

public class ClientNode extends Node implements InternalCompactSerializable {

    private String _clientId;
    private Alachisoft.NCache.Common.Enum.RtContextValue _clientContext;

    /**
     * Gets/Sets the client-id. Each client connecting to a cache server has unique id. If client opens multiple connections with the server, this id remains some.
     */
    public final String getClientID() {
        return _clientId;
    }

    public final void setClientID(String value) {
        _clientId = value;
    }

    public final RtContextValue getClientContext() {
        return _clientContext;
    }

    public final void setClientContext(RtContextValue clientContext) {
        _clientContext = clientContext;
    }

    @Override
    public boolean equals(Object obj) {
        ClientNode other = (ClientNode) ((obj instanceof ClientNode) ? obj : null);
        if (other != null) {
            if (other.getClientID().equals(getClientID())) {
                return true;
            }
        }
        return false;
    }

    //
    public void Deserialize(CompactReader reader) throws IOException, ClassNotFoundException {
        _clientId = (String) Common.readAs(reader.ReadObject(), String.class);
        _clientContext = (String) Common.readAs(reader.ReadObject(), String.class) == "1" ? RtContextValue.JVCACHE : RtContextValue.NCACHE;
        super.Deserialize(reader);
    }

    public void Serialize(CompactWriter writer) throws IOException {
        writer.WriteObject(_clientId);
        writer.WriteObject(_clientContext == RtContextValue.JVCACHE ? "1" : "0");
        super.Serialize(writer);
    }
    //
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy