public boolean killQuery(QueryId queryId) throws ServiceException, IOException { QueryStatus status = getQueryStatus(queryId); try { /* send a kill to the TM */ service.killQuery(null, queryId.getProto()); long currentTimeMillis = System.currentTimeMillis(); long timeKillIssued = currentTimeMillis; while ((currentTimeMillis < timeKillIssued + 10000L) && (status.getState() != QueryState.QUERY_KILLED)) { try { Thread.sleep(1000L); } catch (InterruptedException ie) { /** interrupted, just break */ break; } currentTimeMillis = System.currentTimeMillis(); status = getQueryStatus(queryId); } } catch (ServiceException io) { LOG.debug("Error when checking for application status", io); return false; } return true; }