private void returnMasterConnection(MasterClientService.Client client) { ThriftUtil.returnClient(client); }
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; } }
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); } }
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); } }
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 static void fetchScans() throws Exception { if (context == null) return; for (String server : context.instanceOperations().getTabletServers()) { final HostAndPort parsedServer = HostAndPort.fromString(server); Client tserver = ThriftUtil.getTServerClient(parsedServer, context); try { List<ActiveScan> scans = tserver.getActiveScans(null, context.rpcCreds()); synchronized (allScans) { allScans.put(parsedServer, new ScanStats(scans)); } } catch (Exception ex) { log.debug("Failed to get active scans from {}", server, ex); } finally { ThriftUtil.returnClient(tserver); } } // Age off old scan information Iterator<Entry<HostAndPort,ScanStats>> entryIter = allScans.entrySet().iterator(); long now = System.currentTimeMillis(); while (entryIter.hasNext()) { Entry<HostAndPort,ScanStats> entry = entryIter.next(); if (now - entry.getValue().fetched > 5 * 60 * 1000) { entryIter.remove(); } } }
@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); } } } }
public void compact(ZooLock lock, String tableId, byte[] startRow, byte[] endRow) throws TException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.compact(Tracer.traceInfo(), context.rpcCreds(), lockString(lock), tableId, startRow == null ? null : ByteBuffer.wrap(startRow), endRow == null ? null : ByteBuffer.wrap(endRow)); } finally { ThriftUtil.returnClient(client); } }
private static void updateServer(ClientContext context, Mutation m, KeyExtent extent, HostAndPort server) throws TException, NotServingTabletException, ConstraintViolationException, AccumuloSecurityException { checkArgument(m != null, "m is null"); checkArgument(extent != null, "extent is null"); checkArgument(server != null, "server is null"); checkArgument(context != null, "context is null"); TabletClientService.Iface client = null; try { client = ThriftUtil.getTServerClient(server, context); client.update(Tracer.traceInfo(), context.rpcCreds(), extent.toThrift(), m.toThrift(), TDurability.DEFAULT); return; } catch (ThriftSecurityException e) { throw new AccumuloSecurityException(e.user, e.code); } finally { ThriftUtil.returnClient((TServiceClient) client); } }
public void flush(ZooLock lock, Table.ID tableId, byte[] startRow, byte[] endRow) throws TException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.flush(Tracer.traceInfo(), context.rpcCreds(), lockString(lock), tableId.canonicalID(), startRow == null ? null : ByteBuffer.wrap(startRow), endRow == null ? null : ByteBuffer.wrap(endRow)); } finally { 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); } }
private static GCStatus fetchGcStatus() { GCStatus result = null; HostAndPort address = null; try { // Read the gc location from its lock ZooReaderWriter zk = context.getZooReaderWriter(); String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK; List<String> locks = zk.getChildren(path, null); if (locks != null && locks.size() > 0) { Collections.sort(locks); address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null), UTF_8)) .getAddress(Service.GC_CLIENT); GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(), address, context); try { result = client.getStatus(Tracer.traceInfo(), getContext().rpcCreds()); } finally { ThriftUtil.returnClient(client); } } } catch (Exception ex) { log.warn("Unable to contact the garbage collector at " + address, ex); } return result; }
public void fastHalt(ZooLock lock) throws TException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.fastHalt(Tracer.traceInfo(), context.rpcCreds(), lockString(lock)); } finally { ThriftUtil.returnClient(client); } }
public void halt(ZooLock lock) throws TException, ThriftSecurityException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.halt(Tracer.traceInfo(), context.rpcCreds(), lockString(lock)); } finally { ThriftUtil.returnClient(client); } }
/** * Fetch the tablets for the given table by asking the tablet server. Useful if your balance * strategy needs details at the tablet level to decide what tablets to move. * * @param tserver * The tablet server to ask. * @param tableId * The table id * @return a list of tablet statistics * @throws ThriftSecurityException * tablet server disapproves of your internal System password. * @throws TException * any other problem */ public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID tableId) throws ThriftSecurityException, TException { log.debug("Scanning tablet server {} for table {}", tserver, tableId); Client client = ThriftUtil.getClient(new TabletClientService.Client.Factory(), tserver.getLocation(), context); try { return client.getTabletStats(Tracer.traceInfo(), context.rpcCreds(), tableId.canonicalID()); } catch (TTransportException e) { log.error("Unable to connect to {}: ", tserver, e); } finally { ThriftUtil.returnClient(client); } return null; }
public void unloadTablet(ZooLock lock, KeyExtent extent, TUnloadTabletGoal goal, long requestTime) throws TException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.unloadTablet(Tracer.traceInfo(), context.rpcCreds(), lockString(lock), extent.toThrift(), goal, requestTime); } finally { ThriftUtil.returnClient(client); } }
public void chop(ZooLock lock, KeyExtent extent) throws TException { TabletClientService.Client client = ThriftUtil .getClient(new TabletClientService.Client.Factory(), address, context); try { client.chop(Tracer.traceInfo(), context.rpcCreds(), lockString(lock), extent.toThrift()); } finally { ThriftUtil.returnClient(client); } }
@Override public List<ActiveCompaction> getActiveCompactions(String tserver) throws AccumuloException, AccumuloSecurityException { final HostAndPort parsedTserver = HostAndPort.fromString(tserver); Client client = null; try { client = ThriftUtil.getTServerClient(parsedTserver, context); List<ActiveCompaction> as = new ArrayList<>(); for (org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction activeCompaction : client .getActiveCompactions(Tracer.traceInfo(), context.rpcCreds())) { as.add(new ActiveCompactionImpl(context, activeCompaction)); } return as; } catch (TTransportException e) { throw new AccumuloException(e); } catch (ThriftSecurityException e) { throw new AccumuloSecurityException(e.user, e.code, e); } catch (TException e) { throw new AccumuloException(e); } finally { if (client != null) ThriftUtil.returnClient(client); } }
@Override public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException { final HostAndPort parsedTserver = HostAndPort.fromString(tserver); Client client = null; try { client = ThriftUtil.getTServerClient(parsedTserver, context); List<ActiveScan> as = new ArrayList<>(); for (org.apache.accumulo.core.tabletserver.thrift.ActiveScan activeScan : client .getActiveScans(Tracer.traceInfo(), context.rpcCreds())) { try { as.add(new ActiveScanImpl(context, activeScan)); } catch (TableNotFoundException e) { throw new AccumuloException(e); } } return as; } catch (TTransportException e) { throw new AccumuloException(e); } catch (ThriftSecurityException e) { throw new AccumuloSecurityException(e.user, e.code, e); } catch (TException e) { throw new AccumuloException(e); } finally { if (client != null) 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); } } }