Search in sources :

Example 1 with GridClientCacheBean

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean in project ignite by apache.

the class GridClientNioTcpConnection method nodeBeanToNode.

/**
 * Creates client node instance from message.
 *
 * @param nodeBean Node bean message.
 * @return Created node.
 */
@Nullable
private GridClientNodeImpl nodeBeanToNode(@Nullable GridClientNodeBean nodeBean) {
    if (nodeBean == null)
        return null;
    GridClientNodeImpl.Builder nodeBuilder = GridClientNodeImpl.builder().nodeId(nodeBean.getNodeId()).consistentId(nodeBean.getConsistentId()).tcpAddresses(nodeBean.getTcpAddresses()).tcpPort(nodeBean.getTcpPort()).order(nodeBean.getOrder());
    Map<String, GridClientCacheMode> caches = new HashMap<>();
    if (nodeBean.getCaches() != null) {
        for (GridClientCacheBean cacheBean : nodeBean.getCaches()) {
            try {
                caches.put(cacheBean.getName(), cacheBean.getMode());
            } catch (IllegalArgumentException ignored) {
                log.warning("Invalid cache mode received from remote node (will ignore) [srv=" + serverAddress() + ", cacheName=" + cacheBean.getName() + ", cacheMode=" + cacheBean.getMode() + ']');
            }
        }
    }
    if (!caches.isEmpty())
        nodeBuilder.caches(caches);
    if (nodeBean.getAttributes() != null)
        nodeBuilder.attributes(nodeBean.getAttributes());
    GridClientNodeMetricsBean metricsBean = nodeBean.getMetrics();
    if (metricsBean != null) {
        GridClientNodeMetricsAdapter metrics = new GridClientNodeMetricsAdapter();
        metrics.setStartTime(metricsBean.getStartTime());
        metrics.setAverageActiveJobs(metricsBean.getAverageActiveJobs());
        metrics.setAverageCancelledJobs(metricsBean.getAverageCancelledJobs());
        metrics.setAverageCpuLoad(metricsBean.getAverageCpuLoad());
        metrics.setAverageJobExecuteTime(metricsBean.getAverageJobExecuteTime());
        metrics.setAverageJobWaitTime(metricsBean.getAverageJobWaitTime());
        metrics.setAverageRejectedJobs(metricsBean.getAverageRejectedJobs());
        metrics.setAverageWaitingJobs(metricsBean.getAverageWaitingJobs());
        metrics.setCurrentActiveJobs(metricsBean.getCurrentActiveJobs());
        metrics.setCurrentCancelledJobs(metricsBean.getCurrentCancelledJobs());
        metrics.setCurrentCpuLoad(metricsBean.getCurrentCpuLoad());
        metrics.setCurrentGcCpuLoad(metricsBean.getCurrentGcCpuLoad());
        metrics.setCurrentDaemonThreadCount(metricsBean.getCurrentDaemonThreadCount());
        metrics.setCurrentIdleTime(metricsBean.getCurrentIdleTime());
        metrics.setCurrentJobExecuteTime(metricsBean.getCurrentJobExecuteTime());
        metrics.setCurrentJobWaitTime(metricsBean.getCurrentJobWaitTime());
        metrics.setCurrentRejectedJobs(metricsBean.getCurrentRejectedJobs());
        metrics.setCurrentThreadCount(metricsBean.getCurrentThreadCount());
        metrics.setCurrentWaitingJobs(metricsBean.getCurrentWaitingJobs());
        metrics.setFileSystemFreeSpace(metricsBean.getFileSystemFreeSpace());
        metrics.setFileSystemTotalSpace(metricsBean.getFileSystemTotalSpace());
        metrics.setFileSystemUsableSpace(metricsBean.getFileSystemUsableSpace());
        metrics.setHeapMemoryCommitted(metricsBean.getHeapMemoryCommitted());
        metrics.setHeapMemoryInitialized(metricsBean.getHeapMemoryInitialized());
        metrics.setHeapMemoryMaximum(metricsBean.getHeapMemoryMaximum());
        metrics.setHeapMemoryUsed(metricsBean.getHeapMemoryUsed());
        metrics.setLastDataVersion(metricsBean.getLastDataVersion());
        metrics.setLastUpdateTime(metricsBean.getLastUpdateTime());
        metrics.setMaximumActiveJobs(metricsBean.getMaximumActiveJobs());
        metrics.setMaximumCancelledJobs(metricsBean.getMaximumCancelledJobs());
        metrics.setMaximumJobExecuteTime(metricsBean.getMaximumJobExecuteTime());
        metrics.setMaximumJobWaitTime(metricsBean.getMaximumJobWaitTime());
        metrics.setMaximumRejectedJobs(metricsBean.getMaximumRejectedJobs());
        metrics.setMaximumThreadCount(metricsBean.getMaximumThreadCount());
        metrics.setMaximumWaitingJobs(metricsBean.getMaximumWaitingJobs());
        metrics.setNodeStartTime(metricsBean.getNodeStartTime());
        metrics.setNonHeapMemoryCommitted(metricsBean.getNonHeapMemoryCommitted());
        metrics.setNonHeapMemoryInitialized(metricsBean.getNonHeapMemoryInitialized());
        metrics.setNonHeapMemoryMaximum(metricsBean.getNonHeapMemoryMaximum());
        metrics.setNonHeapMemoryUsed(metricsBean.getNonHeapMemoryUsed());
        metrics.setStartTime(metricsBean.getStartTime());
        metrics.setTotalCancelledJobs(metricsBean.getTotalCancelledJobs());
        metrics.setTotalCpus(metricsBean.getTotalCpus());
        metrics.setTotalExecutedJobs(metricsBean.getTotalExecutedJobs());
        metrics.setTotalIdleTime(metricsBean.getTotalIdleTime());
        metrics.setTotalRejectedJobs(metricsBean.getTotalRejectedJobs());
        metrics.setTotalStartedThreadCount(metricsBean.getTotalStartedThreadCount());
        metrics.setTotalExecutedTasks(metricsBean.getTotalExecutedTasks());
        metrics.setSentMessagesCount(metricsBean.getSentMessagesCount());
        metrics.setSentBytesCount(metricsBean.getSentBytesCount());
        metrics.setReceivedMessagesCount(metricsBean.getReceivedMessagesCount());
        metrics.setReceivedBytesCount(metricsBean.getReceivedBytesCount());
        metrics.setUpTime(metricsBean.getUpTime());
        nodeBuilder.metrics(metrics);
    }
    return nodeBuilder.build();
}
Also used : GridClientNodeMetricsAdapter(org.apache.ignite.internal.client.impl.GridClientNodeMetricsAdapter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) GridClientCacheBean(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean) GridClientNodeImpl(org.apache.ignite.internal.client.impl.GridClientNodeImpl) GridClientCacheMode(org.apache.ignite.internal.client.GridClientCacheMode) GridClientNodeMetricsBean(org.apache.ignite.internal.processors.rest.client.message.GridClientNodeMetricsBean) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with GridClientCacheBean

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean in project ignite by apache.

the class GridTopologyCommandHandler method createCacheBean.

/**
 * Creates cache bean.
 *
 * @param ccfg Cache configuration.
 * @return Cache bean.
 */
public GridClientCacheBean createCacheBean(CacheConfiguration ccfg) {
    GridClientCacheBean cacheBean = new GridClientCacheBean();
    cacheBean.setName(ccfg.getName());
    cacheBean.setMode(GridClientCacheMode.valueOf(ccfg.getCacheMode().toString()));
    cacheBean.setSqlSchema(ccfg.getSqlSchema());
    return cacheBean;
}
Also used : GridClientCacheBean(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean)

Example 3 with GridClientCacheBean

use of org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean in project ignite by apache.

the class GridTopologyCommandHandler method createNodeBean.

/**
 * Creates node bean out of cluster node. Notice that cache attribute is handled separately.
 *
 * @param node Cluster node.
 * @param mtr Whether to include node metrics.
 * @param attr Whether to include node attributes.
 * @param caches Whether to include node caches.
 * @return Grid Node bean.
 */
private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr, boolean caches) {
    assert node != null;
    GridClientNodeBean nodeBean = new GridClientNodeBean();
    nodeBean.setNodeId(node.id());
    nodeBean.setConsistentId(node.consistentId());
    nodeBean.setTcpPort(attribute(node, ATTR_REST_TCP_PORT, 0));
    nodeBean.setOrder(node.order());
    nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS)));
    nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES)));
    if (caches) {
        Map<String, CacheConfiguration> nodeCaches = ctx.discovery().nodePublicCaches(node);
        Collection<GridClientCacheBean> cacheBeans = new ArrayList<>(nodeCaches.size());
        for (CacheConfiguration ccfg : nodeCaches.values()) cacheBeans.add(createCacheBean(ccfg));
        nodeBean.setCaches(cacheBeans);
    }
    if (mtr) {
        ClusterMetrics metrics = node.metrics();
        GridClientNodeMetricsBean metricsBean = new GridClientNodeMetricsBean();
        metricsBean.setStartTime(metrics.getStartTime());
        metricsBean.setAverageActiveJobs(metrics.getAverageActiveJobs());
        metricsBean.setAverageCancelledJobs(metrics.getAverageCancelledJobs());
        metricsBean.setAverageCpuLoad(metrics.getAverageCpuLoad());
        metricsBean.setAverageJobExecuteTime(metrics.getAverageJobExecuteTime());
        metricsBean.setAverageJobWaitTime(metrics.getAverageJobWaitTime());
        metricsBean.setAverageRejectedJobs(metrics.getAverageRejectedJobs());
        metricsBean.setAverageWaitingJobs(metrics.getAverageWaitingJobs());
        metricsBean.setCurrentActiveJobs(metrics.getCurrentActiveJobs());
        metricsBean.setCurrentCancelledJobs(metrics.getCurrentCancelledJobs());
        metricsBean.setCurrentCpuLoad(metrics.getCurrentCpuLoad());
        metricsBean.setCurrentGcCpuLoad(metrics.getCurrentGcCpuLoad());
        metricsBean.setCurrentDaemonThreadCount(metrics.getCurrentDaemonThreadCount());
        metricsBean.setCurrentIdleTime(metrics.getCurrentIdleTime());
        metricsBean.setCurrentJobExecuteTime(metrics.getCurrentJobExecuteTime());
        metricsBean.setCurrentJobWaitTime(metrics.getCurrentJobWaitTime());
        metricsBean.setCurrentRejectedJobs(metrics.getCurrentRejectedJobs());
        metricsBean.setCurrentThreadCount(metrics.getCurrentThreadCount());
        metricsBean.setCurrentWaitingJobs(metrics.getCurrentWaitingJobs());
        metricsBean.setHeapMemoryCommitted(metrics.getHeapMemoryCommitted());
        metricsBean.setHeapMemoryInitialized(metrics.getHeapMemoryInitialized());
        metricsBean.setHeapMemoryMaximum(metrics.getHeapMemoryMaximum());
        metricsBean.setHeapMemoryUsed(metrics.getHeapMemoryUsed());
        metricsBean.setLastDataVersion(metrics.getLastDataVersion());
        metricsBean.setLastUpdateTime(metrics.getLastUpdateTime());
        metricsBean.setMaximumActiveJobs(metrics.getMaximumActiveJobs());
        metricsBean.setMaximumCancelledJobs(metrics.getMaximumCancelledJobs());
        metricsBean.setMaximumJobExecuteTime(metrics.getMaximumJobExecuteTime());
        metricsBean.setMaximumJobWaitTime(metrics.getMaximumJobWaitTime());
        metricsBean.setMaximumRejectedJobs(metrics.getMaximumRejectedJobs());
        metricsBean.setMaximumThreadCount(metrics.getMaximumThreadCount());
        metricsBean.setMaximumWaitingJobs(metrics.getMaximumWaitingJobs());
        metricsBean.setNodeStartTime(metrics.getNodeStartTime());
        metricsBean.setNonHeapMemoryCommitted(metrics.getNonHeapMemoryCommitted());
        metricsBean.setNonHeapMemoryInitialized(metrics.getNonHeapMemoryInitialized());
        metricsBean.setNonHeapMemoryMaximum(metrics.getNonHeapMemoryMaximum());
        metricsBean.setNonHeapMemoryUsed(metrics.getNonHeapMemoryUsed());
        metricsBean.setStartTime(metrics.getStartTime());
        metricsBean.setTotalCancelledJobs(metrics.getTotalCancelledJobs());
        metricsBean.setTotalCpus(metrics.getTotalCpus());
        metricsBean.setTotalExecutedJobs(metrics.getTotalExecutedJobs());
        metricsBean.setTotalIdleTime(metrics.getTotalIdleTime());
        metricsBean.setTotalRejectedJobs(metrics.getTotalRejectedJobs());
        metricsBean.setTotalStartedThreadCount(metrics.getTotalStartedThreadCount());
        metricsBean.setTotalExecutedTasks(metrics.getTotalExecutedTasks());
        metricsBean.setSentMessagesCount(metrics.getSentMessagesCount());
        metricsBean.setSentBytesCount(metrics.getSentBytesCount());
        metricsBean.setReceivedMessagesCount(metrics.getReceivedMessagesCount());
        metricsBean.setReceivedBytesCount(metrics.getReceivedBytesCount());
        metricsBean.setUpTime(metrics.getUpTime());
        nodeBean.setMetrics(metricsBean);
    }
    if (attr) {
        Map<String, Object> attrs = new HashMap<>(node.attributes());
        attrs.remove(ATTR_CACHE);
        attrs.remove(ATTR_TX_CONFIG);
        attrs.remove(ATTR_SECURITY_SUBJECT_V2);
        attrs.remove(ATTR_SECURITY_CREDENTIALS);
        attrs.remove(ATTR_BINARY_CONFIGURATION);
        attrs.remove(ATTR_NODE_CONSISTENT_ID);
        for (Iterator<Map.Entry<String, Object>> i = attrs.entrySet().iterator(); i.hasNext(); ) {
            Map.Entry<String, Object> e = i.next();
            if (!e.getKey().startsWith("org.apache.ignite.") && !e.getKey().startsWith("plugins.") && System.getProperty(e.getKey()) == null) {
                i.remove();
                continue;
            }
            if (e.getValue() != null) {
                if (e.getValue().getClass().isEnum() || e.getValue() instanceof InetAddress)
                    e.setValue(e.getValue().toString());
                else if (e.getValue().getClass().isArray() && !ATTR_IGNITE_FEATURES.equals(e.getKey()))
                    i.remove();
            }
        }
        nodeBean.setAttributes(attrs);
    }
    return nodeBean;
}
Also used : GridClientNodeBean(org.apache.ignite.internal.processors.rest.client.message.GridClientNodeBean) HashMap(java.util.HashMap) GridClientCacheBean(org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean) ArrayList(java.util.ArrayList) GridClientNodeMetricsBean(org.apache.ignite.internal.processors.rest.client.message.GridClientNodeMetricsBean) ClusterMetrics(org.apache.ignite.cluster.ClusterMetrics) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map) InetAddress(java.net.InetAddress) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

GridClientCacheBean (org.apache.ignite.internal.processors.rest.client.message.GridClientCacheBean)3 HashMap (java.util.HashMap)2 GridClientNodeMetricsBean (org.apache.ignite.internal.processors.rest.client.message.GridClientNodeMetricsBean)2 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ClusterMetrics (org.apache.ignite.cluster.ClusterMetrics)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 GridClientCacheMode (org.apache.ignite.internal.client.GridClientCacheMode)1 GridClientNodeImpl (org.apache.ignite.internal.client.impl.GridClientNodeImpl)1 GridClientNodeMetricsAdapter (org.apache.ignite.internal.client.impl.GridClientNodeMetricsAdapter)1 GridClientNodeBean (org.apache.ignite.internal.processors.rest.client.message.GridClientNodeBean)1 Nullable (org.jetbrains.annotations.Nullable)1