Search in sources :

Example 1 with Client

use of org.apache.geode.tools.pulse.internal.data.Cluster.Client in project geode by apache.

the class PropMockDataUpdater method initMemberClient.

private Client initMemberClient(int count, String host) {
    Client memberClient = new Client();
    Random r = new Random(System.currentTimeMillis());
    memberClient.setName("Name_" + count);
    long processCpuTime = (long) (r.nextDouble() * 100);
    memberClient.setProcessCpuTime(processCpuTime);
    memberClient.setCpuUsage(0);
    memberClient.setGets(Math.abs(r.nextInt(100)));
    memberClient.setHost(host);
    memberClient.setId(String.valueOf(1000 + count));
    memberClient.setPuts(Math.abs(r.nextInt(100)));
    memberClient.setCpus(Math.abs(r.nextInt(20)));
    memberClient.setQueueSize(Math.abs(r.nextInt(100)));
    if ((count % 2) == 0) {
        memberClient.setStatus("up");
    } else {
        memberClient.setStatus("down");
    }
    memberClient.setThreads(Math.abs(r.nextInt(100)));
    memberClient.setUptime(Math.abs(System.currentTimeMillis() - r.nextLong()));
    return memberClient;
}
Also used : Random(java.util.Random) Client(org.apache.geode.tools.pulse.internal.data.Cluster.Client)

Example 2 with Client

use of org.apache.geode.tools.pulse.internal.data.Cluster.Client in project geode by apache.

the class PropMockDataUpdater method updateData.

/**
   * function used for updating Cluster data for Mock
   */
@Override
public boolean updateData() {
    cluster.setConnectedFlag(true);
    Random r = new Random(System.currentTimeMillis());
    long totalHeapSize = Math.abs(r.nextInt(3200 - 2048) + 2048);
    cluster.setTotalHeapSize(totalHeapSize);
    long usedHeapSize = Math.abs(r.nextInt(2048));
    cluster.setUsedHeapSize(usedHeapSize);
    double writePerSec = Math.abs(r.nextInt(100));
    cluster.setWritePerSec(writePerSec);
    // propfile
    cluster.setSubscriptionCount(testbed.getRootDs().getClients().size());
    cluster.setRegisteredCQCount((long) testbed.getRootDs().getCQs().size());
    cluster.setRunningFunctionCount(testbed.getRootDs().getFunction().size());
    cluster.setClusterId(Math.abs(r.nextInt(100)));
    cluster.getWritePerSecTrend().add(writePerSec);
    cluster.setDiskWritesRate(writePerSec);
    long garbageCollectionCount = Math.abs(r.nextInt(100));
    cluster.setGarbageCollectionCount(garbageCollectionCount);
    cluster.getGarbageCollectionTrend().add(garbageCollectionCount);
    long readPerSec = Math.abs(r.nextInt(100));
    cluster.setReadPerSec(readPerSec);
    cluster.getReadPerSecTrend().add(readPerSec);
    long diskReadsRate = readPerSec;
    cluster.setDiskReadsRate(diskReadsRate);
    cluster.setDiskReadsRate(readPerSec);
    long queriesPerSec = Math.abs(r.nextInt(100));
    cluster.setQueriesPerSec(queriesPerSec);
    cluster.getQueriesPerSecTrend().add(queriesPerSec);
    long loadPerSec = Math.abs(r.nextInt(100));
    cluster.setLoadPerSec(loadPerSec);
    cluster.setTotalHeapSize(totalHeapSize);
    long totalBytesOnDisk = totalHeapSize;
    cluster.setTotalBytesOnDisk(totalBytesOnDisk);
    cluster.getTotalBytesOnDiskTrend().add(totalBytesOnDisk);
    cluster.getMemoryUsageTrend().add(usedHeapSize);
    cluster.getThroughoutWritesTrend().add(writePerSec);
    cluster.setMemberCount(0);
    Map<String, Cluster.Member> membersHMap = cluster.getMembersHMap();
    List<Cluster.Region> regionsList = (List<Cluster.Region>) cluster.getClusterRegions().values();
    Map<String, Boolean> wanInformation = cluster.getWanInformation();
    // Create 3 members first time around
    int locatorCount = 0;
    if (membersHMap.size() == 0) {
        for (Locator locator : testbed.getRootDs().getLocators()) {
            String id = "(Launcher_Locator-1099-13-40-24-5368)-" + locatorCount++;
            String name = locator.getName();
            membersHMap.put(id + name, initializeMember(id, name, true, true, true, false, locator.getHost()));
        }
        cluster.setLocatorCount(testbed.getRootDs().getLocators().size());
        int serverCount = 0;
        for (Server server : testbed.getRootDs().getServers()) {
            String id = "(Launcher_Server-1099-13-40-24-5368)-" + serverCount++;
            String name = server.getName();
            membersHMap.put(id + name, initializeMember(id, name, false, true, false, true, server.getHost()));
        }
        cluster.setServerCount(testbed.getRootDs().getServers().size());
        int peerCount = 0;
        for (Peer peer : testbed.getRootDs().getPeers()) {
            String id = "(Launcher_Peer-1099-13-40-24-5368)-" + peerCount++;
            String name = peer.getName();
            membersHMap.put(id + name, initializeMember(id, name, false, true, false, false, peer.getHost()));
        }
        for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
            HashMap<String, Cluster.Region> memberRegions = new HashMap<>();
            HashMap<String, Cluster.Client> memberClientsHM = new HashMap<>();
            Random randomGenerator = new Random();
            // Read from property file
            int randomInt = (randomGenerator.nextInt(5)) + 1;
            List<org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Region> thisMemberRegions = testbed.getRootDs().getRegions(memberSet.getValue().getName());
            int regionExists = 0;
            int index = 0;
            for (org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Region thisMemberRegion : thisMemberRegions) {
                Region region = initMemberRegion(index++, thisMemberRegion.getName(), memberSet.getValue().getName(), thisMemberRegion.getEntryCount(), thisMemberRegion.getType(), // read from
                thisMemberRegion.getMembers().size());
                // property file
                if (regionsList.size() > 0) {
                    for (Region clusterRegion : regionsList) {
                        if ((region.getName()).equals(clusterRegion.getName())) {
                            clusterRegion.getMemberName().add(memberSet.getValue().getName());
                            // clusterRegion.memberCount = clusterRegion.memberCount + 1;
                            // int mcount = clusterRegion.getMemberCount() + 1;
                            // clusterRegion.setMemberCount(mcount);
                            regionExists = 1;
                            break;
                        }
                    }
                    if (regionExists == 0) {
                        regionsList.add(region);
                    }
                } else {
                    regionsList.add(region);
                }
                memberRegions.put(region.getFullPath(), region);
                // totalRegionCount = regionsList.size();
                cluster.setTotalRegionCount(regionsList.size());
            }
            membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
            if (memberSet.getValue().isCache()) {
                // read from prop
                Client client = initMemberClient(0, memberSet.getValue().getHost());
                // File
                memberClientsHM.put(client.getId(), client);
                randomInt = randomGenerator.nextInt(10);
                for (int y = 1; y < randomInt; y++) {
                    Client newClient = initMemberClient(y, memberSet.getValue().getHost());
                    memberClientsHM.put(newClient.getId(), newClient);
                }
                membersHMap.get(memberSet.getKey()).updateMemberClientsHMap(memberClientsHM);
                /*
           * clientConnectionCount = clientConnectionCount +
           * membersHMap.get(memberSet.getKey()).getMemberClientsHMap().size();
           */
                long clientConnectionCount = cluster.getClientConnectionCount() + membersHMap.get(memberSet.getKey()).getMemberClientsHMap().size();
                cluster.setClientConnectionCount(clientConnectionCount);
            }
        }
    }
    // read from property file
    wanInformation.clear();
    int wanInfoSize = Math.abs(r.nextInt(10));
    wanInfoSize++;
    for (int i = 0; i < wanInfoSize; i++) {
        String name = "Mock Cluster" + i;
        Boolean value = false;
        if (i % 2 == 0) {
            value = true;
        }
        wanInformation.put(name, value);
    }
    // memberCount = membersHMap.size();
    cluster.setMemberCount(membersHMap.size());
    totalHeapSize = 0;
    for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
        refresh(membersHMap.get(memberSet.getKey()));
        Member member = membersHMap.get(memberSet.getKey());
        totalHeapSize += member.getCurrentHeapSize();
    }
    for (Region region : regionsList) {
        region.setGetsRate((Math.abs(r.nextInt(100))) + 1);
        region.setPutsRate((Math.abs(r.nextInt(100))) + 1);
        region.getGetsPerSecTrend().add(region.getGetsRate());
        region.getPutsPerSecTrend().add(region.getPutsRate());
    }
    return true;
}
Also used : Server(org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Server) HashMap(java.util.HashMap) Locator(org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator) Random(java.util.Random) ArrayList(java.util.ArrayList) List(java.util.List) Client(org.apache.geode.tools.pulse.internal.data.Cluster.Client) Member(org.apache.geode.tools.pulse.internal.data.Cluster.Member) Peer(org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) Region(org.apache.geode.tools.pulse.internal.data.Cluster.Region)

Aggregations

Random (java.util.Random)2 Client (org.apache.geode.tools.pulse.internal.data.Cluster.Client)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)1 Member (org.apache.geode.tools.pulse.internal.data.Cluster.Member)1 Region (org.apache.geode.tools.pulse.internal.data.Cluster.Region)1 Locator (org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator)1 Peer (org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer)1 Server (org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Server)1