Search in sources :

Example 1 with StorageInfo

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

the class ScriptNearlineStorage method getFlushCommand.

@VisibleForTesting
String[] getFlushCommand(URI dataFile, FileAttributes fileAttributes) {
    StorageInfo storageInfo = StorageInfos.extractFrom(fileAttributes);
    String[] argsArray = Stream.concat(Stream.of(command, "put", fileAttributes.getPnfsId().toString(), getFileString(dataFile), "-si=" + storageInfo), options.stream()).toArray(String[]::new);
    LOGGER.debug("COMMAND: {}", Arrays.deepToString(argsArray));
    return argsArray;
}
Also used : StorageInfo(diskCacheV111.vehicles.StorageInfo) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with StorageInfo

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

the class ScriptNearlineStorage method getFetchCommand.

@VisibleForTesting
String[] getFetchCommand(URI dataFile, FileAttributes fileAttributes) {
    StorageInfo storageInfo = StorageInfos.extractFrom(fileAttributes);
    String[] argsArray = Stream.of(Stream.of(command, "get", fileAttributes.getPnfsId().toString(), getFileString(dataFile), "-si=" + storageInfo), getLocations(fileAttributes).stream().map(uri -> "-uri=" + uri), options.stream()).flatMap(s -> s).toArray(String[]::new);
    LOGGER.debug("COMMAND: {}", Arrays.deepToString(argsArray));
    return argsArray;
}
Also used : NoSuchFileException(java.nio.file.NoSuchFileException) Arrays(java.util.Arrays) FlushRequest(org.dcache.pool.nearline.spi.FlushRequest) BoundedExecutor(org.dcache.util.BoundedExecutor) URISyntaxException(java.net.URISyntaxException) ChecksumType(org.dcache.util.ChecksumType) LoggerFactory(org.slf4j.LoggerFactory) StorageInfos(diskCacheV111.vehicles.StorageInfos) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) AbstractBlockingNearlineStorage(org.dcache.pool.nearline.AbstractBlockingNearlineStorage) RemoveRequest(org.dcache.pool.nearline.spi.RemoveRequest) CacheException(diskCacheV111.util.CacheException) StorageInfo(diskCacheV111.vehicles.StorageInfo) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) URI(java.net.URI) CDCScheduledExecutorServiceDecorator(org.dcache.util.CDCScheduledExecutorServiceDecorator) Splitter(com.google.common.base.Splitter) ExecutorService(java.util.concurrent.ExecutorService) FileAttributes(org.dcache.vehicles.FileAttributes) Logger(org.slf4j.Logger) Files(java.nio.file.Files) Executor(java.util.concurrent.Executor) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Collectors(java.util.stream.Collectors) File(java.io.File) Executors(java.util.concurrent.Executors) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) HsmRunSystem(diskCacheV111.util.HsmRunSystem) TimeUnit(java.util.concurrent.TimeUnit) Checksum(org.dcache.util.Checksum) List(java.util.List) Stream(java.util.stream.Stream) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) StageRequest(org.dcache.pool.nearline.spi.StageRequest) CDCExecutorServiceDecorator(org.dcache.util.CDCExecutorServiceDecorator) StorageInfo(diskCacheV111.vehicles.StorageInfo) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with StorageInfo

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

the class BillingMessageSerializer method transform.

static JSONObject transform(MoverInfoMessage data) {
    JSONObject o = new JSONObject();
    o.put("version", "1.0");
    o.put("msgType", data.getMessageType());
    o.put("date", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(data.getTimestamp()), ZoneId.systemDefault())));
    o.put("queuingTime", data.getTimeQueued());
    o.put("cellName", data.getCellAddress().getCellName());
    o.put("cellType", data.getCellType());
    o.put("cellDomain", data.getCellAddress().getCellDomainName());
    if (!Double.isNaN(data.getMeanReadBandwidth())) {
        o.put("meanReadBandwidth", data.getMeanReadBandwidth());
    }
    if (!Double.isNaN(data.getMeanWriteBandwidth())) {
        o.put("meanWriteBandwidth", data.getMeanWriteBandwidth());
    }
    data.getReadIdle().ifPresent(d -> o.put("readIdle", d.toString()));
    data.getWriteIdle().ifPresent(d -> o.put("writeIdle", d.toString()));
    data.getReadActive().ifPresent(d -> o.put("readActive", d.toString()));
    data.getWriteActive().ifPresent(d -> o.put("writeActive", d.toString()));
    JSONObject status = new JSONObject();
    status.put("code", data.getResultCode());
    status.put("msg", data.getMessage());
    o.put("status", status);
    o.put("session", data.getTransaction());
    JSONArray subject = new JSONArray();
    data.getSubject().getPrincipals().forEach(s -> subject.put(s));
    o.put("subject", subject);
    o.put("pnfsid", data.getPnfsId());
    o.put("billingPath", data.getBillingPath());
    o.put("fileSize", data.getFileSize());
    o.put("storageInfo", data.getStorageInfo().getStorageClass() + "@" + data.getStorageInfo().getHsm());
    o.put("transferSize", data.getDataTransferred());
    o.put("transferTime", data.getConnectionTime());
    o.put("isWrite", data.isFileCreated() ? "write" : "read");
    InetSocketAddress remoteHost = ((IpProtocolInfo) data.getProtocolInfo()).getSocketAddress();
    JSONObject protocolInfo = new JSONObject();
    protocolInfo.put("protocol", data.getProtocolInfo().getProtocol());
    protocolInfo.put("versionMajor", data.getProtocolInfo().getMajorVersion());
    protocolInfo.put("versionMinor", data.getProtocolInfo().getMinorVersion());
    protocolInfo.put("port", remoteHost.getPort());
    protocolInfo.put("host", remoteHost.getAddress().getHostAddress());
    o.put("protocolInfo", protocolInfo);
    o.put("initiator", data.getInitiator());
    o.put("isP2p", data.isP2P());
    o.put("transferPath", data.getTransferPath());
    return o;
}
Also used : JSONObject(org.json.JSONObject) InetSocketAddress(java.net.InetSocketAddress) JSONArray(org.json.JSONArray) IpProtocolInfo(diskCacheV111.vehicles.IpProtocolInfo)

Example 4 with StorageInfo

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

the class DoorRequestMessageSerializer method serialize.

@Override
public byte[] serialize(String topic, DoorRequestInfoMessage data) {
    JSONObject o = new JSONObject();
    o.put("VERSION", "1.0");
    o.put("msgType", data.getMessageType());
    o.put("date", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.ofInstant(Instant.ofEpochMilli(data.getTimestamp()), ZoneId.systemDefault())));
    o.put("queuingTime", data.getTimeQueued());
    o.put("cellName", data.getCellAddress().getCellName());
    o.put("cellType", data.getCellType());
    o.put("cellDomain", data.getCellAddress().getCellDomainName());
    JSONObject status = new JSONObject();
    status.put("code", data.getResultCode());
    status.put("msg", data.getMessage());
    o.put("status", status);
    o.put("session", data.getTransaction());
    o.put("sessionDuration", data.getTransactionDuration());
    o.put("transferPath", data.getTransferPath());
    JSONArray subject = new JSONArray();
    data.getSubject().getPrincipals().forEach(s -> subject.put(s));
    o.put("subject", subject);
    o.put("client", data.getClient());
    o.put("clientChain", data.getClientChain());
    o.put("mappedUID", data.getUid());
    o.put("mappedGID", data.getGid());
    o.put("owner", data.getOwner());
    o.put("pnfsid", data.getPnfsId());
    o.put("billingPath", data.getBillingPath());
    o.put("fileSize", data.getFileSize());
    StorageInfo info = data.getStorageInfo();
    if (info != null) {
        o.put("storageInfo", info.getStorageClass() + "@" + info.getHsm());
    }
    MoverInfoMessage moverInfoMessage = data.getMoverInfo();
    if (moverInfoMessage != null) {
        JSONObject moverInfo = BillingMessageSerializer.transform(moverInfoMessage);
        Arrays.stream(REDUNDANT_MOVER_DATA_KEYS).forEach(moverInfo::remove);
        o.put("moverInfo", moverInfo);
    }
    return o.toString().getBytes(UTF_8);
}
Also used : MoverInfoMessage(diskCacheV111.vehicles.MoverInfoMessage) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) StorageInfo(diskCacheV111.vehicles.StorageInfo)

Example 5 with StorageInfo

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

the class StorageInfoMessageSerializer method buildLocations.

private List<URI> buildLocations(StorageInfoMessage data) {
    StorageInfo si = data.getStorageInfo();
    switch(data.getMessageType()) {
        case StorageInfoMessage.STORE_MSG_TYPE:
            return si.isSetAddLocation() ? si.locations() : Collections.emptyList();
        case StorageInfoMessage.RESTORE_MSG_TYPE:
            String hsmType = data.getHsmType();
            String hsmInstance = data.getHsmInstance();
            // similar assumptions in HsmSet#getInstanceName.
            return si.locations().stream().filter(uri -> Objects.equals(uri.getScheme(), hsmType)).filter(uri -> Objects.equals(uri.getAuthority(), hsmInstance)).collect(Collectors.toList());
        default:
            throw new IllegalArgumentException("Unexpected message type \"" + data.getMessageType() + "\"");
    }
}
Also used : StorageInfoMessage(diskCacheV111.vehicles.StorageInfoMessage) UTF_8(java.nio.charset.StandardCharsets.UTF_8) ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Objects(java.util.Objects) List(java.util.List) StorageInfo(diskCacheV111.vehicles.StorageInfo) JSONObject(org.json.JSONObject) Serializer(org.apache.kafka.common.serialization.Serializer) DateTimeFormatter(java.time.format.DateTimeFormatter) Map(java.util.Map) URI(java.net.URI) Collections(java.util.Collections) StorageInfo(diskCacheV111.vehicles.StorageInfo)

Aggregations

StorageInfo (diskCacheV111.vehicles.StorageInfo)60 Test (org.junit.Test)35 GenericStorageInfo (diskCacheV111.vehicles.GenericStorageInfo)26 URI (java.net.URI)21 CacheException (diskCacheV111.util.CacheException)19 FileAttributes (org.dcache.vehicles.FileAttributes)19 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)12 PnfsGetFileAttributes (org.dcache.vehicles.PnfsGetFileAttributes)11 PnfsId (diskCacheV111.util.PnfsId)9 FileAttribute (org.dcache.namespace.FileAttribute)8 FsInode (org.dcache.chimera.FsInode)7 List (java.util.List)6 ChimeraFsException (org.dcache.chimera.ChimeraFsException)6 NotDirCacheException (diskCacheV111.util.NotDirCacheException)5 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)5 PnfsCreateEntryMessage (diskCacheV111.vehicles.PnfsCreateEntryMessage)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Subject (javax.security.auth.Subject)5 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)4