小编Kav*_*nna的帖子

如何获取docker容器内的服务及其状态?

我在 Linux 服务器中有 docker 容器,我需要知道如何获取容器内应用程序、服务及其状态的详细信息。我需要执行哪个命令才能获取这些详细信息。

例如:

容器包含 tomcat 服务器。我需要获取 tomcat 服务器的详细信息及其状态(服务是否正在运行)。

我不知道是否有任何命令可以获取这些详细信息。

docker

3
推荐指数
1
解决办法
4万
查看次数

尝试使用Java解析JSON字符串时发生错误

我正在尝试使用java解析JSON字符串。我不知道该怎么做,我在互联网上搜索了很多东西,但有了一些主意。有了我,我有构建代码,但它不起作用。当尝试执行我的代码时,它将引发错误。我无法解决错误。

看到下面是我的代码:

import java.util.*;
import java.io.*;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

public class JSOnNStringParsing {

    public static void main(String[] args) {        
        try
        {
            BufferedReader read=new BufferedReader(new FileReader("D:\\Kavi works\\OutputFiles\\JSON_String.txt"));
            String line=read.readLine();
            while(line!=null)
            {
                System.out.println("Line = "+line);
                JSONParser jsonParser = new JSONParser();
                JSONObject jsonObject = (JSONObject) jsonParser.parse(line);
                System.out.println("Read : "+jsonObject.get("read"));
                JSONArray network = (JSONArray) jsonObject.get("network");
                Iterator<String> iterator = network.iterator();
                while (iterator.hasNext()) {
                    System.out.println(iterator.next());
                }
            }
        }
        catch(Exception e)
        {
            System.out.println("Error occured :"+e);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的JSON字符串在该文件中:

{"read":"2015-05-07T19:30:48.165009273+05:30","network":{"rx_bytes":11124,"rx_packets":116,"rx_errors":0,"rx_dropped":0,"tx_bytes":648,"tx_packets":8,"tx_errors":0,"tx_dropped":0},"cpu_stats":{"cpu_usage":{"total_usage":157158138204,"percpu_usage":[157158138204],"usage_in_kernelmode":49530000000,"usage_in_usermode":58420000000},"system_cpu_usage":258964110000000,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"memory_stats":{"usage":73969664,"max_usage":74600448,"stats":{"active_anon":73928704,"active_file":4096,"cache":86016,"hierarchical_memory_limit":18446744073709551615,"inactive_anon":4096,"inactive_file":32768,"mapped_file":32768,"pgfault":62880,"pgmajfault":0,"pgpgin":34656,"pgpgout":34482,"rss":73883648,"rss_huge":67108864,"total_active_anon":73928704,"total_active_file":4096,"total_cache":86016,"total_inactive_anon":4096,"total_inactive_file":32768,"total_mapped_file":32768,"total_pgfault":62880,"total_pgmajfault":0,"total_pgpgin":34656,"total_pgpgout":34482,"total_rss":73883648,"total_rss_huge":67108864,"total_unevictable":0,"total_writeback":0,"unevictable":0,"writeback":0},"failcnt":0,"limit":2099310592},"blkio_stats":{"io_service_bytes_recursive":[],"io_serviced_recursive":[],"io_queue_recursive":[],"io_service_time_recursive":[],"io_wait_time_recursive":[],"io_merged_recursive":[],"io_time_recursive":[],"sectors_recursive":[]}}
Run Code Online (Sandbox Code Playgroud)

当我执行代码时,它会引发如下错误:

Line …
Run Code Online (Sandbox Code Playgroud)

java json

2
推荐指数
1
解决办法
2098
查看次数

首先调用哪个类run()方法?为什么?

我使用线程概念尝试了以下代码.在这段代码中,我在两个不同的类中声明了两个run方法.我从我的main方法中调用了这些方法.其实我想知道的是,首先调用哪个run()方法?当我一次又一次地跑步时,我得到了相同代码的不同输出.

我的代码:

class parent
{
    public synchronized void display1()
    {
        System.out.println("Dispaly_1 is invoked");
    }
    public synchronized void display2()
    {
        System.out.println("Dispaly_2 is invoked");
    }
}
class abc extends Thread{
    parent p;
    public abc(parent p){
        this.p = p;
    }

    public void run(){
        System.out.println("abc start...");     
        p.display1();
    }
}
class xyz extends Thread{
    parent p;
    public xyz(parent p){
        this.p = p;
    }

    public void run(){
        System.out.println("xyz start...");     
        p.display2();
    }
}

public class ThreadExample {

    public static void main(String[] args) {

        parent p=new parent();
        abc …
Run Code Online (Sandbox Code Playgroud)

java multithreading

-2
推荐指数
1
解决办法
62
查看次数

标签 统计

java ×2

docker ×1

json ×1

multithreading ×1