Search in sources :

Example 1 with HttpRequestSender

use of com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender in project coherence-visualvm by oracle.

the class VisualVMModel method getData.

/**
 * This is a wrapper method which will call the underlying implementation
 * to get statistics. If statistics directly from the reporter are available
 * then run the particular report, otherwise do a JMX query.
 *
 * @param requestSender  the {@link RequestSender} to use to query the report
 * @param clazz          the implementation of {@link DataRetriever} to get data for
 *
 * @return the {@link List} of data obtainer by either method
 */
public List<Entry<Object, Data>> getData(RequestSender requestSender, Class clazz) {
    boolean fFallBack = false;
    // are collecting ProxyStats, we need to force to use JMX rather than report
    if (isReporterAvailable() != null && isReporterAvailable() && !(clazz.equals(ProxyData.class) && getClusterVersionAsInt() < 122110)) {
        // retrieve the report XML for this class
        String sReportXML = f_mapReportXML.get(clazz);
        if (sReportXML == null) {
            // this means there is no report for this class
            fFallBack = true;
        }
        if (!fFallBack) {
            try {
                DataRetriever retriever = getDataRetrieverInstance(clazz);
                SortedMap<Object, Data> mapCollectedData = null;
                if (requestSender instanceof HttpRequestSender) {
                    mapCollectedData = retriever.getAggregatedDataFromHttpQuerying(this, ((HttpRequestSender) requestSender));
                } else {
                    mapCollectedData = retriever.getAggregatedDataUsingReport(this, requestSender, sReportXML);
                }
                if (mapCollectedData != null) {
                    return new ArrayList<Map.Entry<Object, Data>>(mapCollectedData.entrySet());
                } else {
                    return null;
                }
            } catch (Exception e) {
                // we received an error running the report, so mark as
                // a fall back so it will be immediately run
                LOGGER.warning(Localization.getLocalText("ERR_Failed_to_run_report", clazz.toString(), e.toString()));
                e.printStackTrace();
                fFallBack = true;
            }
        }
    }
    // are collecting ProxyStats,  we need to force to use JMX rather than report
    if (fFallBack || isReporterAvailable() == null || !isReporterAvailable() || (clazz.equals(ProxyData.class) && getClusterVersionAsInt() < 122110)) {
        try {
            // we may be able to use the reporter
            if (clazz.equals(ClusterData.class)) {
                List<Entry<Object, Data>> clusterData = getDataRetrieverInstance(clazz).getJMXData(requestSender, this);
                // then do it. Also check for the version as well.
                if (isReporterAvailable() == null || is1213AndAbove() == null) {
                    if (clusterData != null) {
                        for (Entry<Object, Data> entry : clusterData) {
                            // there will only be one cluster entry
                            String sCoherenceVersion = entry.getValue().getColumn(ClusterData.VERSION).toString().replaceFirst(" .*$", "").replaceFirst("[\\.-]SNAPSHOT.*$", "").replaceAll("-", ".");
                            m_sClusterVersion = sCoherenceVersion;
                            int nVersion = 0;
                            if (sCoherenceVersion.startsWith("3.5")) {
                                // manual check as version numbering changed after 35
                                nVersion = 353;
                            } else if (sCoherenceVersion.startsWith("2")) {
                                // check for versions such as 20.06 or 20.06.01 and convert them to an ever increasing number
                                // 20.06    -> 2006000
                                // 20.06.1  -> 2006100
                                // 20.06.10 -> 2006100
                                String sStrippedVersion = sCoherenceVersion.replaceAll("\\.", "");
                                nVersion = Integer.parseInt(sStrippedVersion) * (int) Math.pow(10, 7 - sStrippedVersion.length());
                            } else {
                                nVersion = Integer.parseInt(sCoherenceVersion.replaceAll("\\.", ""));
                            }
                            if (nVersion >= 121300) {
                                // only set if the reporter available is it is not already set as we may have
                                // got to this code path because is1213AndAbove() is still null
                                setReporterAvailable(isReporterAvailable() == null ? true : isReporterAvailable());
                                m_fis1213AndAbove = true;
                            } else {
                                setReporterAvailable(isReporterAvailable() == null ? false : isReporterAvailable());
                                m_fis1213AndAbove = false;
                            }
                            m_nClusterVersion = nVersion;
                        }
                    }
                }
                return clusterData;
            } else {
                return getDataRetrieverInstance(clazz).getJMXData(requestSender, this);
            }
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Unable to get data", e);
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) NodeStorageData(com.oracle.coherence.plugin.visualvm.tablemodel.model.NodeStorageData) PersistenceData(com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceData) PersistenceNotificationsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.PersistenceNotificationsData) HttpProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.HttpProxyData) GrpcProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.GrpcProxyData) FederationOriginDetailsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginDetailsData) CacheData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData) ServiceMemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceMemberData) FederationOriginData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationOriginData) ClusterData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData) CacheFrontDetailData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheFrontDetailData) ProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData) HttpProxyMemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.HttpProxyMemberData) HotCachePerCacheData(com.oracle.coherence.plugin.visualvm.tablemodel.model.HotCachePerCacheData) MemberData(com.oracle.coherence.plugin.visualvm.tablemodel.model.MemberData) CacheStorageManagerData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheStorageManagerData) MachineData(com.oracle.coherence.plugin.visualvm.tablemodel.model.MachineData) ExecutorData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ExecutorData) ServiceData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ServiceData) HttpSessionData(com.oracle.coherence.plugin.visualvm.tablemodel.model.HttpSessionData) JCacheConfigurationData(com.oracle.coherence.plugin.visualvm.tablemodel.model.JCacheConfigurationData) FederationDestinationDetailsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationDetailsData) JCacheStatisticsData(com.oracle.coherence.plugin.visualvm.tablemodel.model.JCacheStatisticsData) Data(com.oracle.coherence.plugin.visualvm.tablemodel.model.Data) FlashJournalData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FlashJournalData) CacheDetailData(com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData) RamJournalData(com.oracle.coherence.plugin.visualvm.tablemodel.model.RamJournalData) TopicData(com.oracle.coherence.plugin.visualvm.tablemodel.model.TopicData) HotCacheData(com.oracle.coherence.plugin.visualvm.tablemodel.model.HotCacheData) FederationDestinationData(com.oracle.coherence.plugin.visualvm.tablemodel.model.FederationDestinationData) DataRetriever(com.oracle.coherence.plugin.visualvm.tablemodel.model.DataRetriever) IOException(java.io.IOException) Entry(java.util.Map.Entry) HttpProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.HttpProxyData) GrpcProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.GrpcProxyData) ProxyData(com.oracle.coherence.plugin.visualvm.tablemodel.model.ProxyData) HttpRequestSender(com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 2 with HttpRequestSender

use of com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender in project coherence-visualvm by oracle.

the class PersistenceData method getJMXData.

// ----- DataRetriever methods ------------------------------------------
@Override
public List<Map.Entry<Object, Data>> getJMXData(RequestSender requestSender, VisualVMModel model) {
    SortedMap<Object, Data> mapData = new TreeMap<>();
    Data data;
    String sServiceName;
    if (!model.is1213AndAbove()) {
        return null;
    }
    // erase the known domain partitions
    Set<String> setDomainPartitions = model.getDomainPartitions();
    setDomainPartitions.clear();
    try {
        if (requestSender instanceof HttpRequestSender) {
            return new ArrayList<>(getAggregatedDataFromHttpQuerying(model, (HttpRequestSender) requestSender).entrySet());
        }
        // firstly obtain the list of services that have PersistenceMode
        // not 'n/a'
        Set<ObjectName> servicesSet = requestSender.getAllServiceMembers();
        for (Iterator<ObjectName> serviceNameIter = servicesSet.iterator(); serviceNameIter.hasNext(); ) {
            ObjectName serviceNameObjName = serviceNameIter.next();
            AttributeList listAttr = requestSender.getAttributes(serviceNameObjName, new String[] { "PersistenceMode", "StorageEnabled" });
            String sPersistenceMode = getAttributeValueAsString(listAttr, "PersistenceMode");
            boolean fStorageEnabled = Boolean.parseBoolean(getAttributeValueAsString(listAttr, "StorageEnabled"));
            // only include if PersistenceMode != 'n/a'
            if (!"n/a".equals(sPersistenceMode) && fStorageEnabled) {
                sServiceName = serviceNameObjName.getKeyProperty("name");
                String sDomainPartition = serviceNameObjName.getKeyProperty("domainPartition");
                if (sDomainPartition != null && !setDomainPartitions.contains(sDomainPartition)) {
                    setDomainPartitions.add(sDomainPartition);
                }
                // check for domain partition
                if (sDomainPartition != null) {
                    sServiceName = ServiceData.getFullServiceName(sDomainPartition, sServiceName);
                }
                // try to get data
                data = mapData.get(sServiceName);
                if (data == null) {
                    mapData.put(sServiceName, createData(sServiceName, sPersistenceMode, sDomainPartition, requestSender));
                }
            }
        }
        for (Iterator<Object> serviceNameIter = mapData.keySet().iterator(); serviceNameIter.hasNext(); ) {
            String sServiceNameKey = (String) serviceNameIter.next();
            String[] asParts = ServiceData.getServiceParts(sServiceNameKey);
            String sDomainPartition = asParts.length == 2 ? asParts[0] : null;
            sServiceName = sDomainPartition == null ? sServiceNameKey : asParts[1];
            // select only the current service so we can determine the number of storage-enabled
            // members.
            Set<ObjectName> resultSet = requestSender.getMembersOfService(sServiceName, sDomainPartition);
            int cNodes = 0;
            for (Iterator<ObjectName> iter = resultSet.iterator(); iter.hasNext(); ) {
                ObjectName objectName = (ObjectName) iter.next();
                // only include storage-enabled members
                AttributeList listAttr = requestSender.getAttributes(objectName, new String[] { "StorageEnabled", "PersistenceActiveSpaceUsed", "PersistenceLatencyMax", "PersistenceLatencyAverage" });
                if (Boolean.parseBoolean(getAttributeValueAsString(listAttr, "StorageEnabled"))) {
                    data = (PersistenceData) mapData.get(sServiceNameKey);
                    // PersistenceActiveSpaceUsed is only valid for active persistence mode
                    if ("active".equals(data.getColumn(PERSISTENCE_MODE))) {
                        data.setColumn(TOTAL_ACTIVE_SPACE_USED, (Long) data.getColumn(TOTAL_ACTIVE_SPACE_USED) + Long.parseLong(getAttributeValueAsString(listAttr, "PersistenceActiveSpaceUsed")));
                    }
                    // update the max (of the max latencies)
                    long nMaxLatency = Long.parseLong(getAttributeValueAsString(listAttr, "PersistenceLatencyMax"));
                    if (nMaxLatency > (Long) data.getColumn(MAX_LATENCY)) {
                        data.setColumn(MAX_LATENCY, nMaxLatency);
                    }
                    // count the nodes for working out the average at the end as we are adding up
                    // all of the averages, putting them in the average latency
                    // and average them
                    cNodes++;
                    data.setColumn(AVERAGE_LATENCY, (Float) data.getColumn(AVERAGE_LATENCY) + Float.parseFloat(getAttributeValueAsString(listAttr, "PersistenceLatencyAverage")));
                    mapData.put(sServiceNameKey, data);
                }
            }
            data = (PersistenceData) mapData.get(sServiceNameKey);
            // update the average of the averages only if > 1 service node
            if (cNodes > 0) {
                data.setColumn(AVERAGE_LATENCY, (Float) data.getColumn(AVERAGE_LATENCY) / cNodes);
            }
            data.setColumn(TOTAL_ACTIVE_SPACE_USED_MB, (Long) data.getColumn(TOTAL_ACTIVE_SPACE_USED) / GraphHelper.MB);
            mapData.put(sServiceNameKey, data);
        }
        return new ArrayList<Map.Entry<Object, Data>>(mapData.entrySet());
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Error getting service statistics", e);
        return null;
    }
}
Also used : AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) ObjectName(javax.management.ObjectName) HttpRequestSender(com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 3 with HttpRequestSender

use of com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender in project coherence-visualvm by oracle.

the class CacheData method getJMXData.

// ----- DataRetriever methods ------------------------------------------
@Override
public List<Map.Entry<Object, Data>> getJMXData(RequestSender sender, VisualVMModel model) {
    SortedMap<Object, Data> mapData = new TreeMap<Object, Data>();
    Data data;
    try {
        if (sender instanceof HttpRequestSender) {
            // we can more effectively retrieve the data using REST aggregations
            SortedMap<Object, Data> mapAggregatedData = getAggregatedDataFromHttpQuerying(model, (HttpRequestSender) sender);
            if (mapAggregatedData != null) {
                return new ArrayList<>(mapAggregatedData.entrySet());
            }
        // else fall through and use less efficient way
        }
        // get the list of caches
        Set<ObjectName> cacheNamesSet = sender.getAllCacheMembers();
        for (Iterator<ObjectName> cacheNameIter = cacheNamesSet.iterator(); cacheNameIter.hasNext(); ) {
            ObjectName cacheNameObjName = cacheNameIter.next();
            String sCacheName = cacheNameObjName.getKeyProperty("name");
            String sServiceName = cacheNameObjName.getKeyProperty("service");
            String sDomainPartition = cacheNameObjName.getKeyProperty("domainPartition");
            if (sDomainPartition != null) {
                sServiceName = getFullServiceName(sDomainPartition, sServiceName);
            }
            Pair<String, String> key = new Pair<String, String>(sServiceName, sCacheName);
            data = new CacheData();
            data.setColumn(CacheData.SIZE, 0);
            data.setColumn(CacheData.MEMORY_USAGE_BYTES, 0L);
            data.setColumn(CacheData.MEMORY_USAGE_MB, 0);
            data.setColumn(CacheData.CACHE_NAME, key);
            mapData.put(key, data);
        }
        for (Iterator cacheNameIter = mapData.keySet().iterator(); cacheNameIter.hasNext(); ) {
            Pair<String, String> key = (Pair<String, String>) cacheNameIter.next();
            String sCacheName = key.getY();
            String sRawServiceName = key.getX();
            Set<String> setDistributedCache = model.getDistributedCaches();
            if (setDistributedCache == null) {
                throw new RuntimeException("setDistributedCache must not be null. Make sure SERVICE is before CACHE in enum.");
            }
            boolean fIsDistributedCache = setDistributedCache.contains(sRawServiceName);
            String[] asServiceDetails = getDomainAndService(sRawServiceName);
            String sDomainPartition = asServiceDetails[0];
            String sServiceName = asServiceDetails[1];
            Set resultSet = sender.getCacheMembers(sServiceName, sCacheName, sDomainPartition);
            // indicates if non dist cache size has been counted
            boolean fisSizeCounted = false;
            for (Iterator iter = resultSet.iterator(); iter.hasNext(); ) {
                ObjectName objectName = (ObjectName) iter.next();
                if (objectName.getKeyProperty("tier").equals("back")) {
                    data = (CacheData) mapData.get(key);
                    if (fIsDistributedCache || !fisSizeCounted) {
                        data.setColumn(CacheData.SIZE, (Integer) data.getColumn(CacheData.SIZE) + Integer.parseInt(sender.getAttribute(objectName, "Size")));
                        if (!fisSizeCounted) {
                            fisSizeCounted = true;
                        }
                    }
                    AttributeList listAttr = sender.getAttributes(objectName, new String[] { CacheDetailData.ATTR_UNITS, CacheDetailData.ATTR_UNIT_FACTOR, MEMORY_UNITS });
                    data.setColumn(CacheData.MEMORY_USAGE_BYTES, (Long) data.getColumn(CacheData.MEMORY_USAGE_BYTES) + (Integer.parseInt(getAttributeValueAsString(listAttr, CacheDetailData.ATTR_UNITS)) * 1L * Integer.parseInt(getAttributeValueAsString(listAttr, CacheDetailData.ATTR_UNIT_FACTOR))));
                    // set unit calculator if its not already set
                    if (data.getColumn(UNIT_CALCULATOR) == null) {
                        boolean fMemoryUnits = Boolean.valueOf(getAttributeValue(listAttr, MEMORY_UNITS).toString());
                        data.setColumn(CacheData.UNIT_CALCULATOR, fMemoryUnits ? "BINARY" : "FIXED");
                    }
                    mapData.put(key, data);
                }
            }
            // update the cache entry averages
            data = (CacheData) mapData.get(key);
            // for FIXED unit calculator make the memory bytes and MB and avg object size null
            if ("FIXED".equals(data.getColumn(CacheData.UNIT_CALCULATOR))) {
                data.setColumn(CacheData.AVG_OBJECT_SIZE, 0);
                data.setColumn(CacheData.MEMORY_USAGE_BYTES, 0);
                data.setColumn(CacheData.MEMORY_USAGE_MB, 0);
            } else {
                if ((Integer) data.getColumn(CacheData.SIZE) != 0) {
                    data.setColumn(CacheData.AVG_OBJECT_SIZE, (Long) data.getColumn(CacheData.MEMORY_USAGE_BYTES) / (Integer) data.getColumn(CacheData.SIZE));
                }
                Long nMemoryUsageMB = ((Long) data.getColumn(CacheData.MEMORY_USAGE_BYTES)) / 1024 / 1024;
                data.setColumn(CacheData.MEMORY_USAGE_MB, nMemoryUsageMB.intValue());
            }
            mapData.put(key, data);
        }
        return new ArrayList<>(mapData.entrySet());
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Error getting cache statistics", e);
        return null;
    }
}
Also used : Set(java.util.Set) AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) JMXUtils.getAttributeValueAsString(com.oracle.coherence.plugin.visualvm.helper.JMXUtils.getAttributeValueAsString) TreeMap(java.util.TreeMap) ObjectName(javax.management.ObjectName) HttpRequestSender(com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender) Iterator(java.util.Iterator)

Example 4 with HttpRequestSender

use of com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender in project coherence-visualvm by oracle.

the class ExecutorData method getJMXData.

// ----- DataRetriever methods ------------------------------------------
@Override
public List<Map.Entry<Object, Data>> getJMXData(RequestSender requestSender, VisualVMModel model) {
    SortedMap<Object, Data> mapData = new TreeMap<>();
    try {
        // force to use more efficient http
        if (requestSender instanceof HttpRequestSender) {
            return new ArrayList<>(getAggregatedDataFromHttpQuerying(model, (HttpRequestSender) requestSender).entrySet());
        }
        Set<ObjectName> setNodeNames = requestSender.getAllExecutorMembers();
        for (Iterator<ObjectName> iter = setNodeNames.iterator(); iter.hasNext(); ) {
            ObjectName nodeNameObjName = iter.next();
            String sName = nodeNameObjName.getKeyProperty("name");
            AttributeList listAttr = requestSender.getAttributes(nodeNameObjName, new String[] { ATTR_MEMBER_ID, ATTR_TASKS_COMPLETED, ATTR_TASKS_REJECTED, ATTR_TASKS_IN_PROGRESS, ATTR_DESCRIPTION });
            addToExecutorData(mapData, sName, getAttributeValueAsString(listAttr, ATTR_DESCRIPTION), Long.parseLong(getAttributeValueAsString(listAttr, ATTR_TASKS_IN_PROGRESS)), Long.parseLong(getAttributeValueAsString(listAttr, ATTR_TASKS_COMPLETED)), Long.parseLong(getAttributeValueAsString(listAttr, ATTR_TASKS_REJECTED)));
        }
        return new ArrayList<>(mapData.entrySet());
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Error getting executor statistics", e);
        return null;
    }
}
Also used : AttributeList(javax.management.AttributeList) HttpRequestSender(com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender) ArrayList(java.util.ArrayList) JMXUtils.getAttributeValueAsString(com.oracle.coherence.plugin.visualvm.helper.JMXUtils.getAttributeValueAsString) TreeMap(java.util.TreeMap) ObjectName(javax.management.ObjectName)

Example 5 with HttpRequestSender

use of com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender in project coherence-visualvm by oracle.

the class AbstractVisualVMTest method startupCacheServers.

// ----- test methods ---------------------------------------------------
/**
 * Start the required cache servers using oracle-tools
 *
 * @param fRestRequestSender  if a REST request sender needs to be used
 */
public static void startupCacheServers(boolean fRestRequestSender) {
    try {
        s_sEdition = CacheFactory.getEdition();
        // setup temporary directories for persistence
        s_fileActiveDirA = FileHelper.createTempDir();
        s_fileSnapshotDirA = FileHelper.createTempDir();
        s_fileTrashDirA = FileHelper.createTempDir();
        s_availablePortIteratorWKA = LocalPlatform.get().getAvailablePorts();
        int nLocalPortA1 = s_availablePortIteratorWKA.next();
        // Iterate to next port and waste this as sometimes the second port will
        // already be used up before the realize()
        s_availablePortIteratorWKA.next();
        int nLocalPortA2 = s_availablePortIteratorWKA.next();
        int nLocalPortB1 = s_availablePortIteratorWKA.next();
        int nLocalPortB2 = s_availablePortIteratorWKA.next();
        // Iterate to next port and waste this as sometimes the second port will
        // already be used up before the realize()
        s_availablePortIteratorWKA.next();
        LocalPlatform platform = LocalPlatform.get();
        OptionsByType optionsByTypeA1 = createCacheServerOptions(CLUSTER_NAME, nLocalPortA1, s_fileActiveDirA, s_fileSnapshotDirA, s_fileTrashDirA, nLocalPortA1, nLocalPortB1);
        OptionsByType optionsByTypeA2 = createCacheServerOptions(CLUSTER_NAME, nLocalPortA2, s_fileActiveDirA, s_fileSnapshotDirA, s_fileTrashDirA, nLocalPortA1, nLocalPortB1);
        OptionsByType optionsByTypeMemberA1 = OptionsByType.of(optionsByTypeA1).add(DisplayName.of("memberA1"));
        OptionsByType optionsByTypeMemberA2 = OptionsByType.of(optionsByTypeA2).add(DisplayName.of("memberA2"));
        if (fRestRequestSender) {
            optionsByTypeMemberA1.add(SystemProperty.of("coherence.management", "dynamic"));
            optionsByTypeMemberA1.add(SystemProperty.of("coherence.management.http", "inherit"));
            optionsByTypeMemberA1.add(SystemProperty.of("coherence.management.http.host", REST_MGMT_HOST));
            optionsByTypeMemberA1.add(SystemProperty.of("coherence.management.http.port", REST_MGMT_PORT));
        }
        s_memberA1 = platform.launch(CoherenceCacheServer.class, optionsByTypeMemberA1.asArray());
        s_memberA2 = platform.launch(CoherenceCacheServer.class, optionsByTypeMemberA2.asArray());
        s_requestSender = fRestRequestSender ? new HttpRequestSender("http://" + REST_MGMT_HOST + ":" + "8080") : new JMXRequestSender(s_memberA1.get(JmxFeature.class).getDeferredJMXConnector().get().getMBeanServerConnection());
        Eventually.assertThat(invoking(s_memberA1).getClusterSize(), is(2));
        // only start second cluster if we are running Commercial version
        if (isCommercial()) {
            // setup temporary directories for persistence
            s_fileActiveDirB = FileHelper.createTempDir();
            s_fileSnapshotDirB = FileHelper.createTempDir();
            s_fileTrashDirB = FileHelper.createTempDir();
            OptionsByType optionsByTypeB1 = createCacheServerOptions(CLUSTER_B_NAME, nLocalPortB1, s_fileActiveDirB, s_fileSnapshotDirB, s_fileTrashDirB, nLocalPortA1, nLocalPortB1);
            OptionsByType optionsByTypeB2 = createCacheServerOptions(CLUSTER_B_NAME, nLocalPortB2, s_fileActiveDirB, s_fileSnapshotDirB, s_fileTrashDirB, nLocalPortA1, nLocalPortB1);
            OptionsByType optionsByTypeMemberB1 = OptionsByType.of(optionsByTypeB1).add(DisplayName.of("memberB1"));
            OptionsByType optionsByTypeMemberB2 = OptionsByType.of(optionsByTypeB2).add(DisplayName.of("memberB2"));
            s_memberB1 = platform.launch(CoherenceCacheServer.class, optionsByTypeMemberB1.asArray());
            s_memberB2 = platform.launch(CoherenceCacheServer.class, optionsByTypeMemberB2.asArray());
            Eventually.assertThat(invoking(s_memberB1).getClusterSize(), is(2));
        }
    } catch (Exception e) {
        System.err.println("Error starting cache servers. " + e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    }
}
Also used : CoherenceCacheServer(com.oracle.bedrock.runtime.coherence.CoherenceCacheServer) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) HttpRequestSender(com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender) JMXRequestSender(com.oracle.coherence.plugin.visualvm.helper.JMXRequestSender) OptionsByType(com.oracle.bedrock.OptionsByType)

Aggregations

HttpRequestSender (com.oracle.coherence.plugin.visualvm.helper.HttpRequestSender)6 ArrayList (java.util.ArrayList)5 TreeMap (java.util.TreeMap)5 AttributeList (javax.management.AttributeList)4 ObjectName (javax.management.ObjectName)4 JMXUtils.getAttributeValueAsString (com.oracle.coherence.plugin.visualvm.helper.JMXUtils.getAttributeValueAsString)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 OptionsByType (com.oracle.bedrock.OptionsByType)1 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)1 CoherenceCacheServer (com.oracle.bedrock.runtime.coherence.CoherenceCacheServer)1 JMXRequestSender (com.oracle.coherence.plugin.visualvm.helper.JMXRequestSender)1 CacheData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheData)1 CacheDetailData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheDetailData)1 CacheFrontDetailData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheFrontDetailData)1 CacheStorageManagerData (com.oracle.coherence.plugin.visualvm.tablemodel.model.CacheStorageManagerData)1 ClusterData (com.oracle.coherence.plugin.visualvm.tablemodel.model.ClusterData)1 Data (com.oracle.coherence.plugin.visualvm.tablemodel.model.Data)1 DataRetriever (com.oracle.coherence.plugin.visualvm.tablemodel.model.DataRetriever)1