Search in sources :

Example 1 with PoolMoverKillMessage

use of diskCacheV111.vehicles.PoolMoverKillMessage in project dcache by dCache.

the class XrootdDoor method messageArrived.

/**
 * Requests to start movers are processed synchronously by the Transfer class. This message
 * handler will only ever receive replies for those requests for which the Transfer class timed
 * out or interrupted.
 * <p>
 * To avoid that orphaned movers fill a transfer slot on the pool, we kill it right away.
 */
public void messageArrived(PoolIoFileMessage message) {
    if (message.getReturnCode() == 0) {
        String pool = message.getPoolName();
        _poolStub.notify(new CellPath(pool), new PoolMoverKillMessage(pool, message.getMoverId(), "door timed out before pool"));
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMoverKillMessage(diskCacheV111.vehicles.PoolMoverKillMessage)

Example 2 with PoolMoverKillMessage

use of diskCacheV111.vehicles.PoolMoverKillMessage in project dcache by dCache.

the class TransferManagerHandler method killMover.

public void killMover(int moverId, String explanation) {
    LOGGER.debug("sending mover kill to pool {} for moverId={}", pool, moverId);
    PoolMoverKillMessage killMessage = new PoolMoverKillMessage(pool.getName(), moverId, "killed by TransferManagerHandler: " + explanation);
    killMessage.setReplyRequired(false);
    manager.getPoolStub().notify(new CellPath(pool.getAddress()), killMessage);
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMoverKillMessage(diskCacheV111.vehicles.PoolMoverKillMessage)

Example 3 with PoolMoverKillMessage

use of diskCacheV111.vehicles.PoolMoverKillMessage in project dcache by dCache.

the class Transfer method killMover.

/**
 * Kills the mover of the transfer. Blocks until the mover has died or until a timeout is
 * reached. An error is logged if the mover failed to die or if the timeout was reached.
 *
 * @param millis      Timeout in milliseconds
 * @param explanation short information why the transfer is killed
 */
public void killMover(long millis, String explanation) {
    if (!hasMover()) {
        return;
    }
    Integer moverId = getMoverId();
    Pool pool = getPool();
    setStatus("Mover " + pool + "/" + moverId + ": Killing mover");
    try {
        /* Kill the mover.
             */
        PoolMoverKillMessage message = new PoolMoverKillMessage(pool.getName(), moverId, explanation);
        message.setReplyRequired(false);
        _poolStub.notify(new CellPath(pool.getAddress()), message);
        /* To reduce the risk of orphans when using PNFS, we wait
             * for the transfer confirmation.
             */
        if (millis > 0 && !waitForMover(millis)) {
            _log.error("Failed to kill mover {}/{}: Timeout", pool, moverId);
        }
    } catch (CacheException e) {
        // Not surprising that the pool reported a failure
        // when we killed the mover.
        _log.debug("Killed mover and pool reported: {}", e.getMessage());
    } catch (InterruptedException e) {
        _log.warn("Failed to kill mover {}/{}: {}", pool, moverId, e.getMessage());
        Thread.currentThread().interrupt();
    } finally {
        setStatus(null);
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) FileIsNewCacheException(diskCacheV111.util.FileIsNewCacheException) FileExistsCacheException(diskCacheV111.util.FileExistsCacheException) TimeoutCacheException(diskCacheV111.util.TimeoutCacheException) CacheException(diskCacheV111.util.CacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) NotFileCacheException(diskCacheV111.util.NotFileCacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) Pool(diskCacheV111.vehicles.Pool) PoolMoverKillMessage(diskCacheV111.vehicles.PoolMoverKillMessage)

Example 4 with PoolMoverKillMessage

use of diskCacheV111.vehicles.PoolMoverKillMessage in project dcache by dCache.

the class DcacheResourceFactory method messageArrived.

/**
 * Fall back message handler for mover creation replies. We only receive these if the Transfer
 * timed out before the mover was created. Instead we kill the mover.
 */
public void messageArrived(PoolIoFileMessage message) {
    if (message.getReturnCode() == 0) {
        String pool = message.getPoolName();
        _poolStub.notify(new CellPath(pool), new PoolMoverKillMessage(pool, message.getMoverId(), "door timed out before pool"));
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolMoverKillMessage(diskCacheV111.vehicles.PoolMoverKillMessage)

Example 5 with PoolMoverKillMessage

use of diskCacheV111.vehicles.PoolMoverKillMessage in project dcache by dCache.

the class PoolInfoResources method killMovers.

@DELETE
@ApiOperation("Kill a mover.  Requires admin role.")
@ApiResponses({ @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 403, message = "Pool command only accessible to admin users."), @ApiResponse(code = 500, message = "Internal Server Error") })
@Path("/{pool}/movers/{id : [0-9]+}")
@Produces(MediaType.APPLICATION_JSON)
public Response killMovers(@ApiParam(value = "The pool with the mover to be killed.", required = true) @PathParam("pool") String pool, @ApiParam(value = "The id of the mover to be killed.", required = true) @PathParam("id") int id) {
    if (!RequestUser.isAdmin()) {
        throw new ForbiddenException("Pool command only accessible to admin users.");
    }
    try {
        poolStub.sendAndWait(new CellPath(pool), new PoolMoverKillMessage(pool, id, "Killed by user."));
        transferInfoService.setCancelled(pool, id);
    } catch (IllegalArgumentException e) {
        throw new BadRequestException(e);
    } catch (CacheException e) {
        if (e.getRc() == CacheException.MOVER_NOT_FOUND) {
            transferInfoService.setCancelled(pool, id);
        } else {
            LOGGER.warn(Exceptions.meaningfulMessage(e));
            throw new InternalServerErrorException(e);
        }
    } catch (InterruptedException | NoRouteToCellException e) {
        LOGGER.warn(Exceptions.meaningfulMessage(e));
        throw new InternalServerErrorException(e);
    }
    return successfulResponse(Response.Status.OK);
}
Also used : CellPath(dmg.cells.nucleus.CellPath) ForbiddenException(javax.ws.rs.ForbiddenException) CacheException(diskCacheV111.util.CacheException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) BadRequestException(javax.ws.rs.BadRequestException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) PoolMoverKillMessage(diskCacheV111.vehicles.PoolMoverKillMessage) Path(javax.ws.rs.Path) CellPath(dmg.cells.nucleus.CellPath) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

PoolMoverKillMessage (diskCacheV111.vehicles.PoolMoverKillMessage)5 CellPath (dmg.cells.nucleus.CellPath)5 CacheException (diskCacheV111.util.CacheException)2 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)1 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)1 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)1 NotFileCacheException (diskCacheV111.util.NotFileCacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)1 Pool (diskCacheV111.vehicles.Pool)1 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 BadRequestException (javax.ws.rs.BadRequestException)1 DELETE (javax.ws.rs.DELETE)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1