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();
}
}
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;
}
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));
}
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;
}
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);
}
Aggregations