public boolean isConnected() { if (!closed.get()) { try { return getTajoMasterConnection().isConnected(); } catch (Throwable e) { return false; } } return false; }
public boolean isConnected() { if (!closed.get()) { try { return getTajoMasterConnection().isConnected(); } catch (Throwable e) { return false; } } return false; }
public synchronized void connect() throws ConnectTimeoutException { if (isConnected()) return; final AtomicInteger retries = new AtomicInteger(); InetSocketAddress address = key.addr; if (address.isUnresolved()) { address = resolveAddress(address); } /* do not call await() inside handler */ ChannelFuture f = doConnect(address).awaitUninterruptibly(); retries.incrementAndGet(); if (!f.isSuccess() && numRetries > 0) { doReconnect(address, f, retries); } }
/** * * @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; }
/** * * @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 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; } }
/** * Connect a {@link NettyClientBase} to the remote {@link NettyServerBase}, and returns rpc client by protocol. * This client will be shared per protocol and address. Client is removed in shared map when a client is closed * @param addr * @param protocolClass * @param asyncMode * @return * @throws NoSuchMethodException * @throws ClassNotFoundException * @throws ConnectTimeoutException */ public NettyClientBase getClient(InetSocketAddress addr, Class<?> protocolClass, boolean asyncMode) throws NoSuchMethodException, ClassNotFoundException, ConnectTimeoutException { RpcConnectionKey key = new RpcConnectionKey(addr, protocolClass, asyncMode); NettyClientBase client; synchronized (clients) { client = clients.get(key); if (client == null) { clients.put(key, client = makeClient(key)); } } if (!client.isConnected()) { client.connect(); client.getChannel().closeFuture().addListener(new ConnectionCloseFutureListener(key)); } assert client.isConnected(); 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; } }
public synchronized <T extends NettyClientBase> T newBlockingClient(InetSocketAddress addr, Class<?> protocolClass, EventLoopGroup eventLoopGroup, Properties rpcParams) throws NoSuchMethodException, ClassNotFoundException, ConnectException { T client = makeClient(eventLoopGroup, new RpcConnectionKey(addr, protocolClass, false), rpcParams); client.connect(); assert client.isConnected(); return client; }
public synchronized <T extends NettyClientBase> T newBlockingClient(InetSocketAddress addr, Class<?> protocolClass, EventLoopGroup eventLoopGroup, Properties rpcParams) throws NoSuchMethodException, ClassNotFoundException, ConnectException { T client = makeClient(eventLoopGroup, new RpcConnectionKey(addr, protocolClass, false), rpcParams); client.connect(); assert client.isConnected(); return client; }
if (!client.isConnected()) { assert client.isConnected(); return (T) client;
public synchronized void connect() throws ConnectException { if (isConnected()) return; int retries = 0; InetSocketAddress address = key.addr; if (address.isUnresolved()) { address = resolveAddress(address); } /* do not call await() inside handler */ ChannelFuture f = doConnect(address).awaitUninterruptibly(); if (!f.isSuccess()) { if (maxRetryNum > 0) { doReconnect(address, f, ++retries); } else { throw makeConnectException(address, f); } } }
if (!client.isConnected()) { assert client.isConnected(); return (T) client;
public synchronized void connect() throws ConnectException { if (isConnected()) return; int retries = 0; InetSocketAddress address = key.addr; if (address.isUnresolved()) { address = resolveAddress(address); } /* do not call await() inside handler */ ChannelFuture f = doConnect(address).awaitUninterruptibly(); if (!f.isSuccess()) { if (maxRetryNum > 0) { doReconnect(address, f, ++retries); } else { throw makeConnectException(address, f); } } }
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; } }
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; } }