@Override public void run() { try { AsyncRpcClient tajoWorkerRpc = RpcClientManager.getInstance().getClient(worker, TajoWorkerProtocol.class, true, rpcParams); TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerRpcClient = tajoWorkerRpc.getStub(); tajoWorkerRpcClient.stopExecutionBlock(null, requestProto, NullCallback.get(PrimitiveProtos.BoolProto.class)); } catch (Throwable e) { LOG.error(e.getMessage(), e); } } });
@Override public void run() { try { AsyncRpcClient tajoWorkerRpc = RpcClientManager.getInstance().getClient(worker, TajoWorkerProtocol.class, true, rpcParams); TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerRpcClient = tajoWorkerRpc.getStub(); tajoWorkerRpcClient.stopExecutionBlock(null, requestProto, NullCallback.get(PrimitiveProtos.BoolProto.class)); } catch (Throwable e) { LOG.error(e.getMessage(), e); } } });
@Override public void run() { try { AsyncRpcClient rpc = RpcClientManager.getInstance().getClient(worker, TajoWorkerProtocol.class, true, rpcParams); TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerProtocolService = rpc.getStub(); tajoWorkerProtocolService.stopQuery(null, queryId.getProto(), NullCallback.get()); } catch (Throwable e) { LOG.error(e.getMessage(), e); } } });
@Override public void run() { try { AsyncRpcClient rpc = RpcClientManager.getInstance().getClient(worker, TajoWorkerProtocol.class, true, rpcParams); TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerProtocolService = rpc.getStub(); tajoWorkerProtocolService.stopQuery(null, queryId.getProto(), NullCallback.get()); } catch (Throwable e) { LOG.error(e.getMessage(), e); } } });
protected TajoResourceTrackerProtocol.TajoResourceTrackerProtocolService.Interface newStub() throws NoSuchMethodException, ConnectException, ClassNotFoundException { RpcClientManager.cleanup(rmClient); RpcClientManager rpcManager = RpcClientManager.getInstance(); rmClient = rpcManager.newClient(serviceTracker.getResourceTrackerAddress(), TajoResourceTrackerProtocol.class, true, rpcParams); return rmClient.getStub(); }
protected TajoResourceTrackerProtocol.TajoResourceTrackerProtocolService.Interface newStub() throws NoSuchMethodException, ConnectException, ClassNotFoundException { RpcClientManager.cleanup(rmClient); RpcClientManager rpcManager = RpcClientManager.getInstance(); rmClient = rpcManager.newClient(serviceTracker.getResourceTrackerAddress(), TajoResourceTrackerProtocol.class, true, rpcParams); return rmClient.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(); }
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 synchronized NettyClientBase getCatalogConnection() throws ServiceException { if (client != null && client.isConnected()) return client; else { try { if (client != null && client.isConnected()) return client; RpcClientManager.cleanup(client); final Properties clientParams = new Properties(); clientParams.setProperty(RpcConstants.CLIENT_RETRY_NUM, conf.getVar(ConfVars.RPC_CLIENT_RETRY_NUM)); // Client do not closed on idle state for support high available this.client = RpcClientManager.getInstance().newClient(getCatalogServerAddr(), CatalogProtocol.class, false, clientParams); } catch (Exception e) { throw new ServiceException(e); } return client; } }
public synchronized NettyClientBase getCatalogConnection() throws ServiceException { if (client != null && client.isConnected()) return client; else { try { if (client != null && client.isConnected()) return client; RpcClientManager.cleanup(client); final Properties clientParams = new Properties(); clientParams.setProperty(RpcConstants.CLIENT_RETRY_NUM, conf.getVar(ConfVars.RPC_CLIENT_RETRY_NUM)); // Client do not closed on idle state for support high available this.client = RpcClientManager.getInstance().newClient(getCatalogServerAddr(), CatalogProtocol.class, false, clientParams); } catch (Exception e) { throw new ServiceException(e); } return client; } }
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 ExecutionBlockContext(TajoWorker.WorkerContext workerContext, ExecutionBlockContextResponse request, AsyncRpcClient queryMasterClient) throws IOException { this.executionBlockId = new ExecutionBlockId(request.getExecutionBlockId()); this.connManager = RpcClientManager.getInstance(); this.systemConf = workerContext.getConf(); this.reporter = new Reporter(); this.defaultFS = TajoConf.getTajoRootDir(systemConf).getFileSystem(systemConf); this.localFS = FileSystem.getLocal(systemConf); // Setup QueryEngine according to the query plan // Here, we can setup row-based query engine or columnar query engine. this.queryEngine = new TajoQueryEngine(systemConf); this.queryContext = new QueryContext(workerContext.getConf(), request.getQueryContext()); this.plan = request.getPlanJson(); this.resource = new ExecutionBlockSharedResource(); this.workerContext = workerContext; this.shuffleType = request.getShuffleType(); this.queryMasterClient = queryMasterClient; }
protected ExecutionBlockContext createExecutionBlock(ExecutionBlockId executionBlockId, String queryMasterHostAndPort) { LOG.info("QueryMaster Address:" + queryMasterHostAndPort); AsyncRpcClient client = null; try { InetSocketAddress address = NetUtils.createSocketAddr(queryMasterHostAndPort); ExecutionBlockContextRequest.Builder request = ExecutionBlockContextRequest.newBuilder(); request.setExecutionBlockId(executionBlockId.getProto()) .setWorker(getWorkerContext().getConnectionInfo().getProto()); client = RpcClientManager.getInstance().newClient(address, QueryMasterProtocol.class, true, rpcParams); QueryMasterProtocol.QueryMasterProtocolService.Interface stub = client.getStub(); CallFuture<ExecutionBlockContextResponse> callback = new CallFuture<ExecutionBlockContextResponse>(); stub.getExecutionBlockContext(callback.getController(), request.build(), callback); ExecutionBlockContextResponse contextProto = callback.get(); ExecutionBlockContext context = new ExecutionBlockContext(getWorkerContext(), contextProto, client); context.init(); return context; } catch (Throwable e) { RpcClientManager.cleanup(client); LOG.fatal(e.getMessage(), e); throw new RuntimeException(e); } }
public ExecutionBlockContext(TajoWorker.WorkerContext workerContext, ExecutionBlockContextResponse request, AsyncRpcClient queryMasterClient, @Nullable TajoPullServerService pullServerService) throws IOException { this.executionBlockId = new ExecutionBlockId(request.getExecutionBlockId()); this.connManager = RpcClientManager.getInstance(); this.systemConf = workerContext.getConf(); this.reporter = new Reporter(); this.defaultFS = TajoConf.getTajoRootDir(systemConf).getFileSystem(systemConf); this.localFS = FileSystem.getLocal(systemConf); // Setup QueryEngine according to the query plan // Here, we can setup row-based query engine or columnar query engine. this.queryEngine = new TajoQueryEngine(systemConf); this.queryContext = new QueryContext(workerContext.getConf(), request.getQueryContext()); this.plan = request.getPlanJson(); this.resource = new ExecutionBlockSharedResource(pullServerService); this.workerContext = workerContext; this.shuffleType = request.getShuffleType(); this.queryMasterClient = queryMasterClient; }
protected ExecutionBlockContext createExecutionBlock(ExecutionBlockId executionBlockId, String queryMasterHostAndPort) { LOG.info("QueryMaster Address:" + queryMasterHostAndPort); AsyncRpcClient client = null; try { InetSocketAddress address = NetUtils.createSocketAddr(queryMasterHostAndPort); ExecutionBlockContextRequest.Builder request = ExecutionBlockContextRequest.newBuilder(); request.setExecutionBlockId(executionBlockId.getProto()) .setWorker(getWorkerContext().getConnectionInfo().getProto()); client = RpcClientManager.getInstance().newClient(address, QueryMasterProtocol.class, true, rpcParams); QueryMasterProtocol.QueryMasterProtocolService.Interface stub = client.getStub(); CallFuture<ExecutionBlockContextResponse> callback = new CallFuture<>(); stub.getExecutionBlockContext(callback.getController(), request.build(), callback); ExecutionBlockContextResponse contextProto = callback.get(); ExecutionBlockContext context = new ExecutionBlockContext(getWorkerContext(), contextProto, client, pullServerService); context.init(); return context; } catch (Throwable e) { RpcClientManager.cleanup(client); LOG.fatal(e.getMessage(), e); throw new RuntimeException(e); } }
@Override public void serviceInit(Configuration conf) throws Exception { this.systemConf = TUtil.checkTypeAndGet(conf, TajoConf.class); this.manager = RpcClientManager.getInstance(); this.rpcClientParams = RpcParameterFactory.get(this.systemConf); querySessionTimeout = systemConf.getIntVar(TajoConf.ConfVars.QUERY_SESSION_TIMEOUT); queryMasterContext = new QueryMasterContext(systemConf); clock = new SystemClock(); finishedQueryMasterTasksCache = new LRUMap(systemConf.getIntVar(TajoConf.ConfVars.HISTORY_QUERY_CACHE_SIZE)); this.dispatcher = new AsyncDispatcher(); addIfService(dispatcher); globalPlanner = new GlobalPlanner(systemConf, workerContext); dispatcher.register(QueryStartEvent.EventType.class, new QueryStartEventHandler()); dispatcher.register(QueryStopEvent.EventType.class, new QueryStopEventHandler()); super.serviceInit(conf); LOG.info("QueryMaster inited"); }
/** * It sends a kill RPC request to a corresponding worker. * * @param workerId worker unique Id. * @param taskAttemptId The TaskAttemptId to be killed. */ protected void killTaskAttempt(int workerId, TaskAttemptId taskAttemptId) { NettyClientBase tajoWorkerRpc; ExecutionBlockId ebId = taskAttemptId.getTaskId().getExecutionBlockId(); InetSocketAddress workerAddress = getQuery().getStage(ebId).getAssignedWorkerMap().get(workerId); try { tajoWorkerRpc = RpcClientManager.getInstance().getClient(workerAddress, TajoWorkerProtocol.class, true, rpcParams); TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerRpcClient = tajoWorkerRpc.getStub(); CallFuture<PrimitiveProtos.BoolProto> callFuture = new CallFuture<PrimitiveProtos.BoolProto>(); tajoWorkerRpcClient.killTaskAttempt(null, taskAttemptId.getProto(), callFuture); if(!callFuture.get().getValue()){ getEventHandler().handle( new TaskFatalErrorEvent(taskAttemptId, new TajoInternalError("Can't kill task :" + taskAttemptId))); } } catch (Exception e) { /* Node RPC failure */ LOG.error(e.getMessage(), e); getEventHandler().handle(new TaskFatalErrorEvent(taskAttemptId, e)); } }
/** * It sends a kill RPC request to a corresponding worker. * * @param workerId worker unique Id. * @param taskAttemptId The TaskAttemptId to be killed. */ protected void killTaskAttempt(int workerId, TaskAttemptId taskAttemptId) { NettyClientBase tajoWorkerRpc; ExecutionBlockId ebId = taskAttemptId.getTaskId().getExecutionBlockId(); InetSocketAddress workerAddress = getQuery().getStage(ebId).getAssignedWorkerMap().get(workerId); try { tajoWorkerRpc = RpcClientManager.getInstance().getClient(workerAddress, TajoWorkerProtocol.class, true, rpcParams); TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerRpcClient = tajoWorkerRpc.getStub(); CallFuture<PrimitiveProtos.BoolProto> callFuture = new CallFuture<>(); tajoWorkerRpcClient.killTaskAttempt(null, taskAttemptId.getProto(), callFuture); if(!callFuture.get().getValue()){ getEventHandler().handle( new TaskFatalErrorEvent(taskAttemptId, new TajoInternalError("Can't kill task :" + taskAttemptId))); } } catch (Exception e) { /* Node RPC failure */ LOG.error(e.getMessage(), e); getEventHandler().handle(new TaskFatalErrorEvent(taskAttemptId, e)); } }
@Override public void serviceInit(Configuration conf) throws Exception { this.systemConf = TUtil.checkTypeAndGet(conf, TajoConf.class); this.manager = RpcClientManager.getInstance(); this.rpcClientParams = RpcParameterFactory.get(this.systemConf); querySessionTimeout = systemConf.getIntVar(TajoConf.ConfVars.QUERY_SESSION_TIMEOUT); queryMasterContext = new QueryMasterContext(systemConf); clock = new SystemClock(); finishedQueryMasterTasksCache = new LRUMap(systemConf.getIntVar(TajoConf.ConfVars.HISTORY_QUERY_CACHE_SIZE)); this.dispatcher = new AsyncDispatcher(); addIfService(dispatcher); globalPlanner = new GlobalPlanner(systemConf, workerContext); dispatcher.register(QueryStartEvent.EventType.class, new QueryStartEventHandler()); dispatcher.register(QueryStopEvent.EventType.class, new QueryStopEventHandler()); super.serviceInit(conf); LOG.info("QueryMaster inited"); }