Open changyeon opened 9 years ago
bindNamedParameter
takes a type of Name<T>
where T
can be any type.
Thank you for answering so quickly
Thanks for your reply, but could we ask one more question to catch-up?
I found out that bindNamedParameter takes value in the form of Java String. For example, given I have the class below:
@NamedParameter(doc = "A description of a query that QueryMaster will execute",
short_name = "queryRequest")
public static final class QueryRequestProto implements Name
The method still requires the value to be given in the form of String
bindNamedParameter(QueryRequestProto.class, <
In this case, what String value should I give?
Your named parameter should look something like this:
@NamedParameter(doc = "A description of a query that QueryMaster will execute",
short_name = "queryRequest")
public static final class QueryRequestProtoParam implements Name<QueryRequestProto> {
}
Then your call to would look something like this (assuming there's an Impl class):
bindNamedParameter(QueryRequestProto.class, QueryRequestProtoImpl.class)
Here, you're binding an implementation to an interface. Tang will then create a singleton object at the Task, given that the Impl class is injectable (has a valid constructor with @Inject
). Is this what you want to do?
Thanks for the quick reply And sorry, the editor hided some of my writing regarding it as a tag
Following is the parameter that I'm trying to send:
@NamedParameter(doc = "A description of a query that QueryMaster will execute",
short_name = "queryRequest")
public static final class QueryRequestProto implements Name<TajoWorkerProtocol.QueryExecutionRequestProto> {
}
TajoWorkerProtocol.QueryExecutionRequestProto
is the actual parameter we want to send.
So, my question is: to use the following method,
bindNamedParameter(QueryRequestProto.class, <<String value the method expects to have>>)
What value should I give for the second parameter? (String value)
Are you referring to JavaConfigurationBuilder
? It has two overloaded methods named bindNamedParameter
:
public JavaConfigurationBuilder bindNamedParameter(Class<? extends Name<?>> name, String value)
throws BindException;
public <T> JavaConfigurationBuilder bindNamedParameter(Class<? extends Name<T>> iface,
Class<? extends T> impl) throws BindException;
The second, you can give an Implementation. If this is not what you're looking for, please give a high-level explanation of what you need the code to do.
What we want to send is the request
of the following code fragment:
TajoWorkerProtocol.QueryExecutionRequestProto request = builder.setQueryId(queryId.getProto())
.setSession(session.getProto())
.setQueryContext(queryContext.getProto())
.setExprInJson(PrimitiveProtos.StringProto.newBuilder().setValue(queryInfo.getJsonExpr()))
.setLogicalPlanJson(PrimitiveProtos.StringProto.newBuilder().setValue(plan.toJson()).build())
.build();
request
contains the description of the query we want to execute.
We want this instance to be sent to the QueryMaster(=REEFDriver)
What would be the best way to give request
instance above as a parameter?
I deleted Cho's comment by mistake (I didn't know I have such a power). So I'm restoring it. I apologize this.... and thank for the reply!
Have you thought of sending the protobuf as a byte[] message
from the Client to the Driver?
See RunningJob#send(byte[])
. You can get an instance of RunningJob
through the JobRunningHandler
on the client. When the message is received on the Driver side, the ClientMessageHandlers
handler will be triggered.
Using bindNamedParameter
, you would need to construct the object on the Driver side, which doesn't seem to be the right thing to do, given you want to send a request that is already constructed.
Hope this helps.
I want to pass an object to REEF Task and I found "bindNameParameter" method in Tang configuration builder. It seems the "bindNameParameter" support only String type for parameter passing, but I want to pass complex type such as object to REEF Task. So, my question is can I pass an object to REEF Task as parameter?