|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Deutsches Elektronen-Synchroton, |
| 3 | + * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY |
| 4 | + * |
| 5 | + * This library is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Library General Public License as |
| 7 | + * published by the Free Software Foundation; either version 2 of the |
| 8 | + * License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * This library is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Library General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Library General Public |
| 16 | + * License along with this program (see the file COPYING.LIB for more |
| 17 | + * details); if not, write to the Free Software Foundation, Inc., |
| 18 | + * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | + */ |
| 20 | +package org.dcache.nfs.v4; |
| 21 | + |
| 22 | +import org.dcache.nfs.ChimeraNFSException; |
| 23 | +import org.dcache.nfs.nfsstat; |
| 24 | +import org.dcache.nfs.status.InvalException; |
| 25 | +import org.dcache.nfs.status.NfsIoException; |
| 26 | +import org.dcache.nfs.status.NotSuppException; |
| 27 | +import org.dcache.nfs.v4.xdr.nfs4_prot; |
| 28 | +import org.dcache.nfs.v4.xdr.nfs_argop4; |
| 29 | +import org.dcache.nfs.v4.xdr.nfs_opnum4; |
| 30 | +import org.dcache.nfs.v4.xdr.nfs_resop4; |
| 31 | +import org.slf4j.Logger; |
| 32 | +import org.slf4j.LoggerFactory; |
| 33 | + |
| 34 | +import java.io.IOException; |
| 35 | +import java.util.concurrent.TimeoutException; |
| 36 | + |
| 37 | +public class OperationBACKCHANNEL_CTL extends AbstractNFSv4Operation { |
| 38 | + |
| 39 | + public static final Logger LOG = LoggerFactory.getLogger(OperationBACKCHANNEL_CTL.class); |
| 40 | + |
| 41 | + |
| 42 | + public OperationBACKCHANNEL_CTL(nfs_argop4 op) { |
| 43 | + super(op, nfs_opnum4.OP_BACKCHANNEL_CTL); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public void process(CompoundContext context, nfs_resop4 result) throws ChimeraNFSException { |
| 48 | + |
| 49 | + if( context.getMinorversion() == 0) { |
| 50 | + throw new NotSuppException("Backchannel update for minor version " + context.getMinorversion() + " not supported"); |
| 51 | + } |
| 52 | + |
| 53 | + var session = context.getSession(); |
| 54 | + var cb = new ClientCB( |
| 55 | + context.getRpcCall().getTransport().getPeerTransport(), |
| 56 | + _args.opbackchannel_ctl.bca_cb_program.value, |
| 57 | + context.getMinorversion(), |
| 58 | + session.id(), |
| 59 | + session.getMaxCbOps(), |
| 60 | + _args.opbackchannel_ctl.bca_sec_parms); |
| 61 | + |
| 62 | + try { |
| 63 | + cb.cbPing(); |
| 64 | + session.getClient().setCB(cb); |
| 65 | + } catch (IOException | TimeoutException e) { |
| 66 | + LOG.warn("Failed to to replace backchannel for {} : {}", session.getClient(), e.getMessage()); |
| 67 | + throw new NfsIoException(e.getMessage()); |
| 68 | + } |
| 69 | + |
| 70 | + result.opbackchannel_ctl.bcr_status = nfsstat.NFS_OK; |
| 71 | + } |
| 72 | +} |
0 commit comments