<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    #

    在ECLIPSE中切換到新建的分支

    如果已經在ECLIPSE中CLONE了GIT的項目,這時當GIT中又新建了項目,ECLIPSE無法切換到這新建的項目,解決辦法:


    In the Git Repositories view:

    1. Right-click the repository and choose Fetch from Upstream
    2. If the new branch will not shown up below Branches/Remote Tracking, you have to configure fetch:
      1. Right-click the fetch node below Remotes/origin and choose Configure Fetch...
      2. In the Configure Fetch make sure there is only the single Ref mapping (assuming the remote is named origin+refs/heads/*:refs/remotes/origin/*:
        Configure fetch

    這時再次Fetch from upstream,則新建的項目再次重現:Git Repositories View-->Branches-->Remote Checking中。
    雙擊新的分支,選:Check out as New Local Branch即可。

    https://stackoverflow.com/questions/47390703/how-do-i-get-a-new-branch-to-show-up-in-eclipse-git-remote-tracking/47391183

    posted @ 2020-09-24 15:16 paulwong 閱讀(713) | 評論 (0)編輯 收藏

    向所有服務器發送相同命令

    先在主控機執行ssh-keygen,再向被控機傳輸key,
    ssh-copy-id -i ~/.ssh/id_rsa.pub user1@ip

    樣例腳本transfer-artemis.sh如下:
    #!/bin/bash

    loop_server(){
        for ((i=2; i<=8; i++))
        do
          ipd=10.10.31.1${i}2
          echo ${ipd}
          $1 ${ipd}
        done
        
        for ((i=1; i<=2; i++))
        do
          ipd=10.20.31.1${i}2
          echo ${ipd}
          $1 ${ipd}
        done
        
    }

    start_artemis_cmd(){
        echo "ssh user1@${1} '/opt/myapp/artemis/apache-artemis-2.15.0/instance/bin/artemis-service start'"
        ssh user1@${1} '/opt/myapp/artemis/apache-artemis-2.15.0/instance/bin/artemis-service start'
    }

    stop_artemis_cmd(){
        echo "ssh user1@${1} '/opt/myapp/apache-activemq-5.15.10/bin/activemq stop'"
        echo "ssh user1@${1} '/opt/myapp/artemis/apache-artemis-2.15.0/instance/bin/artemis-service stop'"
        ssh user1@${1} '/opt/myapp/apache-activemq-5.15.10/bin/activemq stop'
        ssh user1@${1} '/opt/myapp/artemis/apache-artemis-2.15.0/instance/bin/artemis-service stop'
    }

    scp_artemis_cmd(){
        echo "ssh user1@${1} 'rm -rf /opt/myapp/artemis'"
        echo "scp -r /opt/myapp/artemis user1@${1}:/opt/myapp/"
        ssh user1@${1} 'rm -rf /opt/myapp/artemis'
        scp -r /opt/myapp/artemis user1@${1}:/opt/myapp/
    }

    stop_artemis(){
        loop_server stop_artemis_cmd
    }

    start_artemis(){
        loop_server start_artemis_cmd
    }

    scp_artemis(){ 
        loop_server scp_artemis_cmd
    }

    #start_artemis "Hello start_artemis"

    $1

    執行命令:
    ./transfer-artemis.sh start_artemis

    posted @ 2020-09-24 10:52 paulwong 閱讀(344) | 評論 (0)編輯 收藏

    How do I set directory permissions in maven output?

    pom.xml:
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.1.1</version>

                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>

                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/descriptor.xml</descriptor>
                    </descriptors>
                    <archiverConfig>
                        <directoryMode>0755</directoryMode>
                        <defaultDirectoryMode>0755</defaultDirectoryMode>
                        <fileMode>0644</fileMode>
                    </archiverConfig>
                </configuration>
            </plugin>

    src/main/assembly/descriptor.xml,在此文件覆蓋:
    <fileSets>
        <fileSet>
            <directory>src/conf</directory>
            <outputDirectory>conf</outputDirectory>
            <fileMode>0600</fileMode>
            <directoryMode>0700</directoryMode>
        </fileSet>
        <fileSet>
            <directory>src/db</directory>
            <outputDirectory>db</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>src/bin</directory>
            <outputDirectory>bin</outputDirectory>
            <fileMode>0755</fileMode>
        </fileSet>


    posted @ 2020-09-23 17:01 paulwong 閱讀(242) | 評論 (0)編輯 收藏

    深入淺出 Retrofit,這么牛逼的框架你們還不來看看?

    https://segmentfault.com/a/1190000005638577

    posted @ 2020-09-16 09:41 paulwong 閱讀(254) | 評論 (0)編輯 收藏

    Spring Retry框架——看這篇就夠了

    https://my.oschina.net/marvelcode/blog/4563352

    posted @ 2020-09-15 13:39 paulwong 閱讀(351) | 評論 (0)編輯 收藏

    linux nohup命令詳解

    nohup命令及其輸出文件

    nohup命令:如果你正在運行一個進程,而且你覺得在退出帳戶時該進程還不會結束,那么可以使用nohup命令。該命令可以在你退出帳戶/關閉終端之后繼續運行相應的進程。nohup就是不掛起的意思( n ohang up)。

    一般都是在linux下nohup格式:  

    nohup command

    或者

    nohup command &

    這之間的差別是帶&的命令行,即使terminal(終端)關閉,或者電腦死機程序依然運行(前提是你把程序遞交到服務器上);

    它把標準輸出(STDOUT)和標準錯誤(STDERR)結果輸出到nohup.txt文件這個看似很方便,但是當輸出很大的時候,nohup.txt文件會非常大,或者多個后臺命令的時候大家都會輸出到nohup.txt文件,不利于查找結果和調試程序。

    所以能夠重定向輸出會非常方便。下面要介紹標準輸出,標準輸入 和標準錯誤了。

    其實我們一直都在用,只是沒有注意到, 

    比如

    >./command.sh > output

    #這其中的>就是標準輸出符號,其實是 1>output 的縮寫

    >./command.sh 2> output

    #這里的2>就是將標準錯誤輸出到output文件里。

    而0< 則是標準輸入了。

    下面步入正題,重定向后臺命令

    >nohup ./command.sh > output 2>&1 &

    解釋:前面的nohup 和后面的&我想大家都能明白了把。

    主要是中間的 2>&1的意思

    這個意思是把標準錯誤(2)重定向到標準輸出中(1),而標準輸出又導入文件output里面,   www.2cto.com

    所以結果是標準錯誤和標準輸出都導入文件output里面了。

    至于為什么需要將標準錯誤重定向到標準輸出的原因,那就歸結為標準錯誤沒有緩沖區,而stdout有。

    這就會導致 >output 2>output 文件output被兩次打開,而stdout和stderr將會競爭覆蓋,這肯定不是我門想要的.

    這就是為什么有人會寫成:

    nohup ./command.sh >output 2>output
    出錯的原因了

    ##########################

    最后談一下/dev/null文件的作用

    這是一個無底洞,任何東西都可以定向到這里,但是卻無法打開。

    所以一般很大的stdou和stderr當你不關心的時候可以利用stdout和stderr定向到這里

    >./command.sh >/dev/null 2>&1

    posted @ 2020-09-02 11:52 paulwong 閱讀(390) | 評論 (0)編輯 收藏

    Scheduling a task in Java within a CompletableFuture

    When we want to do something later in our Java code, we often turn to the ScheduledExecutorService. This class has a method called schedule(), and we can pass it some code to be run later like this:

    ScheduledExecutorService executor =
        Executors.newScheduledThreadPool(4);
    executor.schedule(
        () -> {System.out.println("..later");},
        1,
        TimeUnit.SECONDS
    );
    System.out.println("do");
    // (Don't forget to shut down the executor later)

    The above code prints “do…” and then one second later it prints “…later”.

    We can even write code that does some work and returns a result in a similar way:

    // (Make the executor as above.)
    ScheduledFuture future = executor.schedule(
        () -> 10 + 25, 1, TimeUnit.SECONDS);
    System.out.println("answer=" + future.get())


    The above code prints “answer=35”. When we call get() it blocks waiting for the scheduler to run the task and mark the ScheduledFuture as complete, and then returns the answer to the sum (10 + 25) when it is ready.

    This is all very well, but you may note that the Future returned from schedule() is a ScheduledFuture, and a ScheduledFuture is not a CompletableFuture.

    Why do you care? Well, you might care if you want to do something after the scheduled task is completed. Of course, you can call get(), and block, and then do something, but if you want to react asynchronously without blocking, this won’t work.

    The normal way to run some code after a Future has completed is to call one of the “then*” or “when*” methods on the Future, but these methods are only available on CompletableFuture, not ScheduledFuture.

    Never fear, we have figured this out for you. We present a small wrapper for schedule that transforms your ScheduledFuture into a CompletableFuture. Here’s how to use it:

    CompletableFuture<Integer> future =
        ScheduledCompletable.schedule(
            executor,
            () -> 10 + 25,
            1,
            TimeUnit.SECONDS
         );
    future.thenAccept(
        answer -> {System.out.println(answer);}
    );
    System.out.println("Answer coming")


    The above code prints “Answer coming…” and then “35”, so we can see that we don’t block the main thread waiting for the answer to come back.

    So far, we have scheduled a synchronous task to run in the background after a delay, and wrapped its result in a CompletableFuture to allow us to chain more tasks after it.

    In fact, what we often want to do is schedule a delayed task that is itself asynchronous, and already returns a CompletableFuture. In this case it feels particularly natural to get the result back as a CompletableFuture, but with the current ScheduledExecutorService interface we can’t easily do it.

    It’s OK, we’ve figured that out too:

    Supplier<CompletableFuture<Integer>> asyncTask = () ->
        CompletableFuture.completedFuture(10 + 25);
    CompletableFuture<Integer> future =
        ScheduledCompletable.scheduleAsync(
            executor, asyncTask, 1, TimeUnit.SECONDS);
    future.thenAccept(
        answer -> {System.out.println(answer);}
    );
    System.out.println("Answer coming")


    The above code prints “Answer coming…” and then “35”, so we can see that our existing asynchronous task was scheduled in the background, and we didn’t have to block the main thread waiting for it. Also, under the hood, we are not blocking the ScheduledExecutorService‘s thread (from its pool) while the async task is running – that task just runs in whatever thread it was assigned when it was created. (Note: in our example we don’t really run an async task at all, but just immediately return a completed Future, but this does work for real async tasks.)

    I know you’re wondering how we achieved all this. First, here’s how we run a simple blocking task in the background and wrap it in a CompletableFuture:

    public static <T> CompletableFuture<T> schedule(
        ScheduledExecutorService executor,
        Supplier<T> command,
        long delay,
        TimeUnit unit
    ) {
        CompletableFuture<T> completableFuture = new CompletableFuture<>();
        executor.schedule(
            (() -> {
                try {
                    return completableFuture.complete(command.get());
                } catch (Throwable t) {
                    return completableFuture.completeExceptionally(t);
                }
            }),
            delay,
            unit
        );
        return completableFuture;
    }


    And here’s how we delay execution of an async task but still return its result in a CompletableFuture:

    public static <T> CompletableFuture<T> scheduleAsync(
        ScheduledExecutorService executor,
        Supplier<CompletableFuture<T>> command,
        long delay,
        TimeUnit unit
    ) {
        CompletableFuture<T> completableFuture = new CompletableFuture<>();
        executor.schedule(
            (() -> {
                command.get().thenAccept(
                    t -> {completableFuture.complete(t);}
                )
                .exceptionally(
                    t -> {completableFuture.completeExceptionally(t);return null;}
                );
            }),
            delay,
            unit
        );
        return completableFuture;
    }


    Note that this should all work to run methods like exceptionally()thenAccept()whenComplete() etc.

    Feedback and improvements welcome!


    https://www.artificialworlds.net/blog/2019/04/05/scheduling-a-task-in-java-within-a-completablefuture/

    posted @ 2020-08-24 09:06 paulwong 閱讀(395) | 評論 (0)編輯 收藏

    如何找出LINUX中消耗CPU最大的應用的PID

    有時查看LINUX時,會發現當前CPU消耗連續保持80%,如何找出是哪個應用呢?
    top -i //輸出應用列表,并隱藏IDEL的應用
    P //在列表時,按P,則按CPU的使用排序


    How To Check CPU Utilization In Linux With Command Line
    https://phoenixnap.com/kb/check-cpu-usage-load-linux

    posted @ 2020-08-14 11:52 paulwong 閱讀(327) | 評論 (0)編輯 收藏

    CompletableFuture

    很久以前多線程是這樣創建:
    Thread t1 = new Thread();
    Thread t2 = new Thread();
    t1.start(); // 啟動新線程
    t2.start(); // 啟動新線程

    由于創建和銷毀線程是非常耗資源,因此改成線程建好后不銷毀,可以重用,用戶只需提供run方法的具體實現:
    public static void main(String[] args) throws Exception {
            ExecutorService executor = Executors.newSingleThreadExecutor();
            Future<String> stringFuture = executor.submit(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    Thread.sleep(2000);
                    return "async thread";
                }
            });
            Thread.sleep(1000);
            System.out.println("main thread");
            System.out.println(stringFuture.get());

        }

    但如果很多線程被創建,并且線程間有依賴,即按流程和條件執行線程,實現起來就有點復雜,于是CompletableFuture橫空出世。一共有50各方法可供使用。
    CompletableFuture.supplyAsync(),相當于創建了ExecutorService,同時也創建了Callable,然后提交到線程池中執行。
    CompletableFuture<String> futureA = CompletableFuture.supplyAsync(() -> "任務A");
    CompletableFuture<String> futureB = CompletableFuture.supplyAsync(() -> "任務B");
    CompletableFuture<String> futureC = futureB.thenApply(b -> {
          System.out.println("執行任務C.");
          System.out.println("參數:" + b);//參數:任務B
          return "a";
    });


    !!How to use CompletableFuture and Callable in Java
    https://ducmanhphan.github.io/2020-02-10-How-to-use-CompletableFuture-Callable-in-Java/

    使用CompletableFuture優化你的代碼執行效率
    https://www.cnblogs.com/fingerboy/p/9948736.html

    CompletableFuture 使用詳解
    https://www.jianshu.com/p/6bac52527ca4

    使用CompletableFuture
    https://www.liaoxuefeng.com/wiki/1252599548343744/1306581182447650


    https://github.com/eugenp/tutorials/blob/master/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/completablefuture/CompletableFutureLongRunningUnitTest.java

    posted @ 2020-08-14 11:46 paulwong 閱讀(305) | 評論 (0)編輯 收藏

    Springboot+proguard+maven 混淆

    https://blog.csdn.net/qq_35981283/article/details/78529929

    posted @ 2020-08-13 10:53 paulwong 閱讀(919) | 評論 (0)編輯 收藏

    僅列出標題
    共115頁: First 上一頁 14 15 16 17 18 19 20 21 22 下一頁 Last 
    主站蜘蛛池模板: 在线精品免费视频| 亚洲中文字幕日产乱码高清app| 毛片免费视频播放| 无码永久免费AV网站| 亚洲色欲或者高潮影院| 日本免费精品一区二区三区| 国产婷婷高清在线观看免费| 亚洲国产精品无码久久久不卡 | 亚洲国产精品张柏芝在线观看| 野花视频在线官网免费1| 日韩毛片无码永久免费看| 亚洲av午夜电影在线观看| 国产一级高清免费观看| 一级做a爰片久久毛片免费陪 | 免费va人成视频网站全| 亚洲毛片在线免费观看| 免费a级毛片无码a∨蜜芽试看| 亚洲人成人无码.www石榴| 国产又长又粗又爽免费视频 | 亚洲国产中文字幕在线观看| 香蕉免费一级视频在线观看| 亚洲av中文无码乱人伦在线咪咕| 国产精品亚洲二区在线| 色婷婷7777免费视频在线观看| 亚洲精品国产国语| 91嫩草国产在线观看免费| 亚洲欧美熟妇综合久久久久| 亚洲AⅤ无码一区二区三区在线 | 亚洲XX00视频| 色天使亚洲综合一区二区| 亚洲人成电影在线播放| 一级毛片免费观看不卡的| 亚洲人成电影网站久久| 免费人成在线观看网站视频| 三年片在线观看免费观看大全动漫 | 黄色一级视频免费观看| 亚洲AV成人无码久久精品老人| 精品97国产免费人成视频| 中文字幕亚洲免费无线观看日本| 成年人免费视频观看| 一区二区三区免费视频网站|