static void close(ScanState scanState) { if (!scanState.finished && scanState.scanID != null && scanState.prevLoc != null) { TInfo tinfo = Tracer.traceInfo(); log.debug("Closing active scan {} {}", scanState.prevLoc, scanState.scanID); HostAndPort parsedLocation = HostAndPort.fromString(scanState.prevLoc.tablet_location); TabletClientService.Client client = null; try { client = ThriftUtil.getTServerClient(parsedLocation, scanState.context); client.closeScan(tinfo, scanState.scanID); } catch (TException e) { // ignore this is a best effort log.debug("Failed to close active scan " + scanState.prevLoc + " " + scanState.scanID, e); } finally { if (client != null) ThriftUtil.returnClient(client); } } } }
public boolean isActive(long tid) throws TException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { return client.isActive(Tracer.traceInfo(), tid); } finally { ThriftUtil.returnClient(client); } }
public void assignTablet(ZooLock lock, KeyExtent extent) throws TException { if (extent.isMeta()) { // see ACCUMULO-3597 try (TTransport transport = ThriftUtil.createTransport(address, context)) { TabletClientService.Client client = ThriftUtil .createClient(new TabletClientService.Client.Factory(), transport); loadTablet(client, lock, extent); } } else { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { loadTablet(client, lock, extent); } finally { ThriftUtil.returnClient(client); } } }
private void returnMasterConnection(MasterClientService.Client client) { ThriftUtil.returnClient(client); }
/** * Create a Thrift client using the given factory with a pooled transport (if available), the * address, and client context with no timeout. * * @param factory * Thrift client factory * @param address * Server address for client to connect to * @param context * RPC options */ public static <T extends TServiceClient> T getClientNoTimeout(TServiceClientFactory<T> factory, HostAndPort address, ClientContext context) throws TTransportException { return getClient(factory, address, context, 0); }
private TabletClientService.Iface getClient(HostAndPort location) throws TTransportException { TabletClientService.Iface client; if (timeout < context.getClientTimeoutInMillis()) client = ThriftUtil.getTServerClient(location, context, timeout); else client = ThriftUtil.getTServerClient(location, context); return client; }
SSLContext sslContext = createSSLContext(sslParams); transport = createClient(wrappingSslSockFactory, address.getHost(), address.getPort(), timeout); transport = ThriftUtil.transportFactory().getTransport(transport); } else if (saslParams != null) { if (!UserGroupInformation.isSecurityEnabled()) { attemptClientReLogin(); transport = ThriftUtil.transportFactory().getTransport(transport);
public TabletServerStatus getTableMap(boolean usePooledConnection) throws TException, ThriftSecurityException { if (usePooledConnection) throw new UnsupportedOperationException(); long start = System.currentTimeMillis(); TTransport transport = ThriftUtil.createTransport(address, context); try { TabletClientService.Client client = ThriftUtil .createClient(new TabletClientService.Client.Factory(), transport); TabletServerStatus status = client.getTabletServerStatus(Tracer.traceInfo(), context.rpcCreds()); if (status != null) { status.setResponseTime(System.currentTimeMillis() - start); } return status; } finally { if (transport != null) transport.close(); } }
/** * @see #transportFactory(int) */ public static synchronized TTransportFactory transportFactory(long maxFrameSize) { if (maxFrameSize > Integer.MAX_VALUE || maxFrameSize < 1) throw new RuntimeException("Thrift transport frames are limited to " + Integer.MAX_VALUE); return transportFactory((int) maxFrameSize); }
/** * Create a Thrift client using the given factory with a pooled transport (if available) using the * address, client context and timeout * * @param factory * Thrift client factory * @param address * Server address for client to connect to * @param context * RPC options * @param timeout * Socket timeout which overrides the ClientContext timeout */ public static <T extends TServiceClient> T getClient(TServiceClientFactory<T> factory, HostAndPort address, ClientContext context, long timeout) throws TTransportException { TTransport transport = ThriftTransportPool.getInstance().getTransport(address, timeout, context); return createClient(factory, transport); }
private void invalidateSession(long sessionId, HostAndPort location) throws TException { TabletClientService.Iface client = null; TInfo tinfo = Tracer.traceInfo(); try { client = getClient(location); client.invalidateConditionalUpdate(tinfo, sessionId); } finally { ThriftUtil.returnClient((TServiceClient) client); } }
/** * Create a TabletServer Thrift client * * @param address * Server address for client to connect to * @param context * RPC options */ public static TabletClientService.Client getTServerClient(HostAndPort address, ClientContext context) throws TTransportException { return getClient(new TabletClientService.Client.Factory(), address, context); }
private TabletClientService.Iface getClient(HostAndPort location) throws TTransportException { TabletClientService.Iface client; if (timeout < context.getClientTimeoutInMillis()) client = ThriftUtil.getTServerClient(location, context, timeout); else client = ThriftUtil.getTServerClient(location, context); return client; }
SSLContext sslContext = createSSLContext(sslParams); transport = createClient(wrappingSslSockFactory, address.getHost(), address.getPort(), timeout); transport = ThriftUtil.transportFactory().getTransport(transport); } else if (null != saslParams) { if (!UserGroupInformation.isSecurityEnabled()) { attemptClientReLogin(); transport = ThriftUtil.transportFactory().getTransport(transport);
@Override public void ping(String tserver) throws AccumuloException { TTransport transport = null; try { transport = ThriftUtil.createTransport(AddressUtil.parseAddress(tserver, false), context); TabletClientService.Client client = ThriftUtil .createClient(new TabletClientService.Client.Factory(), transport); client.getTabletServerStatus(Tracer.traceInfo(), context.rpcCreds()); } catch (TException e) { throw new AccumuloException(e); } finally { if (transport != null) { transport.close(); } } }
/** * Creates a TThreadPoolServer for normal unsecure operation. Useful for comparing performance * against SSL or SASL transports. * * @param address * Address to bind to * @param processor * TProcessor for the server * @param maxMessageSize * Maximum size of a Thrift message allowed * @return A configured TThreadPoolServer and its bound address information */ public static ServerAddress createBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, long maxMessageSize, String serverName, int numThreads, int numSimpleTimerThreads, long timeBetweenThreadChecks) throws TTransportException { InetSocketAddress isa = new InetSocketAddress(address.getHost(), address.getPort()); // Must use an ISA, providing only a port would ignore the hostname given TServerSocket transport = new TServerSocket(isa); ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSimpleTimerThreads, timeBetweenThreadChecks); TThreadPoolServer server = createTThreadPoolServer(transport, processor, ThriftUtil.transportFactory(maxMessageSize), protocolFactory, pool); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("Blocking Server bound on {}", address); } return new ServerAddress(server, address); }
/** * Create a Thrift client using the given factory with a pooled transport (if available), the * address and client context. Client timeout is extracted from the ClientContext * * @param factory * Thrift client factory * @param address * Server address for client to connect to * @param context * RPC options */ public static <T extends TServiceClient> T getClient(TServiceClientFactory<T> factory, HostAndPort address, ClientContext context) throws TTransportException { TTransport transport = ThriftTransportPool.getInstance().getTransport(address, context.getClientTimeoutInMillis(), context); return createClient(factory, transport); }
private void sendQueued(int threshhold) { if (queuedDataSize > threshhold || threshhold == 0) { loadQueue.forEach((server, tabletFiles) -> { if (log.isTraceEnabled()) { log.trace("tid {} asking {} to bulk import {} files for {} tablets", fmtTid, server, tabletFiles.values().stream().mapToInt(Map::size).sum(), tabletFiles.size()); } TabletClientService.Client client = null; try { client = ThriftUtil.getTServerClient(server, master.getContext(), timeInMillis); client.loadFiles(Tracer.traceInfo(), master.getContext().rpcCreds(), tid, bulkDir.toString(), tabletFiles, setTime); } catch (TException ex) { log.debug("rpc failed server: " + server + ", tid:" + fmtTid + " " + ex.getMessage(), ex); } finally { ThriftUtil.returnClient(client); } }); loadQueue.clear(); queuedDataSize = 0; } }
public void splitTablet(KeyExtent extent, Text splitPoint) throws TException, ThriftSecurityException, NotServingTabletException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.splitTablet(Tracer.traceInfo(), context.rpcCreds(), extent.toThrift(), ByteBuffer.wrap(splitPoint.getBytes(), 0, splitPoint.getLength())); } finally { ThriftUtil.returnClient(client); } }
@Override public void run() { TabletClientService.Iface client = null; for (SessionID sid : sessions) { if (!sid.isActive()) continue; TInfo tinfo = Tracer.traceInfo(); try { client = getClient(sid.location); client.closeConditionalUpdate(tinfo, sid.sessionID); } catch (Exception e) {} finally { ThriftUtil.returnClient((TServiceClient) client); } } } }