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

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

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common.Monitoring;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;

public class ClientMonitor implements Serializable {
    private String _clientID;
    private String _address;
    private java.util.ArrayList _activities = new java.util.ArrayList();
    private java.util.HashMap _currentActivities = new HashMap();


    public ClientMonitor(String id, String address) {
        _clientID = id;
        _address = address;
    }

    public final String getID() {
        return _clientID;
    }

    public final String getAddress() {
        return _address;
    }

    public final ClienfInfo getInfo() {
        return new ClienfInfo(_clientID, _address);
    }

    public final void StartActivity() {
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
//#if VS2005
        ClientActivity acitvity = new ClientActivity();
        acitvity._thread = Thread.currentThread();
        long tId = Thread.currentThread().getId();


        _currentActivities.put(tId, acitvity);

//#endif
    }

    public final void StopActivity() {
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
//#if VS2005
        long tId = Thread.currentThread().getId();
        ClientActivity activity = null;

        activity = (ClientActivity) ((_currentActivities.get(tId) instanceof ClientActivity) ? _currentActivities.get(tId) : null);
        _currentActivities.remove(tId);

        if (activity != null) {
            activity.StopActivity();

            _activities.add(activity);

        }
//#endif
    }

    public final void LogActivity(String method, String log) {
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
//#if VS2005
        ClientActivity activity = (ClientActivity) ((_currentActivities.get(Thread.currentThread().getId()) instanceof ClientActivity) ? _currentActivities.get(Thread.currentThread().getId()) : null);
        if (activity != null) {
            activity.LogActivity(method, log);
        }
//#endif
    }

    public final void Clear() {

        _activities.clear();


        _currentActivities.clear();

    }

    public final java.util.ArrayList GetCompletedClientActivities() {
        java.util.ArrayList completedActivities = null;

        Object tempVar = _activities.clone();
        completedActivities = (java.util.ArrayList) ((tempVar instanceof java.util.ArrayList) ? tempVar : null);


        return completedActivities;
    }

    public final java.util.ArrayList GetCurrentClientActivities() throws CloneNotSupportedException {
        java.util.ArrayList completedActivities = new java.util.ArrayList();

        Iterator ide = _currentActivities.entrySet().iterator();
        while (ide.hasNext()) {
            Object obj = ide.next();
            if (obj != null) {
                completedActivities.add(((ClientActivity) obj).clone());
            }
        }

        return completedActivities;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy