<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
        <title>BUCHERS&apos;</title>
        <description>BUCHERS&apos; - Buchers&apos;</description>
        <link>https://evildracula.github.io</link>
        <atom:link href="https://evildracula.github.io/rss.xml" rel="self" type="application/rss+xml" />
        <lastBuildDate>Sat, 01 Nov 2025 07:19:38 +0000</lastBuildDate>
        <pubDate>Sat, 01 Nov 2025 07:19:38 +0000</pubDate>
        <ttl>60</ttl>


        <item>
                <title>Git 版本回退</title>
                <description>
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;参考,部分转载:https://yorkyu.cn/how-to-use-rebase-to-gracefully-fallback-code-08cdafe3d403.html&lt;/code&gt;&lt;/p&gt;

&lt;h1 id=&quot;基本操作概念&quot;&gt;基本操作概念&lt;/h1&gt;
&lt;ol&gt;
  &lt;li&gt;Git Revert
使用命令 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git revert commit_id&lt;/code&gt; 能产生一个 与 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit_id&lt;/code&gt; 完全相反的提交，即在 log 中会看到一条新的提交 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;new_commit_id&lt;/code&gt;， revert 提交就是删除 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit_id&lt;/code&gt; 的提交。&lt;/li&gt;
  &lt;li&gt;Git Reset
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reset&lt;/code&gt; 也能使代码回到某次提交，但跟 revert 不同的是， reset 是将提交的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HEAD&lt;/code&gt; 指针指到某次提交，之后的提交记录会消失，就像从没有过这么一次提交&lt;/li&gt;
  &lt;li&gt;Get Rebase
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rebase&lt;/code&gt; 是“变基”的意思，这里的“基”，指[多次] commit 形成的 git workflow，使用 rebase，我们可以改变这些历史提交，修改 commit 信息，将多个 commit 进行组合。&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;rebaserevert回退&quot;&gt;Rebase+Revert回退&lt;/h1&gt;
&lt;ol&gt;
  &lt;li&gt;切出一个新分支 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt;
首先，切出一个新分支 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt;，使用 git log 查询一下&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;要回退到的&lt;/code&gt; commit 版本 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit_n&lt;/code&gt;。&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 分支执行命令 git rebase -i commit_n&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 合并 commit2 ~ commit4 到最旧的 commit1 上
在合并 commit 时，我们可以选择 pick(p) 最旧的 commit1，然后在后续的 commit_xxx 前添加 squash(s) 命令，将这些 commits 都合并到最旧的 commit1 上。
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pick 6fa5869 commit1
squash 0b84ee7 commit2
squash 986c6c8 commit3
squash 91a0dcc commit4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 合并提交记录
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 执行rebase 生成的新记录
commit 5
# 回退代码的版本号
commit_n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 合并 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; 到 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt;&lt;br /&gt;
由于 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 分支落后与 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; 分支，因此需要执行 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git merge master&lt;/code&gt; 将&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; 分支向 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 分支合并。
合并后 git 会发现 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit1&lt;/code&gt; 到 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit4&lt;/code&gt; 提交的内容和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 分支上 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit5&lt;/code&gt; 的修改内容是完全相同的，会自动进行合并，内容不变，但多了一个 commit5。
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# feature1 分支
commit 5
commit 4
commit 3
commit 2
commit 1
# 回退代码的版本号
commit_n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 分支执行 revert 反提交&lt;br /&gt;
在 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt; 分支上对 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit5&lt;/code&gt; 进行一次 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;revert&lt;/code&gt; 反提交，就实现了把 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit1&lt;/code&gt; 到 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit4&lt;/code&gt; 的提交全部回退。即撤回步骤5中的合并。
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git revert commit_5
# 执行rebase 生成的新记录
commit 5
# 回退代码的版本号
commit_n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; 分支执行合并&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature1&lt;/code&gt;到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; 代码回退，但保留了&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;commit_n, 1,2,3,4,5&lt;/code&gt;所有记录
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# 切回到 master
$ git checkout master
# 合并 feature1
$ git merge feature1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

</description>
                <link>https://evildracula.github.io/tech/2021/03/13/git-%E7%89%88%E6%9C%AC%E5%9B%9E%E9%80%80</link>
                <guid>https://evildracula.github.io/tech/2021/03/13/git 版本回退</guid>
                <pubDate>Sat, 13 Mar 2021 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>循环fibnaci</title>
                <description>
&lt;p&gt;&lt;img src=&quot;/resources/images/2019/1/0-sc-fibnaci.png&quot; alt=&quot;Fibnaci&quot; height=&quot;100%&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.test&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FibnaciStack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;printStack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;STACK:BEGIN&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;STACK_SIZE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;b,s,n&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;STACK_SIZE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;--)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;no&quot;&gt;T&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;T&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;obj&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;objs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;obj&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;STACK:END&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// this will goto last one, as nothing to operate&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// pop next things to operate, define $rt as last result in {0,1}&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;// we have the result, there is no need for current stack.&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;rt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Print $$n&amp;lt;2, n=&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// Push F(n), F(n-2), F(n-2-2)&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// TODO STEP1 压栈操作&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                            &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
                            &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;branch=0,&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;n&quot;&gt;printStack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// F(n+1) = F(n) + F(n-1)&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// Push F(n) and handle F(n-1)&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// TODO STEP2 保留 $rt 结果，F(n) 分支压栈; F(n-1) 到 $branch0 再压栈&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;// $branch=1 的情况就是有 $rt 中间结果&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// push the F(n):&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// 1. $branch will be 2 when (n--) &amp;lt;=2 in next step;(Refer TODO $2)&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// 2. Otherwise $branch will remain 0 for stack push(Refer TODO $1)&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// 最终结果还是保留在了 $s=$rt，中间结果&lt;/span&gt;
                        &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;});&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// process F(n-1):&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// Goto $BRANCH=0 if (n--)&amp;gt;=2 ;&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// Otherwise goto n&amp;lt;2 and then go to TODO $$Popup;&lt;/span&gt;
                        &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;--;&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// goto branch0,将 n-- 结果压栈&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// TODO $1&lt;/span&gt;
                        &lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;branch=1,&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;n&quot;&gt;printStack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
                    &lt;span class=&quot;cm&quot;&gt;/** TODO STEP3 更新当前 $rt:
                     *
                     *  1. n &amp;gt;=2 时, $rt 下次直接被保留 到 $branch1 压栈
                     *  2. n &amp;lt; 2 时，$rt 会被跟新 $rn = n
                     */&lt;/span&gt;

                    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// 1. calc rs til now in one F(n),calc from $BRANCH=1, $BRANCH++&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// we have the result, there is no need for current stack.&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// 2. Stack will be popup, if the popped $branch==1, we&lt;/span&gt;
                        &lt;span class=&quot;c1&quot;&gt;// will be here again&lt;/span&gt;
                        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;We have the previous Result!!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                        &lt;span class=&quot;n&quot;&gt;rt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
                        &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Result is :&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// TODO $$Popup&lt;/span&gt;
            &lt;span class=&quot;cm&quot;&gt;/**
             * TODO STEP4 弹出操作栈
             * 1. 弹出 branch0 -&amp;gt;1 下次操作保留 TODO $rt;
             * 2. 弹出 branch1 -&amp;gt;2 下次操作更新 TODO $rt+=s;
             */&lt;/span&gt;

            &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Long&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;POPUP Branch=&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; s=&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; n=&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; rt=&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;printStack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// TODO $2&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;branch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++;&lt;/span&gt;

        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
                <link>https://evildracula.github.io/tech/2019/02/13/%E5%BE%AA%E7%8E%AFFibnaci</link>
                <guid>https://evildracula.github.io/tech/2019/02/13/循环Fibnaci</guid>
                <pubDate>Wed, 13 Feb 2019 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Cas exchanger</title>
                <description>
&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;package&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;com.test.distrib&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.io.PrintStream&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.concurrent.atomic.AtomicLong&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;java.util.concurrent.atomic.AtomicReferenceFieldUpdater&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FileDistributionStreamExchangeTask&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Runnable&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counterGrp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;edit-counters&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeName1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;wikipedia-stats1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeName2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;wikipedia-stats2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeKey1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hello1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeKey2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Hello2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PrintStream&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OUTPUT_STREAM&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counterName1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;repeat-edits1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counterName2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;repeat-edits2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;limits&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2000&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;volatile&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cworker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;volatile&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AtomicReferenceFieldUpdater&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;FileDistributionStreamExchangeTask&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeCAS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;AtomicReferenceFieldUpdater&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;newUpdater&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;FileDistributionStreamExchangeTask&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;s&quot;&gt;&quot;cworker&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;


    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;FileDistributionStreamExchangeTask&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;taskContext&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;taskContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeName1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;());&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;taskContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeName2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;());&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;worker1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AtomicLong&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;taskContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeName1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;worker2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AtomicLong&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;taskContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeName2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// cworker should be null, init once&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;storeCAS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAndSet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Timer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Timer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;schedule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TimerTask&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IncomingMessageEnvelope&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;envelope&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sWorker&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cworker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;limits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;// TODO 1&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// TODO 2&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sWorker&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeCAS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;compareAndSet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;n&quot;&gt;sWorker&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cworker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                    &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Swap 1 - 2&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeCAS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;compareAndSet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;worker1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                    &lt;span class=&quot;n&quot;&gt;sWorker&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cworker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                    &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Swap 2 - 1&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                    &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
                &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;sWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;purge&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;limits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// TODO 5&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cworker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;handleMsg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;envelope&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Send the remains&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;window flush==============================&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cworker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;purge&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;IncomingMessageEnvelope&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IncomingMessageEnvelope&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HashMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;orderDetails&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Generator &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentThread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentTimeMillis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Thread &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentThread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;: some msg&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;IncomingMessageEnvelope&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;


        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;setMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;


    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DistributionStreamWorker&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;volatile&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AtomicLong&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;volatile&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batchInfo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;DistributionStreamWorker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AtomicLong&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;counter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;store&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;storeKey&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;synchronized&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;purge&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;limit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// TODO 3&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;limit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;limit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stack&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;no&quot;&gt;OUTPUT_STREAM&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Start to flush&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;l&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;batchInfo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;synchronized&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;handleMsg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;IncomingMessageEnvelope&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;envelope&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;c1&quot;&gt;// TODO 4&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;limits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;flush&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Clean&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentThread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;());&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;edit&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;envelope&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getMessage&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ArrayList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;gt;();&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;store&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;put&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;storeKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;edit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;orderDetails&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;kt&quot;&gt;long&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;limits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Out of limists!!!!&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
                &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Total :&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Current Consumer ===&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;currentThread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getId&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;
                    &lt;span class=&quot;s&quot;&gt;&quot;+++++++++++&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;arr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// Update Batch here if possible&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;batchInfo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAndIncrement&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;throws&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;InterruptedException&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FileDistributionStreamExchangeTask&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FileDistributionStreamExchangeTask&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;];&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Thread&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;tgroup&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;



&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/resources/images/2021/4/CAS_1.png&quot; alt=&quot;CAS1&quot; height=&quot;100%&quot; width=&quot;100%&quot; /&gt;&lt;br /&gt;
&lt;img src=&quot;/resources/images/2021/4/CAS_2.png&quot; alt=&quot;CAS2&quot; height=&quot;100%&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;
</description>
                <link>https://evildracula.github.io/tech/2019/01/25/CAS-Exchanger</link>
                <guid>https://evildracula.github.io/tech/2019/01/25/CAS Exchanger</guid>
                <pubDate>Fri, 25 Jan 2019 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Kafka cluaster partitions replicas group</title>
                <description>
&lt;h2 id=&quot;partition--replicas&quot;&gt;Partition &amp;amp; Replicas&lt;/h2&gt;
&lt;h3 id=&quot;kafka-集群默认自动分配解析&quot;&gt;Kafka 集群默认自动分配解析&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;下面以一个Kafka集群中4个Broker举例，创建1个topic包含4个Partition，2 Replication；数据Producer流动如图所示：&lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker1&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker2&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker3&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker4&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;BrokerX&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;BrokerX&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;N/A&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;N/A&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;N/A&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;N/A&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;ul&gt;
  &lt;li&gt;当集群中新增2节点，Partition增加到6个时分布情况如下：&lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker1&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker2&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker3&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker4&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker5&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Broker6&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P0&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P5&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;副本分配逻辑规则如下&quot;&gt;副本分配逻辑规则如下：&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;在Kafka集群中，每个Broker都有均等分配Partition的Leader机会。&lt;/li&gt;
  &lt;li&gt;上述图Broker Partition中，箭头指向为副本，以Partition-0为例:broker1中parition-0为Leader，Broker2中Partition-0为副本。&lt;/li&gt;
  &lt;li&gt;上述图种每个Broker(按照BrokerId有序)依次分配主Partition,下一个Broker为副本，如此循环迭代分配，多副本都遵循此规则。&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;副本分配算法如下&quot;&gt;副本分配算法如下：&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;将所有N Broker和待分配的i个Partition排序.&lt;/li&gt;
  &lt;li&gt;将第i个Partition分配到第(i mod n)个Broker上.&lt;/li&gt;
  &lt;li&gt;将第i个Partition的第j个副本分配到第((i + j) mod n)个Broker上.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;group-on-consumers&quot;&gt;Group on Consumers&lt;/h2&gt;
&lt;h3 id=&quot;kafka-partition--group&quot;&gt;Kafka Partition &amp;amp; Group&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;原理图&lt;/li&gt;
  &lt;li&gt;原理描述&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;一个topic 可以配置几个partition，produce发送的消息分发到不同的partition中，consumer接受数据的时候是按照group来接受，kafka确保每个partition只能同一个group中的同一个consumer消费，如果想要重复消费，那么需要其他的组来消费。Zookeerper中保存这每个topic下的每个partition在每个group中消费的offset  
新版kafka把这个offsert保存到了一个__consumer_offsert的topic下  
这个__consumer_offsert 有50个分区，通过将group的id哈希值%50的值来确定要保存到那一个分区.  这样也是为了考虑到zookeeper不擅长大量读写的原因。  
所以，如果要一个group用几个consumer来同时读取的话，需要多线程来读取，一个线程相当于一个consumer实例。当consumer的数量大于分区的数量的时候，有的consumer线程会读取不到数据。   
假设一个topic test 被groupA消费了，现在启动另外一个新的groupB来消费test，默认test-groupB的offset不是0，而是没有新建立，除非当test有数据的时候，groupB会收到该数据，该条数据也是第一条数据，groupB的offset也是刚初始化的ofsert, 除非用显式的用–from-beginnging 来获取从0开始数据   
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;查看topic-group的offsert&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;位置：zookeeper 
路径：[zk: localhost:2181(CONNECTED) 3] ls /brokers/topics/__consumer_offsets/partitions 
在zookeeper的topic中有一个特殊的topic __consumer_offserts 
计算方法：（放入哪个partitions）

int hashCode = Math.abs(&quot;ttt&quot;.hashCode());
int partition = hashCode % 50;
先计算group的hashCode，再除以分区数(50),可以得到partition的值 
使用命令查看： kafka-simple-consumer-shell.sh --topic __consumer_offsets --partition 11 --broker-list localhost:9092,localhost:9093,localhost:9094 --formatter &quot;kafka.coordinator.GroupMetadataManager\$OffsetsMessageFormatter&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;参数&lt;br /&gt;
auto.offset.reset:默认值为largest，代表最新的消息，smallest代表从最早的消息开始读取，当consumer刚开始创建的时候没有offset这种情况，如果设置了largest，则为当收到最新的一条消息的时候开始记录offsert,若设置为smalert，那么会从头开始读partition&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Consumer Group 
使用Consumer high level API时，同一Topic的一条消息只能被同一个Consumer Group内的一个Consumer消费，但多个Consumer Group可同时消费这一消息。&lt;br /&gt;
这是Kafka用来实现一个Topic消息的广播（发给所有的Consumer）和单播（发给某一个Consumer）的手段。一个Topic可以对应多个Consumer Group。如果需要实现广播，只要每个Consumer有一个独立的Group就可以了。要实现单播只要所有的Consumer在同一个Group里。用Consumer Group还可以将Consumer进行自由的分组而不需要多次发送消息到不同的Topic。&lt;br /&gt;
实际上，Kafka的设计理念之一就是同时提供离线处理和实时处理。根据这一特性，可以使用Storm这种实时流处理系统对消息进行实时在线处理，同时使用Hadoop这种批处理系统进行离线处理，还可以同时将数据实时备份到另一个数据中心，只需要保证这三个操作所使用的Consumer属于不同的Consumer Group即可。&lt;br /&gt;
下面这个例子更清晰地展示了Kafka Consumer Group的特性。首先创建一个Topic (名为topic1，包含3个Partition)，然后创建一个属于group1的Consumer实例，并创建三个属于group2的Consumer实例，最后通过Producer向topic1发送key分别为1，2，3的消息。结果发现属于group1的Consumer收到了所有的这三条消息，同时group2中的3个Consumer分别收到了key为1，2，3的消息。&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
                <link>https://evildracula.github.io/tech/2019/01/20/Kafka-Cluaster-Partitions-Replicas-Group</link>
                <guid>https://evildracula.github.io/tech/2019/01/20/Kafka Cluaster Partitions Replicas Group</guid>
                <pubDate>Sun, 20 Jan 2019 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>List node 节点大树算法</title>
                <description>
&lt;p&gt;只适合差一位和相同位数两数相加；若需要实现相差多位数相加，需要另外探深度&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
package ext.lc;

import java.util.HashSet;
import java.util.Set;

public class Solution {

    private static Set&amp;lt;ListNode&amp;gt; l = new HashSet&amp;lt;&amp;gt;();
    public static int[] vlist = new int[10];

    public static ListNode addTwoNumbers(ListNode n1, ListNode n2) {
        return addNext(n1, n2, null, null, 0);
    }

    public static ListNode addNext(ListNode n1, ListNode n2, ListNode p1,
                                   ListNode p2, int level) {
        if (n1 == null &amp;amp;&amp;amp; n2 == null) {
            return null;
        } else if (n1 != null &amp;amp;&amp;amp; n2 != null) {
            System.out.println(&quot;N1: &quot; + n1.val + &quot; N2:&quot; + n2.val);
            if (n1.next != null || n2.next != null) {
                if (n1.next != null ^ n2.next != null) {
                    // At least one n.next is not null, recurse to find next
                    // 1,2,3 (next 3 is not null)
                    // 1,2,(2)(next is null, align to next
                    ListNode temp = addNext(n1.next == null ? n1 : n1.next,
                            n2.next == null ? n2 : n2.next, n1, n2, level + 1);
                    int val = temp.val;
                    temp.val = val % 10;
                    l.add(temp);
                    // 1,2,3
                    //   1,2(1 is p1/p2, whose next is null)
                    temp = new ListNode((n1.next == null ? p1.val : n1.val) + (n2.next == null ? p2.val : n2.val) + val / 10);
                    val = temp.val;
                    temp.val = val % 10;
                    // Update p for val &amp;gt; 9
                    if (p1 != null) {
                        p1.val += val / 10;
                    } else if (p2 != null) {
                        p2.val += val / 10;
                    }
                    // FIXME POS_1
                    if (n1.next == null) {
                        n1.val = p1.val;
                        n1.next = p1.next;
                    } else if (n2.next == null) {
                        n2.val = p2.val;
                        n2.next = p2.next;
                    }
                    vlist[level] = temp.val;
                    l.add(temp);
                    return temp;
                } else {
                    // all next are not null
                    ListNode temp = addNext(n1.next, n2.next, n1, n2,
                            level + 1);
                    l.add(temp);
                    // All next are not null, n is loop equals. n.next == n
                    // .next.net
                    // If so, n renew with p next for further check.
                    // Initialed by FIXME POS_1
                    renewNode(n1, p1);
                    renewNode(n2, p2);
                    int val = n1.val + n2.val;
                    temp = new ListNode(val % 10);
                    if (p1 != null) {
                        p1.val += val / 10;
                    } else if (p2 != null) {
                        p2.val += val / 10;
                    }
                    vlist[level] = temp.val;
                    l.add(temp);
                    return temp;
                }
            }
            // all next null, return n1 + n2
            int val = n1.val + n2.val;
            ListNode temp = new ListNode(val % 10);
            if (p1 != null) {
                p1.val += val / 10;
            } else if (p2 != null) {
                p2.val += val / 10;
            }
            vlist[level] = temp.val;
            l.add(temp);
            return temp;
        } else {
            // at least 1 null
            ListNode tNode = addNext(n1 == null ? null : n1.next, n2 == null ?
                    null : n2.next, n1, n2, level + 1);
            tNode = tNode == null ? (n1 == null ? n2 : n1) : tNode;
            vlist[level] = tNode.val;
            l.add(tNode);
            return tNode;
        }
    }

    /**
     * Check if n is loop equals n.next == n.next.next;
     * Renew n to p if p is not null.
     *
     * @param n
     * @param p
     */
    private static void renewNode(ListNode n, ListNode p) {
        if (n.next != null &amp;amp;&amp;amp; n.next == n.next.next) {
            if (p == null) {
                n.val = 0;
            } else {
                n.val = p.val;
                n.next = p.next;
            }
        }
    }

    public static void main(String[] args) {
        // Init list1 7247
        ListNode n1 = new ListNode(7);
        ListNode n2 = new ListNode(2);
        ListNode n3 = new ListNode(4);
        ListNode n4 = new ListNode(7);
        n1.next = n2;
        n2.next = n3;
        n3.next = n4;
        // 7247
        //  954
        // 8201
        ListNode n11 = new ListNode(9);
        ListNode n12 = new ListNode(5);
        ListNode n13 = new ListNode(4);
        n11.next = n12;
        n12.next = n13;
        for (int i = 0; i &amp;lt; 10; i++) {
            System.out.print(vlist[i]);
        }
        System.out.println();
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/12/02/List-Node-%E8%8A%82%E7%82%B9%E5%A4%A7%E6%A0%91%E7%AE%97%E6%B3%95</link>
                <guid>https://evildracula.github.io/tech/2018/12/02/List Node 节点大树算法</guid>
                <pubDate>Sun, 02 Dec 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Winscp_scripts</title>
                <description>
&lt;p&gt;&lt;em&gt;scp.bat&lt;/em&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SET rootPath=&quot;C:\Program Files (x86)\WinSCP\&quot;
SET folderDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
mkdir e:\%folderDate%
SET localFilePath=e:\%folderDate%
%rootPath%\WinSCP.exe /console /script=&quot;C:\Users\yuanhui\Desktop\GetValidationData.txt&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;GetValidationData.txt&lt;/em&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;option batch continue
option confirm off
option transfer binary
open sftp://user:psw@localhost:22
cd /data/streaming/%folderDate%
lcd %localFilePath%
get *
close
exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/11/03/Winscp_scripts</link>
                <guid>https://evildracula.github.io/tech/2018/11/03/Winscp_scripts</guid>
                <pubDate>Sat, 03 Nov 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Password expire</title>
                <description>
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;TODAY=`date &quot;+%b %d, %Y&quot;`
cat vmlist.txt|while read line;do
    EXPIRE_DATE=`ssh -n $line &quot;chage -l wmuser|grep &apos;expires&apos;;exit&quot;|tail|awk &apos;{print $4,$5,$6}&apos;`;
    echo $EXPIRE_DATE;
    echo $TODAY;
    t1=`date -d &quot;$EXPIRE_DATE&quot; +%s`;
    t2=`date -d &quot;$TODAY&quot; +%s`;
    if [ &quot;$t1&quot; -gt &quot;$t2&quot; ]; then
        echo &quot;$EXPIRE_DATE &amp;gt; $TODAY&quot;
    else
        echo &quot;$TODAY &amp;gt; $EXPIRE_DATE&quot;
    fi;
done;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/11/03/Password-expire</link>
                <guid>https://evildracula.github.io/tech/2018/11/03/Password expire</guid>
                <pubDate>Sat, 03 Nov 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Grafana环境搭建</title>
                <description>
&lt;h4 id=&quot;install-sqlite3&quot;&gt;Install sqlite3&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo wget https://www.sqlite.org/2018/sqlite-tools-linux-x86-3240000.zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install-mysql&quot;&gt;Install mysql&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-community-server

service mysqld start/stop

mysql -u root
CREATE DATABASE grafana_db
insert into mysql.user(Host,User,Password) values(&quot;localhost&quot;,&quot;grafanaReader&quot;,password(&quot;password&quot;));
flush privileges;
grant all privileges on granfana_db.* to grafanaReader@localhost identified by &apos;password&apos;;
flush privileges;

mysql -u grafanaReader -p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;install-grafana&quot;&gt;Install grafana&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;touch bin/grafana.db
sudo bin/grafana-server -config=&quot;conf/defaults.ini&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/09/08/Grafana%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA</link>
                <guid>https://evildracula.github.io/tech/2018/09/08/Grafana环境搭建</guid>
                <pubDate>Sat, 08 Sep 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Flumeagentsource搭建</title>
                <description>
&lt;h3 id=&quot;keytool&quot;&gt;keytool&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;生成key
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;keytool -genkeypair -alias avro -keyalg RSA -keystore mykeystore/keystore.jks -dname &quot;CN=localhost, OU=localhost,O=localhost, L=SH, ST=SH, C=CN&quot; -keypass changeit -storepass changeit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;查阅
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;keytool -list -v -alias avro -keystore mykeystore/keystore.jks -storepass changeit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;导出
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;keytool -export -alias avro -keystore mykeystore/keystore.jks -rfc -file mykeystore/mycert.cer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;生成 truststore
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;keytool -import -alias avro -file mykeystore/mycert.cer  -keystore truststore.jks
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;avro-source-agent&quot;&gt;Avro Source Agent&lt;/h3&gt;
&lt;h4 id=&quot;command&quot;&gt;Command&lt;/h4&gt;
&lt;p&gt;sudo bin/flume-ng agent -n agent -c conf -f conf/avro-src.conf -Dflume.root.logger=INFO,console&lt;/p&gt;
&lt;h4 id=&quot;config&quot;&gt;Config&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;agent.sources = src-avro
agent.channels = memoryChannel
agent.sinks = loggerSink
# For each one of the sources, the type is defined
agent.sources.src-avro.type =avro
# The channel can be defined as follows.
agent.sources.src-avro.channels = memoryChannel
agent.sources.src-avro.bind=127.0.0.1
agent.sources.src-avro.port=1000
agent.sources.src-avro.ssl=true
agent.sources.src-avro.keystore=/home/yuanhui0628/temp/mykeystore/keystore.jks
agent.sources.src-avro.keystore-password=changeit
agent.sources.src-avro.keystore-type=JKS
# Each sink&apos;s type must be defined
agent.sinks.loggerSink.type = logger
#Specify the channel the sink should use
agent.sinks.loggerSink.channel = memoryChannel
# Each channel&apos;s type is defined.
agent.channels.memoryChannel.type = memory
# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
agent.channels.memoryChannel.capacity = 100 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;avro-sink-agent&quot;&gt;Avro Sink Agent&lt;/h3&gt;
&lt;h4 id=&quot;command-1&quot;&gt;Command&lt;/h4&gt;
&lt;p&gt;bin/flume-ng agent -n agent -c conf -f conf/avro-agent.conf -Dflume.root.logger=INFO,console&lt;/p&gt;

&lt;h4 id=&quot;config-1&quot;&gt;Config&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;agent.sources = netSrc
agent.channels = memoryChannel
agent.sinks = avro-sink
# For each one of the sources, the type is defined
agent.sources.netSrc.type = netcat
agent.sources.netSrc.bind= 127.0.0.1
agent.sources.netSrc.port= 9999
# The channel can be defined as follows.
agent.sources.netSrc.channels = memoryChannel
# Each sink&apos;s type must be defined
agent.sinks.avro-sink.type = avro
#Specify the channel the sink should use
agent.sinks.avro-sink.channel = memoryChannel
agent.sinks.avro-sink.hostname= 127.0.0.1
agent.sinks.avro-sink.port = 1000

agent.sinks.avro-sink.ssl=true
agent.sinks.avro-sink.trust-all-certs=true
agent.sinks.avro-sink.truststrore=/home/yuanhui0628/temp/mykeystore/truststore.jks
agent.sinks.avro-sink.truststrore-password=changeit
agent.sinks.avro-sink.truststrore-type=JKS
# Each channel&apos;s type is defined.
agent.channels.memoryChannel.type = memory
# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
agent.channels.memoryChannel.capacity = 100 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/09/07/FlumeAgentSource%E6%90%AD%E5%BB%BA</link>
                <guid>https://evildracula.github.io/tech/2018/09/07/FlumeAgentSource搭建</guid>
                <pubDate>Fri, 07 Sep 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>标志位配置设计</title>
                <description>
&lt;h3 id=&quot;枚举包装接口&quot;&gt;枚举包装接口&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FilterEnums&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

    &lt;span class=&quot;nc&quot;&gt;Enumeration&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;FlagStatsCode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;实现&quot;&gt;实现&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class StatCodeEnumerator implements FilterEnums {

    private FlagStatsCode[] codes;


    public StatCodeEnumerator(FlagStatsCode[] codes) {
        assert (codes != null);
        this.codes = codes;

    }

    @Override
    public Enumeration&amp;lt;FlagStatsCode&amp;gt; elements() {
        return new Enumeration&amp;lt;FlagStatsCode&amp;gt;() {
            private int count = 0;

            @Override
            public boolean hasMoreElements() {
                return count &amp;lt; StatCodeEnumerator.this.codes.length;
            }

            @Override
            public FlagStatsCode nextElement() {
                return StatCodeEnumerator.this.codes[count++];
            }
        };
    }

    @Override
    public int length() {
        return codes.length;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;状态entries&quot;&gt;状态Entries&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class FlagStatsCode {

    private int code;
    private String stats;

    public FlagStatsCode(String stats, int code) {
        this.code = code;
        this.stats = stats;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getStats() {
        return stats;
    }

    public void setStats(String stats) {
        this.stats = stats;
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;聚合计算器&quot;&gt;聚合计算器&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class FilterAggregator {
    final int F_FLAG = 0xffffffff;
    final int H_FLAG = 0xffff0000;
    final int L_FLAG = 0x0000ffff;

    private int allowedStatus = 0;

    StatCodeEnumerator userFilter = null;

    public FilterAggregator(StatCodeEnumerator userFilter) {
        assert (userFilter != null);
        this.userFilter = userFilter;
        validate();
    }

    public int aggStatus(int mix_signal) {
        if (allowedStatus != (allowedStatus | mix_signal)) {
            throw new RuntimeException(&quot;Can&apos;t match signal&quot;);
        }
        return allowedStatus &amp;amp; mix_signal;
    }

    public List&amp;lt;FlagStatsCode&amp;gt; aggStatusDef(int mix_signal) {
        List&amp;lt;FlagStatsCode&amp;gt; filters = new ArrayList&amp;lt;&amp;gt;();
        if (allowedStatus != (allowedStatus | mix_signal)) {
            throw new RuntimeException(&quot;Can&apos;t match signal&quot;);
        }
        int op = allowedStatus &amp;amp; mix_signal;
        Enumeration&amp;lt;FlagStatsCode&amp;gt; codes = userFilter.elements();
        while (codes.hasMoreElements()) {
            FlagStatsCode def = codes.nextElement();
            int code = def.getCode();
            if ((op &amp;amp; code) == code) {
                filters.add(new FlagStatsCode(def.getStats(), code));
            }
        }
        return filters;
    }

    public void validate() {
        int rec_flags = 0;
        Enumeration&amp;lt;FlagStatsCode&amp;gt; codes = userFilter.elements();
        while (codes.hasMoreElements()) {
            int f = codes.nextElement().getCode();
            if ((f &amp;amp; H_FLAG) == 0 &amp;amp;&amp;amp; (f &amp;amp; L_FLAG) != 0 &amp;amp;&amp;amp; (f &amp;amp; rec_flags) == 0) {
                int check_point = 1;
                int eql_count = 0;
                for (int i = 0; i &amp;lt; 32; i++) {
                    if ((f &amp;amp; check_point) != 0) {
                        eql_count++;
                    }
                    check_point &amp;lt;&amp;lt;= 1;
                }
                if (eql_count != 1) {
                    System.out.println(&quot;eql_count &quot; + eql_count + &quot;, flag &quot; + f + &quot; is not valid!&quot;);
                    continue;
                }
                rec_flags |= f;
                continue;
            }
            System.out.println(f + &quot; is not valid!&quot;);
        }
        allowedStatus = rec_flags;
    }


    public static void main(String[] args) {
        FlagStatsCode d1 = new FlagStatsCode(&quot;CASH&quot;, 1);
        FlagStatsCode d2 = new FlagStatsCode(&quot;WEIXIN&quot;, 2);
        FlagStatsCode d3 = new FlagStatsCode(&quot;ALI&quot;, 4);
        FlagStatsCode d4 = new FlagStatsCode(&quot;CARD&quot;, 8);
        FlagStatsCode d48 = new FlagStatsCode(&quot;48_WRONG&quot;, 48);
        FilterAggregator s = null;
        s = new FilterAggregator(new StatCodeEnumerator(new FlagStatsCode[]{d1, d2, d3, d4, d48}));
        s = new FilterAggregator(new StatCodeEnumerator(new FlagStatsCode[]{d1, d2, d3}));
        s = new FilterAggregator(new StatCodeEnumerator(new FlagStatsCode[]{d1, d3}));
        System.out.println(s.aggStatus(5));
        s = new FilterAggregator(new StatCodeEnumerator(new FlagStatsCode[]{d1, d2, d3, d4}));
        for (FlagStatsCode d : s.aggStatusDef(5)) {
            System.out.println(d.getStats() + &quot; - &quot; + d.getCode());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/07/10/%E6%A0%87%E5%BF%97%E4%BD%8D%E9%85%8D%E7%BD%AE%E8%AE%BE%E8%AE%A1</link>
                <guid>https://evildracula.github.io/tech/2018/07/10/标志位配置设计</guid>
                <pubDate>Tue, 10 Jul 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Hadoop ha +zookeeper +yarn</title>
                <description>
&lt;h3 id=&quot;hadoop-配置&quot;&gt;Hadoop 配置&lt;/h3&gt;
&lt;p&gt;hadoop配置主要涉及hdfs-site.xml，core-site.xml，mapred-site.xml，yarn-site.xml四个文件。以下详细介绍每个文件的配置。&lt;/p&gt;

&lt;h4 id=&quot;core-sitexml&quot;&gt;core-site.xml&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;configuration&amp;gt;  
&amp;lt;property&amp;gt;  
      &amp;lt;name&amp;gt;fs.defaultFS&amp;lt;/name&amp;gt;  
      &amp;lt;value&amp;gt;hdfs://cluster1&amp;lt;/value&amp;gt;  
      &amp;lt;description&amp;gt;HDFS namenode的逻辑名称，也就是namenode HA,此值要对应hdfs-site.xml里的dfs.nameservices&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;property&amp;gt;  
    &amp;lt;name&amp;gt;hadoop.tmp.dir&amp;lt;/name&amp;gt;  
    &amp;lt;value&amp;gt;/home/hadoop/bigdata/tmp&amp;lt;/value&amp;gt;  
    &amp;lt;description&amp;gt;hdfs中namenode和datanode的数据默认放置路径，也可以在hdfs-site.xml中分别指定&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;ha.zookeeper.quorum&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm01:2181,m7-psdc-kvm02:2181,m7-psdc-kvm03:2181&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;zookeeper集群的地址和端口，zookeeper集群的节点数必须为奇数&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;/configuration&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;hdfs-sitexml的配置重点配置&quot;&gt;hdfs-site.xml的配置（重点配置）&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;configuration&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.name.dir&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;/home/hadoop/bigdata/nn&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;namenode的数据放置目录&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.data.dir&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;/home/hadoop/bigdata/dn&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;datanode的数据放置目录&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.replication&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;数据块的备份数，默认是3&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.nameservices&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;cluster1&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;HDFS namenode的逻辑名称，也就是namenode HA&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.ha.namenodes.cluster1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;ns1,ns2&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;nameservices对应的namenode逻辑名&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.namenode.rpc-address.cluster1.ns1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm01:8020&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;指定namenode(ns1)的rpc地址和端口&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.namenode.http-address.cluster1.ns1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm01:50070&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;指定namenode(ns1)的web地址和端口&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.namenode.rpc-address.cluster1.ns2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:9000&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;指定namenode(ns2)的rpc地址和端口&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.namenode.http-address.cluster1.ns2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:50070&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;指定namenode(ns2)的web地址和端口&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.namenode.shared.edits.dir&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;qjournal://m7-psdc-kvm01:8485;m7-psdc-kvm02:8485;m7-psdc-kvm03:8485;m7-psdc-kvm04:8485/cluster1 &amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;这是NameNode读写JNs组的uri，active NN 将 edit log 写入这些JournalNode，而 standby NameNode 读取这些 edit log，并作用在内存中的目录树中&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.journalnode.edits.dir&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;/home/hadoop/bigdata/journal&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;journalNode 所在节点上的一个目录，用于存放 editlog 和其他状态信息。&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
           &amp;lt;name&amp;gt;dfs.ha.automatic-failover.enabled&amp;lt;/name&amp;gt;  
           &amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;  
           &amp;lt;description&amp;gt;启动自动failover。自动failover依赖于zookeeper集群和ZKFailoverController（ZKFC），后者是一个zookeeper客户端，用来监控NN的状态信息。每个运行NN的节点必须要运行一个zkfc&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.client.failover.proxy.provider.cluster1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;配置HDFS客户端连接到Active NameNode的一个java类&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.ha.fencing.methods&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;sshfence&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;解决HA集群脑裂问题（即出现两个 master 同时对外提供服务，导致系统处于不一致状态）。在 HDFS HA中，JournalNode 只允许一个 NameNode 写数据，不会出现两个 active NameNode 的问题,但是，当主备切换时，之前的 active NameNode 可能仍在处理客户端的 RPC 请求，为此，需要增加隔离机制（fencing）将之前的 active NameNode 杀死。常用的fence方法是sshfence，要指定ssh通讯使用的密钥dfs.ha.fencing.ssh.private-key-files和连接超时时间&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.ha.fencing.ssh.private-key-files&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;/home/hadoop/.ssh/id_rsa&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;ssh通讯使用的密钥&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;dfs.ha.fencing.ssh.connect-timeout&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;30000&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;连接超时时间&amp;lt;/description&amp;gt;  
    &amp;lt;/property&amp;gt;  
&amp;lt;/configuration&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;mapred-sitexml的配置&quot;&gt;mapred-site.xml的配置&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;configuration&amp;gt;  
&amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;mapreduce.framework.name&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;yarn&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;指定运行mapreduce的环境是yarn，与hadoop1截然不同的地方&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;mapreduce.jobhistory.address&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm01:10020&amp;lt;/value&amp;gt;  
         &amp;lt;description&amp;gt;MR JobHistory Server管理的日志的存放位置&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;mapreduce.jobhistory.webapp.address&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm01:19888&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;查看历史服务器已经运行完的Mapreduce作业记录的web地址，需要启动该服务才行&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;property&amp;gt;  
   &amp;lt;name&amp;gt;mapreduce.jobhistory.done-dir&amp;lt;/name&amp;gt;  
   &amp;lt;value&amp;gt;/home/hadoop/bigdata/done&amp;lt;/value&amp;gt;  
   &amp;lt;description&amp;gt;MR JobHistory Server管理的日志的存放位置,默认:/mr-history/done&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;property&amp;gt;  
   &amp;lt;name&amp;gt;mapreduce.jobhistory.intermediate-done-dir&amp;lt;/name&amp;gt;  
   &amp;lt;value&amp;gt;hdfs://mycluster-pha/mapred/tmp&amp;lt;/value&amp;gt;  
   &amp;lt;description&amp;gt;MapReduce作业产生的日志存放位置，默认值:/mr-history/tmp&amp;lt;/description&amp;gt;  
&amp;lt;/property&amp;gt;  
&amp;lt;/configuration&amp;gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;yarn-sitexml&quot;&gt;yarn-site.xml&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;configuration&amp;gt;  
  
  
&amp;lt;!-- Site specific YARN configuration properties --&amp;gt;  
    &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.ha.enabled&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.cluster-id&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;yarn-cluster1&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
&amp;lt;!-- 指定RM的名字 --&amp;gt;  
        &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.ha.rm-ids&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;rm1,rm2&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
&amp;lt;!-- 分别指定RM的地址 --&amp;gt;  
        &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.hostname.rm1&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;m7-psdc-kvm03&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
        &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.hostname.rm2&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;m7-psdc-kvm02&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.recovery.enabled&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
  
  
        &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.store.class&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
        &amp;lt;!-- 指定zk集群地址 --&amp;gt;  
        &amp;lt;property&amp;gt;  
                &amp;lt;name&amp;gt;yarn.resourcemanager.zk-address&amp;lt;/name&amp;gt;  
                &amp;lt;value&amp;gt;m7-psdc-kvm01:2181,m7-psdc-kvm02:2181,m7-psdc-kvm03:2181&amp;lt;/value&amp;gt;  
        &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.ha.automatic-failover.embedded&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.admin.address.rm1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm03:8033&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.admin.address.rm2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:8033&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
  
  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.address.rm1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm03:8032&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.address.rm2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:8032&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
  
  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.resource-tracker.address.rm1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm03:8031&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.resource-tracker.address.rm2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:8031&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
  
  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.webapp.address.rm1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm03:8088&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.webapp.address.rm2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:8088&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
  
  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.scheduler.address.rm1&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm03:8030&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.scheduler.address.rm2&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;m7-psdc-kvm02:8030&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
  
  
       &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.nodemanager.aux-services&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;mapreduce_shuffle&amp;lt;/value&amp;gt;  
        &amp;lt;description&amp;gt;默认&amp;lt;/description&amp;gt;  
       &amp;lt;/property&amp;gt;  
  
  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.nodemanager.pmem-check-enabled&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.log-aggregation-enable&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
&amp;lt;!--  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.resourcemanager.ha.id&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;rm1&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
--&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.nodemanager.delete.debug-delay-sec&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;86400&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
  
  
       &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.nodemanager.auxservices.mapreduce.shuffle.class&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;org.apache.hadoop.mapred.ShuffleHandler&amp;lt;/value&amp;gt;  
       &amp;lt;/property&amp;gt;  
       &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.nodemanager.resource.memory-mb&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;102400&amp;lt;/value&amp;gt;  
     &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.nodemanager.resource.cpu-vcores&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;20&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
    &amp;lt;property&amp;gt;  
        &amp;lt;name&amp;gt;yarn.scheduler.maximum-allocation-mb&amp;lt;/name&amp;gt;  
        &amp;lt;value&amp;gt;102400&amp;lt;/value&amp;gt;  
    &amp;lt;/property&amp;gt;  
&amp;lt;/configuration&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;zookeeper-配置&quot;&gt;ZooKeeper 配置&lt;/h3&gt;
&lt;blockquote&gt;
  &lt;p&gt;Hadoop 正常配置&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;hadoop-集群启动&quot;&gt;Hadoop 集群启动&lt;/h3&gt;

&lt;h4 id=&quot;第一次配置启动&quot;&gt;第一次配置启动&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;在三个节点上启动Journalnode deamons，然后jps，出现JournalNode进程。
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbin/./hadoop-daemon.sh start journalnode
jps
JournalNode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;格式化master上的namenode（任意一个），然后启动该节点的namenode。
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bin/hdfs namenode -format
sbin/hadoop-daemon.sh start namenode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;在另一个namenode节点slave1上同步master上的元数据信息
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bin/hdfs namenode -bootstrapStandby
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;停止hdfs上的所有服务
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbin/stop-dfs.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;初始化zkfc
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bin/hdfs zkfc -formatZK
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;启动hdfs
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbin/start-dfs.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;启动yarn
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbin/start-yarn.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;非第一次配置启动&quot;&gt;非第一次配置启动&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;直接启动hdfs和yarn即可，namenode、datanode、journalnode、DFSZKFailoverController都会自动启动。
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbin/start-dfs.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;启动yarn
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sbin/start-yarn.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/29/Hadoop-HA-+zookeeper-+yarn</link>
                <guid>https://evildracula.github.io/tech/2018/04/29/Hadoop HA +zookeeper +yarn</guid>
                <pubDate>Sun, 29 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>运维知识体系</title>
                <description>
&lt;p&gt;转载请注明来自于-运维社区：https://www.unixhot.com/&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan=&quot;3&quot; width=&quot;283&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维架构层级/运维角度&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;内容描述/主要技术关键词&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;监控体系&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;自动化/DevOps&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;云计算&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;81&quot; height=&quot;120&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;客户端层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;浏览器&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Cookie、浏览器缓存协商（Last-Modified、Expires、Etag）、组件分离、前端优化、运维检测工具&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;舆论监控外部网络监控&lt;/span&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;APM&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;故障检测工具&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;DNS服务&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; CDN服务&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 移动服务&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 云盾&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;DNS&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;浏览器DNS缓存、DNS缓存、自建DNS服务器、商业DNS产品、智能DNS、公共DNS（BGP&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; anycast）、bind+DLZ/DPDK&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;客户端/APP&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;HTTP-DNS、打点日志、加密传输、移动推送、各类SDK（监控SDK、推流SDK等）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;81&quot; height=&quot;80&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;外部层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;第三方CDN&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;GSLB、反向代理缓存、分布式存储、流量调度、配置管理、用户端（各类API如：带宽监控、预缓存、缓存刷新）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;基于开放API开发&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;云计算&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;公有云服务、混合云、运维外包服务、APM（应用性能管理）、第三方安全解决方案（防DDOS、WAF）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;81&quot; height=&quot;160&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;网络层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;互联层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;多机房互联（VPN、专线）、异地灾备--&amp;gt;异地多活--&amp;gt;按SET部署&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;设备监控&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; （Zabbix SNMP）网络质量监控&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; （Smokeping）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;SDN&lt;/span&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;OpenvSwitch&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; （GRE、Vxlan）&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;高速通道&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;核心层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;防火墙、路由器、Ipsec VPN、链路负载均衡和高可用 （CCNP级别）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;VPC（专有网络）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;汇聚层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;三层交换 动态路由（OSPF）、静态路由、EC（端口汇聚）、MSTP+VRRP等 （CCNP级别）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;接入层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;二层交换 （VTP、SPF、Trunk、端口安全）等 （CCNA级别）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;81&quot; height=&quot;120&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;接入层&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;100&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;负载均衡&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 高可用&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;102&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;四层负载均衡&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;开源：LVS（IP负载均衡）+Keepalived、Haproxy 商业：F5、Netscaler&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;服务监控（API）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;平台开发&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; （LBaas）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;高防IP&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 云负载均衡SLB&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; CDN服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;七层负载均衡&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;反向代理：Haproxy、Nginx、Apache（根据HTTP协议支持的属性进行L7分发）、A/B Test&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Gateway、WAF&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;反向代理缓存&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;ATS、Squid、Varnish、Nginx(缓存分级、预缓存、缓存刷新）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;81&quot; height=&quot;200&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;应用服务层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Web服务层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;HTTP协议、Web服务器（Apache、Nginx/OpenResty、Tomcat、Resin、Jboss）安全设置、性能优化&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;业务监控(API)流量分析(Piwik)&lt;/span&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;服务监控(API)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;安全监控(WAF)&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;配置管理：SaltStack&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 过载保护-服务降级&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 灰度发布-openresty&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 项目管理-Readmine&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 代码仓库-gitlab&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 持续集成-Jenkins&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 持续审查-SonarQube&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;镜像市场&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;应用服务层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运行环境（PHP Python Java C&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; C++）、性能优化、缓存（OPCache、LocalCache）、Session存储、代码部署&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;2&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;各种SAAS服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;100&quot; height=&quot;80&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;业务层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;102&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;业务实现&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;API网关、302调度、业务模块化（电商例：用户、商品、购物车、结算中心、价格等服务）、微服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;服务层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;SOA框架（Dubbo）、微服务框架（Spring Cloud）、协议（RPC、RESTful）、框架安全、应用性能监控&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;分布式应用服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;100&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;分布式层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;102&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;消息队列&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;ActiveMQ（成熟）、RabbitMQ（成熟、案例多）、RocketMQ（业务应用）、Kafka（日志传输）、ZeroMQ（快）&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;消息队列服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;10&quot; width=&quot;81&quot; height=&quot;402&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;存储层&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;100&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;文件存储&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;单机存储&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;块存储 - 机械硬盘、SSD、文件系统（ext4、xfs）、LVM、tmpfs&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;系统监控&lt;/span&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;软件自带监控&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;配置管理&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;云硬盘&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 对象存储&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;单机存储扩展&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;文件分发（多级分发）、文件同步（rsync、inotify）、DRBD、DAS（块存储）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;共享存储&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;文件存储 - NAS[NFS（Unix/Linux）]、FTP、SAN、iSCSI&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;分布式存储&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;对象存储 - GlusterFS、MooseFS、Ceph、FastDFS（非对象存储）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;100&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;DAL&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;102&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;数据访问层&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;应用层分片、淘宝TDDL、开源：360（Atlas）、阿里（Cobar）、MyCat、MySQL-Proxy、根据业务开发&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;数据库服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;100&quot; height=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;数据存储&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;102&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;分布式缓存&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Memcached、Redis（客户端分片、Redis Cluster、Twemproxy、Codis）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;数据库监控&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;数据库运维平台&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;云数据库-RDS&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Mongodb、Redis&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Memcached&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; OceanBase&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;NoSQL&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Redis、LevelDB（SSDB）、CouchDB、Mongodb、Couchbase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 、Cassandra、TiDB（支持MySQL协议）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;时间序列&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;RRDTool、Graphite&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Whisper、OpenTSDB、InfluxDB、KairosDB、ElasticSearch&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;RDBMS&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;MySQL（PXC集群、MHA）、Oracle（DG、OGG、RAC）、PostgreSQL、SqlServer、SQLite、DB2&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;102&quot; height=&quot;42&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;大数据&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Hadoop生态圈（HDFS、Hive、Hbase、Zookeeper、Pig、Spark、Impala、Kudu）、Mahout智能推荐&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;服务监控&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Ambari、CM&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;大数据服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;81&quot; height=&quot;162&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;基础服务层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;业务决策&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;灰度发布、服务降级、异地灾备、数据分析平台、智能扩容决策树（需要各层支持）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;监控工具：&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Zabbix&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Nagios&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Cacti&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Open-Falcon&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Sensu&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;自动化工具&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; （Puppet&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Chef&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; SaltStack&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Ansible）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;4&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;日志服务&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 操作审计&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 资源编排&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 运维监控服务&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 持续交付系统&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维相关&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;项目管理（Redmine、Jira、知识库、Bugzilla、CodeReview）、工单系统、运维操作平台、监控平台&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;应用相关&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;持续集成、日志收集平台（ELKStack）、自动化部署平台、Job管理（调度）平台、安全扫描平台&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;系统相关&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;LDAP、内部DNS、DHCP、Mail、SMS、Gitlab、Yum仓库、操作审计（xenapp）、堡垒机&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;81&quot; height=&quot;120&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;容器层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;容器编排&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Mesos（Marathon、Chronos）、Kubernetes（SKYDNS）、Docker&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Swarm、CoreOS（fleet）、OpenStack（Magnum）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Docker Stats&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; cAdvisor&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; DataDog&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Zabbix&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;Docker&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Swarm&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Mesos&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Kubernetes&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;容器服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;容器和系统&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;容器：LXC、LXD、Docker、rkt、系统：CoreOS、Atomic、RancherOS&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;网络和存储&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;网络：Calico、Flanel、Weave Net 存储：Ceph 镜像管理：Docker Registry、Harbor&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;81&quot; height=&quot;200&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;操作系统层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;CPU&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;CPU运行级别、使用率、上下文切换、运行队列、进程调度、系统调用、CPU管理（进程管理、taskset、intel VT-X）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;mpstat、strace&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;5&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;虚拟化&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;8&quot; width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;公有云&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 弹性计算产品&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;内存&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;虚拟内存、SWAP换入换出、内存寻址、内存管理（Buffer Cache、HugePages、ksmd、EPT）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;vmstat、free&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;I/O（磁盘）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;缺页中断、IOPS（顺序IO、随机IO）、IO管理（IO调度算法、virtio）、VFS&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;iostat、iotop&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;I/O（网络）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;TCP/IP（三次握手、四次挥手、状态转换、TCP队列）、IO模型、Bonding、Bridge、网络管理（iftop、tcpdump）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;iftop&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;内核/Shell&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;内核定制、内存参数优化、脚本编程（AWK、Sed、Shell、Python、PHP、Perl、Ruby、Lua）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;系统监控&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;3&quot; width=&quot;81&quot; height=&quot;122&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;基础设施层&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;IAAS(基础设施即服务)&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;公有云、私有云（OpenStack/cloudstack+KVM/XEN、oVirt）、混合云&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;服务监控&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;配置管理&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;42&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;硬件管理&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;硬件选型、配件更换、资产录入、系统安装（Cobbler）、标签化、Raid构建、远程控制（KVM、iDrac、ILO、IMM）&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;巡检、IPMI&lt;/span&gt;&lt;/td&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;IPMI、CMDB&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;IDC托管&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;需求分析、IDC选型、网络测试、谈价格、签合同、设备采购（原厂vs渠道）、机柜和机位规划&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td rowspan=&quot;2&quot; width=&quot;81&quot; height=&quot;80&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维产品化&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;基于DevOps产品思路&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;项目管理（类似Jira）、Bug管理、代码托管（类似Gitlab）、持续交付（类似Jenkins的构建、测试、部署）&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;监控平台、看板&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;软件定义数据中心&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;DevOps产品&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;自动化运维产品思路&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;818&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;CMDB、ITSM管理系统（事件管理、问题管理、故障管理、工单系统）、作业平台、堡垒机、APM、私有云平台&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;146&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;监控平台&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;153&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;CI/CD系统&lt;/span&gt;&lt;/td&gt;
&lt;td width=&quot;131&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维管理产品&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td width=&quot;81&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维服务化&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; width=&quot;202&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;OAAS&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;4&quot; width=&quot;1248&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;OAAS：Operations as a&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Service,运维咨询、运维托管、技术培训、应急处理、产品即服务、DevOps专家服务&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;3&quot; width=&quot;283&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;测试和开发相关&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;4&quot; width=&quot;1248&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维协助：性能测试（TCPCopy、日志转换）、单机监控（nmon）、环境规划（开发、测试、预生产、生产）、CI（持续集成）、自动化部署&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;3&quot; width=&quot;283&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维管理体系&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;4&quot; width=&quot;1248&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维管理必会：ITSM、ITIL&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; V3、IT Service CMM、Six Sigma、DevOps&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; Master、项目管理（PMBok）、架构层面（知识体系、运维方案、容量规划、灾备规划、服务降级）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;3&quot; width=&quot;283&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维发展趋势（个人理解）&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;4&quot; width=&quot;1248&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;打杂（小公司啥都干）-&amp;gt;分层（应用运维、系统运维、基础运维、运维开发等）-&amp;gt;场景化（分业务）-&amp;gt;自动化（最终大家的目标都是自动化）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;3&quot; width=&quot;283&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;运维自动化发展趋势（个人理解）&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;4&quot; width=&quot;1248&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;标准化（文档化、流程化）-&amp;gt;工具化（流程固化为工具）-&amp;gt;Web化（平台化）-&amp;gt;服务化（API化）-&amp;gt;智能化（自动化）-&amp;gt;产品化（服务化，云服务、运维创业）&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan=&quot;3&quot; width=&quot;283&quot; height=&quot;40&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;备注：&lt;/span&gt;&lt;/td&gt;
&lt;td colspan=&quot;4&quot; width=&quot;1248&quot;&gt;&lt;span style=&quot;font-size: 10pt;&quot;&gt;1.本表格只体现和运维相关的内容；2.表格没有严格意义上的层级关系；3.持续更新中，由于每个层次内容多，只例举比较出名（重要/开源）的关键词；&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: 10pt;&quot;&gt; 4.运维人员要给自己划好知识边界！（横向|纵向）5.转载请注明来自-运维社区https://www.unixhot.com/page/ops&lt;/span&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/20/%E8%BF%90%E7%BB%B4%E7%9F%A5%E8%AF%86%E4%BD%93%E7%B3%BB</link>
                <guid>https://evildracula.github.io/tech/2018/04/20/运维知识体系</guid>
                <pubDate>Fri, 20 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Github pages和mixpanel 统计</title>
                <description>
&lt;h3 id=&quot;简介&quot;&gt;简介&lt;/h3&gt;
&lt;p&gt;Jekyll 提供了功能强大的博客功能，但是还是缺乏用户统计的功能。缺的这一块当前github io Pages&lt;br /&gt;
考虑使用麻雀虽小五脏俱全的MixPanel。Jekyll 本身带有分析统计的框架，需要客制化代码后才能正常运作。&lt;/p&gt;
&lt;h3 id=&quot;git-hub-配置&quot;&gt;Git Hub 配置&lt;/h3&gt;
&lt;h4 id=&quot;_configxml-配置token-变量&quot;&gt;_config.xml 配置Token 变量&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;analytics :
    provider : mixpanel # 设置provider 为 mixpanel
    gauges : 
        site_id : &apos;SITE ID&apos;
    google : 
        tracking_id : &apos;UA-123-12&apos;
    getclicky : 
      site_id : 
    mixpanel : 
        token : &apos;Mixpanel Token&apos; # 配置Token
    piwik : 
        baseURL : &apos;myserver.tld/piwik&apos; # Piwik installation address (without protocol)
        idsite : &apos;1&apos;                   # the id of the site on Piwik

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;修改analytics-providersmixpanel&quot;&gt;修改analytics-providers/mixpanel&lt;/h4&gt;
&lt;p&gt;&lt;strong&gt;路径&lt;/strong&gt;&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;_includes/JB/analytics-providers/mixpanel&lt;br /&gt;
&lt;strong&gt;内容&lt;/strong&gt;&lt;/p&gt;
  &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;script type=&quot;text/javascript&quot;&amp;gt;
(function(e,a){if(!a.__SV){var b=window;try{var c,l,i,j=b.location,g=j.hash;c=function(a,b){return(l=a.match(RegExp(b+&quot;=([^&amp;amp;]*)&quot;)))?l[1]:null};g&amp;amp;&amp;amp;c(g,&quot;state&quot;)&amp;amp;&amp;amp;(i=JSON.parse(decodeURIComponent(c(g,&quot;state&quot;))),&quot;mpeditor&quot;===i.action&amp;amp;&amp;amp;(b.sessionStorage.setItem(&quot;_mpcehash&quot;,g),history.replaceState(i.desiredHash||&quot;&quot;,e.title,j.pathname+j.search)))}catch(m){}var k,h;window.mixpanel=a;a._i=[];a.init=function(b,c,f){function e(b,a){var c=a.split(&quot;.&quot;);2==c.length&amp;amp;&amp;amp;(b=b[c[0]],a=c[1]);b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments, 0)))}}var d=a;&quot;undefined&quot;!==typeof f?d=a[f]=[]:f=&quot;mixpanel&quot;;d.people=d.people||[];d.toString=function(b){var a=&quot;mixpanel&quot;;&quot;mixpanel&quot;!==f&amp;amp;&amp;amp;(a+=&quot;.&quot;+f);b||(a+=&quot; (stub)&quot;);return a};d.people.toString=function(){return d.toString(1)+&quot;.people (stub)&quot;};k=&quot;disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user&quot;.split(&quot; &quot;); for(h=0;h&amp;lt;k.length;h++)e(d,k[h]);a._i.push([b,c,f])};a.__SV=1.2;b=e.createElement(&quot;script&quot;);b.type=&quot;text/javascript&quot;;b.async=!0;b.src=&quot;undefined&quot;!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:&quot;file:&quot;===e.location.protocol&amp;amp;&amp;amp;&quot;//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js&quot;.match(/^\/\//)?&quot;https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js&quot;:&quot;//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js&quot;;c=e.getElementsByTagName(&quot;script&quot;)[0];c.parentNode.insertBefore(b,c)}})(document,window.mixpanel||[]); mixpanel.init(&quot;\\{\\{ site.JB.analytics.mixpanel.token\\}\\}&quot;);
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/div&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;修改-posts-的内容&quot;&gt;修改 posts 的内容&lt;/h4&gt;
&lt;blockquote&gt;
  &lt;p&gt;_includes/themes/bootstrap-3/post.html&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;\\{\\% include JB/analytics \\%\\}
&amp;lt;script&amp;gt;
 mixpanel.track(&quot;View posts&quot;);
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;mixpanel-统计截图&quot;&gt;Mixpanel 统计截图&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;/resources/images/2018/4/sc-mixpanel-1.png&quot; alt=&quot;Mix Panel 统计&quot; height=&quot;100%&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/16/Github-Pages%E5%92%8CMixpanel-%E7%BB%9F%E8%AE%A1</link>
                <guid>https://evildracula.github.io/tech/2018/04/16/Github Pages和Mixpanel 统计</guid>
                <pubDate>Mon, 16 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>最大回文算法</title>
                <description>
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;table class=&quot;rouge-table&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=&quot;gutter gl&quot;&gt;&lt;pre class=&quot;lineno&quot;&gt;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
&lt;/pre&gt;&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;

	&lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sa&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Solution&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

	&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;left&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

	&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;longestPalindrome&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toCharArray&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;substring&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;left&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// ()-&amp;gt;rr || []-&amp;gt;ll&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// [ll,rr]-&amp;gt;(a)aa    rr=index&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// [a](a)a           rr=index+1 传递&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// [a]a(a)           rr=index+2&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++;&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// ll-1 | rr+1，下一个匹配&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;// [ll-1][a]a(a)(rr+1) rr=index+2&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;length&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ss&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++;&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;--;&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;max&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 计算长度&lt;/span&gt;
			&lt;span class=&quot;n&quot;&gt;left&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ll&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// 记录开始位置&lt;/span&gt;
		&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
		&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;temp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

	&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
		&lt;span class=&quot;nc&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;out&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sa&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;longestPalindrome&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;babad&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
	&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
                <link>https://evildracula.github.io/tech/2018/04/12/%E6%9C%80%E5%A4%A7%E5%9B%9E%E6%96%87%E7%AE%97%E6%B3%95</link>
                <guid>https://evildracula.github.io/tech/2018/04/12/最大回文算法</guid>
                <pubDate>Thu, 12 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>字符串查找以及edi报文</title>
                <description>
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;package ext.spring.smooks;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.milyn.Smooks;
import org.milyn.container.ExecutionContext;
import org.milyn.payload.StringResult;
import org.milyn.payload.StringSource;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class SmookEDITest {

	public static String parseStreamToString(InputStream in) {
		StringBuffer sb = new StringBuffer();
		if (in != null) {
			byte[] b = new byte[128];
			int c = -1;
			try {
				while ((c=in.read(b)) != -1) {
					for (int i = 0;i &amp;lt; c;i++) {
						sb.append((char)b[i]);
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}

		}

		return sb.toString();
	}


	public static void testEdi2Smook(String cfgInStr, String orderInStr) {
		InputStream cfgIn = null;
		InputStream orderIn=null;
		try {
			cfgIn = new FileInputStream(cfgInStr);
			orderIn = new FileInputStream(orderInStr);
			String msgIn = SmookEDITest.parseStreamToString(orderIn);
			System.out.println(msgIn);
			Smooks smooks1 = new Smooks(cfgIn);

			/*
			 * Create a Smook Validator
			 */
			// SmooksResourceConfiguration pojoConf = new SmooksResourceConfiguration(&quot;&quot;, Profile.DEFAULT_PROFILE, &quot;&quot;);

			ExecutionContext executionContext = smooks1.createExecutionContext();
			StringResult stringRs = new StringResult();
			smooks1.filterSource(executionContext, newStringSource(msgIn), stringRs);




			System.out.println(stringRs.getResult());

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cfgIn != null) {
				try {
					cfgIn.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (orderIn != null) {
				try {
					orderIn.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}   

	}

	private static XPathExpression EXP_TRANSACTION_TABLE= null;
	private static XPathExpression EXP_NODE_DATA_ELEMENT = null;

	static {
		XPathFactory factory = XPathFactory.newInstance();
		XPath xpath = factory.newXPath();

		try {
			EXP_TRANSACTION_TABLE = xpath.compile(&quot;/transactionSet/table&quot;);
			EXP_NODE_DATA_ELEMENT = xpath.compile(&quot;dataElement&quot;);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}


	public Document transDoc(InputStream in) {
		Document doc = null;
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		dbf.setNamespaceAware(true);
		dbf.setIgnoringElementContentWhitespace(true);

		try {
			DocumentBuilder db = dbf.newDocumentBuilder();
			doc = db.parse(in);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return doc;
	}

	public void TranslateOBOE2Smook(String oboeIn) {
		File oboeCfgFile = new File(oboeIn);

		String tabs=&quot;\t&quot;;
		InputStream in = null;
		try {

			System.out.println(this.appendix);
			in = new FileInputStream(oboeCfgFile);
			Document doc = transDoc(in);
			NodeList topNodes = (NodeList) EXP_TRANSACTION_TABLE.evaluate(doc, XPathConstants.NODESET);
			int topLen = topNodes.getLength();
			System.out.println(tabs+&quot;&amp;lt;medi:segmentGroup maxOccurs=\&quot;1\&quot; xmltag=\&quot;&quot; + &quot;TransactionSet&quot; + &quot;\&quot;&amp;gt;&quot;);
			for (int i=0;i&amp;lt;topLen;i++) {
				//transactionSet
				Node tranNode = topNodes.item(i);
				// String tblSecName = tranNode.getAttributes().getNamedItem(&quot;section&quot;).getNodeValue();

				// Smook Group for 
				// Do loop
				NodeList segNodes = tranNode.getChildNodes();
				for (int j=0;j&amp;lt;segNodes.getLength();j++) {
					doLoop(segNodes.item(j),tabs+&quot;\t&quot;, false, false);
				}
			}
			System.out.println(tabs+&quot;&amp;lt;/medi:segmentGroup&amp;gt;&quot;);
			System.out.println(this.suffix);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}


	}


	public static String mapAttrOboe2Smook(Node node, String oboeAttr, String smookAttr) {
		StringBuffer preSb = new StringBuffer();
		Node segCodeAttr = node.getAttributes().getNamedItem(oboeAttr);
		if (segCodeAttr != null) {
			preSb.append(&quot; &quot; + smookAttr + &quot;=\&quot;&quot;).append(segCodeAttr.getNodeValue()).append(&quot;\&quot;&quot;);
		}
		return preSb.toString();
	}

	public static void doLoop(Node node, String tabs, booleanisTop, boolean isPreLoop) {
		String nodeName = node.getNodeName();
		if (&quot;segment&quot;.equals(nodeName)) {
			String occurs = node.getAttributes().getNamedItem(&quot;occurs&quot;).getNodeValue();
			String segGroupOrSeg = &quot;&quot;;

			StringBuffer preSb = new StringBuffer();


			String required = node.getAttributes().getNamedItem(&quot;required&quot;).getNodeValue();
			String toDup = &quot;&quot;;
			if(&quot;M&quot;.equals(required)) {
				preSb.append(&quot; minOccurs=\&quot;1\&quot;&quot;);
				toDup = &quot; minOccurs=\&quot;1\&quot;&quot;;
			} else if (&quot;O&quot;.equals(required)) {
				preSb.append(&quot; minOccurs=\&quot;0\&quot;&quot;);
				toDup = &quot; minOccurs=\&quot;0\&quot;&quot;;
			} else {
				System.out.println(required+&quot;&amp;lt;!------------------------------------------------------------------------&amp;gt;&quot;);
			}

			if (isPreLoop) {
				segGroupOrSeg = &quot;segment&quot;;
				preSb.append(mapAttrOboe2Smook(node, &quot;id&quot;, &quot;segcode&quot;)).append(mapAttrOboe2Smook(node, &quot;xmlTag&quot;, &quot;xmltag&quot;));
				preSb.append(&quot; truncatable=\&quot;true\&quot;&quot;);
			} else {
				if (!(occurs == null || &quot;&quot;.equals(occurs))) {
					if (&quot;1&quot;.equals(occurs)) {
						segGroupOrSeg = &quot;segment&quot;;
						preSb.append(mapAttrOboe2Smook(node, &quot;id&quot;, &quot;segcode&quot;)).append(mapAttrOboe2Smook(node, &quot;xmlTag&quot;, &quot;xmltag&quot;));
						preSb.append(&quot; truncatable=\&quot;true\&quot;&quot;);
					} else {
						segGroupOrSeg = &quot;segmentGroup&quot;;
						preSb.append(mapAttrOboe2Smook(node, &quot;xmlTag&quot;, &quot;xmltag&quot;)).append(mapAttrOboe2Smook(node, &quot;occurs&quot;, &quot;maxOccurs&quot;));
					}
				} else {
					segGroupOrSeg = &quot;segment&quot;;
					preSb.append(mapAttrOboe2Smook(node, &quot;id&quot;, &quot;segcode&quot;)).append(mapAttrOboe2Smook(node, &quot;xmlTag&quot;, &quot;xmltag&quot;));
					preSb.append(&quot; truncatable=\&quot;true\&quot;&quot;);
				}
			}
			System.out.println(tabs+&quot;&amp;lt;medi:&quot; + segGroupOrSeg + preSb.toString() + &quot;&amp;gt;&quot;);

			NodeList dataEleNodes;
			try {
				dataEleNodes = (NodeList) EXP_NODE_DATA_ELEMENT.evaluate(node, XPathConstants.NODESET);
				if (!(dataEleNodes == null || dataEleNodes.getLength() &amp;lt; 1)) {

					if (&quot;segmentGroup&quot;.equals(segGroupOrSeg)) {
						String tt = tabs+&quot;&amp;lt;medi:segment &quot; + mapAttrOboe2Smook(node, &quot;xmlTag&quot;, &quot;xmltag&quot;) + mapAttrOboe2Smook(node, &quot;id&quot;, &quot;segcode&quot;) + toDup + &quot; truncatable=\&quot;true\&quot;&quot; + &quot;&amp;gt;&quot;;
						System.out.println(tt);
					}
					for (int i=0;i&amp;lt;dataEleNodes.getLength();i++) {
						// process data elements
						Node dataEleNode = dataEleNodes.item(i);
						if (&quot;dataElement&quot;.equals(dataEleNode.getNodeName())) {
							System.out.println(tabs+&quot;\t&amp;lt;medi:field xmltag=\&quot;&quot; + dataEleNode.getAttributes().getNamedItem(&quot;xmlTag&quot;).getNodeValue() + &quot;\&quot;/&amp;gt;&quot;);
						}
					}
					if (&quot;segmentGroup&quot;.equals(segGroupOrSeg)) {
						System.out.println(tabs+&quot;&amp;lt;/medi:segment&amp;gt;&quot;);
					}
				}

			} catch (XPathExpressionException e) {
				e.printStackTrace();
			}

			System.out.println(tabs+&quot;&amp;lt;/medi:&quot; + segGroupOrSeg + &quot;&amp;gt;&quot;);
		} else if (&quot;loop&quot;.equals(nodeName)) {


			String occurs = node.getAttributes().getNamedItem(&quot;occurs&quot;).getNodeValue();
			String xmltag = node.getAttributes().getNamedItem(&quot;xmlTag&quot;).getNodeValue();


			String required = node.getAttributes().getNamedItem(&quot;required&quot;).getNodeValue();
			String toDup = &quot;&quot;;
			if(&quot;M&quot;.equals(required)) {
				toDup = &quot; minOccurs=\&quot;1\&quot;&quot;;
			} else if (&quot;O&quot;.equals(required)) {
				toDup = &quot; minOccurs=\&quot;0\&quot;&quot;;
			} else {
				System.out.println(required+&quot;&amp;lt;!------------------------------------------------------------------------&amp;gt;&quot;);
			}
			boolean isLoop = false;
			String tt =&quot;&quot;;
			if (isTop) {

			} else {
				tt = tabs+&quot;&amp;lt;medi:segmentGroup xmltag=\&quot;&quot; + xmltag + &quot;\&quot; maxOccurs=\&quot;&quot; + occurs + &quot;\&quot;&quot;+ toDup + &quot;&amp;gt;&quot;;
				isLoop=true;
				//tt = tabs+&quot;&amp;lt;medi:segment&quot; + mapAttrOboe2Smook(node, &quot;xmlTag&quot;, &quot;xmltag&quot;) + mapAttrOboe2Smook(node, &quot;id&quot;, &quot;segcode&quot;) + &quot; truncatable=\&quot;true\&quot;&quot; + &quot; maxOccurs=\&quot;&quot; + occurs + &quot;\&quot;&quot;+ toDup + &quot;&amp;gt;&quot;;
			}
			System.out.println(tt);
			NodeList childNodes = node.getChildNodes();
			for(int i=0;i&amp;lt;childNodes.getLength();i++) {
				doLoop(childNodes.item(i),tabs+&quot;\t&quot;, false, isLoop);

			}
			if (isTop) {

			} else {
				//System.out.println(tabs+&quot;&amp;lt;/medi:segment&amp;gt;&quot;);
				System.out.println(tabs+&quot;&amp;lt;/medi:segmentGroup&amp;gt;&quot;);
			}
		} else if (&quot;compositeDE&quot;.equals(nodeName)) {
			String occurs = node.getAttributes().getNamedItem(&quot;occurs&quot;).getNodeValue();
			String xmltag = node.getAttributes().getNamedItem(&quot;xmlTag&quot;).getNodeValue();
			String required = node.getAttributes().getNamedItem(&quot;required&quot;).getNodeValue();

			Integer minLength = Integer.valueOf(node.getAttributes().getNamedItem(&quot;minLength&quot;).getNodeValue());
			Integer maxLength = Integer.valueOf(node.getAttributes().getNamedItem(&quot;maxLength&quot;).getNodeValue());
			boolean isRequired = false;
			if(&quot;M&quot;.equals(required)) {
				isRequired = true;
			} else if (&quot;O&quot;.equals(required)) {
				isRequired = false;
			}
			if (isPreLoop) {
				System.out.println(tabs + &quot;&amp;lt;medi:field xmltag=\&quot;&quot; + xmltag + &quot;\&quot; required=\&quot;&quot; + isRequired + &quot;\&quot; minLength=\&quot;&quot; + minLength + &quot;\&quot; maxLength=\&quot;&quot; + maxLength + &quot;\&quot;/&amp;gt;&quot;);
			} else {
				System.out.println(tabs+&quot;&amp;lt;medi:component xmltag=\&quot;&quot; + xmltag+ &quot;\&quot; required=\&quot;&quot; + isRequired + &quot;\&quot; minLength=\&quot;&quot; + minLength + &quot;\&quot; maxLength=\&quot;&quot; + maxLength + &quot;\&quot;&amp;gt;&quot;);
				NodeList childNodes = node.getChildNodes();
				for(int i=0;i&amp;lt;childNodes.getLength();i++) {
					doLoop(childNodes.item(i),tabs+&quot;\t&quot;, false, true);
				}
			}
			System.out.println(&quot;&amp;lt;/medi:component&amp;gt;&quot;);
		} else {
			// do nothing

		}
	}

	private String appendix=&quot;&quot;;
	private String suffix=&quot;&quot;;

	public void readAppendix(String fileloc) {
		InputStream in = null;
		try {
			in = new FileInputStream(fileloc);
			this.appendix = parseStreamToString(in);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	public void readSuffix(String fileloc) {
		InputStream in = null;
		try {
			in = new FileInputStream(fileloc);
			this.suffix = parseStreamToString(in);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} finally {
			if (in != null) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}





	public static int findChar(int c, String pattern, int step) {
		int strLen = pattern.length();
		++step;
		if (step &amp;lt; strLen) {
			if (pattern.charAt(step) == c) {
			} else {
				step = -1;
			}
		}
		return step;
	}


	public static void tryToFindUnknown(String strSource, String defination, String pattern) {


		Map&amp;lt;String, Boolean&amp;gt; segments = checkUnknownSegmentsPattern(strSource, pattern);
		for (String keyPattern : segments.keySet()) {
			System.out.println(&quot;Key:\t&quot; + keyPattern + &quot;\t\t\t ?Exists:\t&quot; + findAsPattern(defination, &quot;\&quot;&quot; + keyPattern + &quot;\&quot;&quot;));
		}
	}


	public static Map&amp;lt;String, Boolean&amp;gt; checkUnknownSegmentsPattern(String strSource, String pattern) {
		// search segments in ediFile
		Map&amp;lt;String, Boolean&amp;gt; result = new HashMap&amp;lt;String, Boolean&amp;gt;();
		FileReader reader = null;
		BufferedReader br = null;
		try {
			reader = new FileReader(strSource);
			br = new BufferedReader(reader);
			Pattern p = Pattern.compile(pattern);
			int c = -1;
			StringBuffer sb = new StringBuffer();
			while ((c = br.read()) != -1) {
				sb.append((char) c);
			}
			Matcher m = p.matcher(sb.toString());
			while (m.find()) {
				result.put(m.group().substring(1, m.group().length()-1), false);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return result;
	}


	public static boolean findAsPattern(String strSource, String pattern) {
		// search segments in ediFile
		FileReader reader = null;
		BufferedReader br = null;
		boolean rs =false;
		try {
			reader = new FileReader(strSource);
			br = new BufferedReader(reader);

			int c = -1;
			int step = -1;
			int count = 0;
			int pos = -1;
			StringBuffer sb = new StringBuffer();
			while ((c = br.read()) != -1) {
				pos++;
				count++;
				sb.append((char) c);
				step = findChar(c, pattern, step);
				if (step == pattern.length()-1) {
					step = -1;
					String ss =sb.toString().substring(1);
					pos-=ss.length();
					br.mark(pos);
					count = 0;
					sb = new StringBuffer();
					rs = true;
					break;
				} else if (step == -1 ) {
					if( count &amp;gt; 1) {
						String ss =sb.toString().substring(1);
						pos-=ss.length();
						br.mark(pos);
						count = 0;
					} else if (count == 1) {

					}
					sb = new StringBuffer();
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return rs;
	}


	public static void main(String[] args) {
		String regex = &quot;~...?\\*&quot;;
		Pattern p =Pattern.compile(regex);
		String str = &quot;ISA*00* *00* *ZZ*DHIWAL *....IEA*1*000000000~&quot;;
		Matcher m = p.matcher(str);
		while(m.find()) {
			System.out.println(m.group());
		}
		String ediPath = SmookEDITest.class.getResource(&quot;order.edi&quot;).getPath();
		String defPath = SmookEDITest.class.getResource(&quot;edi-mapping-856-test.xml&quot;).getPath();
		tryToFindUnknown(ediPath, defPath, regex);
		SmookEDITest t = new SmookEDITest();
		t.readAppendix(SmookEDITest.class.getResource(&quot;appendix&quot;).getPath());
		t.readSuffix(SmookEDITest.class.getResource(&quot;suffix&quot;).getPath());
		t.TranslateOBOE2Smook(SmookEDITest.class.getResource(&quot;856.xml&quot;).getPath());
		testEdi2Smook(SmookEDITest.class.getResource(&quot;edi-smook-config.xml&quot;).getPath(), SmookEDITest.class.getResource(&quot;oboe_order.edi&quot;).getPath());

	}

}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/12/%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%9F%A5%E6%89%BE%E4%BB%A5%E5%8F%8AEDI%E6%8A%A5%E6%96%87</link>
                <guid>https://evildracula.github.io/tech/2018/04/12/字符串查找以及EDI报文</guid>
                <pubDate>Thu, 12 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>压力测试脚本</title>
                <description>
&lt;h2 id=&quot;main&quot;&gt;Main&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/usr/local/bin/perl

#TODO Cofig below will be in configure.xml
$PROP_LOC=shift @ARGV;#Read Argument

printf &quot;Stress Test Config file is:$PROP_LOC\n&quot;;
unless (open($fh, $PROP_LOC)) {#Open file handler
    die(&quot;Can&apos;t open $PROP_LOC&quot;);

};


%config = map /^\s*(\w+)\s*=\s*(.*)/, &amp;lt;$fh&amp;gt;;#Map Property File
($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=localtime(time());#Timestam Function

# variable settings
$TIME_OUT=$config{FileCopyTimeout};
$THREAD_COUNT = $config{ThreadCount};
$FILE_BATCH_SIZE=$config{FileMultiplier};
@TEST_DISTRIBUTORS=split(&quot;,&quot;,$config{TargetDistributorIDs});
@TEST_DIR=split(&quot;,&quot;,$config{TargetDirList});
$FILE_MESSAGE=$config{FileMessage};

$FILE_GEN_PATH=$config{GeneratePath};
#my $test_flag = validate_target(@TEST_DIR);
$GOOD_FILE = $config{GoodDataPath};
$TARGET_PER_HOUR=$config{TargetFilesPerHour};

# Calculate how many messasge to be sent within one thread
$MESSAGE_PER_THREAD=$TARGET_PER_HOUR/$THREAD_COUNT;

# Wating time for thread
$SLEEP_TIME=1/(3600*$MESSAGE_PER_THREAD);
# Indicate how many line of data in the sample good file
$FILE_LENGTH = $config{FileLength};
# Array of threads
my @WORKERS;

#while(my ($key,$val) =each %config) {
#};



# Initiate threads
for(my $i=0;$i&amp;lt;$THREAD_COUNT;$i++) {
    my $pid=fork();#Use fork
    unless($pid) {#Test PID created
        exec(&quot;perl stress_test_CXFTYPE_send_worker.pl &apos;$PROP_LOC&apos; $i”);#Must use exec
        exit;#Should exit
    }
}


# wait all child processs finished.
while(waitpid(-1, WUNTRACED)&amp;gt;0){sleep 1;};#Test if all pid is done, then exit

printf &quot;Exit Stress Test.\n&quot;;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;worker&quot;&gt;Worker&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/usr/local/bin/perl

#TODO Cofig below will be in configure.xml

$PROP_LOC=shift @ARGV;
$Thread_Num=shift @ARGV;
printf &quot;Worker===&amp;gt;Stress Test Config file is:$PROP_LOC\n&quot;;
unless (open($fh, $PROP_LOC)) {
        die(&quot;Can&apos;t open $PROP_LOC&quot;);

};


%config = map /^\s*(\w+)\s*=\s*(.*)/, &amp;lt;$fh&amp;gt;;


#%config=(
#   FileCopyTimeout     =&amp;gt;@STRESS_CXFTYPE_FILE_COPY_TIME_OUT@,
#   FileExtension       =&amp;gt;&quot;@STRESS_CXFTYPE_FILE_EXTENSION@&quot;,
#   FileMultiplier      =&amp;gt;@STRESS_CXFTYPE_FILE_MULTIP@,
#   FileLength          =&amp;gt;@STRESS_CXFTYPE_FILE_LEN@,
#   FileMessage         =&amp;gt;&quot;@STRESS_CXFTYPE_FILE_MSG@&quot;,
#   GoodDataPath        =&amp;gt;&quot;@STRESS_CXFTYPE_GOOD_DATA_PATH@&quot;,
#   GeneratePath        =&amp;gt;&quot;@STRESS_CXFTYPE_GEN_PATH@&quot;,
#   TargetDirList       =&amp;gt;&quot;@STRESS_CXFTYPE_TARGET_DIR_LIST@&quot;,
#   #TargetDirList      =&amp;gt;&quot;/ftpusers/web/delta/inbound/,/ftpusers/web/custname1/inbound/,/ftpusers/web/custname2/inbound/,/ftpusers/web/custname3/inbound/&quot;,
#   TargetDistributorIDs=&amp;gt;&quot;@STRESS_CXFTYPE_TARGET_DISTRIBUTOR_IDS@&quot;,
#   TargetFilesPerHour  =&amp;gt;@STRESS_CXFTYPE_TARGET_FILES_PERHOUR@,
#   TargetHost          =&amp;gt;&quot;@STRESS_CXFTYPE_TARGET_HOST@&quot;,
#   Username            =&amp;gt;&quot;@STRESS_CXFTYPE_USR@&quot;,
#   TargetPort          =&amp;gt;@STRESS_CXFTYPE_PORT@,
#   ThreadCount         =&amp;gt;@STRESS_CXFTYPE_THREAD_COUNT@
#);


($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=localtime(time());

# variable settings
$TIME_OUT=$config{FileCopyTimeout};
$THREAD_COUNT = $config{ThreadCount};
$FILE_BATCH_SIZE=$config{FileMultiplier};
@TEST_DISTRIBUTORS=split(&quot;,&quot;,$config{TargetDistributorIDs});
@TEST_DIR=split(&quot;,&quot;,$config{TargetDirList});
$FILE_MESSAGE=$config{FileMessage};

$FILE_GEN_PATH=$config{GeneratePath};
#my $test_flag = validate_target(@TEST_DIR);
$GOOD_FILE = $config{GoodDataPath};
$TARGET_PER_HOUR=$config{TargetFilesPerHour};

# Calculate how many messasge to be sent within one thread
$MESSAGE_PER_THREAD=$TARGET_PER_HOUR/$THREAD_COUNT;

# Wating time for thread
$SLEEP_TIME=1/(3600*$MESSAGE_PER_THREAD);
# Indicate how many line of data in the sample good file
$FILE_LENGTH = $config{FileLength};
# Array of threads

#SCP command function
$SCP_CMD=&quot;scp -o ConnectTimeout=$TIME_OUT&quot;;
$SSH_CMD=&quot;ssh -o NumberOfPasswordPrompts=0  -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet &quot;;

$CP_CMD=&quot;cp &quot;;
sub sendFile($$) {
    my $src = $_[0];
    my $dest= $_[1];
    my $full_cmd = &quot;$SCP_CMD $src $config{Username}\@$config{TargetHost}:$dest&quot;;
    print $full_cmd;
    system($full_cmd);
}


sub copyFile($$) {# $$ Means String String
    my $src=$_[0];
    my $dest= $_[1];
    my $full_cmd = $CP_CMD.&quot;$src $dest&quot;;
    print $full_cmd;
    system($full_cmd);
}

sub validate_target(@@) {
    my $full_cmd = &quot;$SSH_CMD $config{Username}\@config{TargetHost}&quot;;

}

sub myRand ($){
    my $num_len = $_[0];
    my $rnd_num=int(rand(10**$num_len - 1));
    if ($rnd_num&amp;lt;0) {
        $rnd_num++;
    }
    my $num_str=&quot;&quot;.$rnd_num;
    my $zero_append_num = $num_len - length($num_str);
    if ($zero_append_num &amp;gt; 0) {
        for (my $i=0;$i&amp;lt;$zero_append_num;$i++) {
            $num_str=&quot;0&quot;.$num_str;
        }
    }
    return $num_str;

}





# sender threads
sub work_func_sender{
    my $distributor_count=@TEST_DISTRIBUTORS;
    my $distri_idx=0;
    my $message_counter=0;
    printf &quot;Message per Thread =&amp;gt; $MESSAGE_PER_THREAD\n&quot;;
    while($message_counter&amp;lt;$MESSAGE_PER_THREAD) {
        $cur_distri_id = @TEST_DISTRIBUTORS[$distri_idx];
        $cur_dir = @TEST_DIR[$distri_idx];
        # CUST_Tracking_310_20150608_183000_123456.wff
        my @new_filename_arr;

        # Calc file(message) to send
        my $delta_message=$MESSAGE_PER_THREAD-$message_counter;
        if($delta_message &amp;gt;= $FILE_BATCH_SIZE) {
            $delta_message=$FILE_BATCH_SIZE;
        }
        printf (&quot;File Multi $delta_message\n&quot;);
        for (my $i=0;$i&amp;lt;$delta_message;$i++) {
            print &quot;Thread $Thread_Num i is $i\n&quot;;
            my $new_filename=$FILE_MESSAGE.&quot;_&quot;.$cur_distri_id.&quot;_&quot;.&quot;$year$mon$day_$hour$min$sec&quot;.&quot;_&quot;.myRand(6).&quot;.&quot;.$config{FileExtension};
            my $src_file=$FILE_GEN_PATH.$new_filename;
            copyFile($GOOD_FILE,$src_file);
            # push to new_filename_arr
            push(@new_filename_arr,$src_file);
        }
        # Begin write Data

        # End Write Data
        printf &quot;Gernerate path: $src_file&quot;;
        my $dest_file=$cur_dir;
        # execute send
        $src_file =join(&apos; &apos;, @new_filename_arr);
        sendFile($src_file, $dest_file);
        $message_counter+=$delta_message;
        $distri_idx++;
        $distri_idx = int($distri_idx % $distributor_count);
        # Sleep time
        sleep($SLEEP_TIME);
    }
}


work_func_sender();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/12/%E5%8E%8B%E5%8A%9B%E6%B5%8B%E8%AF%95%E8%84%9A%E6%9C%AC</link>
                <guid>https://evildracula.github.io/tech/2018/04/12/压力测试脚本</guid>
                <pubDate>Thu, 12 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Zookeeper索引</title>
                <description>
&lt;h2 id=&quot;zookeeper&quot;&gt;ZooKeeper&lt;/h2&gt;
&lt;h3 id=&quot;启动&quot;&gt;启动&lt;/h3&gt;
&lt;h4 id=&quot;配置文件&quot;&gt;配置文件&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/var/applications/zk_test/data1
# the port at which the clients will connect
clientPort=2181
server.1=127.0.0.1:2221:3222
server.2=127.0.0.1:2222:3222
server.3=127.0.0.1:2223:3223
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to &quot;0&quot; to disable auto purge feature
#autopurge.purgeInterval=1

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h4 id=&quot;启动命令&quot;&gt;启动命令&lt;/h4&gt;
&lt;blockquote&gt;
  &lt;p&gt;bin/zkServer.sh start conf/zoo1.cfg&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;连接客户端&quot;&gt;连接客户端&lt;/h4&gt;
&lt;blockquote&gt;
  &lt;p&gt;bin/zkCli.sh -server 127.0.0.1:2181&lt;br /&gt;
#如果遇到无法连接，尝试修改iptables&lt;br /&gt;
-A INPUT -m state –state NEW -m tcp -p tcp –dport 2181 -j ACCEPT&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;administration&quot;&gt;Administration&lt;/h3&gt;
&lt;h4 id=&quot;cross-machine&quot;&gt;Cross Machine&lt;/h4&gt;
&lt;p&gt;为了部署一个 能接受 F 台失败机器的集成环境，总共需要总共2*F+1 台机器，所以通常机器数量是 Odd Number&lt;/p&gt;

&lt;h4 id=&quot;maintainance&quot;&gt;Maintainance&lt;/h4&gt;
&lt;h5 id=&quot;ongoing-data-cleanup&quot;&gt;Ongoing Data Cleanup&lt;/h5&gt;
&lt;ul&gt;
  &lt;li&gt;ZooKeeper 不会移除old snapshots 和 log files.&lt;br /&gt;
&lt;a href=&quot;http://zookeeper.apache.org/doc/r3.4.11/api/org/apache/zookeeper/server/PurgeTxnLog.html&quot;&gt;PurgeTxnLog&lt;/a&gt;实现了基本的 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Retention Policy&lt;/code&gt;
    &lt;blockquote&gt;
      &lt;p&gt;java -cp zookeeper.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4j12-1.6.1.jar:lib/log4j-1.2.15.jar:conf org.apache.zookeeper.server.PurgeTxnLog &lt;dataDir&gt; &lt;snapDir&gt; -n &lt;count&gt;&lt;/count&gt;&lt;/snapDir&gt;&lt;/dataDir&gt;&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;3.4.0 后 使用 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;autopurge.snapRetainCount&lt;/code&gt; 和 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;autopurge.purgeInterval&lt;/code&gt; 参数实现自动清理, &lt;a href=&quot;http://zookeeper.apache.org/doc/r3.4.11/zookeeperAdmin.html#sc_advancedConfiguration&quot;&gt;Advance Configuration&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id=&quot;monitoring&quot;&gt;Monitoring&lt;/h5&gt;
&lt;ul&gt;
  &lt;li&gt;4word Command
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;echo `srst|conf|4word_cmd` |nc localhost 2181  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;JMX&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;避免的坑&quot;&gt;避免的坑&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;inconsistent lists of servers&lt;/li&gt;
  &lt;li&gt;incorrect placement of transaction log&lt;/li&gt;
  &lt;li&gt;incorrect Java heap size
    &lt;ul&gt;
      &lt;li&gt;ZooKeeper jvm设置成 no swap to disk&lt;/li&gt;
      &lt;li&gt;4G 的内存，不要设置 4G 及以上的 jvm max heap size&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;publicly accessible deployment
    &lt;ul&gt;
      &lt;li&gt;部署在防火墙内&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;可恢复的重发机制&lt;/li&gt;
  &lt;li&gt;tckTime 的设置&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;zookeeper-waters&quot;&gt;ZooKeeper Waters&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getData()&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getChildren()&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exists()&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;一次性的 watchEvent Trigger
    &lt;blockquote&gt;
      &lt;p&gt;举例子：/zone1 一次修改后，客户端得到watchEvent Trigger。&lt;br /&gt;
/zone1 再一次修改后，除非客户端完成read（这会设置一个watcher）&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;客户端看到的信息是order 保证的&lt;/li&gt;
  &lt;li&gt;Events
    &lt;blockquote&gt;
      &lt;p&gt;Created, Deleted, Changed, Child&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;Watches 机制保证
    &lt;ul&gt;
      &lt;li&gt;ZooKeeper Client Lib 保证一切顺序派发&lt;/li&gt;
      &lt;li&gt;node 的 watch event 于真正获取该 node 值之前发生&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;zookeeper-acl-控制&quot;&gt;ZooKeeper ACL 控制&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;Pluggable ZooKeeper authentication
    &lt;ul&gt;
      &lt;li&gt;authProvider.1=com.f.MyAuth
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public interface AuthenticationProvider {
String getScheme();
KeeperException.Code handleAuthentication(ServerCnxn cnxn, byte authData[]);
boolean isValid(String id);
boolean matches(String id, String aclExpr);
boolean isAuthenticated();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;一致性保证&quot;&gt;一致性保证&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Sequential Consistency&lt;br /&gt;
Updates from a client will be applied in the order that they were sent.&lt;/li&gt;
  &lt;li&gt;Atomicity&lt;br /&gt;
Updates either succeed or fail – there are no partial results.&lt;/li&gt;
  &lt;li&gt;Single System Image&lt;br /&gt;
A client will see the same view of the service regardless of the server that it connects to.&lt;/li&gt;
  &lt;li&gt;Reliability
    &lt;ol&gt;
      &lt;li&gt;If a client gets a successful return code, the update will have been applied. On some failures (communication errors, timeouts, etc) the client will not know if the update has applied or not. We take steps to minimize the failures, but the guarantee is only present with successful return codes. (This is called the monotonicity condition in Paxos.)&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
  &lt;li&gt;Any updates that are seen by the client, through a read request or successful update, will never be rolled back when recovering from server failures.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;Timeliness&lt;br /&gt;
The clients view of the system is guaranteed to be up-to-date within a certain time bound (on the order of tens of seconds). Either system changes will be seen by a client within this bound, or the client will detect a service outage.&lt;/li&gt;
&lt;/ul&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/12/ZooKeeper%E7%B4%A2%E5%BC%95</link>
                <guid>https://evildracula.github.io/tech/2018/04/12/ZooKeeper索引</guid>
                <pubDate>Thu, 12 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Mcsnode chart</title>
                <description>
&lt;h4 id=&quot;时序解析&quot;&gt;时序解析&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;线程顺序&lt;/li&gt;
&lt;/ol&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Thread&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Predecossor&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Currrent&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Next&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;T1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P=null » P=C1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;C1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;C1.next =NULL&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;T2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P=C1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;C2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;C1.next = C2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;T3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;P=C2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;C3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;C2.next = C3&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;ol&gt;
  &lt;li&gt;代码详解&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;T1 &amp;amp; T2
def Lock {
    P = GAS(C1) // P == NULL
}

def Unlock {
    if (c1.next == null) {
        if CAS(C1, NULL) { // T2 情况
            // 确实C1.next == null，因为如果执行过
            // T2 Lock: P = GAS(C2)
            // P = C2, 则CAS(C1, NULL)失败
            return; // 未执行 T2 Lock: P = GAS(C2)
        } else { // T2 情况
            // 确实C1.next == null，因为如果执行过
            // T2 Lock: P = GAS(C2)
            // P = C2, 则CAS(C1, NULL)失败
            while (C1.next == null) { // T2 情况
                // 等待next 挂载 C1.next = C2
            }
        }
    }
    // C1.next != null
    C1.next.isBlock = false; // 执行 T2 的 lock
    c1.next = null // GC
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/resources/images/2018/4/2-MCSNode.png&quot; alt=&quot;MSC Node 时序图&quot; height=&quot;100%&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/07/MCSNode-Chart</link>
                <guid>https://evildracula.github.io/tech/2018/04/07/MCSNode Chart</guid>
                <pubDate>Sat, 07 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Static 和 volatile</title>
                <description>
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;图上纠正：staticInt 会在不同线程同步，时机不确定，但是忙碌时候另外一个线程只能用本线程 staticInt 的copy&lt;/code&gt;&lt;br /&gt;
 &lt;img src=&quot;/resources/images/2018/4/1-static-volatile.png&quot; alt=&quot;Stream Arch&quot; height=&quot;100%&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;static 静态部分  在类加载的时候会在类对象保留一份，此类的实例间共享一份静态资源，并加载到内存，寄存器，缓存，不保证每个线程看到的值是一致，最新值（假设有线程对静态变量修改的话）；而volatile表示每次保证读取到到是主内存中最新的值。&lt;br /&gt;
现在JVM经过优化，已不会出现liveness failure 。所以没事别用volatile。1.7前知名bug&lt;/p&gt;
&lt;/blockquote&gt;

&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;原始代码&lt;/td&gt;
&lt;td&gt;优化代码&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;while(!flag){}&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;if(flag){&lt;br /&gt;
&amp;nbps;&amp;nbps;&amp;nbps;&amp;nbps;while(true){}&lt;br /&gt;
    }&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;h4 id=&quot;死循环-无volatile-关键字&quot;&gt;死循环, 无volatile 关键字&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class TestWithoutVolatile {
    private static boolean bChanged;

    public static void main(String[] args) throws InterruptedException {
        new Thread() {
            @Override
            public void run() {
                for (;;) {
					if (bChanged == !bChanged) {
                        System.out.println(&quot;!=&quot;);
                        System.exit(0);
                    }
                }
            }
        }.start();
        Thread.sleep(300);
        new Thread() {
            @Override
            public void run() {
                for (;;) {
                    bChanged = !bChanged;
                }
            }
        }.start();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;有volatile正确感知&quot;&gt;有volatile，正确感知&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class TestWithVolatile {
    private static volatile boolean bChanged;
    public static void main(String[] args) throws InterruptedException {
        new Thread() {
            @Override
            public void run() {
                for (;;) {
                    if (bChanged == !bChanged) {
                        System.out.println(&quot;!=&quot;);
                        System.exit(0);
                    }
                }
            }
        }.start();
        Thread.sleep(100);
        new Thread() {
            @Override
            public void run() {
                for (;;) {
                    bChanged = !bChanged;
                }
            }
        }.start();
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;测试代码&quot;&gt;测试代码&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;public class NoVisiblility {
    private static boolean ready;
    private static volatile boolean ready;// if $ready is volatile, this can be avoid as well even without $LINE 1
    private static int number;
    private static int cc;


    private static class ReaderThread extends Thread {
        public void run() { // 读线程
            while (!ready) {
                // $LINE 1
                System.out.println(222);// if this is removed, the copy of $ready will be used for ever
            }
            System.out.println(number);
            System.exit(0);
        }

    }

    private static class ReaderThread extends Thread {
        public void run() { // 读线程
            System.out.println(&quot;in&quot;);
            for (;;) {//  等价 while(!ready)
                // boolean aa = ready; 即使加入本变量 $aa 的读，也还是读取本地static copy
               // cc = 1; 即使加入其他变量的读写，也还是读取本地static copy
                // 如果执行ready = false; 就会同步$ready 在主存中的值，系统执行$LINE 2
                 if (ready) {
                    break; // $LINE 2
                }
            }
            System.out.println(number);
            System.out.println(&quot;exit&quot;);
            System.exit(0);
        }

    }


    public static void main(String[] args) throws InterruptedException { // 主线程
        new ReaderThread().start();
        Thread.sleep(10);
        new Thread(new Runnable() {

            @Override
            public void run() {
                for (;;) {
                    ready = true;
                    number = 42;
                }
            }
        }).start();;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/01/static-%E5%92%8C-volatile</link>
                <guid>https://evildracula.github.io/tech/2018/04/01/static 和 volatile</guid>
                <pubDate>Sun, 01 Apr 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Jmx security</title>
                <description>
&lt;h4 id=&quot;jvm-启动配置&quot;&gt;JVM 启动配置&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=1234
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;配置用户及权限对应信息&quot;&gt;配置用户及权限对应信息&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${JAVA_HOME}/jre/lib/management/jmxremote.access&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;somebody readwrite
monitorRole readonly
controlRole readwrite
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;user-informatio-config&quot;&gt;User Informatio Config&lt;/h4&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${JAVA_HOME}/jre/lib/management/jmxremote.password.template&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;somebody somebody_psw
monitorRole 123456
controlRole 123456
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;启动生效&quot;&gt;启动生效&lt;/h4&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=1234
 
-Dcom.sun.management.jmxremote.authenticate=true
-Dcom.sun.management.jmxremote.password.file=jmxpassword
-Dcom.sun.management.jmxremote.access.file=jmxaccess
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
                <link>https://evildracula.github.io/tech/2018/04/01/JMX-security</link>
                <guid>https://evildracula.github.io/tech/2018/04/01/JMX security</guid>
                <pubDate>Sun, 01 Apr 2018 00:00:00 +0000</pubDate>
        </item>


</channel>
</rss>
