I am trying the hot code feature of erlang following the guide from LYAE but i do not understand how to make the update message to get triggered.
I have a module which runs a method that is upgradeable:
Module
-module(upgrade).
-export([main/1,upgrade/1,init/1,init_link/1]).
-record(state,{ version=0,comments=""}).
init(State)->
spawn(?MODULE,main,[State]).
main(State)->
receive
update->
NewState=?MODULE:upgrade(State),
if NewState#state.version>3 -> exit("Max Version Reached") end,
?MODULE:main(NewState);
SomeMessage->
main(State)
end.
upgrade(State=#state{version=Version,comments=Comments})->
Comm=case Version rem 2 of
0 -> "Even version";
_ -> "Uneven version"
end,
#state{version=Version+1,comments=Comm}.
Shell
>c(upgrade).
>rr(upgrade,state).
>U=upgrade:init(#state{version=0,comments="initial"}).
>Monitor=monitor(process,U).
> ......to something to trigger the update message
> flush(). % see the exit message reason
I do not understand how can i perform a hot code reload in order to trigger the update message.
I want when i use flush to get the exit reason from my main method.
The process expects to get the atom update as a message. Since you have the pid of the process in the variable U, you can send the message like this:
U ! update.
Note that the strings Even version and Uneven version are only kept in the state, never printed, so you won't see those. The only thing you'll see is the exit message, after sending update four times and calling flush().
I am trying to create a simple echo bot in ejabberd. I cam get the mod_echo working ok and i'm fairly certain I had my own version working at one point (debugging has played tricks with my head). I am getting the error below but i can't figure out what to do next to debug it. There seems to be an issue routing but not quite sure why. Any tips?
2016-03-31 16:49:38.350 [debug] <0.448.0>#ejabberd_router:do_route:324 route
from {jid,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>}
to {jid,<<>>,<<"echo.alchemy.local">>,<<>>,<<>>,<<"echo.alchemy.local">>,<<>>}
packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"echo.alchemy.local">>},{<<"id">>,<<"aacca">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"subject">>,[],[]},{xmlcdata,<<"\n">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"testme">>}]},{xmlcdata,<<"\n">>},{xmlel,<<"nick">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/nick">>}],[{xmlcdata,<<"user1">>}]},{xmlcdata,<<"\n">>}]}
2016-03-31 16:49:38.351 [error] <0.448.0>#ejabberd_router:route:77 {function_clause,[{mod_echobot,route,[{jid,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>},{jid,<<>>,<<"echo.alchemy.local">>,<<>>,<<>>,<<"echo.alchemy.local">>,<<>>},{xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"echo.alchemy.local">>},{<<"id">>,<<"aacca">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"subject">>,[],[]},{xmlcdata,<<"\n">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"testme">>}]},{xmlcdata,<<"\n">>},{xmlel,<<"nick">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/nick">>}],[{xmlcdata,<<"user1">>}]},{xmlcdata,<<"\n">>}]}],[{file,"mod_echobot.erl"},{line,86}]},{ejabberd_router,route,3,[{file,"src/ejabberd_router.erl"},{line,75}]},{ejabberd_c2s,check_privacy_route,5,[{file,"src/ejabberd_c2s.erl"},{line,2121}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1288}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]}
when processing: {{jid,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>,<<"user1">>,<<"alchemy.local">>,<<"alchemy">>},{jid,<<>>,<<"echo.alchemy.local">>,<<>>,<<>>,<<"echo.alchemy.local">>,<<>>},{xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"echo.alchemy.local">>},{<<"id">>,<<"aacca">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"subject">>,[],[]},{xmlcdata,<<"\n">>},{xmlel,<<"body">>,[],[{xmlcdata,<<"testme">>}]},{xmlcdata,<<"\n">>},{xmlel,<<"nick">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/nick">>}],[{xmlcdata,<<"user1">>}]},{xmlcdata,<<"\n">>}]}}
2016-03-31 16:50:16.356 [debug] <0.447.0>#ejabberd_receiver:process_data:282 Received XML on stream = <<"\n">>
It seems that in the code sample (which was from an older sample i found online) https://gist.github.com/stevenlivz/d666200595a23c42b2a662fef87bf281 i need to use <<"message">> in the clauses to actually match, whereas the sample code i used did not do that, using just "message" and so on. Also, also worth noting that xmlelement is now xmlel and so clauses also need to be updated. E.g.
route(From, To, {xmlel, <<"message">>, _, _} = Packet) ->
I have a RPG program A and a CL program B. A accepts some user input from display file and use it as the entry parameter of B. b processes the entry parameter, and if there is an error the message will be received and resent by B so that it will be displayed on the bottom of the display file using message subfile. This message displaying mechanism works but not completely, as the message sent could only be glanced in a very short period of time, then it disappeared from the display file. What would be the cause of this problem? How to stop the message from disappearing?
Here is the sample code inside program B:
DCLF FILE(ECSWIFP1)
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR))
OVRDBF FILE(ECSWIFP1) TOFILE(ECSWIFP1) SHARE(*YES)
OPNQRYF FILE(ECSWIFP1) QRYSLT(&QRYSTR)
RCVF
CLOF FILE(ECSWIFP1)
DLTOVR FILE(ECSWIFP1)
RTVDTAARA DTAARA(&E4LIBN/&E4OBJN) RTNVAR(&DTARVAL)
GOTO CMDLBL(END)
ERROR:
CLOF FILE(ECSWIFP1)
MONMSG MSGID(CPF4520)
DLTOVR FILE(ECSWIFP1)
MONMSG MSGID(CPF9841)
MSG:
RCVMSG MSGTYPE(*ANY) MSGDTA(&MSGDTA) MSGID(&MSGID)
IF COMD(%SST(&MSGID 1 3)) *NE 'CPF') THEN(GOTO CMDLBL(MSG))
SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) MSGTYPE(*STATUS) TOPGMQ(*EXT)
END:
ENDPGM
And here is part of the display file DDS for displaying message:
A R MSG SFL
A SFLMSGRCD(24)
A S0MSGK SFLMSGKEY
A S0PGMQ SFLPGMQ
A R MSGCTL SFLCTL(MSG)
A OVERLAY
A SFLDSP
A SFLINZ
A SFLSIZ(0005)
A SFLPAG(0001)
A S0PGMQ SFLPGMQ
Suppose there is no matching record based on the query string, then RCVF causes CPF0864 to be sent out, and this message can be displayed on the screen without problem.
But if a record is found and the field values are used in the RTVDTAARA command, and the failure of this command (e.g. data area not found) will causes the problem I described above, which is that the received message can only be glimpsed in a short period of time and then disappears. Why this happens?
The typical sequence is
write msgctl
write bottom
exfmt main
Make sure that any record format displayed after the message subfile has OVERLAY specified. Without OVERLAY, 'bottom' will erase the message subfile and 'main' will erase 'bottom'.
Application Display Programming is an old but useful reference.
EDIT After seeing the CL and DDS.
I believe the issue is due to SNDPGMMSG MSGTYPE(*STATUS). Status messages are special, and do not normally go into a subfile message queue. The Messages section in the Infocenter has more information on the different message types.
In CL PGMB, change the SNDPGMMSG to MSGTYPE(*DIAG) TOPGMQ(*PRV). This will throw the exception message to the caller (to PGMA) as a diagnostic message. Double check that you have OVERLAY in the DDS where you need it - my example above that would be bottom and main.
This sequence worked and display the message of message-subfile on the screen
The typical sequence is
write msgctl
write bottom
exfmt main
Make sure that any record format displayed after the message subfile has OVERLAY specified. Without OVERLAY, 'bottom' will erase the message subfile and 'main' will erase 'bottom'.
c
Im currently using Xebium, which is allows Selenium to be used with Fitnesse testing.
In Selenium i can set a pause for 3000 milliseconds. When i look at the source code for fitnesse it has the following line :
| do | pause | on | 3000 |
However when i run this test in fitnesse it doesn't wait for 3 seconds liek i thought it would and goes on to the next line instead.
I need the pause for the screen to load a button properly.
I think fitnesse has a problem with seleniums use of pause or interrupts it another way.
I tried this and it worked:
ensure | do | pause | on | 3000 |
I know it's been more than two years but I hope this will help people like me who have just started working on Xebium. Cheers
A bit late, but for future visitors: Have you tried waiting for the button to appear? Selenium documentation suggests doing this:
Many Actions can be called with the “AndWait” suffix, e.g. “clickAndWait”. This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.
Found at http://seleniumhq.org/docs/02_selenium_ide.jsp#selenium-commands-selenese