遠程pid註冊其"local pid"
和"its node"
名稱已註冊到mnesia
表中。如果另一個節點的pid讀取上面的"local pid<0.xxx.xxx>"
和節點名稱,如何轉換爲remote pid<xxx.xxx.xxx>
。給出本地pid和節點名稱,如何轉換爲遠程pid?
回答
我真的沒有看到爲什麼你必須做任何特別的事情。在這裏,我將創建一個運行在[email protected]
和[email protected]
上的mnesia表,並且從各個節點寫入和讀取pid,並顯示它們不需要「轉換」pid作爲Erlang的分發機制自動照顧它。這一切都會持續很長時間。
節點[email protected]
我們連接或其它節點首先創建我們Mnesia模式:
Eshell V5.9.1 (abort with ^G)
([email protected])1> net_adm:ping([email protected]).
pong
([email protected])3> mnesia:create_schema([node()|nodes()]).
ok
([email protected])5> mnesia:start().
ok
在節點[email protected]
我們剛開始的Mnesia:
Eshell V5.9.1 (abort with ^G)
([email protected])1> mnesia:start().
ok
在節點[email protected]
我們再創建一個表並插入包含本地條目(至[email protected]
)pid:
([email protected])6> mnesia:create_table(local, [{attributes,[node,pid]},{ram_copies,[node()|nodes()]}]).
{atomic,ok}
([email protected])8> mnesia:transaction(fun() -> mnesia:write({local,node(),self()}) end).
{atomic,ok}
請注意,我沒有定義記錄,但顯式讀/寫記錄元組。你可以這樣做,但最好使用記錄。現在,在節點[email protected]
我們可以看到相同的記錄:
([email protected])10> {atomic,[Lr]} = mnesia:transaction(fun() -> mnesia:read(local, [email protected]) end).
{atomic,[{local,[email protected],<5893.37.0>}]}
([email protected])11> node(element(3, Lr)).
[email protected]
([email protected])12> mnesia:transaction(fun() -> mnesia:write({local,node(),self()}) end).
{atomic,ok}
,我們看到,PID指進程另一個節點上(),節點[email protected]
。然後我們向包含當地(至[email protected]
)pid的表格添加了一條記錄。如果我們接着往下看節點[email protected]
該記錄我們看到,它包含節點[email protected]
進程的PID:
([email protected])13> {atomic,[Rp]} = mnesia:transaction(fun() -> mnesia:read(local, [email protected]) end).
{atomic,[{local,[email protected],<6007.85.0>}]}
([email protected])14> node(element(3,Rp)).
[email protected]
所以我們看到,一個「轉換」是沒有必要的。
實際上任何形式的「轉換」其實都是毫無意義的。 pid是指特定節點上的特定進程,因此試圖將其轉換爲無意義。它是一個原子數據類型。即使你可以轉換它,你也不知道它將實際引用什麼進程,如果有的話。
非常感謝。我現在明白了「自動轉換」。 –
- 1. 將Cygwin PID轉換爲Windows PID
- 2. 如何獲得erlang節點名稱的pid?
- 3. 將PID轉換爲HWND
- 4. 按名稱返回PID
- 5. 從PID獲取名稱?
- 6. Linux如何等待遠程pid(telnet)
- 7. 獲取遠程rsync PID?
- 8. 來自pid的Unix進程名稱
- 9. 通過PID獲取進程名稱
- 10. Linux中的pid進程名稱
- 11. 通過PID查找進程名稱
- 12. 如何區分系統過程PID和用戶過程PID?
- 13. Python 3 psutil,提取pid和名稱值?
- 14. 如何通過PID查找應用程序名稱(進程ID)
- 15. Bash如何從PID得到完整的腳本名稱
- 16. 如何從PID使用C獲取進程名稱
- 17. 如何從C++中的PID獲取進程名稱?
- 18. 如何使用PID從服務器層獲取進程名稱
- 19. 如何從java中的pid中找到進程名稱?
- 20. python - subprocess.Popen()。pid返回父腳本的pid
- 21. 在Debian中顯示進程名稱和pid
- 22. 如何將Erlang中的PID轉換爲二進制的1個字節?
- 23. /proc/[pid]/pagemaps和/ proc/[pid]/maps | linux
- 24. xslt - 如何輸出所有節點作爲節點名稱和節點值
- 25. 的netstat的PID /節目名稱甚至使用sudo破折號
- 26. 如何將pid轉換爲C++中的const char指針?
- 27. 如何殺死一個PID在PID文件中的進程?
- 28. PID爲新的線程
- 29. SENDTO PID和組
- 30. 分叉和pid
如果一個進程本地註冊在節點上,你能不能:rpc:call('node @ remote-host',erlang,whereis,[localpid])來檢索遠程pid? – 2012-11-24 11:00:07
whereis的參數是regname,不是localpid。 –