Search in sources :

Example 41 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class PoolHistoriesHandler method getAggregateFileLifetime.

/*
     *  First try to fetch the stored aggregate histogram.
     *  Failing that, do the aggregation here.
     */
public CountingHistogram getAggregateFileLifetime(String poolGroup, List<PoolInfoWrapper> pools) {
    AggregateFileLifetimeRequestMessage message = new AggregateFileLifetimeRequestMessage(poolGroup);
    try {
        message = historyService.sendAndWait(message, historyService.getTimeoutInMillis());
    } catch (NoRouteToCellException | InterruptedException | TimeoutCacheException e) {
        LOGGER.debug("Could not fetch aggregated lifetime data for {}: {}.", poolGroup, e.getMessage());
    } catch (CacheException e) {
        LOGGER.warn("Could not fetch aggregated lifetime data for {}: {}.", poolGroup, e.getMessage());
    }
    Serializable error = message.getErrorObject();
    if (error != null) {
        LOGGER.warn("Could not fetch aggregated lifetime data for {}: {}.", message.getPoolGroup(), error);
    }
    CountingHistogram histogram = message.getAggregateLifetime();
    /*
         *  If missing, try to merge here.
         */
    if (histogram == null) {
        LOGGER.info("Fetch of aggregated lifetime histogram unsuccessful; " + "merging data here.");
        histogram = PoolInfoCollectorUtils.mergeLastAccess(pools);
    }
    return histogram;
}
Also used : AggregateFileLifetimeRequestMessage(org.dcache.vehicles.histograms.AggregateFileLifetimeRequestMessage) Serializable(java.io.Serializable) CacheException(diskCacheV111.util.CacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CountingHistogram(org.dcache.util.histograms.CountingHistogram) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException)

Example 42 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class MovePinRequestProcessor method messageArrived.

public PinManagerExtendPinMessage messageArrived(PinManagerExtendPinMessage message) throws CacheException, InterruptedException {
    try {
        Pin pin = _dao.get(_dao.where().pnfsId(message.getFileAttributes().getPnfsId()).id(message.getPinId()));
        if (pin == null) {
            throw new InvalidMessageCacheException("Pin does not exist");
        } else if (!_pdp.canExtend(message.getSubject(), pin)) {
            throw new PermissionDeniedCacheException("Access denied");
        } else if (pin.getState() == PINNING) {
            throw new InvalidMessageCacheException("File is not pinned yet");
        } else if (pin.getState() == READY_TO_UNPIN || pin.getState() == UNPINNING || pin.getState() == FAILED_TO_UNPIN) {
            throw new InvalidMessageCacheException("Pin is no longer valid");
        }
        if (_maxLifetime > -1) {
            message.setLifetime(Math.min(_maxLifetimeUnit.toMillis(_maxLifetime), message.getLifetime()));
        }
        long lifetime = message.getLifetime();
        if (pin.hasRemainingLifetimeLessThan(lifetime)) {
            long now = System.currentTimeMillis();
            Date date = (lifetime == -1) ? null : new Date(now + lifetime);
            move(pin, pin.getPool(), date);
            message.setExpirationTime(date);
        } else {
            message.setExpirationTime(pin.getExpirationTime());
        }
        LOGGER.info("Extended pin for {} ({})", pin.getPnfsId(), pin.getPinId());
        return message;
    } catch (NoRouteToCellException e) {
        throw new CacheException("Failed to extend pin due to communication failure: " + e.getDestinationPath(), e);
    }
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) Pin(org.dcache.pinmanager.model.Pin) CacheException(diskCacheV111.util.CacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) Date(java.util.Date)

Example 43 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class LegacyAdminShellCommand method runAsciiMode.

private void runAsciiMode() throws IOException {
    Ansi.setEnabled(_console.getTerminal().isAnsiSupported() && _useColors);
    while (!_adminShellThread.isInterrupted()) {
        String prompt = Ansi.ansi().bold().a(_shell.getPrompt()).boldOff().toString();
        String str = _console.readLine(prompt);
        Object result;
        try {
            if (str == null) {
                throw new CommandExitException();
            }
            if (_useColors) {
                String trimmed = str.trim();
                if (trimmed.startsWith("help ")) {
                    str = "help -format=" + HelpFormat.ANSI + trimmed.substring(4);
                } else if (trimmed.equals("help")) {
                    str = "help -format=" + HelpFormat.ANSI;
                }
            }
            result = _shell.executeCommand(str);
        } catch (IllegalArgumentException e) {
            result = e.getMessage() + " (Please check the spelling of your command or your config file(s)!)";
        } catch (SerializationException e) {
            result = "There is a bug here, please report to support@dcache.org";
            LOGGER.error("This must be a bug, please report to support@dcache.org.", e);
        } catch (CommandSyntaxException e) {
            result = e;
        } catch (CommandEvaluationException e) {
            result = e.getMessage();
        } catch (CommandExitException e) {
            break;
        } catch (CommandPanicException e) {
            result = "Command '" + str + "' triggered a bug (" + e.getTargetException() + "); the service log file contains additional information. Please " + "contact support@dcache.org.";
        } catch (CommandException e) {
            result = e.getMessage();
        } catch (NoRouteToCellException e) {
            result = "Cell name does not exist or cell is not started: " + e.getMessage();
            LOGGER.warn("The cell the command was sent to is no " + "longer there: {}", e.getMessage());
        } catch (InterruptedException e) {
            result = e.getMessage();
        } catch (RuntimeException e) {
            result = String.format("Command '%s' triggered a bug (%s); please" + " locate this message in the log file of the admin service and" + " send an email to support@dcache.org with this line and the" + " following stack-trace", str, e);
            LOGGER.error((String) result, e);
        } catch (Exception e) {
            result = e.getMessage();
            if (result == null) {
                result = e.getClass().getSimpleName() + ": (null)";
            }
        }
        if (result != null) {
            String s;
            if (result instanceof CommandSyntaxException) {
                CommandSyntaxException e = (CommandSyntaxException) result;
                Ansi sb = Ansi.ansi();
                sb.fg(RED).a("Syntax error: ").a(e.getMessage()).newline();
                String help = e.getHelpText();
                if (help != null) {
                    sb.fg(CYAN);
                    sb.a("Help : ").newline();
                    sb.a(help);
                }
                s = sb.reset().toString();
            } else {
                s = Strings.toMultilineString(result);
            }
            if (!s.isEmpty()) {
                _console.println(s);
                _console.flush();
            }
        }
    }
}
Also used : SerializationException(dmg.cells.nucleus.SerializationException) CommandEvaluationException(dmg.util.CommandEvaluationException) CommandException(dmg.util.CommandException) CommandExitException(dmg.util.CommandExitException) CommandExitException(dmg.util.CommandExitException) SerializationException(dmg.cells.nucleus.SerializationException) CommandSyntaxException(dmg.util.CommandSyntaxException) CommandEvaluationException(dmg.util.CommandEvaluationException) CommandException(dmg.util.CommandException) IOException(java.io.IOException) CommandPanicException(dmg.util.CommandPanicException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) Ansi(org.fusesource.jansi.Ansi) CommandSyntaxException(dmg.util.CommandSyntaxException) CommandPanicException(dmg.util.CommandPanicException)

Example 44 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class ReservationCaches method buildSpaceLookupCache.

/**
 * Build a loading cache for looking up space reservations by space token.
 */
public static LoadingCache<String, Optional<Space>> buildSpaceLookupCache(CellStub spaceManager, Executor executor) {
    return CacheBuilder.newBuilder().maximumSize(1000).expireAfterWrite(10, MINUTES).refreshAfterWrite(30, SECONDS).recordStats().build(new CacheLoader<String, Optional<Space>>() {

        @Override
        public Optional<Space> load(String token) throws CacheException, NoRouteToCellException, InterruptedException {
            Space space = spaceManager.sendAndWait(new GetSpaceMetaData(token)).getSpaces()[0];
            return Optional.ofNullable(space);
        }

        @Override
        public ListenableFuture<Optional<Space>> reload(String token, Optional<Space> oldValue) {
            final SettableFuture<Optional<Space>> future = SettableFuture.create();
            CellStub.addCallback(spaceManager.send(new GetSpaceMetaData(token)), new AbstractMessageCallback<GetSpaceMetaData>() {

                @Override
                public void success(GetSpaceMetaData message) {
                    future.set(Optional.ofNullable(message.getSpaces()[0]));
                }

                @Override
                public void failure(int rc, Object error) {
                    CacheException exception = CacheExceptionFactory.exceptionOf(rc, Objects.toString(error, null));
                    future.setException(exception);
                }
            }, executor);
            return future;
        }
    });
}
Also used : Space(diskCacheV111.services.space.Space) GetSpaceMetaData(diskCacheV111.services.space.message.GetSpaceMetaData) SettableFuture(com.google.common.util.concurrent.SettableFuture) Optional(java.util.Optional) CacheException(diskCacheV111.util.CacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AbstractMessageCallback(org.dcache.cells.AbstractMessageCallback)

Example 45 with NoRouteToCellException

use of dmg.cells.nucleus.NoRouteToCellException in project dcache by dCache.

the class AbstractCellsTopology method buildTopologyMap.

protected Map<String, CellDomainNode> buildTopologyMap(String domain) throws InterruptedException {
    Queue<CellDomainNode> queue = new ArrayDeque<>();
    Map<String, CellDomainNode> map = new HashMap<>();
    CellDomainNode node = new CellDomainNode(domain, "System@" + domain);
    queue.add(node);
    map.put(node.getName(), node);
    while ((node = queue.poll()) != null) {
        try {
            node.setLinks(getCellTunnelInfos(node.getAddress()));
            for (CellDomainNode connectedNode : getConnectedNodes(node)) {
                String name = connectedNode.getName();
                if (!map.containsKey(name)) {
                    queue.add(connectedNode);
                    map.put(name, connectedNode);
                }
            }
        } catch (NoRouteToCellException | CacheException e) {
            LOGGER.warn("Failed to fetch topology info from {}: {}", node.getAddress(), e.getMessage());
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) CellDomainNode(dmg.cells.network.CellDomainNode) ArrayDeque(java.util.ArrayDeque)

Aggregations

NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)67 CacheException (diskCacheV111.util.CacheException)55 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)25 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)22 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)19 ArrayList (java.util.ArrayList)15 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 Produces (javax.ws.rs.Produces)14 BadRequestException (javax.ws.rs.BadRequestException)13 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)13 Path (javax.ws.rs.Path)13 CellPath (dmg.cells.nucleus.CellPath)11 ExecutionException (java.util.concurrent.ExecutionException)11 ForbiddenException (javax.ws.rs.ForbiddenException)11 GET (javax.ws.rs.GET)11 FsPath (diskCacheV111.util.FsPath)10 PnfsId (diskCacheV111.util.PnfsId)10 SRMException (org.dcache.srm.SRMException)10 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)10