Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions modules/dcache/src/main/java/org/dcache/util/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ public synchronized String getDomainName() {
return _cellAddress.getCellDomainName();
}

private synchronized String getMessageEventSource() {
return _cellAddress == null ? "<unknown>" :
_cellAddress.getCellName() + "@" + _cellAddress.getCellDomainName();
}

/**
* The client address is the socket address from which the transfer was initiated.
*/
Expand Down Expand Up @@ -821,7 +826,7 @@ private ListenableFuture<Void> readNameSpaceEntryAsync(boolean allowWrite, long
request.setUpdateAtime(true);

MessageEvent nameSpaceReadEvent = new MessageEvent();
nameSpaceReadEvent.source = getCellName() + "@" + getDomainName();
nameSpaceReadEvent.source = getMessageEventSource();
nameSpaceReadEvent.destination = "PnfsManager";
nameSpaceReadEvent.message = PnfsGetFileAttributes.class.getSimpleName();
nameSpaceReadEvent.begin();
Expand Down Expand Up @@ -996,7 +1001,7 @@ public ListenableFuture<Void> selectPoolAsync(long timeout) {

// init JFR event
MessageEvent poolSelectEvent = new MessageEvent();
poolSelectEvent.source = getCellName() + "@" + getDomainName();
poolSelectEvent.source = getMessageEventSource();
poolSelectEvent.destination = "PoolManager";
poolSelectEvent.message = isWrite() ? PoolMgrSelectReadPoolMsg.class.getSimpleName() : PoolMgrSelectWritePoolMsg.class.getSimpleName();
poolSelectEvent.begin();
Expand Down Expand Up @@ -1102,7 +1107,7 @@ public ListenableFuture<Void> startMoverAsync(long timeout) {

// init JFR event
MessageEvent moverStartEvent = new MessageEvent();
moverStartEvent.source = getCellName() + "@" + getDomainName();
moverStartEvent.source = getMessageEventSource();
moverStartEvent.destination = pool.getName();
moverStartEvent.message = message.getClass().getSimpleName();
moverStartEvent.begin();
Expand Down Expand Up @@ -1169,7 +1174,7 @@ public void killMover(long millis, String explanation) {

// init JFR event
var killMoverEvent = new MessageEvent();
killMoverEvent.source = getCellName() + "@" + getDomainName();
killMoverEvent.source = getMessageEventSource();
killMoverEvent.destination = pool.getName();
killMoverEvent.message = message.getClass().getSimpleName();

Expand Down
64 changes: 64 additions & 0 deletions modules/dcache/src/test/java/org/dcache/util/TransferTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* dCache - http://www.dcache.org/
*
* Copyright (C) 2026 Deutsches Elektronen-Synchrotron
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.dcache.util;

import static com.google.common.util.concurrent.Futures.immediateFuture;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import diskCacheV111.util.FsPath;
import diskCacheV111.util.PnfsHandler;
import diskCacheV111.vehicles.GenericStorageInfo;
import javax.security.auth.Subject;
import org.dcache.auth.attributes.Restrictions;
import org.dcache.cells.CellStub;
import org.dcache.namespace.FileType;
import org.dcache.vehicles.FileAttributes;
import org.dcache.vehicles.PnfsGetFileAttributes;
import org.junit.Test;

public class TransferTest {

@Test
public void shouldReadNamespaceEntryWithoutCellAddress() throws Exception {
CellStub stub = mock(CellStub.class);
when(stub.send(any(PnfsGetFileAttributes.class), anyLong())).thenAnswer(invocation -> {
PnfsGetFileAttributes request = invocation.getArgument(0);
PnfsGetFileAttributes reply =
new PnfsGetFileAttributes(request.getPnfsPath(),
request.getRequestedAttributes());
FileAttributes attributes = FileAttributes.of()
.fileType(FileType.REGULAR)
.size(1L)
.storageInfo(new GenericStorageInfo())
.build();
reply.setFileAttributes(attributes);
return immediateFuture(reply);
});

Transfer transfer = new Transfer(new PnfsHandler(stub), new Subject(),
Restrictions.none(), FsPath.create("/test/path"));

transfer.readNameSpaceEntry(false);

verify(stub).send(any(PnfsGetFileAttributes.class), anyLong());
}
}