Extending TPTP Attach problem - client never receives response from legacy agent [message #106785] |
Fri, 27 July 2007 15:30 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Natasha D'Silva![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ndsilva%40ca.ibm.com) Messages: 25 Registered: July 2009 |
Junior Member |
|
|
Hi,
I wrote a basic agent for TPTP 4.4. that runs as a JVMPI agent in Java 1.4,
and I extended the AbstractDCMutualLauncher class so that I get notified
when the attach is complete. In
AbstractMutualDCLauncher#launch(AgentSelection[]), I spawn a thread to
attach to the agent, send it a command, and wait for the response. The
agent receives the response and sends the command back, but the client
doesn't receive a response. I have tried testing this with 4.2+ versions
of the agent controller, with no success. I have also tested extracting the
code that attaches to the agent, and sends waits for the command and running
it as a standalone java application and that always works. I noticed this
in the AC log:
The log messages in order from agent launch to attach:
msg="Incoming connection request from agent mysample.agent in process 4544
with uuid 2c7700f7-11fd-4b36-895d-b737f821da80" severity="10"
version="1.0.1">
msg="Agent not found mysample.agent 
" severity="10"
version="1.0.1">msg="Registering process 4544
org.eclipse.tptp.legacy.mysample.agent" severity="10" version="1.0.1">
msg="Agent Controller allowed multiple clients to attach to a legacy
agent." severity="50" version="1.0.1">
msg="Agent Controller allowed multiple clients to attach to a legacy
agent." severity="50" version="1.0.1">
msg="Preparing Agent active" severity="10" version="1.0.1">
msg="The requested connection (107d) could not be found during sendMessage"
<---This is where I think my problem isI have tried debugging the code that
leads up to the attach and I'm pretty sure that the agent only gets attached
to once, so I'm not sure why the AC thinks its previously been attached to.
I have tested this with AC v4.1.0 and it appears to work fine, which means
its probably a compatibility issue.
Command sending snippet:
agent.addAgentListener(new CustomAgentListener());
CustomCommand customCommand = new CustomCommand();
customCommand.setData("sendData");
synchronized (lock) {
agent.invokeCustomCommand(customCommand);
lock.wait(); //lock.notify is called in the handleCommand() method
of the agent listener.
}
The listener is able to receive agent active notification as well as the
"KILLED" custom command.
Here is what the agent uses to send the response:
ra_message_t *message;
ra_command_t *command;
message = ra_createMessage( RA_CONTROL_MESSAGE, 0 );
command = ra_addCommandToMessage(message, NULL); //sending in null allocates
space for the command
command->tag = RA_CUSTOM_COMMAND;
command->info.custom_command.processId= ra_getProcessId();
command->info.custom_command.context= context;
command->info.custom_command.message.data = responseData;
ra_createRASTRING(&command->info.custom_command.agent,AGENT_NAME );
ra_createRASTRING(&command->info.custom_command.message, responseData );
int sentMsgLen = ra_sendMessage(handle, message);
ra_destroyMessage(message, TRUE);
fprintf(stderr, "sent %d message bytes\n", sentMsgLen);
Any tips on how to debug this further or on what I'm doing incorrectly would
be greatly appreciated,
Thanks.
Natasha
|
|
|
|
Powered by
FUDForum. Page generated in 0.02903 seconds