Yes, I understand it. Just wanted to hear it from Cloudera before starting
to invent the bicycle.
I've created brand-new bicycle. It rides to random impalad taken from
application configuration and refreshes metadata before giving JDBC
connection to the same impalad.
It's rather ugly, but works.
public class ImpaladMetadataRefresher {
private final Logger LOG =
LoggerFactory.getLogger(ImpaladMetadataRefresher.class);
public void refresh(String user, String password, String host, int
port) throws ImpalaRefresherException{
LOG.debug("Refreshing with params: user={}, password={}, host={},
port={}", user, password, host, port);
Session session = null;
Channel channel = null;
try{
JSch jsch=new JSch();
session = jsch.getSession(user, host, port);
session.setConfig("StrictHostKeyChecking", "no");
session.setTimeout(1500);
session.setPassword(password);
session.connect();
channel = session.openChannel("exec");
InputStream stdout = channel.getInputStream();
InputStream stderr = ((ChannelExec)channel).getErrStream();
((ChannelExec)channel).setCommand("impala-shell -i
'localhost:21000' -q 'refresh web_resource_rating'");
channel.connect();
channel.run();
String stdoutString = IOUtils.toString(stdout);
LOG.info("stdout:{}", stdoutString);
String stdErrString = IOUtils.toString(stderr);
LOG.info("stderr:{}", stdErrString);
if (stdoutString == null || stdoutString.isEmpty() ||
!stdoutString.contains("Successfully refreshed table")){
throw new ImpalaRefresherException(String.format("Looks
like ssh exec failed: %s", stdErrString));
}
}catch (Exception e){
LOG.error("Error while refreshing metadata on impalad daemon",
e);
throw new ImpalaRefresherException("Rethrown original
exception", e);
}finally {
closeSilently(channel);
closeSilently(session);
}
}
public void closeSilently(Session session){
try{
if(session!=null && session.isConnected()){
session.disconnect();
}
}catch (Exception e){
LOG.error("Error while closing ssh session", e);
}
}
public void closeSilently(Channel channel){
try{
if(channel!=null && channel.isConnected()){
channel.disconnect();
}
}catch (Exception e){
LOG.error("Error while closing ssh channel", e);
}
}
}
2013/5/20 Ishaan Joshi <
ishaan@cloudera.com>
Serega, Alex,
At the moment, you have the explicitly refresh the impalad from the
impala-shell. Note that the refresh roc will not automatically refresh each
running impalad, just the one you're connected to.
Thanks,
-- Ishaan
On Mon, May 20, 2013 at 12:17 AM, Serega Sheypak <
serega.sheypak@gmail.comwrote:
The same problem! Is there any way to do it?
I have a table which partitions are updated each hour. So I have to
submit "refresh" in some way bwfore running query...
понедельник, 1 апреля 2013 г., 19:55:10 UTC+4 пользователь Alex I написал:
Hello,
I want to invoke metadata refresh manually from a Java client.
Currently, the JDBC driver prohibits me from doing that.
I can look into impala-shell sources and do a refresh via Thrift/RPC in
the same fashion - however, is there any recommended way for refreshing?
Thanks,
- Alex.