private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); out.writeObject(location.toString()); }
public String hostPort() { return getLocation().toString(); }
@Override public List<String> getActiveTservers(TInfo tinfo, TCredentials credentials) { Set<TServerInstance> tserverInstances = master.onlineTabletServers(); List<String> servers = new ArrayList<>(); for (TServerInstance tserverInstance : tserverInstances) { servers.add(tserverInstance.getLocation().toString()); } return servers; }
private void queueException(HostAndPort location, Map<Long,CMK> cmidToCm, Exception e) { for (CMK cmk : cmidToCm.values()) cmk.cm.queueResult(new Result(e, cmk.cm, location.toString())); }
private Value asMutationValue() { return new Value(getLocation().toString().getBytes(UTF_8)); }
private void queueRetry(List<QCMutation> mutations, HostAndPort server) { if (timeout < Long.MAX_VALUE) { long time = System.currentTimeMillis(); ArrayList<QCMutation> mutations2 = new ArrayList<>(mutations.size()); for (QCMutation qcm : mutations) { qcm.resetDelay(); if (time + qcm.getDelay(TimeUnit.MILLISECONDS) > qcm.entryTime + timeout) { TimedOutException toe; if (server != null) toe = new TimedOutException(Collections.singleton(server.toString())); else toe = new TimedOutException("Conditional mutation timed out"); qcm.queueResult(new Result(toe, qcm, (server == null ? null : server.toString()))); } else { mutations2.add(qcm); } } if (mutations2.size() > 0) failedMutations.addAll(mutations2); } else { for (QCMutation qcm : mutations) qcm.resetDelay(); failedMutations.addAll(mutations); } }
CachedConnection cachedConnection = getCache().get(ttk).reserveAny(); if (cachedConnection != null) { final String serverAddr = ttk.getServer().toString(); log.trace("Using existing connection to {}", serverAddr); return new Pair<>(serverAddr, cachedConnection.transport); CachedConnection cachedConnection = cachedConns.reserveAny(); if (cachedConnection != null) { final String serverAddr = ttk.getServer().toString(); return new Pair<>(serverAddr, cachedConnection.transport); return new Pair<>(ttk.getServer().toString(), createNewTransport(ttk)); } catch (TTransportException tte) { log.debug("Failed to connect to {}", servers.get(index), tte);
private void invalidateSession(HostAndPort location, Map<Long,CMK> cmidToCm, SessionID sessionId) { if (sessionId == null) { queueRetry(cmidToCm, location); } else { try { invalidateSession(sessionId, location); for (CMK cmk : cmidToCm.values()) cmk.cm.queueResult(new Result(Status.UNKNOWN, cmk.cm, location.toString())); } catch (Exception e2) { queueException(location, cmidToCm, e2); } } }
@Override public void unassign(Collection<TabletLocationState> tablets, Map<TServerInstance,List<Path>> logsForDeadServers) throws DistributedStoreException { if (tablets.size() != 1) throw new IllegalArgumentException("There is only one root tablet"); TabletLocationState tls = tablets.iterator().next(); if (tls.extent.compareTo(RootTable.EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location"); if (logsForDeadServers != null) { List<Path> logs = logsForDeadServers.get(tls.futureOrCurrent()); if (logs != null) { for (Path entry : logs) { LogEntry logEntry = new LogEntry(RootTable.EXTENT, System.currentTimeMillis(), tls.futureOrCurrent().getLocation().toString(), entry.toString()); byte[] value; try { value = logEntry.toBytes(); } catch (IOException ex) { throw new DistributedStoreException(ex); } store.put(RootTable.ZROOT_TABLET_WALOGS + "/" + logEntry.getUniqueID(), value); } } } store.remove(RootTable.ZROOT_TABLET_LOCATION); store.remove(RootTable.ZROOT_TABLET_FUTURE_LOCATION); log.debug("unassign root tablet location"); }
private void getZooLock(HostAndPort addr) throws KeeperException, InterruptedException { String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK; LockWatcher lockWatcher = new LockWatcher() { @Override public void lostLock(LockLossReason reason) { Halt.halt("GC lock in zookeeper lost (reason = " + reason + "), exiting!", 1); } @Override public void unableToMonitorLockNode(final Throwable e) { // ACCUMULO-3651 Level changed to error and FATAL added to message for slf4j compatibility Halt.halt(-1, new Runnable() { @Override public void run() { log.error("FATAL: No longer able to monitor lock node ", e); } }); } }; while (true) { lock = new ZooLock(context.getZooReaderWriter(), path); if (lock.tryLock(lockWatcher, new ServerServices(addr.toString(), Service.GC_CLIENT).toString().getBytes())) { log.debug("Got GC ZooKeeper lock"); return; } log.debug("Failed to get GC ZooKeeper lock, will retry"); sleepUninterruptibly(1, TimeUnit.SECONDS); } }
private static void stopTabletServer(final ClientContext context, List<String> servers, final boolean force) throws AccumuloException, AccumuloSecurityException { if (context.getMasterLocations().size() == 0) { log.info("No masters running. Not attempting safe unload of tserver."); return; } final String zTServerRoot = getTServersZkPath(context); final ZooCache zc = context.getZooCache(); for (String server : servers) { for (int port : context.getConfiguration().getPort(Property.TSERV_CLIENTPORT)) { HostAndPort address = AddressUtil.parseAddress(server, port); final String finalServer = qualifyWithZooKeeperSessionId(zTServerRoot, zc, address.toString()); log.info("Stopping server {}", finalServer); MasterClient.executeVoid(context, client -> client.shutdownTabletServer(Tracer.traceInfo(), context.rpcCreds(), finalServer, force)); } } }
sp.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); } catch (Exception e) { log.error("Could not advertise replication service port", e);
} else { QCMutation qcm = cmidToCm.get(tcmResult.cmid).cm; qcm.queueResult(new Result(fromThrift(tcmResult.status), qcm, location.toString())); queueException(location, cmidToCm, ase); } catch (TTransportException e) { locator.invalidateCache(context, location.toString()); invalidateSession(location, cmidToCm, sessionId); } catch (TApplicationException tae) { queueException(location, cmidToCm, new AccumuloServerException(location.toString(), tae)); } catch (TException e) { locator.invalidateCache(context, location.toString()); invalidateSession(location, cmidToCm, sessionId); } catch (Exception e) {
String monitorAddress = HostAndPort.fromParts(advertiseHost, server.getPort()).toString(); context.getZooReaderWriter().putPersistentData( context.getZooKeeperRoot() + Constants.ZMONITOR_HTTP_ADDR, monitorAddress.getBytes(UTF_8),
span.data("File", p.toString()); span.data("Peer instance name", peerContext.getInstanceName()); span.data("Peer tserver", peerTserver.toString()); span.data("Remote table ID", remoteTableId);
replAddress.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
throw new AccumuloServerException(address.toString(), tae); } catch (TTransportException e) { tabLocator.invalidateCache(context, tl.tablet_location);
String address = sa.address.toString(); log.info("Setting master lock data to {}", address); masterLock.replaceLockData(address.getBytes());