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