Search in sources :

Example 1 with Member

use of org.apache.geode.tools.pulse.internal.data.Cluster.Member 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)

Example 2 with Member

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

the class PropMockDataUpdater method initializeMember.

private Member initializeMember(String id, String name, boolean manager, boolean isCache, boolean isLocator, boolean isServer, String host) {
    Member m = new Member();
    m.setId(id);
    m.setName(name);
    // m.setHost(getHostName(System.currentTimeMillis()));
    m.setHost(host);
    m.setMaxHeapSize(247);
    Random r = new Random(System.currentTimeMillis());
    m.setCache(isCache);
    m.setLocator(isLocator);
    m.setServer(isServer);
    m.setManager(manager);
    m.setLoadAverage((double) Math.abs(r.nextInt(100)));
    m.setNumThreads(Math.abs(r.nextInt(100)));
    m.setGarbageCollectionCount((long) Math.abs(r.nextInt(100)));
    m.getGarbageCollectionSamples().add(m.getGarbageCollectionCount());
    m.setTotalFileDescriptorOpen((long) Math.abs(r.nextInt(100)));
    m.setTotalDiskUsage(Math.abs(r.nextInt(100)));
    m.setThroughputWrites(Math.abs(r.nextInt(10)));
    m.getThroughputWritesTrend().add(m.getThroughputWrites());
    GatewayReceiver gatewayReceiver = m.getGatewayReceiver();
    String port = cluster.getPort();
    if (port == null || "".equals(port))
        port = "1099";
    gatewayReceiver.setListeningPort(Integer.parseInt(port));
    gatewayReceiver.setLinkThroughput(Math.abs(r.nextInt(10)));
    gatewayReceiver.setAvgBatchProcessingTime((long) Math.abs(r.nextInt(10)));
    gatewayReceiver.setId(String.valueOf(Math.abs(r.nextInt(10))));
    gatewayReceiver.setQueueSize(Math.abs(r.nextInt(10)));
    gatewayReceiver.setStatus(true);
    gatewayReceiver.setBatchSize(Math.abs(r.nextInt(10)));
    int gatewaySenderCount = Math.abs(r.nextInt(10));
    List<GatewaySender> list = m.getGatewaySenderList();
    for (int i = 0; i < gatewaySenderCount; i++) {
        list.add(createGatewaySenderCount(r));
    }
    Map<String, List<Member>> physicalToMember = cluster.getPhysicalToMember();
    List<Cluster.Member> memberArrList = physicalToMember.get(m.getHost());
    if (memberArrList != null) {
        memberArrList.add(m);
    } else {
        ArrayList<Cluster.Member> memberList = new ArrayList<>();
        memberList.add(m);
        physicalToMember.put(m.getHost(), memberList);
    }
    int memberCount = cluster.getMemberCount();
    memberCount++;
    cluster.setMemberCount(memberCount);
    return m;
}
Also used : GatewaySender(org.apache.geode.tools.pulse.internal.data.Cluster.GatewaySender) Random(java.util.Random) ArrayList(java.util.ArrayList) GatewayReceiver(org.apache.geode.tools.pulse.internal.data.Cluster.GatewayReceiver) ArrayList(java.util.ArrayList) List(java.util.List) Member(org.apache.geode.tools.pulse.internal.data.Cluster.Member)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Random (java.util.Random)2 Member (org.apache.geode.tools.pulse.internal.data.Cluster.Member)2 HashMap (java.util.HashMap)1 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)1 Client (org.apache.geode.tools.pulse.internal.data.Cluster.Client)1 GatewayReceiver (org.apache.geode.tools.pulse.internal.data.Cluster.GatewayReceiver)1 GatewaySender (org.apache.geode.tools.pulse.internal.data.Cluster.GatewaySender)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