Search in sources :

Example 16 with CellPath

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

the class PnfsManagerV3 method postProcessFlush.

private void postProcessFlush(CellMessage envelope, PoolFileFlushedMessage pnfsMessage) {
    long timeout = envelope.getAdjustedTtl() - envelope.getLocalAge();
    /* Asynchronously notify flush notification targets about the flush. */
    PoolFileFlushedMessage notification = new PoolFileFlushedMessage(pnfsMessage.getPoolName(), pnfsMessage.getPnfsId(), pnfsMessage.getFileAttributes());
    List<ListenableFuture<PoolFileFlushedMessage>> futures = new ArrayList<>();
    for (String address : _flushNotificationTargets) {
        futures.add(_stub.send(new CellPath(address), notification, timeout));
    }
    /* Only generate positive reply if all notifications succeeded. */
    Futures.addCallback(Futures.allAsList(futures), new FutureCallback<List<PoolFileFlushedMessage>>() {

        @Override
        public void onSuccess(List<PoolFileFlushedMessage> result) {
            pnfsMessage.setSucceeded();
            reply();
        }

        @Override
        public void onFailure(Throwable t) {
            pnfsMessage.setFailed(CacheException.DEFAULT_ERROR_CODE, "PNFS manager failed while notifying other " + "components about the flush: " + t.getMessage());
            reply();
        }

        private void reply() {
            envelope.revertDirection();
            sendMessage(envelope);
        }
    });
}
Also used : CellPath(dmg.cells.nucleus.CellPath) PoolFileFlushedMessage(diskCacheV111.vehicles.PoolFileFlushedMessage) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with CellPath

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

the class PnfsManagerV3 method cancelUpload.

void cancelUpload(PnfsCancelUpload message) {
    Subject subject = message.getSubject();
    String explanation = message.getExplanation();
    try {
        checkRestriction(message, UPLOAD);
        Set<FileAttribute> requested = message.getRequestedAttributes();
        requested.addAll(EnumSet.of(PNFSID, NLINK, SIZE));
        Collection<FileAttributes> deletedFiles = _nameSpaceProvider.cancelUpload(subject, message.getUploadPath(), message.getPath(), requested, explanation);
        deletedFiles.stream().filter(// currently uploading
        f -> f.isUndefined(SIZE)).filter(// with no hard links
        f -> f.getNlink() == 1).map(FileAttributes::getPnfsId).forEach(id -> _cancelUploadNotificationTargets.stream().map(CellPath::new).forEach(p -> _stub.notify(p, new DoorCancelledUploadNotificationMessage(subject, id, explanation))));
        message.setDeletedFiles(deletedFiles);
        message.setSucceeded();
    } catch (CacheException e) {
        message.setFailed(e.getRc(), e.getMessage());
    } catch (RuntimeException e) {
        LOGGER.error("Cancel upload path failed", e);
        message.setFailed(CacheException.UNEXPECTED_SYSTEM_EXCEPTION, e);
    }
}
Also used : PnfsRemoveExtendedAttributesMessage(diskCacheV111.vehicles.PnfsRemoveExtendedAttributesMessage) Arrays(java.util.Arrays) Restriction(org.dcache.auth.attributes.Restriction) Subjects(org.dcache.auth.Subjects) CellMessage(dmg.cells.nucleus.CellMessage) PermissionHandler(org.dcache.namespace.PermissionHandler) NLINK(org.dcache.namespace.FileAttribute.NLINK) UnixPermission(org.dcache.chimera.UnixPermission) Command(dmg.util.command.Command) MODIFICATION_TIME(org.dcache.namespace.FileAttribute.MODIFICATION_TIME) ACCESS_ALLOWED(org.dcache.acl.enums.AccessType.ACCESS_ALLOWED) READ_METADATA(org.dcache.auth.attributes.Activity.READ_METADATA) Map(java.util.Map) PnfsRenameMessage(diskCacheV111.vehicles.PnfsRenameMessage) SIZE(org.dcache.namespace.FileAttribute.SIZE) EnumSet(java.util.EnumSet) PnfsCreateSymLinkMessage(org.dcache.vehicles.PnfsCreateSymLinkMessage) CDC(dmg.cells.nucleus.CDC) DELETE(org.dcache.auth.attributes.Activity.DELETE) PrintWriter(java.io.PrintWriter) PnfsManagerGetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerGetQuotaMessage) ACCESS_TIME(org.dcache.namespace.FileAttribute.ACCESS_TIME) PnfsManagerSetQuotaMessage(org.dcache.vehicles.quota.PnfsManagerSetQuotaMessage) PNFSID(org.dcache.namespace.FileAttribute.PNFSID) MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) UPDATE_METADATA(org.dcache.auth.attributes.Activity.UPDATE_METADATA) Set(java.util.Set) BlockingQueue(java.util.concurrent.BlockingQueue) Executors(java.util.concurrent.Executors) PnfsFlagMessage(diskCacheV111.vehicles.PnfsFlagMessage) PnfsListExtendedAttributesMessage(diskCacheV111.vehicles.PnfsListExtendedAttributesMessage) AbstractCellComponent(dmg.cells.nucleus.AbstractCellComponent) PnfsCommitUpload(diskCacheV111.vehicles.PnfsCommitUpload) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) UPLOAD(org.dcache.auth.attributes.Activity.UPLOAD) PnfsCreateEntryMessage(diskCacheV111.vehicles.PnfsCreateEntryMessage) PnfsCreateUploadPath(diskCacheV111.vehicles.PnfsCreateUploadPath) LeaderLatchListener(org.apache.curator.framework.recipes.leader.LeaderLatchListener) FsPath(diskCacheV111.util.FsPath) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) SimpleDateFormat(java.text.SimpleDateFormat) Callable(java.util.concurrent.Callable) ACCESS_UNDEFINED(org.dcache.acl.enums.AccessType.ACCESS_UNDEFINED) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ColumnWriter(org.dcache.util.ColumnWriter) PnfsReadExtendedAttributesMessage(diskCacheV111.vehicles.PnfsReadExtendedAttributesMessage) Strings(com.google.common.base.Strings) OWNER(org.dcache.namespace.FileAttribute.OWNER) NotDirCacheException(diskCacheV111.util.NotDirCacheException) CellStub(org.dcache.cells.CellStub) TYPE(org.dcache.namespace.FileAttribute.TYPE) PnfsListDirectoryMessage(org.dcache.vehicles.PnfsListDirectoryMessage) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) FileType(org.dcache.namespace.FileType) PnfsManagerRemoveQuotaMessage(org.dcache.vehicles.quota.PnfsManagerRemoveQuotaMessage) PnfsId(diskCacheV111.util.PnfsId) ROOT(org.dcache.auth.Subjects.ROOT) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) QuotaInfo(org.dcache.quota.data.QuotaInfo) FutureCallback(com.google.common.util.concurrent.FutureCallback) File(java.io.File) LIST(org.dcache.auth.attributes.Activity.LIST) Futures(com.google.common.util.concurrent.Futures) CREATION_TIME(org.dcache.namespace.FileAttribute.CREATION_TIME) PnfsRemoveLabelsMessage(diskCacheV111.vehicles.PnfsRemoveLabelsMessage) TransactionException(org.springframework.transaction.TransactionException) FileAttribute(org.dcache.namespace.FileAttribute) ByteUnit(org.dcache.util.ByteUnit) PnfsMapPathMessage(diskCacheV111.vehicles.PnfsMapPathMessage) ScheduledFuture(java.util.concurrent.ScheduledFuture) SortedSet(java.util.SortedSet) AccessLatency(diskCacheV111.util.AccessLatency) ACCESS_DENIED(org.dcache.acl.enums.AccessType.ACCESS_DENIED) ChecksumType(org.dcache.util.ChecksumType) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) XATTR(org.dcache.namespace.FileAttribute.XATTR) PnfsCancelUpload(diskCacheV111.vehicles.PnfsCancelUpload) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) AccessType(org.dcache.acl.enums.AccessType) Locale(java.util.Locale) RequestCounters(org.dcache.commons.stats.RequestCounters) QuotaHandler(org.dcache.chimera.quota.QuotaHandler) PnfsWriteExtendedAttributesMessage(diskCacheV111.vehicles.PnfsWriteExtendedAttributesMessage) Splitter(com.google.common.base.Splitter) FileAttributes(org.dcache.vehicles.FileAttributes) PnfsManagerQuotaMessage(org.dcache.vehicles.quota.PnfsManagerQuotaMessage) CellMessageReceiver(dmg.cells.nucleus.CellMessageReceiver) PnfsGetParentMessage(diskCacheV111.vehicles.PnfsGetParentMessage) CommandException(dmg.util.CommandException) CHANGE_TIME(org.dcache.namespace.FileAttribute.CHANGE_TIME) Collection(java.util.Collection) PnfsGetCacheLocationsMessage(diskCacheV111.vehicles.PnfsGetCacheLocationsMessage) CellCommandListener(dmg.cells.nucleus.CellCommandListener) Instant(java.time.Instant) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Collectors(java.util.stream.Collectors) List(java.util.List) UOID(dmg.cells.nucleus.UOID) Activity(org.dcache.auth.attributes.Activity) Optional(java.util.Optional) MODE(org.dcache.namespace.FileAttribute.MODE) CellPath(dmg.cells.nucleus.CellPath) RetentionPolicy(diskCacheV111.util.RetentionPolicy) Argument(dmg.util.command.Argument) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) PnfsClearCacheLocationMessage(diskCacheV111.vehicles.PnfsClearCacheLocationMessage) PnfsDeleteEntryMessage(diskCacheV111.vehicles.PnfsDeleteEntryMessage) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) PnfsMessage(diskCacheV111.vehicles.PnfsMessage) QuotaRequest(org.dcache.quota.data.QuotaRequest) CellAddressCore(dmg.cells.nucleus.CellAddressCore) StorageInfos(diskCacheV111.vehicles.StorageInfos) Message(diskCacheV111.vehicles.Message) DOWNLOAD(org.dcache.auth.attributes.Activity.DOWNLOAD) QuotaType(org.dcache.quota.data.QuotaType) CacheException(diskCacheV111.util.CacheException) StorageInfo(diskCacheV111.vehicles.StorageInfo) Objects.requireNonNull(java.util.Objects.requireNonNull) ListHandler(org.dcache.namespace.ListHandler) MANAGE(org.dcache.auth.attributes.Activity.MANAGE) PoolFileFlushedMessage(diskCacheV111.vehicles.PoolFileFlushedMessage) TimeUtils(org.dcache.util.TimeUtils) ExecutorService(java.util.concurrent.ExecutorService) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) FireAndForgetTask(org.dcache.util.FireAndForgetTask) RequestExecutionTimeGauges(org.dcache.commons.stats.RequestExecutionTimeGauges) Subject(javax.security.auth.Subject) TabulatedRow(org.dcache.util.ColumnWriter.TabulatedRow) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) TimeUnit(java.util.concurrent.TimeUnit) Checksum(org.dcache.util.Checksum) PnfsRemoveChecksumMessage(org.dcache.vehicles.PnfsRemoveChecksumMessage) DoorCancelledUploadNotificationMessage(diskCacheV111.vehicles.DoorCancelledUploadNotificationMessage) Quota(org.dcache.chimera.quota.Quota) Args(org.dcache.util.Args) Option(dmg.util.command.Option) AccessMask(org.dcache.acl.enums.AccessMask) OWNER_GROUP(org.dcache.namespace.FileAttribute.OWNER_GROUP) PnfsAddCacheLocationMessage(diskCacheV111.vehicles.PnfsAddCacheLocationMessage) CommandLine(dmg.util.command.CommandLine) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Required(org.springframework.beans.factory.annotation.Required) Collections(java.util.Collections) JdbcQuota(org.dcache.chimera.quota.JdbcQuota) Transactional(org.springframework.transaction.annotation.Transactional) CellPath(dmg.cells.nucleus.CellPath) DoorCancelledUploadNotificationMessage(diskCacheV111.vehicles.DoorCancelledUploadNotificationMessage) MissingResourceCacheException(diskCacheV111.util.MissingResourceCacheException) NotDirCacheException(diskCacheV111.util.NotDirCacheException) InvalidMessageCacheException(diskCacheV111.util.InvalidMessageCacheException) FileNotFoundCacheException(diskCacheV111.util.FileNotFoundCacheException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) PnfsSetFileAttributes(org.dcache.vehicles.PnfsSetFileAttributes) PnfsGetFileAttributes(org.dcache.vehicles.PnfsGetFileAttributes) FileAttributes(org.dcache.vehicles.FileAttributes) Subject(javax.security.auth.Subject) FileAttribute(org.dcache.namespace.FileAttribute)

Example 18 with CellPath

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

the class PoolStatisticsV0 method getPoolRepositoryStatistics.

// 
// expected format from 'rep ls -s -binary'
// Object[*]
// Object [2]
// 0 String <storageClass>
// 1 long[2]
// 0  # of bytes in repository
// 1  # of files in repository
// 
private Map<String, Map<String, long[]>> getPoolRepositoryStatistics() throws InterruptedException, NoRouteToCellException, IOException {
    LOGGER.info("getPoolRepositoryStatistics : asking PoolManager for cell info");
    PoolManagerCellInfo info;
    try {
        info = _poolManager.sendAndWait(GET_CELL_INFO, PoolManagerCellInfo.class);
    } catch (CacheException e) {
        throw new IOException(e.getMessage(), e);
    }
    LOGGER.info("getPoolRepositoryStatistics :  PoolManager replied : {}", info);
    Map<String, Map<String, long[]>> map = new HashMap<>();
    for (Map.Entry<String, CellAddressCore> pool : info.getPoolMap().entrySet()) {
        CellAddressCore address = pool.getValue();
        try {
            LOGGER.info("getPoolRepositoryStatistics : asking {} for statistics", address);
            Object[] result = _poolStub.sendAndWait(new CellPath(address), GET_REP_STATISTICS, Object[].class);
            Map<String, long[]> classMap = new HashMap<>();
            for (Object entry : result) {
                Object[] e = (Object[]) entry;
                classMap.put((String) e[0], (long[]) e[1]);
            }
            LOGGER.info("getPoolRepositoryStatistics : {} replied with {}", address, classMap);
            map.put(pool.getKey(), classMap);
        } catch (InterruptedException ie) {
            LOGGER.warn("getPoolRepositoryStatistics : sendAndWait interrupted");
            throw ie;
        } catch (CacheException e) {
            LOGGER.warn("getPoolRepositoryStatistics : {} : {}", address, e.getMessage());
        }
    }
    return map;
}
Also used : CellPath(dmg.cells.nucleus.CellPath) CellAddressCore(dmg.cells.nucleus.CellAddressCore) CacheException(diskCacheV111.util.CacheException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IOException(java.io.IOException) PoolManagerCellInfo(diskCacheV111.poolManager.PoolManagerCellInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 19 with CellPath

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

the class PoolStatisticsV0 method starting.

@Override
protected void starting() throws Exception {
    Args args = getArgs();
    if (args.argc() < 1) {
        throw new IllegalArgumentException("Usage : ... <baseDirectory> " + "[-htmlBase=<htmlBase>|none] [-create] [-images=<images>]");
    }
    _poolManager = new CellStub(this, new CellPath(args.getOption("poolManager")), TimeUnit.MILLISECONDS.convert(args.getLongOption("poolManagerTimeout"), TimeUnit.valueOf(args.getOption("poolManagerTimeoutUnit"))));
    _billing = new CellStub(this, new CellPath(args.getOption("billing")), TimeUnit.MILLISECONDS.convert(args.getLongOption("billingTimeout"), TimeUnit.valueOf(args.getOption("billingTimeoutUnit"))));
    _poolStub = new CellStub(this, null, TimeUnit.MILLISECONDS.convert(args.getLongOption("poolTimeout"), TimeUnit.valueOf(args.getOption("poolTimeoutUnit"))));
    _htmlBase = _dbBase = new File(args.argv(0));
    String tmp = args.getOpt("htmlBase");
    if ((tmp != null) && (!tmp.isEmpty())) {
        if (tmp.equals("none")) {
            _createHtmlTree = false;
        } else {
            _htmlBase = new File(tmp);
        }
    }
    tmp = args.getOpt("domain");
    if (tmp != null) {
        _domainName = tmp;
    }
    if (args.hasOption("create")) {
        if (!_dbBase.exists()) {
            // noinspection ResultOfMethodCallIgnored
            _dbBase.mkdirs();
        }
        if (_createHtmlTree && !_htmlBase.exists()) {
            // noinspection ResultOfMethodCallIgnored
            _htmlBase.mkdirs();
        }
    } else {
        if ((!_dbBase.exists()) || (_createHtmlTree && !_htmlBase.exists())) {
            throw new IllegalArgumentException("Either <baseDirectory> or <htmlBase> doesn't exist");
        }
    }
}
Also used : CellPath(dmg.cells.nucleus.CellPath) Args(org.dcache.util.Args) CellStub(org.dcache.cells.CellStub) File(java.io.File)

Example 20 with CellPath

use of dmg.cells.nucleus.CellPath 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)

Aggregations

CellPath (dmg.cells.nucleus.CellPath)77 CacheException (diskCacheV111.util.CacheException)20 CellMessage (dmg.cells.nucleus.CellMessage)19 CellAddressCore (dmg.cells.nucleus.CellAddressCore)15 PnfsId (diskCacheV111.util.PnfsId)14 FileAttributes (org.dcache.vehicles.FileAttributes)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)9 CellStub (org.dcache.cells.CellStub)9 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)9 HashSet (java.util.HashSet)8 ExecutionException (java.util.concurrent.ExecutionException)8 FileAttribute (org.dcache.namespace.FileAttribute)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 PoolMoverKillMessage (diskCacheV111.vehicles.PoolMoverKillMessage)7 Map (java.util.Map)7 PoolMgrSelectReadPoolMsg (diskCacheV111.vehicles.PoolMgrSelectReadPoolMsg)6 IOException (java.io.IOException)6 PoolV2Mode (diskCacheV111.pools.PoolV2Mode)5