@Override BlockingInterface getStub() throws ServiceException { return getCatalogConnection().getStub(); }
@Override BlockingInterface getStub() throws ServiceException { return getCatalogConnection().getStub(); }
protected BlockingInterface getTMStub() { NettyClientBase tmClient; tmClient = getTajoMasterConnection(); BlockingInterface stub = tmClient.getStub(); checkSessionAndGet(tmClient); return stub; }
protected BlockingInterface getTMStub() { NettyClientBase tmClient; tmClient = getTajoMasterConnection(); BlockingInterface stub = tmClient.getStub(); checkSessionAndGet(tmClient); return stub; }
@Override public void close() { if (closed.getAndSet(true)) { return; } // remove session NettyClientBase client = null; try { client = getTajoMasterConnection(); BlockingInterface tajoMaster = client.getStub(); tajoMaster.removeSession(null, sessionId); } catch (Throwable e) { // ignore } finally { RpcClientManager.cleanup(client); NettyUtils.shutdown(eventLoopGroup); } }
@Override public void close() { if (closed.getAndSet(true)) { return; } // remove session NettyClientBase client = null; try { client = getTajoMasterConnection(); BlockingInterface tajoMaster = client.getStub(); tajoMaster.removeSession(null, sessionId); } catch (Throwable e) { // ignore } finally { RpcClientManager.cleanup(client); NettyUtils.shutdown(eventLoopGroup); } }
private void connectQueryMaster(WorkerConnectionInfo connectionInfo) throws NoSuchMethodException, ConnectException, ClassNotFoundException { RpcClientManager.cleanup(queryMasterRpc); InetSocketAddress addr = NetUtils.createSocketAddr(connectionInfo.getHost(), connectionInfo.getQueryMasterPort()); LOG.info("Try to connect to QueryMaster:" + addr); queryMasterRpc = RpcClientManager.getInstance().newClient(addr, QueryMasterProtocol.class, true, rpcParams); queryMasterRpcClient = queryMasterRpc.getStub(); }
private void connectQueryMaster(WorkerConnectionInfo connectionInfo) throws NoSuchMethodException, ConnectException, ClassNotFoundException { RpcClientManager.cleanup(queryMasterRpc); InetSocketAddress addr = NetUtils.createSocketAddr(connectionInfo.getHost(), connectionInfo.getQueryMasterPort()); LOG.info("Try to connect to QueryMaster:" + addr); queryMasterRpc = RpcClientManager.getInstance().newClient(addr, QueryMasterProtocol.class, true, rpcParams); queryMasterRpcClient = queryMasterRpc.getStub(); }
public String getCurrentDatabase() { NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); StringResponse response; try { response = tajoMasterService.getCurrentDatabase(null, sessionId); } catch (ServiceException e) { throw new RuntimeException(e); } ensureOk(response.getState()); return response.getValue(); }
public String getCurrentDatabase() { NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); StringResponse response; try { response = tajoMasterService.getCurrentDatabase(null, sessionId); } catch (ServiceException e) { throw new RuntimeException(e); } ensureOk(response.getState()); return response.getValue(); }
public Map<String, String> getAllSessionVariables() { NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface stub = client.getStub(); KeyValueSetResponse response; try { response = stub.getAllSessionVariables(null, sessionId); } catch (ServiceException e) { throw new RuntimeException(e); } ensureOk(response.getState()); return ProtoUtil.convertToMap(response.getValue()); }
private void checkTajoMasterConnectivity(TajoConf tajoConf) throws Exception { RpcClientManager manager = RpcClientManager.getInstance(); ServiceTracker serviceTracker = ServiceTrackerFactory.get(tajoConf); NettyClientBase masterClient = manager.getClient(serviceTracker.getUmbilicalAddress(), QueryCoordinatorProtocol.class, true, RpcParameterFactory.get(tajoConf)); masterClient.getStub(); }
private void checkTajoMasterConnectivity(TajoConf tajoConf) throws Exception { RpcClientManager manager = RpcClientManager.getInstance(); ServiceTracker serviceTracker = ServiceTrackerFactory.get(tajoConf); NettyClientBase masterClient = manager.getClient(serviceTracker.getUmbilicalAddress(), QueryCoordinatorProtocol.class, true, RpcParameterFactory.get(tajoConf)); masterClient.getStub(); }
public Map<String, String> getAllSessionVariables() { NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface stub = client.getStub(); KeyValueSetResponse response; try { response = stub.getAllSessionVariables(null, sessionId); } catch (ServiceException e) { throw new RuntimeException(e); } ensureOk(response.getState()); return ProtoUtil.convertToMap(response.getValue()); }
public List<TajoProtos.WorkerConnectionInfoProto> getAllWorker() { NettyClientBase rpc = null; try { // In TajoMaster HA mode, if backup master be active status, // worker may fail to connect existing active master. Thus, // if worker can't connect the master, worker should try to connect another master and // update master address in worker context. ServiceTracker serviceTracker = workerContext.getServiceTracker(); rpc = manager.getClient(serviceTracker.getUmbilicalAddress(), QueryCoordinatorProtocol.class, true, rpcClientParams); QueryCoordinatorProtocolService masterService = rpc.getStub(); CallFuture<WorkerConnectionsResponse> callBack = new CallFuture<>(); masterService.getAllWorkers(callBack.getController(), PrimitiveProtos.NullProto.getDefaultInstance(), callBack); WorkerConnectionsResponse connectionsProto = callBack.get(); return connectionsProto.getWorkerList(); } catch (Exception e) { LOG.error(e.getMessage(), e); } return new ArrayList<>(); }
public String getSessionVariable(final String varname) throws NoSuchSessionVariableException { synchronized (sessionVarsCache) { // If a desired variable is client side one and exists in the cache, immediately return the variable. if (sessionVarsCache.containsKey(varname)) { return sessionVarsCache.get(varname); } } NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface stub = client.getStub(); StringResponse response; try { response = stub.getSessionVariable(null, getSessionedString(varname)); } catch (ServiceException e) { throw new RuntimeException(e); } if (isThisError(response.getState(), NO_SUCH_SESSION_VARIABLE)) { throw new NoSuchSessionVariableException(response.getState()); } ensureOk(response.getState()); return response.getValue(); }
public String getSessionVariable(final String varname) throws NoSuchSessionVariableException { synchronized (sessionVarsCache) { // If a desired variable is client side one and exists in the cache, immediately return the variable. if (sessionVarsCache.containsKey(varname)) { return sessionVarsCache.get(varname); } } NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface stub = client.getStub(); StringResponse response; try { response = stub.getSessionVariable(null, getSessionedString(varname)); } catch (ServiceException e) { throw new RuntimeException(e); } if (isThisError(response.getState(), NO_SUCH_SESSION_VARIABLE)) { throw new NoSuchSessionVariableException(response.getState()); } ensureOk(response.getState()); return response.getValue(); }
protected void checkSessionAndGet(NettyClientBase client) { if (sessionId == null) { BlockingInterface tajoMasterService = client.getStub(); CreateSessionRequest.Builder builder = CreateSessionRequest.newBuilder(); builder.setUsername(userInfo.getUserName()).build(); if (baseDatabase != null) { builder.setBaseDatabaseName(baseDatabase); } CreateSessionResponse response = null; try { response = tajoMasterService.createSession(null, builder.build()); } catch (ServiceException se) { throw new RuntimeException(se); } if (isSuccess(response.getState())) { sessionId = response.getSessionId(); updateSessionVarsCache(ProtoUtil.convertToMap(response.getSessionVars())); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Got session %s as a user '%s'.", sessionId.getId(), userInfo.getUserName())); } } else { throw new TajoRuntimeException(response.getState()); } } }
public Map<String, String> updateSessionVariables(final Map<String, String> variables) { NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); KeyValueSet keyValueSet = new KeyValueSet(); keyValueSet.putAll(variables); UpdateSessionVariableRequest request = UpdateSessionVariableRequest.newBuilder() .setSessionId(sessionId) .setSessionVars(keyValueSet.getProto()).build(); SessionUpdateResponse response; try { response = tajoMasterService.updateSessionVariables(null, request); } catch (ServiceException e) { throw new RuntimeException(e); } ensureOk(response.getState()); updateSessionVarsCache(ProtoUtil.convertToMap(response.getSessionVars())); return Collections.unmodifiableMap(sessionVarsCache); }
public Map<String, String> updateSessionVariables(final Map<String, String> variables) { NettyClientBase client = getTajoMasterConnection(); checkSessionAndGet(client); BlockingInterface tajoMasterService = client.getStub(); KeyValueSet keyValueSet = new KeyValueSet(); keyValueSet.putAll(variables); UpdateSessionVariableRequest request = UpdateSessionVariableRequest.newBuilder() .setSessionId(sessionId) .setSessionVars(keyValueSet.getProto()).build(); SessionUpdateResponse response; try { response = tajoMasterService.updateSessionVariables(null, request); } catch (ServiceException e) { throw new RuntimeException(e); } ensureOk(response.getState()); updateSessionVarsCache(ProtoUtil.convertToMap(response.getSessionVars())); return Collections.unmodifiableMap(sessionVarsCache); }