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(); }
@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); } } });
/** * * @param key RpcConnectionKey * @param <T> Rpc Protocol Class * @return Rpc Client Class * @throws NoSuchMethodException * @throws ClassNotFoundException * @throws ConnectException */ public synchronized <T extends NettyClientBase> T newClient(RpcConnectionKey key, Properties connectionParameters) throws NoSuchMethodException, ClassNotFoundException, ConnectException { T client = makeClient(key, connectionParameters); client.connect(); assert client.isConnected(); return client; }
public synchronized NettyClientBase getTajoMasterConnection() { if (client != null && client.isConnected()) { return client; } else { try { RpcClientManager.cleanup(client); // Client do not closed on idle state for support high available this.client = manager.newBlockingClient(getTajoMasterAddr(), TajoMasterClientProtocol.class, eventLoopGroup, clientParams); } catch (Throwable t) { throw new TajoRuntimeException(new ClientConnectionException(t)); } return client; } }
@Override public void close() { RpcClientManager.cleanup(client); } }
queryInfo.getHostNameOfQM(), queryInfo.getQueryMasterClientPort()); RpcClientManager manager = RpcClientManager.getInstance(); NettyClientBase qmClient = null; qmClient = manager.newClient(qmAddress, QueryMasterClientProtocol.class, false, new Properties());
/** * Run this instance against the server once. * @return an object of type T * @throws java.io.IOException if a remote or network exception occurs * @throws RuntimeException other unspecified error */ public T withoutRetries() throws IOException, RuntimeException { NettyClientBase client = null; try { beforeCall(); client = manager.getClient(addr, protocol, asyncMode); return call(client); } catch (Throwable t) { Throwable t2 = translateException(t); if (t2 instanceof IOException) { throw (IOException)t2; } else { throw new RuntimeException(t2); } } finally { afterCall(); if(closeConn) { RpcClientManager.cleanup(client); } } }
/** * Connect to TajoMaster * * @param tracker TajoMaster address * @param baseDatabase The base database name. It is case sensitive. If it is null, * the 'default' database will be used. * @param properties configurations * @throws SQLException */ public SessionConnection(@NotNull ServiceTracker tracker, @Nullable String baseDatabase, @NotNull KeyValueSet properties) { this.serviceTracker = tracker; this.baseDatabase = baseDatabase; this.properties = properties; this.manager = RpcClientManager.getInstance(); this.userInfo = UserRoleInfo.getCurrentUser(); // update the connection parameters to RPC client from connection properties this.clientParams = ClientParameterHelper.getConnParams(properties.getAllKeyValus().entrySet()); this.eventLoopGroup = NettyUtils.createEventLoopGroup(getClass().getSimpleName(), 4); try { this.client = getTajoMasterConnection(); } catch (TajoRuntimeException e) { NettyUtils.shutdown(eventLoopGroup); throw e; } // update the session variables from connection parameters updateSessionVariables(ClientParameterHelper.getSessionVars(properties.getAllKeyValus().entrySet())); }
/** * Connect a {@link NettyClientBase} to the remote {@link NettyServerBase}, and returns rpc client by protocol. * This client does not managed. It should close. */ public <T extends NettyClientBase> T newClient(InetSocketAddress addr, Class<?> protocolClass, boolean asyncMode, Properties rpcParams) throws NoSuchMethodException, ClassNotFoundException, ConnectException { return newClient(new RpcConnectionKey(addr, protocolClass, asyncMode), rpcParams); }
@Override public void run() { LOG.info("Start QueryMaster heartbeat thread"); while(!isStopped) { List<QueryMasterTask> tempTasks = new ArrayList<>(); tempTasks.addAll(queryMasterTasks.values()); for(QueryMasterTask eachTask: tempTasks) { NettyClientBase tmClient; try { ServiceTracker serviceTracker = queryMasterContext.getWorkerContext().getServiceTracker(); tmClient = manager.getClient(serviceTracker.getUmbilicalAddress(), QueryCoordinatorProtocol.class, true, rpcClientParams); QueryCoordinatorProtocolService masterClientService = tmClient.getStub(); TajoHeartbeatRequest queryHeartbeat = buildTajoHeartBeat(eachTask); masterClientService.heartbeat(null, queryHeartbeat, NullCallback.get()); } catch (Throwable t) { t.printStackTrace(); } } synchronized(this) { try { this.wait(2000); } catch (InterruptedException e) { break; } } } LOG.info("QueryMaster heartbeat thread stopped"); } }
/** * Close client manager and shutdown Netty RPC worker pool * After it is shutdown it is not possible to reuse it again. */ public static void shutdown() { close(); RpcChannelFactory.shutdownGracefully(); }
@Override public void close() { RpcClientManager.cleanup(client); } }
queryInfo.getHostNameOfQm(), queryInfo.getQueryMasterClientPort()); RpcClientManager manager = RpcClientManager.getInstance(); NettyClientBase qmClient = null; qmClient = manager.newClient(qmAddress, QueryMasterClientProtocol.class, false, new Properties());
/** * Connect to TajoMaster * * @param tracker TajoMaster address * @param baseDatabase The base database name. It is case sensitive. If it is null, * the 'default' database will be used. * @param properties configurations * @throws SQLException */ public SessionConnection(@NotNull ServiceTracker tracker, @Nullable String baseDatabase, @NotNull KeyValueSet properties) { this.serviceTracker = tracker; this.baseDatabase = baseDatabase; this.properties = properties; this.manager = RpcClientManager.getInstance(); this.userInfo = UserRoleInfo.getCurrentUser(); // update the connection parameters to RPC client from connection properties this.clientParams = ClientParameterHelper.getConnParams(properties.getAllKeyValus().entrySet()); this.eventLoopGroup = NettyUtils.createEventLoopGroup(getClass().getSimpleName(), 4); try { this.client = getTajoMasterConnection(); } catch (TajoRuntimeException e) { NettyUtils.shutdown(eventLoopGroup); throw e; } // update the session variables from connection parameters updateSessionVariables(ClientParameterHelper.getSessionVars(properties.getAllKeyValus().entrySet())); }
public synchronized NettyClientBase getTajoMasterConnection() { if (client != null && client.isConnected()) { return client; } else { try { RpcClientManager.cleanup(client); // Client do not closed on idle state for support high available this.client = manager.newBlockingClient(getTajoMasterAddr(), TajoMasterClientProtocol.class, eventLoopGroup, clientParams); } catch (Throwable t) { throw new TajoRuntimeException(new ClientConnectionException(t)); } return client; } }
/** * Connect a {@link NettyClientBase} to the remote {@link NettyServerBase}, and returns rpc client by protocol. * This client does not managed. It should close. */ public <T extends NettyClientBase> T newClient(InetSocketAddress addr, Class<?> protocolClass, boolean asyncMode, Properties rpcParams) throws NoSuchMethodException, ClassNotFoundException, ConnectException { return newClient(new RpcConnectionKey(addr, protocolClass, asyncMode), rpcParams); }
@Override public void run() { LOG.info("Start QueryMaster heartbeat thread"); while(!isStopped) { List<QueryMasterTask> tempTasks = new ArrayList<QueryMasterTask>(); tempTasks.addAll(queryMasterTasks.values()); for(QueryMasterTask eachTask: tempTasks) { NettyClientBase tmClient; try { ServiceTracker serviceTracker = queryMasterContext.getWorkerContext().getServiceTracker(); tmClient = manager.getClient(serviceTracker.getUmbilicalAddress(), QueryCoordinatorProtocol.class, true, rpcClientParams); QueryCoordinatorProtocolService masterClientService = tmClient.getStub(); TajoHeartbeatRequest queryHeartbeat = buildTajoHeartBeat(eachTask); masterClientService.heartbeat(null, queryHeartbeat, NullCallback.get()); } catch (Throwable t) { t.printStackTrace(); } } synchronized(this) { try { this.wait(2000); } catch (InterruptedException e) { break; } } } LOG.info("QueryMaster heartbeat thread stopped"); } }
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(); }
@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); } } });