<commit_before>/*******************************************************************************
 * 
 * Copyright (c) 2012 GigaSpaces Technologies Ltd. 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 org.openspaces.admin.samples;

import org.openspaces.admin.Admin;
import org.openspaces.admin.AdminFactory;
import org.openspaces.admin.esm.ElasticServiceManager;
import org.openspaces.admin.gsc.GridServiceContainer;
import org.openspaces.admin.gsm.GridServiceManager;
import org.openspaces.admin.lus.LookupService;
import org.openspaces.admin.machine.Machine;
import org.openspaces.admin.os.OperatingSystemStatistics;
import org.openspaces.admin.pu.ProcessingUnit;
import org.openspaces.admin.pu.ProcessingUnitInstance;
import org.openspaces.admin.space.Space;
import org.openspaces.admin.space.SpaceInstance;
import org.openspaces.admin.space.SpacePartition;
import org.openspaces.admin.vm.VirtualMachine;
import org.openspaces.pu.service.ServiceMonitors;

/**
 * @author kimchy
 */
public class TestSampler {

    public static void main(String[] args) throws InterruptedException {
        Admin admin = new AdminFactory().addGroup("kimchy").createAdmin();
        ProcessingUnit myPU = admin.getProcessingUnits().getProcessingUnit("myPU");

//        admin.getGridServiceManagers().waitFor(2);
//        Space space1 = admin.getSpaces().waitFor("test");
//        space1.waitFor(1, SpaceMode.PRIMARY);
        while (true) {
            try {
                for (LookupService lookupService : admin.getLookupServices()) {
                    System.out.println("Lookup [" + lookupService.getUid() + "] : " + lookupService.getMachine());
                }
                for (ElasticServiceManager esm : admin.getElasticServiceManagers()) {
                    System.out.println("ESM [" + esm.getUid() + "] running on Machine " + esm.getMachine().getHostAddress());
                }
                for (GridServiceManager gsm : admin.getGridServiceManagers()) {
                    System.out.println("GSM [" + gsm.getUid() + "] running on Machine " + gsm.getMachine().getHostAddress());
                }
                for (GridServiceContainer gsc : admin.getGridServiceContainers()) {
                    System.out.println("GSC [" + gsc.getUid() + "] running on Machine " + gsc.getMachine().getHostAddress());
                    for (ProcessingUnitInstance puInstance : gsc) {
                        System.out.println("   -> PU [" + puInstance.getName() + "][" + puInstance.getInstanceId() + "][" + puInstance.getBackupId() + "]");
                    }
                }
//                for (GridServiceAgent gsa : admin.getGridServiceAgents()) {
//                    System.out.println("GSA [" + gsa.getUid() + "] running on Machine [" + gsa.getMachine().getHostAddress());
//                    for (AgentProcessDetails processDetails : gsa.getProcessesDetails()) {
//                        System.out.println("   -> Process [" + Arrays.toString(processDetails.getCommand()) + "]");
//                    }
//                }
//                System.out.println("VM TOTAL STATS: Heap Committed [" + admin.getVirtualMachines().getStatistics().getMemoryHeapCommittedInGB() + "GB]");
//                System.out.println("VM TOTAL STATS: GC PERC [" + admin.getVirtualMachines().getStatistics().getGcCollectionPerc() + "], Heap Used [" + admin.getVirtualMachines().getStatistics().getMemoryHeapPerc() + "%]");
                for (VirtualMachine virtualMachine : admin.getVirtualMachines()) {
                    System.out.println("VM [" + virtualMachine.getUid() + "] " +
                            "PID [" + virtualMachine.getDetails().getPid() + "] " +
                            "Host [" + virtualMachine.getMachine().getHostAddress() + "] " +
                            "CPU [" + virtualMachine.getStatistics().getCpuPercFormatted() + "] " +
                            "GC Perc [" + virtualMachine.getStatistics().getGcCollectionPerc() + "], " +
                            "Heap Usage [" + virtualMachine.getStatistics().getMemoryHeapUsedPerc() + "%]");

//                    for (ProcessingUnitInstance processingUnitInstance : virtualMachine.getProcessingUnitInstances()) {
//                        System.out.println("   -> PU [" + processingUnitInstance.getUid() + "]");
//                    }
//                    for (SpaceInstance spaceInstance : virtualMachine.getSpaceInstances()) {
//                        System.out.println("   -> Space [" + spaceInstance.getUid() + "]");
//                    }
                }
                for (Machine machine : admin.getMachines()) {
                    System.out.println("Machine [" + machine.getUid() + "], Processors [" + machine.getOperatingSystem().getDetails().getAvailableProcessors() + "] CPU [" + machine.getOperatingSystem().getStatistics().getCpuPerc() + "]");
                    System.out.println(" | " + machine.getOperatingSystem().getStatistics().getTimestamp() + " -> " + machine.getOperatingSystem().getStatistics().getAdminTimestamp());
                    if (machine.getOperatingSystem().getStatistics().getNetworkStats() != null) {
                    for (OperatingSystemStatistics.NetworkStatistics netStats : machine.getOperatingSystem().getStatistics().getNetworkStats().values()) {
                        System.out.println("   -> " + netStats.getName() + ", Rx " + netStats.getRxBytes() + ", Tx " + netStats.getTxBytes() + ", RxPerSecond " + netStats.getRxBytesPerSecond() + ", TxPerSecond " + netStats.getTxBytesPerSecond());
                    }
                    }
//                    System.out.println("   -> Mem Total [" + machine.getOperatingSystem().getDetails().getTotalPhysicalMemorySizeInGB() + "GB], " + "Free [" + machine.getOperatingSystem().getStatistics().getFreePhysicalMemorySizeInGB() + "GB]");
//                    System.out.println("   -> Swap Total [" + machine.getOperatingSystem().getDetails().getTotalSwapSpaceSizeInGB() + "GB], " + "Free [" + machine.getOperatingSystem().getStatistics().getFreeSwapSpaceSizeInGB() + "GB]");
//                    for (SpaceInstance spaceInstance : machine.getSpaceInstances()) {
//                        System.out.println("   -> Space [" + spaceInstance.getUid() + "]");
//                    }
//                    for (ProcessingUnitInstance processingUnitInstance : machine.getProcessingUnitInstances()) {
//                        System.out.println("   -> PU [" + processingUnitInstance.getUid() + "]");
//                    }
                }
                for (ProcessingUnit processingUnit : admin.getProcessingUnits()) {
                    System.out.println("Processing Unit: " + processingUnit.getName() + " status: " + processingUnit.getStatus());
                    if (processingUnit.isManaged()) {
                        System.out.println("   -> Managing GSM: " + processingUnit.getManagingGridServiceManager().getUid());
                    } else {
                        System.out.println("   -> Managing GSM: NA");
                    }
                    for (GridServiceManager backupGSM : processingUnit.getBackupGridServiceManagers()) {
                        System.out.println("   -> Backup GSM: " + backupGSM.getUid());
                    }
                    for (ProcessingUnitInstance processingUnitInstance : processingUnit) {
                        System.out.println("   [" + processingUnitInstance.getClusterInfo() + "] on GSC [" + processingUnitInstance.getGridServiceContainer().getUid() + "]");
                        for (ServiceMonitors monitors : processingUnitInstance.getStatistics()) {
                            System.out.println("      -> Service [" + monitors.getDetails().getId() + "] " + monitors.getMonitors());
                        }
                    }
                }
                for (Space space : admin.getSpaces()) {
                    System.out.println("Space [" + space.getUid() + "] numberOfInstances [" + space.getNumberOfInstances() + "] numberOfbackups [" + space.getNumberOfBackups() + "]");
                    System.out.println("  Stats: Write [" + space.getStatistics().getWriteCount() + "/" + space.getStatistics().getWritePerSecond() + "]");
                    for (SpaceInstance spaceInstance : space) {
                        System.out.println("   -> INSTANCE [" + spaceInstance.getUid() + "] instanceId [" + spaceInstance.getInstanceId() +
                                "] backupId [" + spaceInstance.getBackupId() + "] Mode [" + spaceInstance.getMode() + "]");
                        System.out.println("         -> Host: " + spaceInstance.getMachine().getHostAddress());<commit_msg>GS-12498 usw a single rocksdb instance instead of 10 per space<commit_after>/*******************************************************************************
 * 
 * Copyright (c) 2012 GigaSpaces Technologies Ltd. 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 org.openspaces.admin.samples;

import org.openspaces.admin.Admin;
import org.openspaces.admin.AdminFactory;
import org.openspaces.admin.esm.ElasticServiceManager;
import org.openspaces.admin.gsc.GridServiceContainer;
import org.openspaces.admin.gsm.GridServiceManager;
import org.openspaces.admin.lus.LookupService;
import org.openspaces.admin.machine.Machine;
import org.openspaces.admin.os.OperatingSystemStatistics;
import org.openspaces.admin.pu.ProcessingUnit;
import org.openspaces.admin.pu.ProcessingUnitInstance;
import org.openspaces.admin.space.Space;
import org.openspaces.admin.space.SpaceInstance;
import org.openspaces.admin.space.SpacePartition;
import org.openspaces.admin.vm.VirtualMachine;
import org.openspaces.core.space.SpaceServiceDetails;
import org.openspaces.pu.service.ServiceDetails;
import org.openspaces.pu.service.ServiceMonitors;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author kimchy
 */
public class TestSampler {

    public static void main(String[] args) throws InterruptedException {
        Admin admin = new AdminFactory().addGroup("kobi").addLocator("pc-lab132").createAdmin();
        Map<String, ServiceMonitors> monitors = admin.getProcessingUnits().getProcessingUnit("rocksdb-pu").getInstances()[0].getStatistics().getMonitors();
        ServiceDetails details = admin.getProcessingUnits().getProcessingUnit("rocksdb-pu").getInstances()[0].getServiceDetailsByServiceId("RocksDB");

//        Admin admin = new AdminFactory().addGroup("kobi").addLocator("pc-lab132").createAdmin();
//        Map<String, ServiceMonitors> monitors = admin.getProcessingUnits().getProcessingUnit("blobstore-pu").getInstances()[0].getStatistics().getMonitors();
//        ServiceDetails details = admin.getProcessingUnits().getProcessingUnit("blobstore-pu").getInstances()[0].getServiceDetailsByServiceId("ZetaScale");


//        admin.getGridServiceManagers().waitFor(2);
//        Space space1 = admin.getSpaces().waitFor("test");
//        space1.waitFor(1, SpaceMode.PRIMARY);
        while (true) {
            try {
                for (LookupService lookupService : admin.getLookupServices()) {
                    System.out.println("Lookup [" + lookupService.getUid() + "] : " + lookupService.getMachine());
                }
                for (ElasticServiceManager esm : admin.getElasticServiceManagers()) {
                    System.out.println("ESM [" + esm.getUid() + "] running on Machine " + esm.getMachine().getHostAddress());
                }
                for (GridServiceManager gsm : admin.getGridServiceManagers()) {
                    System.out.println("GSM [" + gsm.getUid() + "] running on Machine " + gsm.getMachine().getHostAddress());
                }
                for (GridServiceContainer gsc : admin.getGridServiceContainers()) {
                    System.out.println("GSC [" + gsc.getUid() + "] running on Machine " + gsc.getMachine().getHostAddress());
                    for (ProcessingUnitInstance puInstance : gsc) {
                        System.out.println("   -> PU [" + puInstance.getName() + "][" + puInstance.getInstanceId() + "][" + puInstance.getBackupId() + "]");
                    }
                }
//                for (GridServiceAgent gsa : admin.getGridServiceAgents()) {
//                    System.out.println("GSA [" + gsa.getUid() + "] running on Machine [" + gsa.getMachine().getHostAddress());
//                    for (AgentProcessDetails processDetails : gsa.getProcessesDetails()) {
//                        System.out.println("   -> Process [" + Arrays.toString(processDetails.getCommand()) + "]");
//                    }
//                }
//                System.out.println("VM TOTAL STATS: Heap Committed [" + admin.getVirtualMachines().getStatistics().getMemoryHeapCommittedInGB() + "GB]");
//                System.out.println("VM TOTAL STATS: GC PERC [" + admin.getVirtualMachines().getStatistics().getGcCollectionPerc() + "], Heap Used [" + admin.getVirtualMachines().getStatistics().getMemoryHeapPerc() + "%]");
                for (VirtualMachine virtualMachine : admin.getVirtualMachines()) {
                    System.out.println("VM [" + virtualMachine.getUid() + "] " +
                            "PID [" + virtualMachine.getDetails().getPid() + "] " +
                            "Host [" + virtualMachine.getMachine().getHostAddress() + "] " +
                            "CPU [" + virtualMachine.getStatistics().getCpuPercFormatted() + "] " +
                            "GC Perc [" + virtualMachine.getStatistics().getGcCollectionPerc() + "], " +
                            "Heap Usage [" + virtualMachine.getStatistics().getMemoryHeapUsedPerc() + "%]");

//                    for (ProcessingUnitInstance processingUnitInstance : virtualMachine.getProcessingUnitInstances()) {
//                        System.out.println("   -> PU [" + processingUnitInstance.getUid() + "]");
//                    }
//                    for (SpaceInstance spaceInstance : virtualMachine.getSpaceInstances()) {
//                        System.out.println("   -> Space [" + spaceInstance.getUid() + "]");
//                    }
                }
                for (Machine machine : admin.getMachines()) {
                    System.out.println("Machine [" + machine.getUid() + "], Processors [" + machine.getOperatingSystem().getDetails().getAvailableProcessors() + "] CPU [" + machine.getOperatingSystem().getStatistics().getCpuPerc() + "]");
                    System.out.println(" | " + machine.getOperatingSystem().getStatistics().getTimestamp() + " -> " + machine.getOperatingSystem().getStatistics().getAdminTimestamp());
                    if (machine.getOperatingSystem().getStatistics().getNetworkStats() != null) {
                    for (OperatingSystemStatistics.NetworkStatistics netStats : machine.getOperatingSystem().getStatistics().getNetworkStats().values()) {
                        System.out.println("   -> " + netStats.getName() + ", Rx " + netStats.getRxBytes() + ", Tx " + netStats.getTxBytes() + ", RxPerSecond " + netStats.getRxBytesPerSecond() + ", TxPerSecond " + netStats.getTxBytesPerSecond());
                    }
                    }
//                    System.out.println("   -> Mem Total [" + machine.getOperatingSystem().getDetails().getTotalPhysicalMemorySizeInGB() + "GB], " + "Free [" + machine.getOperatingSystem().getStatistics().getFreePhysicalMemorySizeInGB() + "GB]");
//                    System.out.println("   -> Swap Total [" + machine.getOperatingSystem().getDetails().getTotalSwapSpaceSizeInGB() + "GB], " + "Free [" + machine.getOperatingSystem().getStatistics().getFreeSwapSpaceSizeInGB() + "GB]");
//                    for (SpaceInstance spaceInstance : machine.getSpaceInstances()) {
//                        System.out.println("   -> Space [" + spaceInstance.getUid() + "]");
//                    }
//                    for (ProcessingUnitInstance processingUnitInstance : machine.getProcessingUnitInstances()) {
//                        System.out.println("   -> PU [" + processingUnitInstance.getUid() + "]");
//                    }
                }
                for (ProcessingUnit processingUnit : admin.getProcessingUnits()) {
                    System.out.println("Processing Unit: " + processingUnit.getName() + " status: " + processingUnit.getStatus());
                    if (processingUnit.isManaged()) {
                        System.out.println("   -> Managing GSM: " + processingUnit.getManagingGridServiceManager().getUid());
                    } else {
                        System.out.println("   -> Managing GSM: NA");
                    }
                    for (GridServiceManager backupGSM : processingUnit.getBackupGridServiceManagers()) {
                        System.out.println("   -> Backup GSM: " + backupGSM.getUid());
                    }
                    for (ProcessingUnitInstance processingUnitInstance : processingUnit) {
                        System.out.println("   [" + processingUnitInstance.getClusterInfo() + "] on GSC [" + processingUnitInstance.getGridServiceContainer().getUid() + "]");
                        for (ServiceMonitors monitors1 : processingUnitInstance.getStatistics()) {
                            System.out.println("      -> Service [" + monitors1.getDetails().getId() + "] " + monitors1.getMonitors());
                        }
                    }
                }
                for (Space space : admin.getSpaces()) {
                    System.out.println("Space [" + space.getUid() + "] numberOfInstances [" + space.getNumberOfInstances() + "] numberOfbackups [" + space.getNumberOfBackups() + "]");
                    System.out.println("  Stats: Write [" + space.getStatistics().getWriteCount() + "/" + space.getStatistics().getWritePerSecond() + "]");
                    for (SpaceInstance spaceInstance : space) {
                        System.out.println("   -> INSTANCE [" + spaceInstance.getUid() + "] instanceId [" + spaceInstance.getInstanceId() +
                                "] backupId [" + spaceInstance.getBackupId() + "] Mode [" + spaceInstance.getMode() + "]");
                        System.out.println("         -> Host: " + spaceInstance.getMachine().getHostAddress());
{'fraction_non_alphanumeric': 0.15297072845645154, 'fraction_numerical': 0.0022556005536474087, 'mean_word_length': 2.4098933752840415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5010097', 'n_tokens_mistral': 5074, 'n_tokens_neox': 4854, 'n_words': 822}