public static layouttype4 valueOf(int value) throws BadLayoutException { for (layouttype4 l : values()) { if (l.getValue() == value) { return l; } } throw new BadLayoutException("Bad layouttype: " + value); } }
public CompoundBuilder withGetdeviceinfo(deviceid4 devId) { nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_GETDEVICEINFO; op.opgetdeviceinfo = new GETDEVICEINFO4args(); op.opgetdeviceinfo.gdia_device_id = devId; op.opgetdeviceinfo.gdia_layout_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); op.opgetdeviceinfo.gdia_maxcount = new count4(1024); op.opgetdeviceinfo.gdia_notify_types = new bitmap4(); op.opgetdeviceinfo.gdia_notify_types.value = new int[] {1}; ops.add(op); return this; }
public CompoundBuilder withGetdevicelist() { nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_GETDEVICELIST; op.opgetdevicelist = new GETDEVICELIST4args(); op.opgetdevicelist.gdla_cookie = new nfs_cookie4(0); op.opgetdevicelist.gdla_cookieverf = new verifier4(); op.opgetdevicelist.gdla_cookieverf.value = new byte[nfs4_prot.NFS4_VERIFIER_SIZE]; op.opgetdevicelist.gdla_layout_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); op.opgetdevicelist.gdla_maxdevices = new count4(256); ops.add(op); return this; }
public static nfs_argop4 generateRequest(deviceid4 devId) { nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_GETDEVICEINFO; op.opgetdeviceinfo = new GETDEVICEINFO4args(); op.opgetdeviceinfo.gdia_device_id = devId; op.opgetdeviceinfo.gdia_layout_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); op.opgetdeviceinfo.gdia_maxcount = new count4(0xffffff); op.opgetdeviceinfo.gdia_notify_types = new bitmap4( new int[] {0}); return op; } }
public static nfs_argop4 normal() { nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_GETDEVICELIST; op.opgetdevicelist = new GETDEVICELIST4args(); op.opgetdevicelist.gdla_cookie = new nfs_cookie4(0); op.opgetdevicelist.gdla_cookieverf = new verifier4(); op.opgetdevicelist.gdla_cookieverf.value = new byte[nfs4_prot.NFS4_VERIFIER_SIZE]; op.opgetdevicelist.gdla_layout_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); op.opgetdevicelist.gdla_maxdevices = new count4(256); return op; }
public CompoundBuilder withLayoutreturn(long offset, long len, byte[] body, stateid4 stateid) { nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_LAYOUTRETURN; op.oplayoutreturn = new LAYOUTRETURN4args(); op.oplayoutreturn.lora_reclaim = false; op.oplayoutreturn.lora_iomode = layoutiomode4.LAYOUTIOMODE4_ANY; op.oplayoutreturn.lora_layout_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); op.oplayoutreturn.lora_layoutreturn = new layoutreturn4(); op.oplayoutreturn.lora_layoutreturn.lr_returntype = layoutreturn_type4.LAYOUTRETURN4_FILE; op.oplayoutreturn.lora_layoutreturn.lr_layout = new layoutreturn_file4(); op.oplayoutreturn.lora_layoutreturn.lr_layout.lrf_offset = new offset4(offset); op.oplayoutreturn.lora_layoutreturn.lr_layout.lrf_length = new length4(len); op.oplayoutreturn.lora_layoutreturn.lr_layout.lrf_body = body; op.oplayoutreturn.lora_layoutreturn.lr_layout.lrf_stateid = stateid; ops.add(op); return this; }
public CompoundBuilder withLayoutget(boolean signal_layout_avail, layouttype4 layout_type, int iomode, long offset, long length, long minlength, int maxcount, stateid4 stateid) { nfs_argop4 op = new nfs_argop4(); op.argop = nfs_opnum4.OP_LAYOUTGET; op.oplayoutget = new LAYOUTGET4args(); op.oplayoutget.loga_signal_layout_avail = signal_layout_avail; op.oplayoutget.loga_layout_type = layout_type.getValue(); op.oplayoutget.loga_iomode = iomode; op.oplayoutget.loga_offset = new offset4(offset); op.oplayoutget.loga_length = new length4(length); op.oplayoutget.loga_minlength = new length4(minlength); op.oplayoutget.loga_maxcount = new count4(maxcount); op.oplayoutget.loga_stateid = stateid; ops.add(op); return this; }
@Override public device_addr4 getDeviceAddress(InetSocketAddress... deviceAddress) { nfsv4_1_file_layout_ds_addr4 file_type = new nfsv4_1_file_layout_ds_addr4(); file_type.nflda_multipath_ds_list = new multipath_list4[1]; file_type.nflda_multipath_ds_list[0] = new multipath_list4(); file_type.nflda_multipath_ds_list[0].value = new netaddr4[deviceAddress.length]; for (int i = 0; i < deviceAddress.length; i++) { file_type.nflda_multipath_ds_list[0].value[i] = new netaddr4(deviceAddress[i]); } file_type.nflda_stripe_indices = new uint32_t[1]; file_type.nflda_stripe_indices[0] = new uint32_t(0); byte[] retBytes; try(Xdr xdr = new Xdr(128)){ xdr.beginEncoding(); file_type.xdrEncode(xdr); xdr.endEncoding(); retBytes = xdr.getBytes(); } catch (OncRpcException e) { /* forced by interface, should never happen. */ throw new RuntimeException("Unexpected OncRpcException:", e); } catch (IOException e) { /* forced by interface, should never happen. */ throw new RuntimeException("Unexpected IOException:", e); } device_addr4 addr = new device_addr4(); addr.da_layout_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); addr.da_addr_body = retBytes; return addr; }
fs_layout_type.value = new int[] {layouttype4.LAYOUT4_NFSV4_1_FILES.getValue()}; } else { fs_layout_type.value = exportLayouts.stream()
@Override public layout_content4 getLayoutContent(stateid4 stateid, int stripeSize, nfs_fh4 fh, deviceid4 ... deviceids) throws ChimeraNFSException { checkArgument(deviceids.length > 0, "Layout driver supports need at least one (1) device."); ff_layout4 layout = new ff_layout4(); layout.ffl_stripe_unit = new length4(0); layout.ffl_mirrors = createMirrors(deviceids, 0, stateid, fh); layout.ffl_flags4 = layoutFlags; layout.ffl_stats_collect_hint = new uint32_t(0); byte[] body; try (Xdr xdr = new Xdr(512)) { xdr.beginEncoding(); layout.xdrEncode(xdr); xdr.endEncoding(); body = xdr.getBytes(); } catch (IOException e) { throw new ServerFaultException("failed to encode layout body", e); } layout_content4 content = new layout_content4(); content.loc_type = layouttype4.LAYOUT4_FLEX_FILES.getValue(); content.loc_body = body; return content; }
addr.da_layout_type = layouttype4.LAYOUT4_FLEX_FILES.getValue(); addr.da_addr_body = retBytes;
public void cbLayoutRecallFsid() throws OncRpcException, IOException { CB_LAYOUTRECALL4args cbLayoutrecall = new CB_LAYOUTRECALL4args(); cbLayoutrecall.clora_changed = true; cbLayoutrecall.clora_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); cbLayoutrecall.clora_iomode = layoutiomode4.LAYOUTIOMODE4_ANY; cbLayoutrecall.clora_recall = new layoutrecall4(); cbLayoutrecall.clora_recall.lor_recalltype = layoutrecall_type4.LAYOUTRECALL4_FSID; cbLayoutrecall.clora_recall.lor_fsid = new fsid4(); cbLayoutrecall.clora_recall.lor_fsid.major = new uint64_t(17); cbLayoutrecall.clora_recall.lor_fsid.minor = new uint64_t(17); nfs_cb_argop4 opArgs = new nfs_cb_argop4(); opArgs.argop = nfs_cb_opnum4.OP_CB_LAYOUTRECALL; opArgs.opcblayoutrecall = cbLayoutrecall; XdrAble args = generateCompound("cb_layout_recall_fs", opArgs); _rpc.call(nfs4_prot.CB_COMPOUND_1, args, new CB_COMPOUND4res()); }
public void cbLayoutRecallFile(nfs_fh4 fh, stateid4 stateid) throws OncRpcException, IOException { CB_LAYOUTRECALL4args cbLayoutrecall = new CB_LAYOUTRECALL4args(); cbLayoutrecall.clora_changed = true; cbLayoutrecall.clora_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); cbLayoutrecall.clora_iomode = layoutiomode4.LAYOUTIOMODE4_ANY; cbLayoutrecall.clora_recall = new layoutrecall4(); cbLayoutrecall.clora_recall.lor_recalltype = layoutrecall_type4.LAYOUTRECALL4_FILE; cbLayoutrecall.clora_recall.lor_layout = new layoutrecall_file4(); cbLayoutrecall.clora_recall.lor_layout.lor_fh = fh; cbLayoutrecall.clora_recall.lor_layout.lor_offset = new offset4(0L); cbLayoutrecall.clora_recall.lor_layout.lor_length = new length4(nfs4_prot.NFS4_UINT64_MAX); cbLayoutrecall.clora_recall.lor_layout.lor_stateid = stateid; nfs_cb_argop4 opArgs = new nfs_cb_argop4(); opArgs.argop = nfs_cb_opnum4.OP_CB_LAYOUTRECALL; opArgs.opcblayoutrecall = cbLayoutrecall; XdrAble args = generateCompound("cb_layout_recall_file", opArgs); CB_COMPOUND4res res = new CB_COMPOUND4res(); _rpc.call(nfs4_prot.CB_COMPOUND_1, args, res); nfsstat.throwIfNeeded(res.status); }
content.loc_type = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); content.loc_body = body;
@Test public void testDefaultLayoutType() throws IOException, URISyntaxException { NFSv41DeviceManager dm = mock(NFSv41DeviceManager.class); RpcCall call = mock(RpcCall.class); RpcTransport transport = mock(RpcTransport.class); ExportFile exportFile = new ExportFile(ClassLoader.getSystemResource("org/dcache/nfs/exports").toURI()); given(dm.getLayoutTypes()).willReturn(Sets.newHashSet(layouttype4.values())); given(transport.getRemoteSocketAddress()).willReturn(new InetSocketAddress("172.16.4.1", 0)); given(call.getCredential()).willReturn(new RpcAuthTypeNone()); given(call.getTransport()).willReturn(transport); CompoundContext context = new CompoundContextBuilder() .withDeviceManager(dm) .withCall(call) .withExportFile(exportFile) .build(); Optional<fattr4_fs_layout_types> res = (Optional<fattr4_fs_layout_types>) OperationGETATTR.fattr2xdr(nfs4_prot.FATTR4_FS_LAYOUT_TYPES, null, null, null, context); assertArrayEquals("export without explicit layout type must return nfsv41_files layout", new int[] {layouttype4.LAYOUT4_NFSV4_1_FILES.getValue()}, res.get().value); }
public void cbDeleteDevice(deviceid4 id) throws OncRpcException, IOException { CB_NOTIFY_DEVICEID4args cbDeleteDeciveId = new CB_NOTIFY_DEVICEID4args(); cbDeleteDeciveId.cnda_changes = new notify4[1]; cbDeleteDeciveId.cnda_changes[0] = new notify4(); cbDeleteDeciveId.cnda_changes[0].notify_mask = bitmap4.of(notify_deviceid_type4.NOTIFY_DEVICEID4_DELETE); notify_deviceid_delete4 deleteDevice = new notify_deviceid_delete4(); deleteDevice.ndd_layouttype = layouttype4.LAYOUT4_NFSV4_1_FILES.getValue(); deleteDevice.ndd_deviceid = id; try (Xdr xdr = new Xdr(32)) { xdr.beginEncoding(); deleteDevice.xdrEncode(xdr); xdr.endEncoding(); byte[] b = xdr.getBytes(); cbDeleteDeciveId.cnda_changes[0].notify_vals = new notifylist4(b); } nfs_cb_argop4 opArgs = new nfs_cb_argop4(); opArgs.argop = nfs_cb_opnum4.OP_CB_NOTIFY_DEVICEID; opArgs.opcbnotify_deviceid = cbDeleteDeciveId; XdrAble args = generateCompound("cb_delete_device", opArgs); CB_COMPOUND4res res = new CB_COMPOUND4res(); _rpc.call(nfs4_prot.CB_COMPOUND_1, args, res); nfsstat.throwIfNeeded(res.status); }