use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class ManagerMetadataUtil method replaceDatafiles.
public static void replaceDatafiles(ServerContext context, KeyExtent extent, Set<StoredTabletFile> datafilesToDelete, Set<StoredTabletFile> scanFiles, TabletFile path, Long compactionId, DataFileValue size, String address, TServerInstance lastLocation, ServiceLock zooLock, Optional<ExternalCompactionId> ecid) {
context.getAmple().putGcCandidates(extent.tableId(), datafilesToDelete);
TabletMutator tablet = context.getAmple().mutateTablet(extent);
datafilesToDelete.forEach(tablet::deleteFile);
scanFiles.forEach(tablet::putScan);
if (size.getNumEntries() > 0)
tablet.putFile(path, size);
if (compactionId != null)
tablet.putCompactionId(compactionId);
TServerInstance self = getTServerInstance(address, zooLock);
tablet.putLocation(self, LocationType.LAST);
// remove the old location
if (lastLocation != null && !lastLocation.equals(self))
tablet.deleteLocation(lastLocation, LocationType.LAST);
if (ecid.isPresent())
tablet.deleteExternalCompaction(ecid.get());
tablet.putZooLock(zooLock);
tablet.mutate();
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class ManagerClientServiceHandler method getActiveTservers.
@Override
public List<String> getActiveTservers(TInfo tinfo, TCredentials credentials) {
Set<TServerInstance> tserverInstances = manager.onlineTabletServers();
List<String> servers = new ArrayList<>();
for (TServerInstance tserverInstance : tserverInstances) {
servers.add(tserverInstance.getHostPort());
}
return servers;
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class Manager method getManagerMonitorInfo.
public ManagerMonitorInfo getManagerMonitorInfo() {
final ManagerMonitorInfo result = new ManagerMonitorInfo();
result.tServerInfo = new ArrayList<>();
result.tableMap = new HashMap<>();
for (Entry<TServerInstance, TabletServerStatus> serverEntry : tserverStatus.entrySet()) {
final TabletServerStatus status = serverEntry.getValue();
result.tServerInfo.add(status);
for (Entry<String, TableInfo> entry : status.tableMap.entrySet()) {
TableInfoUtil.add(result.tableMap.computeIfAbsent(entry.getKey(), k -> new TableInfo()), entry.getValue());
}
}
result.badTServers = new HashMap<>();
synchronized (badServers) {
for (TServerInstance bad : badServers.keySet()) {
result.badTServers.put(bad.getHostPort(), TabletServerState.UNRESPONSIVE.getId());
}
}
result.state = getManagerState();
result.goalState = getManagerGoalState();
result.unassignedTablets = displayUnassigned();
result.serversShuttingDown = new HashSet<>();
synchronized (serversToShutdown) {
for (TServerInstance server : serversToShutdown) {
result.serversShuttingDown.add(server.getHostPort());
}
}
DeadServerList obit = new DeadServerList(getContext());
result.deadTabletServers = obit.getList();
result.bulkImports = bulkImportStatus.getBulkLoadStatus();
return result;
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class Manager method getGoalState.
TabletGoalState getGoalState(TabletLocationState tls, MergeInfo mergeInfo) {
KeyExtent extent = tls.extent;
// Shutting down?
TabletGoalState state = getSystemGoalState(tls);
if (state == TabletGoalState.HOSTED) {
if (!upgradeCoordinator.getStatus().isParentLevelUpgraded(extent)) {
// tablet yet.
return TabletGoalState.UNASSIGNED;
}
if (tls.current != null && serversToShutdown.contains(tls.current)) {
return TabletGoalState.SUSPENDED;
}
// Handle merge transitions
if (mergeInfo.getExtent() != null) {
final boolean overlaps = mergeInfo.overlaps(extent);
if (overlaps) {
log.debug("mergeInfo overlaps: {} true", extent);
switch(mergeInfo.getState()) {
case NONE:
case COMPLETE:
break;
case STARTED:
case SPLITTING:
return TabletGoalState.HOSTED;
case WAITING_FOR_CHOPPED:
if (tls.getState(tserverSet.getCurrentServers()).equals(TabletState.HOSTED)) {
if (tls.chopped) {
return TabletGoalState.UNASSIGNED;
}
} else if (tls.chopped && tls.walogs.isEmpty()) {
return TabletGoalState.UNASSIGNED;
}
return TabletGoalState.HOSTED;
case WAITING_FOR_OFFLINE:
case MERGING:
return TabletGoalState.UNASSIGNED;
}
} else {
log.trace("mergeInfo overlaps: {} false", extent);
}
}
// taking table offline?
state = getTableGoalState(extent);
if (state == TabletGoalState.HOSTED) {
// Maybe this tablet needs to be migrated
TServerInstance dest = migrations.get(extent);
if (dest != null && tls.current != null && !dest.equals(tls.current)) {
return TabletGoalState.UNASSIGNED;
}
}
}
return state;
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class Manager method update.
@Override
public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance> added) {
// if we have deleted or added tservers, then adjust our dead server list
if (!deleted.isEmpty() || !added.isEmpty()) {
DeadServerList obit = new DeadServerList(getContext());
if (!added.isEmpty()) {
log.info("New servers: {}", added);
for (TServerInstance up : added) {
obit.delete(up.getHostPort());
}
}
for (TServerInstance dead : deleted) {
String cause = "unexpected failure";
if (serversToShutdown.contains(dead)) {
// maybe an incorrect assumption
cause = "clean shutdown";
}
if (!getManagerGoalState().equals(ManagerGoalState.CLEAN_STOP)) {
obit.post(dead.getHostPort(), cause);
}
}
Set<TServerInstance> unexpected = new HashSet<>(deleted);
unexpected.removeAll(this.serversToShutdown);
if (!unexpected.isEmpty() && (stillManager() && !getManagerGoalState().equals(ManagerGoalState.CLEAN_STOP))) {
log.warn("Lost servers {}", unexpected);
}
serversToShutdown.removeAll(deleted);
badServers.keySet().removeAll(deleted);
// clear out any bad server with the same host/port as a new server
synchronized (badServers) {
cleanListByHostAndPort(badServers.keySet(), deleted, added);
}
synchronized (serversToShutdown) {
cleanListByHostAndPort(serversToShutdown, deleted, added);
}
synchronized (migrations) {
Iterator<Entry<KeyExtent, TServerInstance>> iter = migrations.entrySet().iterator();
while (iter.hasNext()) {
Entry<KeyExtent, TServerInstance> entry = iter.next();
if (deleted.contains(entry.getValue())) {
log.info("Canceling migration of {} to {}", entry.getKey(), entry.getValue());
iter.remove();
}
}
}
nextEvent.event("There are now %d tablet servers", current.size());
}
// clear out any servers that are no longer current
// this is needed when we are using a fate operation to shutdown a tserver as it
// will continue to add the server to the serversToShutdown (ACCUMULO-4410)
serversToShutdown.retainAll(current.getCurrentServers());
}
Aggregations