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

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

package Alachisoft.NCache.Common.Monitoring;

import Alachisoft.NCache.Common.Common;
import Alachisoft.NCache.Common.Net.Address;
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;

//CLIENTSTATS : ClientProcessStats
//C# TO JAVA CONVERTER TODO TASK: The interface type was changed to the closest equivalent Java type, but the methods implemented will need adjustment:
public class ClientProcessStats extends ClientNode implements java.lang.Comparable, InternalCompactSerializable {

    private String _processID;
    private float _bytesSent;
    private float _bytesReceived;
    private String _serverIPAddress;

    public ClientProcessStats(String clientID, Address address, float byteSent, float byteReceived, String serverIPAddress) {
        setAddress(address);
        setClientID(clientID);
        int lastIndex = clientID.lastIndexOf(":");
        if (lastIndex != -1 && lastIndex != clientID.length() - 1) {
            _processID = clientID.substring(lastIndex + 1, lastIndex + 1 + clientID.length() - lastIndex - 1);
        }
        _bytesReceived = byteReceived;
        _bytesSent = byteSent;
        _serverIPAddress = serverIPAddress;
    }

    public final String getServerIPAddress() {
        return _serverIPAddress;
    }

    public final void setServerIPAddress(String value) {
        _serverIPAddress = value;
    }

    public final String getProcessID() {
        return _processID;
    }

    public final float getBytesSent() {
        return _bytesSent;
    }

    public final void setBytesSent(float value) {
        _bytesSent = value;
    }

    public final float getBytesReceived() {
        return _bytesReceived;
    }

    public final void setBytesReceived(float value) {
        _bytesReceived = value;
    }

    //C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
    ///#region IComparable Members
    public final int compareTo(Object obj) {
        ClientProcessStats clientProcessStats = (ClientProcessStats) ((obj instanceof ClientProcessStats) ? obj : null);
        if (clientProcessStats == null) {
            return -1;
        }

        int result = 0;

        result = _processID.compareTo(clientProcessStats._processID);

        if (result != 0) {
            result = getAddress().getIpAddress().toString().compareTo(clientProcessStats.getAddress().getIpAddress().toString());
        }

        if (result != 0) {
            result = (new Integer(getAddress().getPort())).toString().compareTo((new Integer(getAddress().getPort())).toString());
        }

        if (result != 0) {
            result = _serverIPAddress.compareTo(clientProcessStats.getServerIPAddress());
        }

        if (result != 0) {
            result = (new Float(_bytesSent)).compareTo(clientProcessStats.getBytesSent());
        }

        if (result != 0) {
            result = (new Float(_bytesReceived)).compareTo(clientProcessStats.getBytesReceived());
        }

        return result;
    }

    //
    public void Deserialize(CompactReader reader) throws IOException, ClassNotFoundException {
        _processID = (String) Common.readAs(reader.ReadObject(), String.class);
        _bytesSent = reader.ReadSingle();
        _bytesReceived = reader.ReadSingle();
        _serverIPAddress = (String) Common.readAs(reader.ReadObject(), String.class);
        super.Deserialize(reader);
    }

    public void Serialize(CompactWriter writer) throws IOException {
        writer.WriteObject(_processID);
        writer.Write(_bytesSent);
        writer.Write(_bytesReceived);
        writer.WriteObject(_serverIPAddress);
        super.Serialize(writer);
    }
    //
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
    ///#endregion
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy