Search in sources :

Example 1 with MachineListener

use of com.insightfullogic.honest_profiler.core.MachineListener in project honest-profiler by jvm-profiling-tools.

the class AgentIntegrationTest method discoverVirtualMachines.

private AtomicReference<Profile> discoverVirtualMachines() {
    AtomicReference<Profile> lastProfile = new AtomicReference<>();
    parkNanos(SECONDS.toNanos(1));
    new LocalMachineSource(logger, new MachineListener() {

        @Override
        public void onNewMachine(final VirtualMachine machine) {
            if (machine.isAgentLoaded()) {
                final FileLogSource logSource = (FileLogSource) machine.getLogSource();
                file.set(logSource);
                Monitor.pipeFile(logSource, lastProfile::set);
            }
        }

        @Override
        public void onClosedMachine(final VirtualMachine machine) {
        }
    }).discoverVirtualMachines();
    return lastProfile;
}
Also used : FileLogSource(com.insightfullogic.honest_profiler.ports.sources.FileLogSource) LocalMachineSource(com.insightfullogic.honest_profiler.ports.sources.LocalMachineSource) AtomicReference(java.util.concurrent.atomic.AtomicReference) MachineListener(com.insightfullogic.honest_profiler.core.MachineListener) Profile(com.insightfullogic.honest_profiler.core.profiles.Profile) VirtualMachine(com.insightfullogic.honest_profiler.core.sources.VirtualMachine)

Aggregations

MachineListener (com.insightfullogic.honest_profiler.core.MachineListener)1 Profile (com.insightfullogic.honest_profiler.core.profiles.Profile)1 VirtualMachine (com.insightfullogic.honest_profiler.core.sources.VirtualMachine)1 FileLogSource (com.insightfullogic.honest_profiler.ports.sources.FileLogSource)1 LocalMachineSource (com.insightfullogic.honest_profiler.ports.sources.LocalMachineSource)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1