protected TServerInstance parse(byte[] current) { String str = new String(current, UTF_8); String[] parts = str.split("[|]", 2); HostAndPort address = HostAndPort.fromString(parts[0]); if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) { return new TServerInstance(address, parts[1]); } else { // a 1.2 location specification: DO NOT WANT return null; } }
private Set<TServerInstance> parseServers(String servers) { if (servers == null) return null; // parse "host:port[INSTANCE]" Set<TServerInstance> result = new HashSet<>(); if (servers.length() > 0) { for (String part : servers.split(",")) { String parts[] = part.split("\\[", 2); String hostport = parts[0]; String instance = parts[1]; if (instance != null && instance.endsWith("]")) instance = instance.substring(0, instance.length() - 1); result.add(new TServerInstance(AddressUtil.parseAddress(hostport, false), instance)); } } return result; }
private static TServerInstance getTServerInstance(String address, ZooLock zooLock) { while (true) { try { return new TServerInstance(address, zooLock.getSessionId()); } catch (KeeperException | InterruptedException e) { log.error("{}", e.getMessage(), e); } sleepUninterruptibly(1, TimeUnit.SECONDS); } }
public TServerInstance getTabletSession() { String address = getClientAddressString(); if (address == null) return null; try { return new TServerInstance(address, tabletServerLock.getSessionId()); } catch (Exception ex) { log.warn("Unable to read session from tablet server lock" + ex); return null; } }
public TServerInstance getAssignment(SortedMap<TServerInstance,TabletServerStatus> locations, TServerInstance last) { if (locations.size() == 0) return null; if (last != null) { // Maintain locality String fakeSessionID = " "; TServerInstance simple = new TServerInstance(last.getLocation(), fakeSessionID); Iterator<TServerInstance> find = locations.tailMap(simple).keySet().iterator(); if (find.hasNext()) { TServerInstance current = find.next(); if (current.host().equals(last.host())) return current; } } // The strategy here is to walk through the locations and hand them back, one at a time // Grab an iterator off of the set of options; use a new iterator if it hands back something not // in the current list. if (assignments == null || !assignments.hasNext()) assignments = randomize(locations.keySet()).iterator(); TServerInstance result = assignments.next(); if (!locations.containsKey(result)) { assignments = null; return randomize(locations.keySet()).iterator().next(); } return result; }
public Map<TServerInstance,List<UUID>> getAllMarkers() throws WalMarkerException { Map<TServerInstance,List<UUID>> result = new HashMap<>(); try { String path = root(); for (String child : zoo.getChildren(path)) { TServerInstance inst = new TServerInstance(child); List<UUID> logs = result.get(inst); if (logs == null) { result.put(inst, logs = new ArrayList<>()); } // This function is called by the Accumulo GC which deletes WAL markers. Therefore we do not // expect the following call to fail because the WAL info in ZK was deleted. for (String idString : zoo.getChildren(path + "/" + child)) { logs.add(UUID.fromString(idString)); } } } catch (KeeperException | InterruptedException e) { throw new WalMarkerException(e); } return result; }
TServerInstance simple = new TServerInstance(last.getLocation(), fakeSessionID); Iterator<TServerInstance> find = current.tailMap(simple).keySet().iterator(); if (find.hasNext()) {
ServerServices services = new ServerServices(new String(lockData, UTF_8)); HostAndPort client = services.getAddress(ServerServices.Service.TSERV_CLIENT); TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
protected Iterable<Pair<KeyExtent,Location>> getLocationProvider() { return () -> { try { return TabletsMetadata.builder().forTable(tableId).fetchLocation().fetchPrev() .build(context).stream().map(tm -> { Location loc = Location.NONE; if (tm.hasCurrent()) { loc = new Location(new TServerInstance(tm.getLocation())); } return new Pair<>(tm.getExtent(), loc); }).iterator(); } catch (Exception e) { throw new RuntimeException(e); } }; }
throw new AccumuloException("Tablet has multiple future locations " + extent); future = new TServerInstance(entry.getValue(), key.getColumnQualifier()); } else if (cf.equals(TabletsSection.CurrentLocationColumnFamily.NAME)) { log.info("Tablet seems to be already assigned to {} {}", new TServerInstance(entry.getValue(), key.getColumnQualifier())); return null; } else if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(key)) {
compactID = Long.parseLong(entry.getValue().toString()); } else if (family.equals(LastLocationColumnFamily.NAME)) { lastLocation = new TServerInstance(value, key.getColumnQualifier()); } else if (family.equals(BulkFileColumnFamily.NAME)) { Long id = Long.decode(value.toString());
TServerInstance location = new TServerInstance(entry.getValue(), cq); if (future != null) { throw new BadLocationStateException("found two assignments for the same extent " TServerInstance location = new TServerInstance(entry.getValue(), cq); if (current != null) { throw new BadLocationStateException("found two locations for the same extent " } else if (cf.compareTo(TabletsSection.LastLocationColumnFamily.NAME) == 0) { if (lastTimestamp < entry.getKey().getTimestamp()) last = new TServerInstance(entry.getValue(), cq); } else if (cf.compareTo(ChoppedColumnFamily.NAME) == 0) { chopped = true;
TServerInstance instance = new TServerInstance(clientAddress, getLock().getSessionId()); TabletLocationState tls = null; try {
.tailMap(new TServerInstance(tls.suspend.server, " ")).keySet().iterator(); if (find.hasNext()) { TServerInstance found = find.next();
tabletsToWaitFor++; if (tablet.hasCurrent()) { serversToFlush.increment(new TServerInstance(tablet.getLocation()), 1);
tabletsToWaitFor++; if (tablet.hasCurrent()) serversToFlush.add(new TServerInstance(tablet.getLocation()));
protected TServerInstance parse(byte[] current) { String str = new String(current, UTF_8); String[] parts = str.split("[|]", 2); InetSocketAddress address = AddressUtil.parseAddress(parts[0], 0); if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) { return new TServerInstance(address, parts[1]); } else { // a 1.2 location specification: DO NOT WANT return null; } }
protected TServerInstance parse(byte[] current) { String str = new String(current, UTF_8); String[] parts = str.split("[|]", 2); HostAndPort address = HostAndPort.fromString(parts[0]); if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) { return new TServerInstance(address, parts[1]); } else { // a 1.2 location specification: DO NOT WANT return null; } }
private static TServerInstance getTServerInstance(String address, ZooLock zooLock) { while (true) { try { return new TServerInstance(address, zooLock.getSessionId()); } catch (KeeperException e) { log.error(e, e); } catch (InterruptedException e) { log.error(e, e); } UtilWaitThread.sleep(1000); } }
private static TServerInstance getTServerInstance(String address, ZooLock zooLock) { while (true) { try { return new TServerInstance(address, zooLock.getSessionId()); } catch (KeeperException e) { log.error("{}", e.getMessage(), e); } catch (InterruptedException e) { log.error("{}", e.getMessage(), e); } sleepUninterruptibly(1, TimeUnit.SECONDS); } }