-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pnfs: add layoutStats and layoutError methods to device manager
Motivation: When client want's to inform metadata server about errors or statistics in its interactions with the layout, then LAYOUTERROR and LAYOUTSTATS operations are called. This information have to be propagated to the pnfs device manager. Modification: Add NFSv41DeviceManager#layoutError and NFSv41DeviceManager#layoutStats methods. Update corresponding operations to pass requests to device manager. Result: Layout usage errors and statistics available to the pnfs device manager. Acked-by: Paul Millar Target: master
- Loading branch information
Showing
6 changed files
with
243 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
core/src/test/java/org/dcache/nfs/v4/OperationLAYOUTERRORTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.dcache.nfs.v4; | ||
|
||
import java.io.IOException; | ||
import org.dcache.nfs.status.NotSuppException; | ||
import org.dcache.nfs.v4.client.CompoundBuilder; | ||
import org.dcache.nfs.v4.xdr.COMPOUND4args; | ||
import org.dcache.nfs.v4.xdr.device_error4; | ||
import org.dcache.nfs.vfs.VirtualFileSystem; | ||
import org.junit.Test; | ||
import org.junit.Before; | ||
|
||
import static org.dcache.nfs.v4.NfsTestUtils.execute; | ||
import static org.dcache.nfs.v4.NfsTestUtils.generateRpcCall; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
|
||
public class OperationLAYOUTERRORTest { | ||
|
||
private NFSv4StateHandler sh; | ||
private VirtualFileSystem vfs; | ||
private NFSv41DeviceManager dm; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
sh = new NFSv4StateHandler(); | ||
vfs = mock(VirtualFileSystem.class); | ||
dm = mock(NFSv41DeviceManager.class); | ||
} | ||
|
||
@Test(expected = NotSuppException.class) | ||
public void testNoPnfsConfigured() throws IOException { | ||
|
||
COMPOUND4args layoutError = new CompoundBuilder() | ||
.withLayoutError(0, 100, Stateids.OneStateId(), new device_error4[]{}) | ||
.build(); | ||
|
||
CompoundContext context = new CompoundContextBuilder() | ||
.withStateHandler(sh) | ||
.withFs(vfs) | ||
.withMinorversion(1) | ||
.withCall(generateRpcCall()) | ||
.build(); | ||
|
||
execute(context, layoutError); | ||
} | ||
|
||
@Test | ||
public void testStatsPropagation() throws IOException { | ||
|
||
COMPOUND4args layoutError = new CompoundBuilder() | ||
.withLayoutError(0, 100, Stateids.OneStateId(), new device_error4[]{}) | ||
.build(); | ||
|
||
CompoundContext context = new CompoundContextBuilder() | ||
.withStateHandler(sh) | ||
.withFs(vfs) | ||
.withDeviceManager(dm) | ||
.withMinorversion(1) | ||
.withCall(generateRpcCall()) | ||
.build(); | ||
|
||
execute(context, layoutError); | ||
|
||
verify(dm).layoutError(any(), any()); | ||
} | ||
|
||
} |
90 changes: 90 additions & 0 deletions
90
core/src/test/java/org/dcache/nfs/v4/OperationLAYOUTSTATSTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package org.dcache.nfs.v4; | ||
|
||
import java.io.IOException; | ||
import org.dcache.nfs.status.NotSuppException; | ||
import org.dcache.nfs.v4.client.CompoundBuilder; | ||
import org.dcache.nfs.v4.xdr.COMPOUND4args; | ||
import org.dcache.nfs.v4.xdr.deviceid4; | ||
import org.dcache.nfs.v4.xdr.io_info4; | ||
import org.dcache.nfs.v4.xdr.layouttype4; | ||
import org.dcache.nfs.v4.xdr.layoutupdate4; | ||
import org.dcache.nfs.vfs.VirtualFileSystem; | ||
import org.junit.Test; | ||
import org.junit.Before; | ||
|
||
import static org.dcache.nfs.v4.NfsTestUtils.execute; | ||
import static org.dcache.nfs.v4.NfsTestUtils.generateRpcCall; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
public class OperationLAYOUTSTATSTest { | ||
|
||
private NFSv4StateHandler sh; | ||
private VirtualFileSystem vfs; | ||
private NFSv41DeviceManager dm; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
sh = new NFSv4StateHandler(); | ||
vfs = mock(VirtualFileSystem.class); | ||
dm = mock(NFSv41DeviceManager.class); | ||
} | ||
|
||
@Test(expected = NotSuppException.class) | ||
public void testNoPnfsConfigured() throws IOException { | ||
|
||
io_info4 ioInfo = new io_info4(); | ||
ioInfo.ii_bytes = 0; | ||
ioInfo.ii_count = 0; | ||
|
||
deviceid4 deviceId = new deviceid4(new byte[] {0x1}); | ||
layoutupdate4 update = new layoutupdate4(); | ||
update.lou_type = layouttype4.LAYOUT4_BLOCK_VOLUME.getValue(); | ||
update.lou_body = new byte[0]; | ||
|
||
COMPOUND4args layoutStats = new CompoundBuilder() | ||
.withLayoutStats(0, 100, Stateids.OneStateId(), ioInfo, ioInfo, deviceId, update) | ||
.build(); | ||
|
||
CompoundContext context = new CompoundContextBuilder() | ||
.withStateHandler(sh) | ||
.withFs(vfs) | ||
.withMinorversion(1) | ||
.withCall(generateRpcCall()) | ||
.build(); | ||
|
||
execute(context, layoutStats); | ||
} | ||
|
||
@Test | ||
public void testStatsPropagation() throws IOException { | ||
|
||
io_info4 ioInfo = new io_info4(); | ||
ioInfo.ii_bytes = 0; | ||
ioInfo.ii_count = 0; | ||
|
||
deviceid4 deviceId = new deviceid4(new byte[]{0x1}); | ||
layoutupdate4 update = new layoutupdate4(); | ||
update.lou_type = layouttype4.LAYOUT4_BLOCK_VOLUME.getValue(); | ||
update.lou_body = new byte[0]; | ||
|
||
COMPOUND4args layoutStats = new CompoundBuilder() | ||
.withLayoutStats(0, 100, Stateids.OneStateId(), ioInfo, ioInfo, deviceId, update) | ||
.build(); | ||
|
||
CompoundContext context = new CompoundContextBuilder() | ||
.withStateHandler(sh) | ||
.withFs(vfs) | ||
.withDeviceManager(dm) | ||
.withMinorversion(1) | ||
.withCall(generateRpcCall()) | ||
.build(); | ||
|
||
execute(context, layoutStats); | ||
verify(dm).layoutStats(any(), any()); | ||
} | ||
|
||
} |