<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 
    主站蜘蛛池模板: 在线观看免费视频资源| 亚洲成A人片777777| 久久国产免费福利永久| 国产JIZZ中国JIZZ免费看| 亚洲欧美日韩一区二区三区在线 | 亚洲AⅤ男人的天堂在线观看| 亚洲天堂一区二区| 久久精品亚洲男人的天堂| 国产男女猛烈无遮挡免费视频网站 | 一级毛片免费播放视频| 国产精品亚洲专区在线观看| 亚洲大成色www永久网站| 亚洲色图综合在线| 免费国产在线观看不卡| 成人免费无码大片a毛片| 最近免费mv在线电影| 亚欧免费一级毛片| a毛片全部播放免费视频完整18| 青青草97国产精品免费观看 | 日韩精品成人无码专区免费| 日韩免费人妻AV无码专区蜜桃 | 国产不卡免费视频| 成人免费午间影院在线观看| 青青视频观看免费99| 222www免费视频| 99re6热视频精品免费观看| 黄色网站软件app在线观看免费| 九九免费观看全部免费视频| 无套内谢孕妇毛片免费看看| 男男黄GAY片免费网站WWW| 亚洲AV综合永久无码精品天堂 | 免费日本黄色网址| 国产一区在线观看免费| 青青草国产免费久久久下载| 四虎免费大片aⅴ入口| 夜夜爽免费888视频| 情侣视频精品免费的国产| 日本免费网站观看| 免费a级毛片在线观看| 亚洲AV日韩精品一区二区三区| 亚洲成a人片在线观看老师|