Search in sources :

Example 1 with ProtocolInfo

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

the class RemoteHttpDataTransferProtocol method runIO.

@Override
public void runIO(FileAttributes attributes, RepositoryChannel channel, ProtocolInfo genericInfo, Set<? extends OpenOption> access) throws CacheException, IOException, InterruptedException {
    LOGGER.debug("info={}, attributes={},  access={}", genericInfo, attributes, access);
    RemoteHttpDataTransferProtocolInfo info = (RemoteHttpDataTransferProtocolInfo) genericInfo;
    _channel = new MoverChannel<>(access, attributes, info, channel);
    channel.optionallyAs(ChecksumChannel.class).ifPresent(c -> {
        info.getDesiredChecksum().ifPresent(t -> {
            try {
                c.addType(t);
            } catch (IOException e) {
                LOGGER.warn("Unable to calculate checksum {}: {}", t, messageOrClassName(e));
            }
        });
    });
    try {
        if (access.contains(StandardOpenOption.WRITE)) {
            receiveFile(info);
        } else {
            checkThat(!info.isVerificationRequired() || attributes.isDefined(CHECKSUM), "checksum verification failed: file has no checksum");
            sendAndCheckFile(info);
        }
    } finally {
        afterTransfer();
    }
}
Also used : IOException(java.io.IOException) RemoteHttpDataTransferProtocolInfo(diskCacheV111.vehicles.RemoteHttpDataTransferProtocolInfo)

Example 2 with ProtocolInfo

use of diskCacheV111.vehicles.ProtocolInfo 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 3 with ProtocolInfo

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

the class RequestContainerV5Test method shouldSendHitInfoForNotInCacheException.

@Test
public void shouldSendHitInfoForNotInCacheException() throws Exception {
    var protocolInfo = aProtocolInfo().withProtocol("http").withMajorVersion(1).withIPAddress("192.168.1.1").build();
    StorageInfo storageInfo = aStorageInfo().build();
    given(aPartitionManager().withDefault(aPartition().withStageAllowed(false)));
    given(aPoolSelectionUnit().withNetUnit("all-net", "192.168.1.1").withProtocolUnit("HTTP", "http/1"));
    given(aPoolMonitor().thatReturns(aPoolSelectorThat().onReadThrows(aFileNotInCacheException())));
    given(aContainer("PoolManager@dCacheDomain").thatSendsHitMessages());
    whenReceiving(aReadRequest().forFile("80D1B8B90CED30430608C58002811B3285FC").withBillingPath("/public/test").withTransferPath("/uploads/50/test").withFileAttributes(fileAttributes().withSize(10, KiB).withStorageInfo(storageInfo)).withProtocolInfo(protocolInfo));
    var info = notificationSentWith(billing, PoolHitInfoMessage.class);
    assertThat(info.getCellAddress(), equalTo(null));
    assertThat(info.getBillingPath(), equalTo("/public/test"));
    assertThat(info.getTransferPath(), equalTo("/uploads/50/test"));
    assertThat(info.getFileSize(), equalTo(KiB.toBytes(10L)));
    assertThat(info.getFileCached(), equalTo(false));
    assertThat(info.getStorageInfo(), is(storageInfo));
    assertThat(info.getProtocolInfo(), is(protocolInfo));
}
Also used : StorageInfoBuilder.aStorageInfo(org.dcache.util.StorageInfoBuilder.aStorageInfo) StorageInfo(diskCacheV111.vehicles.StorageInfo) Test(org.junit.Test)

Example 4 with ProtocolInfo

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

the class IpProtocolInfoBuilder method build.

@Override
public ProtocolInfo build() {
    IpProtocolInfo mock = mock(IpProtocolInfo.class);
    addBehaviour(mock);
    return mock;
}
Also used : IpProtocolInfo(diskCacheV111.vehicles.IpProtocolInfo)

Example 5 with ProtocolInfo

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

the class PinManagerCLI method pin.

private Future<PinManagerPinMessage> pin(PnfsId pnfsId, String requestId, long lifetime) throws CacheException {
    DCapProtocolInfo protocolInfo = new DCapProtocolInfo("DCap", 3, 0, new InetSocketAddress("localhost", 0));
    PinManagerPinMessage message = new PinManagerPinMessage(FileAttributes.ofPnfsId(pnfsId), protocolInfo, requestId, lifetime);
    return _pinProcessor.messageArrived(message);
}
Also used : DCapProtocolInfo(diskCacheV111.vehicles.DCapProtocolInfo) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)12 CacheException (diskCacheV111.util.CacheException)11 ProtocolInfo (diskCacheV111.vehicles.ProtocolInfo)9 IOException (java.io.IOException)9 FileAttributes (org.dcache.vehicles.FileAttributes)8 DCapProtocolInfo (diskCacheV111.vehicles.DCapProtocolInfo)7 CellPath (dmg.cells.nucleus.CellPath)7 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)5 PnfsId (diskCacheV111.util.PnfsId)5 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)4 IpProtocolInfo (diskCacheV111.vehicles.IpProtocolInfo)4 InetAddress (java.net.InetAddress)4 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)3 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)3 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)3 HttpProtocolInfo (diskCacheV111.vehicles.HttpProtocolInfo)3 URISyntaxException (java.net.URISyntaxException)3 RequestState (diskCacheV111.poolManager.RequestContainerV5.RequestState)2 FileNotInCacheException (diskCacheV111.util.FileNotInCacheException)2 PoolMgrReplicateFileMsg (diskCacheV111.vehicles.PoolMgrReplicateFileMsg)2